music21j -- Javascript reimplementation of Core music21p features.
music21/miditools -- A collection of tools for midi. See the namespace music21.miditools
Copyright (c) 2014-19, Michael Scott Cuthbert and cuthbertLab
Based on music21 (=music21p), Copyright (c) 2006–19, Michael Scott Cuthbert and cuthbertLab
- Source:
Classes
Members
-
<static, constant> exports.callBacks
-
callBacks is an object with three keys:
- raw: function (t, a, b,c) to call when any midi event arrives. Default:
function (t, a, b, c) { return new miditools.Event(t, a, b, c); }
- general: function ( miditools.Event() ) to call when an Event object has been created. Default:
[miditools.sendToMIDIjs, miditools.quantizeLastNote]
- sendOutChord: function (array_of_note.Note_objects) to call when a sufficient time has passed to build a chord from input. Default: empty function.
At present, only "general" can take an Array of event listening functions, but I hope to change that for sendOutChord also.
"general" is usually the callback list to play around with.
- Source:
- raw: function (t, a, b,c) to call when any midi event arrives. Default:
-
<static, constant> exports.loadedSoundfonts :Object
-
a mapping of soundfont text names to true, false, or "loading".
Type:
- Object
- Source:
-
<static, constant> exports.sendToMIDIjs
-
Callback to midiEvent.sendToMIDIjs.
- Source:
Methods
-
<static> exports.clearOldChords()
-
Clears chords that are older than miditools.heldChordTime
Runs a setTimeout on itself.
Calls miditools.sendOutChord- Source:
-
<static> exports.loadSoundfont(soundfont, callback)
-
method to load soundfonts while waiting for other processes that need them
to load first.Parameters:
Name Type Argument Description soundfont
string The name of the soundfont that was just loaded
callback
function <optional>
A function to be called after the soundfont is loaded.
- Source:
Example
s = new music21.stream.Stream(); music21.miditools.loadSoundfont( 'clarinet', function(i) { console.log('instrument object', i, 'loaded'); s.instrument = i; });
-
<static> exports.makeChords(jEvent)
-
Take a series of jEvent noteOn objects and convert them to a single Chord object
so long as they are all sounded within miditools.maxDelay milliseconds of each other.
this method stores notes in miditools.heldChordNotes (Array).Parameters:
Name Type Description jEvent
music21.miditools.Event - Source:
Returns:
undefined
-
<static> exports.postLoadCallback(soundfont, callback)
-
Called after a soundfont has been loaded. The callback is better to be specified elsewhere
rather than overriding this important method.Parameters:
Name Type Description soundfont
string The name of the soundfont that was just loaded
callback
function A function to be called after the soundfont is loaded.
- Source:
-
<static> exports.quantizeLastNote(lastElement) → {music21.note.GeneralNote}
-
Quantizes the lastElement (passed in) or music21.miditools.lastElement.
Parameters:
Name Type Argument Description lastElement
music21.note.GeneralNote <optional>
A
music21.note.Note
to be quantized- Source:
Returns:
The same
music21.note.Note
object passed in with
duration quantized -
<static> exports.sendOutChord(chordNoteList) → {music21.note.Note|music21.chord.Chord|undefined}
-
Take the list of Notes and makes a chord out of it, if appropriate and call
music21.miditools.callBacks.sendOutChord
callback with the Chord or Note as a parameter.Parameters:
Name Type Description chordNoteList
Array.<music21.note.Note> an Array of
music21.note.Note
objects- Source:
Returns:
A
music21.chord.Chord
object,
most likely, but maybe amusic21.note.Note
object)- Type
- music21.note.Note | music21.chord.Chord | undefined