| Author |
Message |
ausz99
Joined: Feb 25, 2008 Posts: 9 Location: UK
Audio files: 1
|
Posted: Wed Apr 30, 2008 5:08 am Post subject:
I'm Back |
 |
|
Hi guys. It's been a long time since i've been on the forum and even longer since i've been playing with chuck. Just wondering if you could have a look at this coding for me. It's trying to get a SinOsc to play a harmonic minor scale but alas i've forgotten how to make use of arrays.
| Code: | SinOsc s => dac;
//Harmonic minor scale
261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D; //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;
[ C1, D, E, F, G, A, B, C2 ] @=> int bassline[];
bassline[] => s.freq |
Don't laugh at it lol coz i have forgotten a lot. I handed in my project and haven't really touched chuck since and want to get back into it now.
Cheers for any help
Ausz99 |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Wed Apr 30, 2008 6:06 am Post subject:
|
 |
|
Try this:
| Code: | SinOsc s => dac;
//Harmonic minor scale
261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D; //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;
[ C1, D, E, F, G, A, B, C2 ] @=> float bassline[];
for (0 => int i; i <8> s.freq;
250::ms => now;
} |
I changed your array to type float, set up a for loop, indexed the array, and put in a time delay for each note.
Welcome back, and by the way you can post to the ChucK forum under DIY now. Cheers. _________________ For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz |
|
|
Back to top
|
|
 |
Blue Hell
Site Admin

Joined: Apr 03, 2004 Posts: 11968 Location: Netherlands, Enschede
Audio files: 28
G2 patch files: 295
|
Posted: Wed Apr 30, 2008 7:23 am Post subject:
|
 |
|
I Moved this thread to the ChucK section. _________________ Jan |
|
|
Back to top
|
|
 |
ausz99
Joined: Feb 25, 2008 Posts: 9 Location: UK
Audio files: 1
|
Posted: Mon May 05, 2008 4:16 am Post subject:
|
 |
|
Cheers Inventor
| Code: | SinOsc s => dac;
//Harmonic minor scale
261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D; //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;
[ C1, D, E, F, G, A, B, C2 ] @=> float bassline[];
for (0 => int i; i <8> s.freq;
250::ms => now;
} |
Unfortunatly this code doesn't work, i think it's something to do with brackets on the "for" loop at the end, i'm gonna have a tinker and if i get it to work i'll post it here
Ausz99 |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Mon May 05, 2008 5:00 am Post subject:
|
 |
|
| Code: | SinOsc s => dac;
//Harmonic minor scale
261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D; //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;
[ C1, D, E, F, G, A, B, C2 ] @=> float bassline[];
for (0 => int i; i < 8; i++ ) {
bassline[i] =>s.freq;
250::ms => now;
} |
There, try that. I forgot to check the box for "Disable HTML in this post" and the forum software misinterpreted the "<" for html. This one should work fine, I tested it. _________________ For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 568 Location: bangkok, thailand
Audio files: 2
|
Posted: Mon May 05, 2008 11:09 am Post subject:
|
 |
|
I propose some adjustments to the original patch:
| Code: | SinOsc s => dac;
//Harmonic minor scale
[261.626, 293.665, 311.127, 349.228, 391.995, 415.305, 493.884, 523.251] @=> float ScaleFreq1[];
0 => int Do;
1 => int Re;
2 => int Mi;
3 => int Fa;
4 => int So;
5 => int La;
6 => int Ti;
[Do, Re, Mi, Fa, So, La, Ti, Do + 7, So, Ti - 7, Do] @=> int bassline[];
int octave;
for (0 => int i; i < bassline.cap(); i++ )
{
0 => octave;
bassline[i] => int GetNote;
while(GetNote < 0)
{
octave--;
7 +=> GetNote;
}
while(GetNote >= 7)
{
octave++;
7 -=> GetNote;
}
ScaleFreq1[GetNote] * Math.pow(2, octave) => s.freq;
250::ms => now;
} |
this works quite the same but added some convenience.
notes can be called by Do Re Mi..
and number of tone can be added or subtracted.
for example, adding with 7 makes it jump to another octave. |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Mon May 05, 2008 1:25 pm Post subject:
|
 |
|
Crank it up, kijjaz! Play that funky music kijjaz! Haha. Nice changes. _________________ For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz |
|
|
Back to top
|
|
 |
|