Style tip: use .dbamp for audio amplitudes


i’ve been using this little notational quirk for a while and i think it’s worth sharing. give it a shot and see what you think.

audio engineers pretty much always think of amplitude ratios in terms of decibels. so instead of this…

SynthDef(\bla, {
    var snd;
    snd = * 0.7;
    snd = snd + ( * 0.01);
    snd = snd + ( * 0.05);\, snd * \;

…i’ve personally moved towards using .dbamp to notate gain factors when amplifying or attenuating audio signals:

SynthDef(\bla, {
    var snd;
    snd = * -3.dbamp;
    snd = snd + ( * -40.dbamp);
    snd = snd + ( * -26.dbamp);\, snd * \;

if you work with dB values normally in other software and hardware, then this should be a no-brainer.

even if you’re like me and you’re not an experienced audio engineer who thinks in dB, decibels are a boon to readability when you’re working with amplitudes across different orders of magnitude. visually comparing -60.dbamp to -80.dbamp seems a lot nicer than comparing 0.001 from 0.0001.

the inverse function, .ampdb, is helpful to convert existing gain values to decibels.

edit: removed incorrect statement that ears perceive amplitude on a roughly exponential scale. i have since learned that loudness perception is closer to linear with sound pressure.


I only built up muscle memory around using -6.dbamp instead of 0.5 a year or two ago. It makes a big difference in clarity, and I notice that I run myself into less cases where sounds are either super loud or way too quiet.


Besides @nathan and @scztt’s good points – an extra benefit to using dB values instead of amplitude is that mixing (and linear interpolation/animation) works very simply when using dB (only converting to amplitude if/when needed, as a final step). If you’re using patterns (playing anything that uses Event.default), you don’t even need to convert to \amp, you can just set the Event’s \db key instead!


Nowadays, I am using .dbamp mainly in SC.

A few weeks ago, I asked myself why the amplitude levels of displaying waveform in audio editors and DAWs are the linear scale.
SoundFileView in SC also uses the linear scale.
Audacity is a rare example supporting this, but the default level is linear.
Which is practical to use? I think displaying in dB is practical, but I am accustomed to the linear scale.


This is a good question - I am also accustomed to linear scale, since nearly all audio applications use it for displaying audio. My intuitive reaction to db scaling is that it increases the visual noise and makes it harder to pick things out in a waveform. I just tested and I can see where that reaction is coming from:

These are db-scaled waveforms, limited to -90, -60, and -30db respectively, and a linear scaled waveform at the bottom. The -90 and -60 waveforms (top 2) have very little useful information about dynamics at a glance. The -30db scale is slightly better, but in that view you’re effectively clipping everything below ~0.3. If I were working with this audio, the linear is clearly the most useful.

My guess: mostly when you’re doing visual inspection of a waveform, you’re either looking for recognizable shapes to find something (“where does that cymbal happen…”), or you’re looking for things that are too loud or too soft. In either of those cases, higher visual contrast for higher values (which is what linear scale gives you) is most useful. Honestly, trying to do either of those things in the mushy top view (-90db) would be a nightmare.

Another thing to keep in mind: in 97% of applications / UI cases, waveforms are showing peak values. These don’t really have a lot to do with how loud/not loud something sounds, so scaling them in a more psychoacoustically coherent way is… still not showing you anything very useful? It does make me wonder what a psychoacoustically useful waveform display would look like?


higher visual contrast for higher values (which is what linear scale gives you) is most useful.

I totally agree with you!

Displaying waveform in the linear scale using the level meter in dB is the best way to work!