Returns the playback state of the player, either "started", "stopped", or "paused".
Returns false iff the player is completely stopped. This will only be false after creating the player or after calling stop(), and will be true after calling start(), pause() or resume().
Loads the audio samples for all valid midi pitches, for a specific program.
Note: this method is rather slow; only use it if you're sure
that you need to load all possible samples (for example, you're
playing a stream of live notes from the user) -- otherwise, if you already
have the NoteSequence you have to play, use loadSamples
instead.
If you do end up using loadAllSamples
, make sure you're calling it
asynchronously, as to not block other main thread work (like UI
interactions) while waiting for it to finish.
(optional) Program number to use for instrument lookup. Default is 0.
(optional) True if the drum status should be used for instrument lookup. Default is false.
Loads the audio samples required to play a NoteSequence.
The NoteSequence to be played.
Pause playing the currently playing sequence right away. Call resume() to resume.
Resume playing the sequence after pause().
Resumes the Audio context. Due to autoplay restrictions, you must call this function in a click handler (i.e. as a result of a user action) before you can start playing audio with a player. This is already done in start(), but you might have to call it yourself if you have any deferred/async calls.
Seek to a number of seconds in the NoteSequence.
Changes the tempo of the playback.
The new qpm to use.
Stop playing the currently playing sequence right away.
Generated using TypeDoc
A
NoteSequence
player based on Tone.js that uses SoundFont samples. TheloadSamples
method may be called beforestart
so that the samples necessary for playing the sequence will be loaded and playing will begin immediately uponstart
.Example (explicitly loading samples):
player.loadSamples(seq).then(() => { player.start(seq) })
Explicitly loads samples, so that playing starts immediately when
start
is called.Example (implicitly loading samples):
player.start(seq)
If the samples for
seq
have not already been loaded, playing will only start after all necessary samples have been loaded.