Set amplitude in decibels?

robedney

Member
Quick dumb question:

I'm building an audio-metric hearing test into my project using Teensy and the audio shield. I've pretty much figured out the program structure, but I need to control the amplitude in decibels. How might I rewrite the following to do that?

waveform1.frequency(440);
waveform1.amplitude(0.9);
wait(250);
waveform1.amplitude(0);
wait(1750);

Thanks so much!
 
What is the reference amplitude?
decibels are relative measurements.
Also decibel of amplitude(0) does not exist. It is minus infinity!

now to your question:
Assume reference amplitude is 1.0, then
the amplitude(0.9) = amplitude(pow(10,-0.915/20))
the amplitude(0.1) = amplitude(pow(10,-20/20))
the amplitude(0.01) = amplitude(pow(10,-40/20))

the values -0.915, -20, -40 are the decibel values relative to 1.0

now, if you wanted to attenuate your signal by 6 dB, then you divide the amplitude by 2
in case of 20 dB attenuation you divide amplitude by 10
and so on

in case of amplification, you multiply and nor divide
 
Back
Top