music.js

easily generate frequencies for notes, chords, scales, and more

This demo uses music.js with audiolet.js for audio synthesis

note syntax

var n = Note.fromLatin('A4');

var freq = n.frequency(); // returns 440
var name = n.latin(); // returns "A"
var octave = n.octave(); // returns 4

note demo

note accidental octave

chord syntax

// by intervals
var c = Note.fromLatin('C4');
var cmaj = c.add(['unison','major third','fifth']);

// or by note names
var cmaj = Note.fromLatin('C4E4G4');


// then loop through chord array for each note object
for (var i = 0; i < cmaj.length; i++) {
console.log(cmaj[i].frequency());
}

chord demo

note accidental octave

unison
minor second
major second
minor third
major third
fourth
augmented fourth
tritone
diminished fifth
fifth
minor sixth
major sixth
minor seventh
major seventh
octave

scale syntax

var n = Note.fromLatin('C4');
var majorScale = n.scale('major');

// then loop through scale array for each note object
for (var i = 0; i < majorScale.length; i++) {
console.log(majorScale[i].frequency());
}

scale demo

note accidental octave


transpose syntax

var c = Note.fromLatin('C3');

// by semitone
var wholeStep = Interval.fromSemitones(2);
var d = c.add(wholeStep);
console.log(d.latin()); // "D"

// by interval name
var g = c.add('fifth');
console.log(g.latin()); // "G"