MidiClip

Object containing all data needed to record and render a MIDI audio clip.

Methods

async finalize()

Stops recording any future MIDI data within the MidiClip, finalizes the internal storage of all recorded data, and calls the user-completion notification callback, if registered.

Note that this function is called automatically if the original call to recordMidiClip() specified a concrete duration for the clip. If no duration was specified, then this function must be called in order to stop recording. A MidiClip is unable to be used or played back until this function has been called.

getDuration() → {number}

Returns the total duration of the MIDI clip in seconds.

Returns:
number -

Duration of the MIDI clip in seconds

async getEncodedData(encodingType) → {Blob}

Encodes this MidiClip into a Blob containing raw audio data according to the EncodingType specified in the encodingType parameter.

Parameters:
Name Type Description
encodingType number

Numeric value corresponding to the desired EncodingType

Returns:
Blob -

Data Blob containing the newly encoded audio data

See:

getRawData() → {Object}

Returns a dictionary of all MIDI event data within the MidiClip, stored according to the relative times (in seconds) that they were received.

Returns:
Object -

Dictionary containing MIDI event data stored according to their relative reception times

notifyWhenComplete(notificationCallback)

Allows a user to register a callback for notification when all MIDI recording activities have been completed for this MidiClip. This corresponds to the time when the finalize() function gets called, either manually or automatically.

A user-defined notification callback will be called with a single parameter which is a reference to this MidiClip.

Parameters:
Name Type Description
notificationCallback RecordCompleteCallback

Callback to fire when recording of this clip has completed