Is it possible to add a "note off" event to a SequenceTrack?

I have a SequenceTrack for a looping instrument that will loop indefinitely, and I'd like to send it a signal to stop at a particular step in the sequence. Is there a way to do that?

(I'm using the C API.)

I think I figured it out. Adding a note event to the sequence with the same note and a velocity of 0 appears to send a "note off" event to the instrument.

Is this in fact the correct way to do it? If so, it should probably be added to the C API documentation!

(However, it also seems to produce incorrect behavior in regards to the instrument's ADSR envelope.)

I have a follow-up question: is it perhaps possible to have a "all notes off" event for a SequenceTrack? That is, every note that is currently being played on the track gets released?

Do you want to stop the playing or just mute a note at a certain step?

For my app PocketBM, I use playdate->sound->track->addNoteEvent and playdate->sound->track->removeNoteEvent to add or remove notes from the track while it's playing. Just make sure you remove the correct MIDI note value.

To stop at a certain step, I guess in your update function, you can get the current step by using playdate->sound->sequence->getCurrentStep and stop the playing when it's at the step that you want.

Thanks for the tip. I've been looking into manipulating the current sequence in the update function to accomplish what I'm after. But my original question is about seeing whether the sequence can contain all of the events necessary to do that without changing it as it plays.

The purpose of having a "note off" event (or even better, an "all notes off" event) as opposed to simply specifying the duration of each note is because I'm trying to implement a player for tracker files (e.g. mod, s3m) and in those formats, notes play indefinitely until another note plays on the same track, unlike a MIDI file where multiple notes can play simultaneously and each note has a specified duration.

It sounds like you may better off using playdate->sound->synth->playNote to play the notes in your update function rather than using the track.

That's the approach I'm taking now. SoundSequence just isn't really appropriate for what I'm trying to do.

1 Like