Module that holds music21 tools for connecting with MIDI.js and somewhat with the
events from the Jazz plugin or the WebMIDI protocol.
- Source:
Classes
Members
-
<static> miditools.callBacks
-
callBacks is an object with three keys:
- raw: function (t, a, b,c) to call when any midievent 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 midievent arrives. Default:
-
<static> miditools.heldChordNotes :Array|undefined
-
An Array (or undefined) of currently held chords that have not been sent out yet.
Type:
- Array | undefined
- Source:
-
<static> miditools.heldChordTime :number
-
At what time (in ms since Epoch) the chord started.
Type:
- number
- Source:
-
<static> miditools.lastElement :music21.chord.Chord|music21.note.Note|undefined
-
The last Note or Chord to be sent out from miditools. This is an important semi-global
attribute, since the last element may need to be quantized by quantizeLastNote() to
determine its length, since the note may need to be placed into a staff before its total
length can be determined.Type:
- music21.chord.Chord | music21.note.Note | undefined
- Source:
-
<static> miditools.loadedSoundfonts :object
-
a mapping of soundfont text names to true, false, or "loading".
Type:
- object
- Source:
-
<static> miditools.maxDelay :number
-
How long to wait in milliseconds before deciding that a note belongs to another chord. Default 100ms
Type:
- number
- Source:
-
<static> miditools.metronome :music21.tempo.Metronome
-
Assign (or query) a Metronome object to run all timing information.
Type:
- Source:
-
<static> miditools.timeOfLastNote :number
-
When, in MS since Jan 1, 1970, was the last
music21.note.Noteplayed.
Defaults to the time that the module was loaded.Type:
- number
- Source:
Methods
-
<static> miditools.clearOldChords()
-
Clears chords that are older than miditools.heldChordTime
Runs a setTimeout on itself.
Calls miditools.sendOutChord- Source:
-
<static> miditools.loadSoundfont(soundfont, callback)
-
method to load soundfonts while waiting for other processes that need them
to load first.Parameters:
Name Type Description soundfontString The name of the soundfont that was just loaded
callbackfunction 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> miditools.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 jEventmusic21.miditools.Event - Source:
Returns:
undefined
-
<static> miditools.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 soundfontString The name of the soundfont that was just loaded
callbackfunction A function to be called after the soundfont is loaded.
- Source:
-
<static> miditools.quantizeLastNote(lastElement) → {music21.note.GeneralNote}
-
Quantizes the lastElement (passed in) or music21.miditools.lastElement.
Parameters:
Name Type Description lastElementmusic21.note.GeneralNote A
music21.note.Noteto be quantized- Source:
Returns:
The same
music21.note.Noteobject passed in with
duration quantized -
<static> miditools.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.sendOutChordcallback with the Chord or Note as a parameter.Parameters:
Name Type Description chordNoteListArray.<music21.note.Note> an Array of
music21.note.Noteobjects- Source:
Returns:
A
music21.chord.Chordobject,
most likely, but maybe amusic21.note.Noteobject)- Type
- music21.note.Note | music21.chord.Chord | undefined
-
<static> miditools.sendToMIDIjs(midiEvent)
-
Callback to midiEvent.sendToMIDIjs.
Parameters:
Name Type Description midiEventmusic21.miditools.Event event to send out.
- Source:
Returns:
undefined