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?
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?
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. 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.