0

AudioUnitSampleType is a SInt32. When I log it to the console I get readings roughly between -22000 and 22000.

Can someone explain what those values represent? How do they describe the wave form? I suppose because they are positive and negative that the axis is in the center of the wave form.

How would I convert the values to decibel such that 0 dB is loudest?

Proud Member
  • 40,078
  • 47
  • 146
  • 231

1 Answers1

1

Although the sample type is a 32-bit int, the values you received will generally fit in a 16-bit int (ie, 32767..-32767). 32767 (or floating point 1.0) corresponds to 0dB.

After converting the sample to floating point value, the power in decibels looks something like this:

double sampleValue = (double)intSampleValue / 32767.0;
double db = 20.0 * log10(value);

I've done the above calculations as double precision to avoid overflow.

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160