Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Use of non 8/16/24-bit audio, like 12-bit audio (Read 965 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Use of non 8/16/24-bit audio, like 12-bit audio

Hi all,

Currently I'm trying to build a nice set of test files for FLAC decoders. In a recent post on this board, I mentioned that there might be quite a few hardware decoders out there that do not support a FLAC file with a variable blocksize. Instead of just distributing a single file so people can check their devices, I thought making a comprehensive set of files with all kinds of FLAC features that are not often used would be even nicer.

Anyway, FLAC's format supports 8, 12, 16, 20 and 24 bit audio within it's subset. I have been looking around to find some tool to create 12 and 20 bit audio to feed to a FLAC encoder, but I can't really find anything.

Does anyone know of 12-bit and 20-bit audio being used anywhere? Or should I just ignore this part of the specification?
Music: sounds arranged such that they construct feelings.


Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #2
20 bit can be found on some DVD-Audio discs.

Thanks! That's a very good reason to include a 20-bit test file.

I just hacked the FLAC encoder to accept 12-bit raw, so I'm no longer looking for tools to do this. The question remains, where else these bitdepths might be used.
Music: sounds arranged such that they construct feelings.

Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #3
For example, Sonar claims to be able to export to some "12 bit DWVW AIFF (Apple/SGI) " - https://www.cakewalk.com/Documentation?product=SONAR&language=3&help=Dialogs2.146.html
sndfile-convert also has such option - https://helpmanual.io/help/sndfile-convert/
Audacity has such option too (amongst "Other uncompressed formats"), but it doesn't works for me for reasons unknown.

After looking at Wikiipedia i realized that DWVW is "Delta with variable word width", so don't know if it can be PCM at all - https://en.wikipedia.org/wiki/Audio_Interchange_File_Format#Common_compression_types



Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #6
ffmpeg reports wood12.aiff as bitrate 705 pcm_16be (fb2k: 706, due to different round-off conventions).
Indicating 16 bits (mono)?
Whatever flac.exe's error message means ...
High Voltage socket-nose-avatar


Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #8
The only program I know of that can write 20-bit flac is Awave Audio by FMJ-Software. But since only new players are compatible with it, saving as 24-bit with a tiny overhead is preferable.

Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #9
You can create such files easily with qaac/refalac. Use -b option.
qaac/refalac actually allows arbitrary bits per sample in 2-31.

Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #10
ffmpeg reports wood12.aiff as bitrate 705 pcm_16be (fb2k: 706, due to different round-off conventions).
Indicating 16 bits (mono)?
From the format spec:
Quote
Sample points are stored in an integral number of contiguous bytes.  One to 8 bit wide sample
points are stored in one byte, 9 to 16 bit wide sample points are stored in two bytes, ...
So effectively it is 12 bits in 16 bits container.
Whatever flac.exe's error message means ...
Mine says:
Quote
ERROR during read, sample data (channel#0 sample#0 = 2) has non-zero least-significant bits
  WAVE/AIFF header said the last 4 bits are not significant and should be zero.
My guess, again, from the format spec:
Quote
When the width of a sample point is less than a multiple of 8 bits, the sample point data is left
justified, with the remaining bits zeroed.
and that is not what happens in that file:
Code: [Select]
53 53  4e 44   00 00 0c b4   00 00 00 00   00 00 00 00   00 02 ...
"SSND"         chunk size    offset        block size    data

Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #11
In the attachment there is a fixed wood12 sample and a flac created from it:
Code: [Select]
]$ metaflac --list --block-type=STREAMINFO wood12fix.flac
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 1394 bytes
  maximum framesize: 1394 bytes
  sample_rate: 44100 Hz
  channels: 1
  bits-per-sample: 12
  total samples: 1622
  MD5 signature: fa5ac05726a6fb8d5f4e31613e6710ac

Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #12
So, it seems after whole-byte bitdepths (8/16/24) there are few cases of using the whole-nibble bitdepths that are in-between (12/20). Wikipedia seems to mention 10 and 11 bit for the NICAM compression format. µ-law can be losslessly converted to 14 bit LPCM and A-law to 13-bit LPCM if I understand correctly. Any others?
Music: sounds arranged such that they construct feelings.

Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #13
You can create such files easily with qaac/refalac. Use -b option.
qaac/refalac actually allows arbitrary bits per sample in 2-31.
This was a life saver when dealing with some HDCD files and being far too anal about how to "best" store them as efficiently as possible. wavpack's "pre-quantize" option was out of the question because it still reported the "original" bit-depth.
I let foobar decode an album with Peak Extend, told foo_hdcd not to halve volume, and then used the album ReplayGain value under "Processing" while outputting to float32 PCM to prevent clipping according to peaks. The ReplayGain values did take the HDCD decoding into account, peaks of ~1.23 on the unconverted CD rip, since it was scanned with foo_hdcd active.
refalac will happily accept float input and truncate as many bits as you ask it to, with or without dither. I was going to convert to wavpack or FLAC since they're always at least slightly more efficient than ALAC and I haven't had an iPod in a decade, then I looked at the actual float32 WAVs. There isn't a single point in the entire album that goes below -96 dB, even "silence" - back through refalac again with -b 16 --no-dither. Would've been storing an extra ~100-150 MB of useless quantization noise at 24 or even 20 bits.
Speaking of wavpack, it's got an interesting peculiarity, at least if you use foobar to encode. Try encoding a 20-bit FLAC to wavpack and note the MD5: it changes. Encode it to FLAC again, get your original MD5 back...
Now re-encode that wavpack file to 24-bit by manually selecting that bit-depth, your MD5 will not change, neither will the filesize. The wavpack encoder is smart enough to not only realize it's padding 4 bits of zeros, but actually throw them away entirely. It will still ID itself as a 24-bit file. Now decode either of them to 24-bit FLAC, or manually pad that first 20-bit FLAC to 24-bits, and note that all of those files have the same MD5 as the 20-bit wavpack file...
Not sure if the bug lies with foobar or with how wavpack calculates MD5s, but it sounds like it pads any bit-depth between 17 and 23 to 24 before calculating it.

Re: Use of non 8/16/24-bit audio, like 12-bit audio

Reply #14
If you halve the amplitude by a factor of exactly 2, then you can store the data more efficiently, by only using additional bits during moments when peak extend or gain are active. But if you normalize to peak, or enter any number in decibels (you can't input exactly 0.5), the word length expands and dither must be used. Files processed wtih a declipper can be treated similarly. You could choose to quantize to 18 bits, effectively giving no more than an extra bit for peaks and fades.