Calling `playdate.sound.synth:setFrequencyMod()` with nil after it previously had a mod causes crashes

So I have a synth. I had set it up with an arpeggio frequency mod like so:

local mod <const> = snd.lfo.new()
mod:setRetrigger(true)
mod:setArpeggio(0, obj.effect.note0, obj.effect.note1)
mod:setRate(obj.effect.rate)
synth:setFrequencyMod(mod)

But then later I try to remove that mod, by calling synth:setFrequencyMod(nil), and the Playdate simulator immediately crashes.

	mod->used = 1;

and mod is NULL there. :man_facepalming: This has been in there since Dec. 2017, and pretty much every other modulator setter function does the same thing, too. Oof.

okay, fixed! As a temporary workaround you could use a dummy modulator, like

dummymod = snd.lfo.new()
dummymod:setDepth(0)
1 Like