Methods
bytesProcessed() → {number}
Number of bytes processed in the loaded MIDI file.
Returns:
- Type:
-
number
disableTrack(trackNumber) → {Player}
Disables a track for playing.
Parameters:
Name | Type | Description |
---|---|---|
trackNumber |
number
|
Track number |
Returns:
- Type:
-
Player
dryRun() → {Player}
Plays the loaded MIDI file without regard for timing and saves events in this.events. Essentially used as a parser.
Returns:
- Type:
-
Player
emitEvent(event) → {Player}
Sends MIDI event out to listener.
Parameters:
Name | Type | Description |
---|---|---|
event |
object
|
Returns:
- Type:
-
Player
enableTrack(trackNumber) → {Player}
Enables a track for playing.
Parameters:
Name | Type | Description |
---|---|---|
trackNumber |
number
|
Track number |
Returns:
- Type:
-
Player
endOfFile() → {boolean}
Determines if the player pointer has reached the end of the loaded MIDI file.
Used in two ways:
1. If playing result is based on loaded JSON events.
2. If parsing (dryRun) it's based on the actual buffer length vs bytes processed.
Returns:
- Type:
-
boolean
eventsPlayed() → {number}
Number of events played up to this point.
Returns:
- Type:
-
number
fileLoaded() → {Player}
Sets default tempo, parses file for necessary information, and does a dry run to calculate total length.
Populates this.events & this.totalTicks.
Returns:
- Type:
-
Player
getCurrentTick() → {number}
Gets the current tick number in playback.
Returns:
- Type:
-
number
getEvents() → {array}
Gets an array of events grouped by track.
Returns:
- Type:
-
array
getFilesize() → {number}
Get filesize of loaded file in number of bytes.
Returns:
- Type:
-
number
- The filesize.
getSongPercentRemaining() → {number}
Gets remaining percent of playback.
Returns:
- Type:
-
number
getSongTime() → {number}
Gets song duration in seconds.
Returns:
- Type:
-
number
getSongTimeRemaining() → {number}
Gets remaining number of seconds in playback.
Returns:
- Type:
-
number
getTotalEvents() → {number}
Gets total number of events in the loaded MIDI file.
Returns:
- Type:
-
number
getTotalTicks() → {number}
Gets total number of ticks in the loaded MIDI file.
Returns:
- Type:
-
number
getTracks() → {Player}
Parses out tracks, places them in this.tracks and initializes this.pointers
Returns:
- Type:
-
Player
isPlaying() → {boolean}
Checks if player is playing
Returns:
- Type:
-
boolean
loadArrayBuffer(arrayBuffer) → {Player}
Load an array buffer into the player.
Parameters:
Name | Type | Description |
---|---|---|
arrayBuffer |
array
|
Array buffer of file to be loaded. |
Returns:
- Type:
-
Player
loadDataUri(dataUri) → {Player}
Load a data URI into the player.
Parameters:
Name | Type | Description |
---|---|---|
dataUri |
string
|
Data URI to be loaded. |
Returns:
- Type:
-
Player
loadFile(path) → {Player}
Load a file into the player (Node.js only).
Parameters:
Name | Type | Description |
---|---|---|
path |
string
|
Path of file. |
Returns:
- Type:
-
Player
on(playerEvent, fn) → {Player}
Subscribes events to listeners
Parameters:
Name | Type | Description |
---|---|---|
playerEvent |
string
|
Name of event to subscribe to. |
fn |
function
|
Callback to fire when event is broadcast. |
Returns:
- Type:
-
Player
playLoop(dryRun) → {undefined}
The main play loop.
Parameters:
Name | Type | Description |
---|---|---|
dryRun |
boolean
|
Indicates whether or not this is being called simply for parsing purposes. Disregards timing if so. |
Returns:
- Type:
-
undefined
setStartTime(startTime) → {Player}
Setter for startTime.
Parameters:
Name | Type | Description |
---|---|---|
startTime |
number
|
UTC timestamp |
Returns:
- Type:
-
Player
setTempo(tempo)
Setter for tempo.
Parameters:
Name | Type | Description |
---|---|---|
tempo |
number
|
Tempo in bpm (defaults to 120) |
skipToPercent(percent) → {Player}
Skips player pointer to specified percentage.
Parameters:
Name | Type | Description |
---|---|---|
percent |
number
|
Percent value in integer format. |
Returns:
- Type:
-
Player
skipToSeconds(seconds) → {Player}
Skips player pointer to specified seconds.
Parameters:
Name | Type | Description |
---|---|---|
seconds |
number
|
Seconds to skip to. |
Returns:
- Type:
-
Player
skipToTick(tick) → {Player}
Skips player pointer to specified tick.
Parameters:
Name | Type | Description |
---|---|---|
tick |
number
|
Tick to skip to. |
Returns:
- Type:
-
Player