-
-
Notifications
You must be signed in to change notification settings - Fork 13
Sequencer Class
This is the module that plays the parsed MIDI files using the Synthetizer
class.
import {Sequencer} from "./spessasynth_lib/sequencer/sequencer.js";
const sequencer = new Sequencer(parsedMidi, synth);
- parsedMidi - the parsed MIDI file to play, an instance of the
MIDI
class. - synth - the synthetizer to use. An instance of the
Synthetizer
class.
Connects an instance of the Renderer
class to the sequencer for visualization of the played sequence.
sequencer.connectRenderer(renderer);
- renderer - an instance of the
Renderer
class to connect the sequencer to.
Starts playing the sequence. If the sequence was paused, it won't change any controllers, but if it wasn't (ex. the time was changed) then it will go through all the controller changes from the start before playing. This function does NOT modify the current playback time!
sequencer.play(resetTime);
- resetTime - boolean, if set to
true
then the playback will start from 0. Defaults tofalse
;
Pauses the playback of the sequence.
sequencer.pause();
Stops the playback of the sequence. Currently only used internally by the pause
function.
sequencer.stop();
Read-only boolean, indicating that if the sequencer's playback is paused.
if(sequencer.paused)
{
console.log("Sequencer paused!");
}
else
{
console.log("Sequencer playing or stopped!");
}
Boolean that controls if the sequencer loops.
sequencer.loop = false; // the playback will stop after reaching the end
Property used for changing and reading the current playback time.
Returns the current playback time in seconds.
console.log("The sequences is playing for"+sequencer.currentTime+" seconds.");
Sets the current playback time. Calls stop
and then play
internally.
sequencer.currentTime = 0; // go to the start
Length of the track in seconds. Equivalent of Audio.duration
;
console.log(`The track lasts for ${sequencer.duration} seconds!`);
Tip
If you encounter any errors in this documentation, please open an issue!
Warning
Make sure you always update worklet_processor.min.js
along with the npm package!