Sequence breaks on excessive tempo changes

Mac SDK 1.12.3

In our game Grand Tour Legends we have a ratchet clicking sound effect playing when you're not pedalling - its trigger frequency based on the speed you're going. We tried using playdate.sound.sequence to get better timing resolution for this effect, but met with some problems:

  1. the audio engine plays garbage if a Sample is shorter than the duration of a note (which varies with tempo)
  2. we modulate the sequence tempo every frame in a very wide range, after a few seconds the sequence stops playing.
function self:startTicks()
    local inst = snd.instrument.new()
    for i = 1, kTickSamples do
        local sample = snd.sample.new('audio/tick_' .. i)
        local s = snd.synth.new(sample)
        inst:addVoice(s, i)
    end

    local track = snd.track.new()
    track:setInstrument(inst)
    for i = 1, kTickSamples do
        track:addNote(i, i, 1, 100)
    end

    self.tickChannel = snd.channel.new()
    self.tickChannel:addSource(inst)

    self.tickSequence = snd.sequence.new()
    self.tickSequence:addTrack(track)
    self.tickSequence:setLoops(0, 6)
    self.tickSequence:setTempo(10)
    self.tickSequence:play()
end

function self:setTickSpeed(speed)
    self.tickSequence:setTempo(speed)
end
1 Like

I finally had a chance to look at this, sorry for the delay. I'm not having any luck reproducing the problem. Here's my demo, based on the above: sequencetempo.pdx.zip (60.2 KB) (Source: source.zip (65.8 KB)) Hit up and down buttons to speed up/slow down the sequence.

I'm not sure what the fundamental difference is between this and yours. :thinking: If you post your tick sounds I could see if that has anything to do with it.

ha. Right after posting that I reread

we modulate the sequence tempo every frame in a very wide range

so I added sequence:setTempo(math.random(120)) to the A button. After five or six of those the sequence does stop playing. I think it's goofing up the current time offset calculation and getting so out of whack it confuses the player--when doing the up and down buttons I sometime get a bit of a stall in the sequence.

I'll take a peek in the debugger and see if that's the issue or it's something else.

1 Like

Dave, you're the best!

Any progress on this? I realise it's not top priority :smiling_face:

I finally got a fix in for this, scheduled it for 2.1.0. Sorry for the delay!

1 Like