Getting voltage data for postprocessing in Audacity

Dear all,

I m new to audacity and currently trying to learn and use audacity to record audible vibration from some mechanical testing. I had a 30khz resonant type acoustic emission sensor connecting to a preamplifier to amplify the signal. The signal was eventually transmitted through a external usb type sound card to my dell inspiron 15 laptop. I also realized audacity had a good gui and convenient to use during the monitoring process.

Till now, i managed to obtain the wanted audio signal. I could even export part of the audio data (i believed it is already converted to machine bit or bytes unit from the voltage) into csv file for postprocessing purpose. However, i still find the output csv data was shown in either linear scale or db units. They r both relative terms after taking into account the “peak” voltage or a spefified amplitude (i guess).

How can we see the voltage data when it is sent to the sound card? If not, is there any way to see the reference value being used to normalize the data to become relative nature?

Lookong forward to the replies.
Thanks!

To get absolute voltage measurements, you would need to input a known signal into the usb type sound card as a reference level.
Usually you would use a maximum level signal as your “0 dB” reference, then adjust the amplifier and USB sound card input gain so that it produces “full scale” (0 dB, linear 1.0) in Audacity.

Note that most audio sound cards roll off the frequency response at around 20 kHz.

All that and you have to make sure Windows isn’t helping you with voice management, ambience processing and echo reduction. Windows always assumes you’re a corporate user with a business account and conferencing, not a scientist.

People with science jobs always have trouble with Audacity. Audacity’s Prime Directive as a sound editor is to sound good, not maintain strict data accuracy.

Koz

Good point Koz, though typically Windows doesn’t enable effects for USB device.
To check that Windows isn’t adding effects, ensure that Windows Sound “Enhancements” (if present) are turned off (see: FAQ:Recording - Troubleshooting - Audacity Manual)

I presume that you are referring to “dither”. For “scientific” work, it’s usually best to turn off “dither” in Preferences (see: Quality Preferences - Audacity Manual)
For audio processing, it is generally best for “High Quality Conversion” to use “Shaped” dither, as this reduces quantization noise when exporting in less than 32-bit format.

Dear all,

Thank you very much to all the great replies, which were indeed quite specific to the manipulation of audacity audio proxessing.

Thabks koz, I understood the fact that audacity is not primary created for data analysis purpose, and the main reason i used this audio program was simply its good gui. I used python for my post processing data. iIt seems to me all kind of wav data also presenting in “relative” way and the outcome from audacity identical to other ways (python audio record, etc). I felt the current audio quality is good and able to show the information i m seeking.

Actually, the ae sensor could measure a wide range frequency (100hz to 30khz), but my main focus was to measure frequency of movement of particles near 6khz, which was audible and sounds like a finger click.Yeah, i knew Steve’s suggestion was to conduct a calibration test to obtain the 0db reference before the test.

Steve, i am still wondering how does the audacity selecting the 0db reference raw value? Is it a fixed value that was decided before any realtime monitoring, or it was selected progressively on the course of monotoring? Is it possible way to allow us checking the selected threshold value from the program? (I suspected the data had been normalized all the way during the recording, and we could not retrieve if this was the fact)

Thanks again for the replies. Initially i was worried the audacity forum was not active recently. But it looks good!

Looking forward to hearing from you soon.

Dear all,

Thanks for the comments.

Koz, i understood that audacity was not primary designated for data analysis, especially for windows users. Up to now, the audio data obtained was good to allow me se the infornation i m seeking.

Steve, you meant to say a calibration test was required before test, to determine the voltage corresponding to 0db. I am stil wonder whether we can retrieve the 0db reference value from the program? I suspected that the program normalized the data wrt the preset 0db value during the recording whilst that reference value was not stored. I m curious how do they decided that value? Is the value referred to a value decided (and can be computed?) or it was picked up “peak” progressively in the test?
This was cobfusing to me.

Thanks again and looking forward to hearing from u all soon.

Audacity’s 0 dB reference level is determined from the data format.

For integer formats:
16-bit 0dB is 32,767 or -32,768 (the most negative or most positive values possible for 16-bit numbers)
24-bit 0 dB is similarly 8,388,607 or -8,388,608
These values are normalized to floating point values in the range 1.0 to -1.0. (strictly speaking, a tiny fraction less than +1.0 because there is one less positive integer than negative.)
For example, 16-bit values are divided by 32768 to give the sample value, which Audacity represents internally as a 32-bit floating point number.

32-bit float (which is used internally by Audacity) is the range 1.0 to -1.0.

Dear Steve,

I see…
Now I am understanding that Audacity dealt with the integer format data, which would be normalized by a pre-determined value to showcase the “relative” kind of data (either in linear scale or db).

I am not quite sure the 32bit integer reference number for 0db? Did you mean the 32 bit reference of 0db was 1.0, and the exported values were directly referred to the actual absolute data (in integer format)?

Another concern was whether Audacity will treat all data above the reference as “peak” all the way? (Thats shown as the red clipping in the audio record) If this is the case, the values exceeding 0db threshold could be arbitrary higher or lower with respect to the threshold.

Looking forward to hearing from you soon.
Thanks!

If Audacity supported 32-bit integer format (it doesn’t, but if it did), then zero dB would be the maximum / minimum possible 32-bit integer value:
2,147,483,647 or -2,147,483,648
Audacity would represent the values internally in 32-bit float format by dividing each sample value by 2147483648 so that the sample values lie in the range +/- 1.0

For integer formats, it is impossible for data to be above the 0 dB reference, because the reference is the maximum possible value.

By way of example, let’s imagine that we are using “unsigned 4-bit integer” format. That means that the possible values are:
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
and no other 4-bit values are possible.

In this case, 0000 is the most negative possible value, and 1111 is the most positive possible value.
In decimal, this is equivalent to the numbers 0 to 15, but because we need both positive and negative values, zero is considered to be the half way point (binary 1000, decimal 8), so we have values in the range -8 to +7. Audacity then converts these numbers to 32-bit float format by dividing each integer value by 8.0.
4-bit integer format would therefore have possible sample values of:
-1
-0.875
-0.75
-0.625
-0.5
-0.375
-0.25
-0.125
0
0.125
0.25
0.375
0.5
0.625
0.75
0.875

An interesting point to note is that integer formats never quite get up to 0 dB on the positive side of the range. As we can see in this 4-bit example, 0 dB is defined as +/- 1.0, but the maximum possible sample value (for 4-bit) is 0.875.

Dear Steve,

Thanks for your great comments, I really learnt and benefited from your statement!

When I open my Audacity, the default option was 32 bits float. May I know where can we check the bit integer numbers being used?

Your simplified example of “4-bits integer” greatly stimulated my understanding.
With regard to this, my understanding was that the machine read the converted reading through ADC to binary type of values (just like the 4 bits integer example u shown to me; from 0000 to 1111) from some kind of electrical signals (like voltage and the like). At the same time, the “datum” numeric value (center level) was set to take into account the +ve and -ve nature of data. Later, all float-type values were normalized wrt the max value to become the “relative” data. During the process, machine manipulates using binary values for the computation. Am I right?

However, I m still puzzled on how does ADC converted the voltage signal into binary type (I guess the process involving dividing the raw voltage by a maximum voltage level) and whether the raw voltage had been deposited in the program (retrievable?)? If this was not wrong, can I use the 0db corresponding voltage to multiply with the audio ratio to obtain the actual absolute voltage?

I am sorry for asking you a lot as I m still a newbie in this area.
Thanks!

Normally you should keep Audacity set to 32-bit float. This will convert all incoming audio streams to 32-bit float data. Audacity can then work with the data without any more format conversions until you export. If you set Audacity to any other format, then because Audacity works in 32-bit float format internally, the data would need to be converted to 32-bit float and back again each time you apply any process (effect) to the audio.

Because the format conversion to 32-bit float occurs as the audio is being read into Audacity, it is not possible to directly access the integer format data. However, you can see the numeric values of the samples after they have been written to the track, by using the “Sample Data Export” effect: Sample Data Export - Audacity Manual


Yes, in the case of “unsigned integer” formats, the center level is set half way between zero and the highest number that can be represented by the number of bits (in binary, all the 1’s).

For “signed integer” formats, it works a bit differently, usually using a numeric representation that is called “two’s compliment”. Detailed information about signed integer representation is available here: https://en.wikipedia.org/wiki/Signed_number_representations#Ones’_complement


You need to be careful here. The kind of “normalization” is not like Audacity’s “Normalize” effect. The conversion to 32-bit float makes no attempt to modify the data in any way other than representing it in a different way.

If, in our 4-bit example, we have a signal that only uses the numeric values -0.25, -0.125, 0.0, 0.125, and 0.25 (binary 0101, 0110, 0111, 1000, and 1001), there is no attempt to “stretch” the range to +/- 1.0. the values are simply represented in 32-bit float format as -0.25, -0.125, 0.0, 0.125, and 0.25.

“Normalizing” in this context just means converting the format’s integer range (for example 0 to 15 for unsigned 4-bit, or -32,768 to 32,767 for signed 16-bit) into floating point numbers in the range of -1.0 to 1.0.


Yes.
The maximum / minimum voltage levels are in effect “0 dB”. For a 16-bit A/D converter, the maximum voltage that the converter can take will output the number 32,767 (signed binary 0111111111111111).
The lowest (most negative) voltage will output the number -32,768 (signed binary 1111111111111111).
Assuming that the DAC is “perfect”, an input of 0 v would output the number zero (signed binary 0000000000000000).

In practice, DAC’s are not perfect, and a certain amount of “noise” can be expected, so zero input voltage will more likely to produce output numbers that fluctuate close to zero.


You can only directly access the numeric data, not the analog voltage level (unless you attach an oscilloscope to the DAC input). However, if you know what the maximum / minimum voltage levels are (the voltage required to produce digital 0 dB), then you can calculate the voltage as a proportion of the max voltage.

Example:

  1. Calibration: Adjust the input level of the audio device so that your maximum voltage level is on the threshold of going into the red for the audio device (requires an audio device that has some kind of input metering, even if only a red “clip” LED). This is your audio device’s “0 dB” level.
    Then adjust the Windows recording level so that your maximum voltage peaks at full scale. 0 dB going into the audio device now produces (digital) 0 dB in the computer.

  2. Launch Audacity: You should now see that your maximum voltage meters at 0 dB, and creates a waveform trace that touches the top of the track.

  3. Measurement: Apply the signal that you want to measure, and check the peak signal level in Audacity. If the level in Audacity is +0.5, then you can deduce that the voltage level is half of the maximum (0 dB) voltage. So if your audio device has a maximum input voltage of say 1.5v, then you can deduce that the measured signal represents an input voltage of 1.5/2 = 0.75v.

Dear Steve,

Thanks again to your comprehensive explanation.

Now I can understood myself that the Audacity (and many other audio programs) read incoming electrical signal and converted them into those “relative” data with respect to a particular reference 0db, and communicating in the machine using binary-like language. The maximum voltage corresponding to the threshold of 0db level could be affected by many factors, such as electrical signal in a cable, preamplifier amplification, adc amplification, etc. In my previous attempts, it was extremely hard (practically) to retrieve the threshold 0db voltage value, unless I will conduct the voltage calibration check every time before the measurement. Am I right in this sense?

Also, I found that the adc and sound card manufactured by National instrument can usually provide the absolute voltage measurement and “relative” decibels unit. For other cheaper options, like Arduino adc I think calibration was also required. Do you think it is one of the reasons that NI product and the like is always costly?

It depends what the device is.

If you built an A/D converter using an AD1877 chip, and you designed your circuit to have unity gain (x1 gain) on the input, then 0dB for the circuit would be the same as 0 dB for the chip, and the chip manufacturer specify that “full scale” (the 0 dB reference) is +/- 1.55v

On the other hand, if you use a typical off the shelf, USB audio interface, there may be an input level control that adjusts the input gain. In this case the 0 dB level is dependent on the input level control.

Steve,

Thanks for your reply.
It was really helpful to me!