Hello. I am very new to supercollider and programming in general. I have a big assignment in my final year of high school/gymnasium to develop a program that creates music through algorithmic composition. I have a slight problem that involves the chord progression. I want to create several packages that each have a definition of z and y so I can create a chord progression that is often used in pop music for example I-IV-V, I-V-IV, ii-V-I etc. So for a start i want to create a variable that has variables stored inside it like the letter a has y=5 and z=7 and b has y=7 and z=5 and then i can randomly choose between those variables through the choose commando:
var frqxbass = rrand(36,47);
chord1 = Synth(\default, [freq: (frqxbass).midicps]);
chord2 = Synth(\default, [freq: (frqxbass + y).midicps]);
chord3 = Synth(\default, [freq: (frqxbass + z).midicps]);
Any help would be appreciated. Sorry for my english
Hello and welcome to this forum,
There can be many ways to approach the question you outline, but to your specific question, you don’t have to think in terms of variables. You could think in terms of Arrays of Arrays, and corresponding indices:
x = [ [5, 7], [7, 5] ];
x.choose.at(0); // this is what you called "y"
x.choose.at(1); // this is your "z"
The choose above randomly picks one of the sub-arrays; then the .at(n) accesses a given index inside that sub-array.
Another route would be to use a Dictionary of Dictionaries, where you could refer to elements by a “label” (key), if you don’t want to think in numerical indices. Take a look at the Dictionary help file for examples.
Hope this helps,
here’s an array of events:
a.x . //evaluates to 5
a.y . //evaluates to 5
or the dictionary of dictionaries Bruno suggested (with Events because of nice syntax):
a= ( chord1: (x:5, y:7), chord2: (x:7,y:5) )
Thank you so much! Will try this when I get the time