Sequence:setLoops doesn't stop when it should?

I'm trying this on Windows, SDK v2.0.3 but I think the problem is older than that.

This is what I'm doing:

  1. Create a sequence, add a track, add a synth
  2. Add Notes to a track on positions 1,5,9,13 (making the sequence greater than 5 steps)
  3. Set the sequence to loop from position 1 to 5 two times
  4. The sequence plays twice, but after that it continues to the end of the sequence. Shouldn't it stop at position 5?

sequence:setLoops(1,5,2)
The sequence plays like this:
1,2,3,4,5,1,2,3,4,5,6,7,8,9,10,11,12,13,stop

Example code:


local seq2 = playdate.sound.sequence.new()
seq2:setTempo(4)
local track = playdate.sound.track.new()
seq2:addTrack(track)

track:addNote(1, "C3", 1, 1)
track:addNote(5, "C4", 1, 1)
track:addNote(9, "C5", 1, 1)
track:addNote(13, "C6", 1, 1)

local synth = playdate.sound.synth.new(playdate.sound.kWavePOVosim)
synth:setADSR(0, 0.1, 0.6, 0)
local instrument = playdate.sound.instrument.new()
instrument:addVoice(synth)
track:setInstrument(instrument)

seq2:setLoops(1, 5, 2)
seq2:play()

note: it doesn't matter where I call setLoops(), the result is always the same.

I guess it's a little redundant for me to say "no I'd expect it to continue to the end of the sequence" since that's how I implemented it. Can you explain the case where you've got notes in a sequence but you don't want to play all of them? I can kind of imagine if you've got a large sequence and you want to play a section of it, though setting a loop range doesn't seem the obvious way to do that. We could add a setPlayRange() function like sampleplayer has, or add arguments to play() to set a range.

1 Like

I would love if the two had matching method names (and arguments)