sound.synth.tone

sound.synth

tone(opts) -> buf, err

Generate a tone buffer

opts fielddefaultdescription
freq440frequency, Hz
notenilnote name such as "A4" or "C#5"; used when freq is absent
dur0.25duration, seconds
rate48000sample rate, Hz
channels2channel count
wave"sine""sine", "square", "saw", "triangle", or "noise"
amp0.5amplitude, 0..1
attack0.005ADSR attack, seconds
decay0.0ADSR decay, seconds
sustain1.0ADSR sustain level, 0..1
release0.02ADSR release, seconds
seednilnoise only: a 32-bit seed that makes the tone the same every call; without it the noise draws the process-wide stream, so two tones differ

Returns nil and an error for an unreadable note or an unknown wave.