Namespace: miditools

music21. miditools

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

Event
MidiPlayer

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:

<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:
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.Note played.
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
soundfont String

The name of the soundfont that was just loaded

callback function

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
jEvent music21.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
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> miditools.quantizeLastNote(lastElement) → {music21.note.GeneralNote}

Quantizes the lastElement (passed in) or music21.miditools.lastElement.

Parameters:
Name Type Description
lastElement music21.note.GeneralNote

A music21.note.Note to be quantized

Source:
Returns:

The same music21.note.Note object passed in with
duration quantized

Type
music21.note.GeneralNote

<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.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 a music21.note.Note object)

Type
music21.note.Note | music21.chord.Chord | undefined

<static> miditools.sendToMIDIjs(midiEvent)

Callback to midiEvent.sendToMIDIjs.

Parameters:
Name Type Description
midiEvent music21.miditools.Event

event to send out.

Source:
Returns:

undefined

Music21j, Copyright © 2013-2018 Michael Scott Cuthbert and cuthbertLab.
Documentation generated by JSDoc 3.5.5 on Wed Jul 4th 2018 using the DocStrap template.