-
-
Notifications
You must be signed in to change notification settings - Fork 15
Renderer Class
spessasus edited this page Jun 15, 2023
·
11 revisions
This is the module that is resposible for drawing the waveforms and the notes.
const renderer = new Renderer(channelColors, synth)
- channelColors - an array of 16 strings with css colors for each channel.
- synth - an instance of Synthetizer class. Used for rendering its waveforms.
Makes a note with infinite length start falling from the top.
renderer.startNoteFall(midiNote, channel, timeOffsetMs);
- midiNote - the note to play. Ranges from 0 to 127.
- channel - the midi channel. Determines the note's color. Ranges from 0 to 15.
- timeOffsetMs - in miliseconds, how late the should the note start. How low the note starts is determined by the
noteFallingTimeMs
property. For example, ifnoteFallingTimeMs
is 1000ms (one second) and the offset is 500ms (half a second), then the note will instantly fill half of the screen and start falling from there.
Makes all matching notes stop falling from the top.
renderer.stopNoteFall(midiNote, channel, timeOffsetMs);
- midiNote - the note to stop. Ranges from 0 to 127.
- channel - the midi channel. Used for detecting notes to stop. Ranges from 0 to 15.
- timeOffsetMs - in miliseconds, how late the should the note cut off. How low the note gets cut off is determined by the
noteFallingTimeMs
property. For example, ifnoteFallingTimeMs
is 1000ms (one second) and the offset is 500ms (half a second), then the note will get cut off in the middle of the screen and it's "tail" will start falling from there.
Clears all notes instantly.
renderer.clearNotes(); // boom, notes are gone >:)
Pauses all the notes. Doesn't affect the waveforms.
renderer.pause(); // freeze!
Resumes the notes' fall. Doesn't affect the waveforms.
renderer.resume(); // go, my notes!
In miliseconds, how long should the note take to fall from the top to the bottom. Defaults to 1000ms.
renderer.noteFallingTimeMs = 1000; // notes will take one second to fall.
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!