Open Orpheus

Open Orpheus is under heavy construction. To hear an early result from the synthesizer (a small part of the whole project), have a listen to (the first part of) Bach's Prelude and a look at the Javascript file it was generated from below:

		
/*
 * Prelude No. 2 in C Minor from The Well Tempered Clavier
 * by J.S. Bach
 */

var beatsPerMinute = 85;

var currBeat = 0;
function beatLength(beats) { return 60 * beats / beatsPerMinute; };
function startAt(time) { currBeat = time; return currBeat; }
function nextBeat(beats) { currBeat += beatLength(beats); return currBeat; }

function preludeMotif(order, volumes, delay, beatLengths) {
	return function(track, notes) {
		var n = 0;
		for (i in order) {
			track.note(notes[order[i]],volumes[n],nextBeat(0.25) + delay, beatLength(beatLengths[n]));
			++n;
		}
	}
}

var preludeMotifUpper = preludeMotif(
		[0,1,2,1,3,1,2,1], 					//note sequence
		[80,30,50,60,30,60,40,70], 			//velocities
		0, 									//delay
		[.3,.25,.125,.25,.13,.15,.125,.25]	//lengths (in beats)
	);

var preludeMotifLower = preludeMotif(
		[0,1,2,1,3,1,2,1], 					//note sequence
		[80,30,50,60,70,60,40,70], 			//velocities
		-0.03, 								//delay
		[.2,.12,.125,.3,.13,.15,.125,.25]	//lengths (in beats)
	);

function playMotifs(track, motif, noteSeqs) {
	for (i in noteSeqs) {
		motif(track, noteSeqs[i]);
	}
}

//"Meat" of song (repetitive part)
track(0).programChange(0,0);
track(0).volume(1.0,0);
startAt(0);
playMotifs(track(0), preludeMotifUpper,
	[
		["C5", "Eb4", "D4", "C4"], ["C5", "Eb4", "D4", "C4"], //one line == 1 measure
		["Ab4", "F4", "E4", "C4"], ["Ab4", "F4", "E4", "C4"],
		["B4", "F4", "Eb4", "D4"], ["B4", "F4", "Eb4", "D4"],
		["C5", "G4", "F4", "Eb4"], ["C5", "G4", "F4", "Eb4"],

		["Eb5", "Ab4", "G4", "Eb4"], ["Eb5", "Ab4", "G4", "Eb4"],
		["D5", "F#4", "E4", "D4"], ["D5", "F#4", "E4", "D4"],
		["D5", "G4", "F#4", "D4"], ["D5", "G4", "F#4", "D4"],
		["C5", "E4", "D4", "C4"], ["C5", "E4", "D4", "C4"],

		["C5", "F4", "E4", "C4"], ["C5", "F4", "E4", "C4"],
		["Bb4", "F4", "Eb4", "D4"], ["Bb4", "F4", "Eb4", "D4"],
		["Bb4", "G4", "F4", "Eb4"], ["Bb4", "G4", "F4", "Eb4"],
		["Ab4", "G4", "F4", "Eb4"], ["Ab4", "G4", "F4", "Eb4"],

		["Ab4", "D4", "C4", "Bb3"], ["Ab4", "D4", "C4", "Bb3"],
		["G4", "Bb3", "Ab3", "Eb4"], ["G4", "Bb3", "Ab3", "Eb4"],
		["F4", "C4", "Bb3", "A3"], ["F4", "C4", "Bb3", "A3"],
		["F4", "D4", "C4", "B3"], ["F4", "D4", "C4", "B3"],

		["F4", "D4", "C4", "B3"], ["F4", "D4", "C4", "B3"],
		["Eb4", "C4", "B3", "G3"], ["Eb4", "C4", "B3", "G3"],
		["F3", "Eb4", "D4", "F4"], ["F3", "Eb4", "D4", "F4"],
		["F#3", "C4", "B3", "Eb4"], ["F#3", "C4", "B3", "Eb4"],

		["Eb4", "C4", "B3", "G3"], ["Eb4", "C4", "B3", "G3"],
		["F#4", "C4", "B3", "A3"], ["F#4", "C4", "B3", "A3"],
		["G4", "C4", "B3", "D4"], ["G4", "C4", "B3", "D4"],
		["A4", "C4", "B3", "D4"], ["A4", "C4", "B3", "D4"]
	]
);
track(0).trackEnd(nextBeat(2.0));

track(1).programChange(1,0);
track(1).volume(0.4,0);
startAt(0);
playMotifs(track(1), preludeMotifLower,
	[
		["C3", "G3", "F3", "Eb3"], ["C3", "G3", "F3", "Eb3"],
		["C3", "Ab3", "G3", "F3"], ["C3", "Ab3", "G3", "F3"],
		["C3", "Ab3", "G3", "F3"], ["C3", "Ab3", "G3", "F3"],
		["C3", "Eb3", "D3", "G3"], ["C3", "Eb3", "D3", "G3"],

		["C3", "C4", "Bb3", "Ab3"], ["C3", "C4", "Bb3", "Ab3"],
		["C3", "A3", "G3", "F#3"], ["C3", "A3", "G3", "F#3"],
		["Bb2", "Bb3", "A3", "G3"], ["Bb2", "Bb3", "A3", "G3"],
		["Bb2", "G3", "F3", "E3"], ["Bb2", "G3", "F3", "E3"],

		["Ab2", "Ab3", "G3", "F3"], ["Ab2", "Ab3", "G3", "F3"],
		["Ab2", "D3", "C3", "F3"], ["Ab2", "D3", "C3", "F3"],
		["G2", "Eb3", "D3", "G3"], ["G2", "Eb3", "D3", "G3"],
		["C3", "Eb3", "D3", "Ab3"], ["C3", "Eb3", "D3", "Ab3"],

		["D3", "F3", "Eb3", "Ab3"], ["D3", "F3", "Eb3", "Ab3"],
		["Eb3", "G3", "F3", "Ab3"], ["Eb3", "G3", "F3", "Ab3"],
		["Eb3", "A3", "G3", "F3"], ["Eb3", "A3", "G3", "F3"],
		["D3", "F3", "Eb3", "Ab3"], ["D3", "F3", "Eb3", "Ab3"],

		["C3", "F3", "E3", "Ab3"], ["C3", "F3", "E3", "Ab3"],
		["C3", "Eb3", "D3", "F3"], ["Bb2", "Eb3", "D3", "F3"], //one different note
		["Ab2", "C3", "B2", "D3"], ["Ab2", "C3", "B2", "D3"],
		["A2", "Eb3", "D3", "C3"], ["A2", "Eb3", "D3", "C3"],

		["G2", "Eb3", "D3", "F3"], ["G2", "Eb3", "D3", "F3"],
		["G2", "Eb3", "D3", "C3"], ["G2", "Eb3", "D3", "C3"],
		["G2", "Eb3", "D3", "F3"], ["G2", "Eb3", "D3", "F3"],
		["G2", "Eb3", "D3", "F3"], ["G2", "Eb3", "D3", "F3"]

	]
);
track(1).trackEnd(nextBeat(0.0));