MidiAudioPlayer

Source: MidiAudioPlayer.js:45

A simple MIDI player based on MidiPlayerJS
https://github.com/grimmdude/MidiPlayerJS
See also: http://www.midijs.net (https://github.com/babelsberg/babelsberg-js/tree/master/midijs)


Constructor

new MidiAudioPlayer( data: external:ArrayBuffer, options?: object, ): MidiAudioPlayer

MidiAudioPlayer constructor

Parameters

  • data (external:ArrayBuffer) — The MIDI file content, in ArrayBuffer format
  • options (object, optional, default: "{}") — Optional params related to the type of soundfont used. Valid options inside this object are:

Instance Methods

pause()

Pauses the player

play()

Starts or resumes playing

playEvent(ev: object)

Plays a MIDI event

Parameters

Static Methods

prepareInstrument( options: object, audioContext: external:AudioContext, )

Initializes the soundfont instrument, loading data from GitHub
NOTE: This will not work when off-line!
TODO: Provided a basic, simple, static soundfont

Parameters

Instance Fields

paused

Gets the ' paused' state of the current player

Returns

  • boolean

ended

Checks if the current player has ended or is already playing

Returns

  • boolean

currentTime

Gets the current time

Returns

  • number

currentTime

Sets the current time of this player (in milliseconds)

Parameters

  • time (number) — The time position where the player pointer must be placed

data: external:ArrayBuffer

The MIDI file data used by this MIDI player

player: external:MidiPlayerJS

The grimmdude's MidiPlayer used by this player

playTo: number

When >0, time position at which the music must end

mainVolume: number

Main volume of this track (set with a MIDI message of type Controller Change #7)

startedNotes: Array.<function()>

This array is used when processing 'Note off' events to stop notes that are currently playing.
It contains a collection of 'instrument.play' instances, one for each active note

Static Fields

audioContext: external:AudioContext

The external:AudioContext used by this MIDI player.

instrument: external:Instrument

The "Instrument" object used by this MIDI player.
See: https://github.com/danigb/soundfont-player

loadingInstrument: boolean

A flag used to avoid re-entrant calls to prepareInstrument

MIDISoundFontObject: object

An object containing the full soundfont data used by instrument
When this member is set, no other settings related to the sounfFont will be used.
This value can be overwritten by the global parameter MIDISoundFontObject

MIDISoundFontBase: string

The URL used as base for the current collection of MIDI soundfonts.
This value can be overwritten by the global parameter MIDISoundFontBase

MIDISoundFontName: string

The MIDI instrument name.
This value can be overwritten by the global parameter MIDISoundFontName
See MIDI.js Soundfonts for full lists of MIDI instrument names.

MIDISoundFontExtension: string

An extension to be added to MIDISoundFontName in order to build the full file name of the soundfont JS file.
Current valid options are -mp3.js and -ogg.js
This value can be overwritten by the global parameter MIDISoundFontExtension