tone(
opts) ->buf,err
Generate a tone buffer
| opts field | default | description |
|---|---|---|
freq | 440 | frequency, Hz |
note | nil | note name such as "A4" or "C#5"; used when freq is absent |
dur | 0.25 | duration, seconds |
rate | 48000 | sample rate, Hz |
channels | 2 | channel count |
wave | "sine" | "sine", "square", "saw", "triangle", or "noise" |
amp | 0.5 | amplitude, 0..1 |
attack | 0.005 | ADSR attack, seconds |
decay | 0.0 | ADSR decay, seconds |
sustain | 1.0 | ADSR sustain level, 0..1 |
release | 0.02 | ADSR release, seconds |
seed | nil | noise 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.