24 bits truncated to 16 bits...

Hello

I use Audacity with an external USB box “Terratec Phase26”.
This box is set to external audio digital input 48 kHz, 24 bits.

I record a sequence using audacity in “Stereo 48 kHz 24 bit PCM” mode.
My goal is to get a file containing the exact sequence of 24-bit samples.
I export this recorded sequence selecting “other uncompressed format” option “Wav, Signed 24 bit PCM”.

In this sequence I am supposed to find the following samples in hexadecimal.
0x96f872, 0xA54E1F.
Instead of this, I find into my 24 bit wav file : 0x96f800, 0xA54E00
What gives me the 24-bit truncated to 16 bits.

Where are these eight bits missing?
What is the method to record an accurate and complete sequence of digital samples without any processing, any sample rate conversion… ?

Best regards

Audacity uses Portaudio to communicate with the computers audio in/out system.
On Windows, the version of Portaudio that Audacity is currently using only reliably supports MME, DirectSound and ASIO. WaveRT is not yet supported and Audacity cannot be distributed with ASIO support due to licensing restrictions.

On Windows 7 and Vista, MME and DirectSound are “emulated” - they can only access the audio hardware indirectly through WASAPI. Unfortunately 24-bit audio data is not fully supported by MME or DirectSound on Vista or Win 7 - the audio data is limited to 16 bit and padded to 24 bit.

I’ve had a look on the Portaudio web site and it looks like full support for WASAPI is coming along nicely. I think that it is unlikely that the Audacity developers will upgrade to a newer version of Portaudio before Audacity 2.0 is released as the development team are working hard to get Audacity 2 out and I doubt they will want to risk building in instability by introducing a new core library. However, looking ahead, when the version of Portaudio that Audacity uses is updated there will hopefully be full support for WASAPI and it will become possible to record full 24-bit data.

See here for information about this on the Audacity wiki: http://wiki.audacityteam.org/wiki/Windows_Vista_OS#Audio_architecture

Hi Steve

Thank you for your quick Answer

So, I have to find an other solution, avoiding protools, I am not so rich…

Best regards

Perhaps Wavosaur will suit your recording needs http://www.wavosaur.com/
Of course you can still use Audacity for editing and processing.

Can you clarify whether the bits are lost on input recording or on file export from Audacity? I use Audacity on Windows 7, recording with a Roland UA-1EX USB sound capture device.

On Windows, regardless of the hardware, on Windows, Audacity always records 16 bit data.
If you are using 24 bit audio hardware, then you will only get a theoretical best of 96 dB SNR rather than a 144 dB SNR. This isn’t as bad as it might sound. Even the best 24-bit converters fall short of full 24 bit performance so you are loosing a lot less than the theory suggests. Also, unless you are using very high end equipment it likely that the noise level of the sound source will swamp the dynamic range limitations of 16 bit.
As long as you are reasonably careful with your recording levels it is unlikely to be a problem. The main advantage of 24 bit is that you can allow a lot more headroom.

With the default settings, Audacity will convert that 16 bit data to 32 bit (float) for higher quality processing. It is generally advisable to keep this set at 32 bit float.

When you export you can choose from a wide range of formats, including uncompressed PCM WAV at 16, 24, 32, 32 bit float or 64 bit float. 32 bit float will give you the very best quality, though few other programs support this format. If you intend to make an audio CD you would export as 16 bit, 44100 Hz as this is the correct format for audio CDs.

Thanks. I generally record in 32-bit float @ 96KHz and export as 24-bit WAV.

The following is the start of a WAV file hex dump.

  1. Recorded by Audacity as 24-bit on Windows 7.
  2. Exported as 24-bit WAV without additional processing
  3. I’m not sure I see the pattern of zeroes that would indicate that the recording actually has 16-bit samples.
  4. Help?

0000000 4952 4646 6dfc 001a 4157 4556 6d66 2074
0000020 0010 0000 0001 0002 7700 0001 ca00 0008
0000040 0006 0018 494c 5453 001c 0000 4e49 4f46
0000060 4149 5452 0010 0000 6c43 7561 6564 4220
0000100 6c6f 696c 676e 0000 6164 6174 6db4 001a ← Header Up to Here?

0000120 98ff 00fc ff4b ee02 00fc ff28 3efe 00fd ← Sound Samples?
0000140 ff08 8101 00fd fee8 ae00 00fd fec3 c900
0000160 fffd fe96 d9ff 03fd fe6a e401 fcfd fe3b
0000200 e500 04fd fe0e ddff fdfd fddd cd02 01fd
0000220 fdab b7fe 01fd fd75 a001 fefd fd4a 7d00
0000240 02fd fd2f 56ff fefd fd27 3b01 02fd fd3b
0000260 3d00 fefd fd6e 6000 02fd fdce 9eff fffd
0000300 fe4e f601 fffd fee5 63ff 02fe ff7f da01
0000320 fefe 0010 5800 02ff 009e d5ff feff 0126
0000340 4a00 0300 01ac b402 fc00 0221 05fd 0401
0000360 0282 4503 fd01 02d5 70fe 0101 0328 9000
0000400 0101 0372 9f01 fe01 03b0 a600 0201 03e9
0000420 a5ff ff01 0425 9d02 0001 046d 89fd 0001
0000440 04bc 6d03 0001 050d 4bfe 0001 0553 2402
0000460 ff01 0588 faff 0300 05b0 cf00 fc00 05c6
0000500 ac00 0500 05cf 9600 fa00 05c9 8c01 0500
0000520 05b4 8cff fd00 058a 9101 0200 0549 89fe
0000540 0000 04e5 6d02 fe00 045f 40ff 0200 03d2
0000560 0a01 ff00 0352 cdff 00ff 02f5 9100 01ff
0000600 02b1 5700 ffff 0280 2601 01ff 025a 04ff
0000620 ffff 023b f200 00fe 0221 e400 00fe 01fc
0000640 cd00 00fe 01c8 a601 01fe 0197 6ffe fffe
0000660 017d 3702 00fe 0187 04fe 00fe 01b6 dd02
0000700 fffd 0201 c0fe 02fd 025e ac03 fefd 02b5

I see what you’re doing and this is interesting because I’ve never tried this myself (I don’t have a 24 bit sound card or Windows 7).
When you export in an integer format, by default Audacity will dither the output.
For your test, try disabling dither and see what happens.
Edit menu > Preferences > Quality"
Set dither to “none” in the high quality conversion settings.
(Remember to turn it back on after testing - After any sort of processing there will be “in between” values that cannot be represented exactly as integers and dither smooths the quantise errors).

I edited that to Edit Menu > Preferences: Quality in Steve’s post.

Just to add before someone else does; dithering even when exporting to the same or a higher integer format is a bug. It should only be dithering when downsampling.


Gale

I’ll run another experiment to ensure what options are in effect for the recording I upload.

But should I be changing the dither for “real time conversion” or “high quality conversion”?


TGD

Oops :blush:
Thanks for correcting.

The “real time conversion” settings affect playback. Dither should normally be set to “None” for best playback performance.

The “high quality conversion” settings affect mixing and export. Dither should normally be set to “Triangle” or “Shaped” for best quality.
For testing the sample values of the exported 24 bit file you will need to temporarily set this to “None”.

The WAV files are too big to upload. I’ve attached the start of the hex dumps.
The files record the same track but don’t start precisely at the same point.
There does appear to be a repeating pattern of 0’s every third byte when dithering is shut off (KJSNDhead.txt).

So … in this situation, would it be truer to the source to take the 16-bit samples or the dithered 24-bit samples?

The question only affects the archived source recordings. There is much downstream processing in 32-bit float before exporting the individual tracks.


Thanks,
TGD
KJShead.txt (3.06 KB)
KJNDhead.txt (3.06 KB)

If you are not applying any processing at all then it will be “truer” to the source to turn of dither whether you export as 16, 24 or 32 bit uncompressed audio.

“Processing” includes Amplify, Normalize, Fade, Noise Removal, and anything else that alters the sample values. It does not include simple cut/trim/paste edits.

If you apply any processing, then dither will produce “truer” results by preventing harmonic noise being created by quantise errors and increasing the dynamic range of the output. This is at the cost of introducing a tiny amount of randomised noise. In the case of 24-bit export with “Triangle” dither, the randomised noise is at the extremely low level of around -148 dBFS RMS (A-weighted).

In my processing pipeline, I save an Audacity project for the source and a separate project for the processed result. The idea is, to record the LP once in as good a representation that can be created and store it away (“one and done”); then export a WAV file to start the processing pipeline, proecssing as often as needed, given new tools and techniques becoming available.

So my takeaway is:

  1. Export the source archival WAV with dithering turned off.
  2. Export the final product (after DeClick, additional post processing, amplify, etc.) with dithering set to Triangle.

And try to find a way to record in 24-bit :slight_smile:


TGD

Or as FLAC (with dither turned off) if you want to some disk space. The quality of FLAC is the same as WAV, just smaller files.

You may want to test both Triangle and Shaped dither to see which you prefer - the difference is very subtle when played at normal volume, in fact with 24-bit you’ll probably be hard pressed to hear any difference at all.

Disk space is essentially free, but there is the annoying migration problem when you find that a 1TB drive wasn’t enough, then a 2TB drive wasn’t enough, etc.

But I still would like to record in true 24-bit mode if possible. Are all the tools necessary to build a personal Windows 7 version of Audacity (with ASIO enabled) freely available?


Thanks,
TGD

The ASIO SDK is free, but closed source - you have to register (free) with Steinberg to download it.
All of the rest is free open source.

I build Audacity regularly on Linux, but to date I’ve failed miserably on Windows. It certainly does not help that the free versions of Visual Studio Express and Microsoft SDK are riddled with bugs. You can read about my adventures in this forum topic: "Setup.h" not found - Compiling Audacity - Audacity Forum

The official Audacity documentation for building Audacity on Windows are here: Missing features - Audacity Support
Additional information about adding ASIO support is here: Missing features - Audacity Support

Don’t rush when you’re building WxWidgets - take your time with this and ensure that you fulfil all of the steps required to build a “Unicode Release” version of Audacity.

If you get stuck, post in this part of the forum: Compiling Audacity - Audacity Forum

There’s also a forum topic here that may have some useful information: [Solved] Trouble compiling Audacity from SVN with ASIO

PortAudio’s implementation of WASAPI has been stable since May 2011 and works well (I had a hand in its development). The current stable version of PortAudio was released on November 21, 2011.