7.3.07

CC Week 1 - SuperCollider

[1] Create a function that takes two arguments - pitch class and octave number - and produces the corresponding the MIDI note number. [2] Create a function that can convert the pitch class and octave number into its corresponding MIDI Note number and then into its corresponding frequency. It will include extensive commenting, descriptive arguments and variable names, default values including a set tuning frequency.

Here is a SuperCollider patch I created to convert Pitch and Octave class to MIDI note number. The resultant MIDI note number is then converted to a Frequency value. Unfortunately my HTML coding skills are about as good as my SuperColliding skills, so the formatting leaves a lot to be desired.

(
// 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

};
};
};


a = table.atAll(#[a4]).postln; // Creates MIDI Note number

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

)


__________
[1] Christian Haines. "Creative Computing: Semester 1, Week 1. Introduction." Lecture presented at EMU, University of Adelaide, South Australia, 1st March 2007.