Tuesday, March 20, 2007

Supercollider Week 2 Exercise

What doesn't collide, can't SUPERcollide; and what can't supercollide isn't worth colliding with....

SUPERCOLLIDER 3:

The return of the beast...



(
// build a table of note names

var table = ();

value
{
var semitones = [0, 2, 4, 5, 7, 9, 11];
var naturalNoteNames = ["c", "d", "e", "f", "g", "a", "b"];


(0..9).do
{
arg o;

naturalNoteNames.do
{

arg c, i;

var n = (o + 1) * 12 + semitones[i];

table[(c ++ o).asSymbol] = n; table[(c ++ "s" ++ o).asSymbol] = n + 1; //determine sharp
table[(c ++ "ss" ++ o).asSymbol] = n + 2; //determine double sharp
table[(c ++ "b" ++ o).asSymbol] = n - 1; //determine flat
table[(c ++ "bb" ++ o).asSymbol] = n - 2; //determine double flat

};
};
};

"Pitch class and Octave Number, MIDI Note Number, Frequency Value" .postln;
a = table.atAll (#[a4].postln).postln;// Creates MIDI Note number --Enter Pitch class and Octave number here.


a = 2**((a-69)/12) *440; //Coverts MIDI note number to frequency value


)

No comments: