How to smoothly change the pitch of a playing synth sound

Hi! Audio newbie looking to play a synth while changing the pitch dynamically. I can achieve this by stopping and starting the sound, but this prevents LFO from working.
Can someone instruct me? Thanks!

Also - is there no audio tag?

2 Likes

Hi did you figure this one out?

I just took another look at this, and it's a bit of a mess right now. In theory you should be able to call synth:setLegato(true) and then when you do playNote() it won't reset the synth's envelope but instead continue legato style, only changing the pitch. Any LFOs attached to the synth will reset, but you can stop that with lfo:setRetrigger(false). In practice, though, setLegato() doesn't appear to work. So I tried synth:getEnvelope():setRetrigger(false) but I discovered a bug where synths won't play after setEnvelope() is called on them. :person_facepalming: I fixed the getEnvelope() bug and it's still not quite right, something's getting reset by the playNote() call.

Okay.. multiple playNote()s isn't going to work right now, so how about using the frequency modulator? I added custom signals to the C API, but they're not available in Lua because running Lua code on the audio thread isn't feasible at all. We can abuse LFOs to make a constant value, though:

snd = playdate.sound

s = snd.synth.new(snd.kWaveSquare)

l = snd.lfo.new()
l:setRate(0)
l:setDepth(0)
s:setFrequencyMod(l)

function playdate.AButtonDown() s:playNote("C3") end
function playdate.AButtonUp() s:noteOff() end

function playdate.update()
  l:setCenter(playdate.getCrankPosition()/360)
end

Not the best solution, but it does work. Thanks for the question! It uncovered a number of bugs that have crept in. And apologies for the very late response. I missed the post first time around, and then we've just been crazy busy this last month. :sweat_smile:

I've just hit this, I think. Can I confirm it is still an issue in the latest 2.x? Thanks

With a normal bug tracker we'd have visibility of status, so all I can do is ask here.

Uh, which part did you hit? There were a number of different bugs that popped up there. :flushed:

We talked a while about whether a public bug tracker would be useful or not. I don't remember the details but I think what we decided in the end is that the SDK Bug Reports topic here works well enough for now. It would be more useful if we remembered to leave a note on threads when we've shipped a fix to the bug. I'll.. file an issue on that, I guess?

2 Likes