Constructor
new SynthesizerPlayer(audioContext, synthesizer, notes, duration)
Create a SynthesizerPlayer.
Parameters:
| Name | Type | Description |
|---|---|---|
audioContext |
Object | An AudioContext. |
synthesizer |
Object | A synthesizer for playing notes. |
notes |
Object | The notes to play. |
duration |
number | The duration of the notes. |
Methods
(async) isReady() → {Promise}
Is this player ready to play? This returns a Promise that is already resolved to true.
Returning a Promise makes this method compatible with the isReady() method of the AudioFilePlayer.
Returns:
A promise resolved to true.
- Type
- Promise
pause()
Pause playing.
play()
Play the notes with this synthesizer.
playNotes()
Plays notes by determining which notes need to be played and starting note scheduling via setInterval().
scheduleCurrentNotes()
Schedules notes to be played in the current scheduling interval when called by setInterval().
setTimeRange(start, stop)
Sets the specified time range for playing notes.
Parameters:
| Name | Type | Description |
|---|---|---|
start |
number | The start time. |
stop |
number | The end time. |
skip(time)
Skip to playing at the specified time. If this player is not paused, playing will stop and then immediately continue at the specified time.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number | The time to skip to. |
stop()
Stop playing.
stopNotes()
Stops notes by clearing both the note scheduling interval and the ending interval.