Synth for UI Sound Effects

I don't know much about synths, but I'd like to use the synth features to generate UI sounds. From the Steven Frank YouTube demo, I got this bit of code to make some sound:

local snd = playdate.sound
local synth = snd.synth.new(snd.kWaveSawtooth)
synth:setADSR(0,0.1,0,0)
synth:playNote(200)

And of course I can tweak that to make other sounds, but I'm wondering if anyone has any tips/tools/tutorials or even pre-made values for nice sounds?

We built a basic utility function to help simplify it visually when creating a new synth:

function _newSynth(a, d, s, r, volume, sound)
	local synth = playdate.sound.synth.new(sound)
	synth:setADSR(a, d, s, r)
	synth:setVolume(volume)
	return synth
end

and a few random very basic placeholder/in-progress UI sounds I've been using:

boop = _newSynth(0.2, 0.02, 0, 0, 0.6, snd.kWavePOVosim)
beep = _newSynth(0, 0.04, 0, 0, 0.25, snd.kWaveSawtooth)
blop = _newSynth(0, 0.1, 0, 0.2, 0.4, snd.kWavePOVosim)

...

boop:playNote(220)
boop:playNote(440)
beep:playNote(200)
blop:playNote(620)

It's probably going to depend how deep you want to get into sound design. Do you know how envelopes work in general? Or if you're interested in learning, that would be a good place to start. If you don't, you may find that twiddling with ADSR can sometimes feel a little frustrating or unintuitive.

One tip to keep in mind is that the audio functions all use seconds as values, but that envelopes (for short UI sounds) can often have very small values, so you may want to think about it in ms, as many DAWs do.

Attack, Delay, and Release might land between 0.00s and 1.00s generally, but not limited to it. It's important to note that Sustain works differently, it's a volume value between 0 and 1 that the note sustains when it's being held, which is only particularly relevant if you're also using the [length] property of :playNote() to play your note.

There's tons of great info online about envelopes and sound design, so it really depends how crazy you want to go. :slight_smile: The infograph on this page is a pretty good explanation of ADSR.

Good luck!

4 Likes

Wow, couldn't have asked for a better answer, thank you! I will be digging in to all of this.

1 Like

Unrelated, but can I ask when you use underscore in front of a function name? I'm new to Lua and just really curious to learn more about techniques people use.

btw, the youtube video on the page you linked is excellent.

1 Like

absolutely no technical reason :laughing: - we're just slowing building a _utilities.lua file for ourselves to reuse general convenience functions we've made... but across future projects. So my personal way to keep those straight against other SDK functions or Lua functions is to add the underscore.

1 Like

Check out the tool I made. Might be very useful when working with synth

1 Like

That's excellent, lovely UI for that too!

You can also use something like jsfxr: https://sfxr.me

But there's some work to map the values it produces to Playdate functions as their names are different and some missing functions will need reimplementing.

It'd be great to have something like jsfxr natively on Playdate. I'd be happy to assist if somebody wanted to take it on?

1 Like