# How to record wav file in bit depths lower than 8 bit?

First of all, sorry if this is not the right stackexchange site to ask this, but here it goes.

For research and learning purposes I want to record wav files at different sample rates and bit depths and compare the recordings, listen to their differences, etc.

The sample rate part is rather easy, many programs like Audacity in linux give this possibility. Also the bit depth is easy, but I cannot find a program or command that would allow me to record at lower bit depths than 8-bit.

I'm aware that this is probably impractical and also that 8-bit is a byte and probably that's the reason why programs don't usually go lower than this, because of integer data types representation. But for learning purposes and from a theoretical point of view, it should be possible to record an audio signal at arbitraty low bit depths such as 2-bit, 4-bit, etc.

For example, in the Audacity Wiki (http://wiki.audacityteam.org/wiki/Bit_Depth#sources), it is mentioned that a cassette is equivalent to a 6-bit depth, and that an Edison Cylinder home recording is as low a 2-bit depth in resolution.

So, my question is, do you know of any program or command that would allow me to record at lower-than-8-bit depths? (Preferably linux). If not, can you explain why this seems not easy to do with default/most common linux programs (Audacity, sox, arecord, etc)?

Thanks!

EDIT: I've found this very interesting article about speech processing in different sample rates and bit depths, which is precissely the field I'm investigating also: http://iitg.vlab.co.in/?sub=59&brch=164&sim=474&cnt=1

Source: (2011). Sampling Frequency and Bit Resolution for Speech Signal Processing. Retrieved 11 June 2016 from http://iitg.vlab.co.in/?sub=59&brch=164&sim=474&cnt=1

However, I cannot seem to find which programs or techniques are used to record at low bit-depth, or if they record at 16-bit and then lower the bit depth of the already recorded signal (I believe this is called "bit crushing" technique?).

• As you write in your last paragraph, I think you'll want to find ways to lower the resolution of already recorded audio, rather than try to record at lower bit depths. Just record one file at 24 bits and then save/render several copies at lower and lower resolutions. Jun 11 '16 at 17:59
• @ToddWilcox yes I think I'll do that! However I'm still curious about low bit depth recording. Thanks! Jun 11 '16 at 19:30

Lower bit depths are not easily available simply because they are not looked for commercially, not because of some intrinsic technical difficulty. Audio interfaces or other capturing devices have their ADCs (Analog do Digital converters) based on integrated chips optimized for the features that are most requested commercially. In principle it would not be hard in the software driver to quantize the samples to lower bit rates, but again, why would a manufacturer bother to overload their sw with features that almost nobody would use?

So in practical terms Todd Wilcox's suggestion of "lo-fiing" your audio by software is a good one, and BTW, there is a filter in Audacity to do just that: Effect/Decimator.

Note: actually the Decimator filter is not part of the Audacity install package, but it's part of the Audicity "sponsored" additional plugins pack LADSPA [thanks to @horta for noticing that and check in a comment below his alternative approach to achieve the same result using the Nyquist procedural language].

The basic technique to do that is just to discard either

• samples (to reduce sample rate) or
• low order bits from samples (to reduce bit-depth by powers of 2),

hence the more technical name "decimator" (Bitcrusher is just a another name for the same thing). Many decimator/bitcrusher effects (including the one in Audacity) also allow resampling and quantization by non integer proportions.

Note that you will also be creating your files with higher bit-depths, as the file formats (e.g. WAV) require it, but they will sound as the lower bit-depth audio you created.

Other than that, to actually capture and/or reproduce sound in real low bit-depth, I guess you would have to use a microprocessor platform, like the Arduino or the TIva LaunchPad, and do you own programming.You could even create and directly program your own "low-bit" compositions.

BTW, in this regard it may be interesting to check the work of composer Tristan Perich, who created and distributed 1 bit-depth music through a simple dedicated electronic device.

• great answer and very interesting work by Tristan Perich, thanks! Jun 11 '16 at 23:51
• One more detail, I said your files "will sound like the low bitd-depth audio", well, when working with low bit-depths (say 6 or 4), the physical response (namely, the latency) of the output speaker, Can have a lot of influence on how the sound is reproduced. A speaker that is slower to respond will "atenuate" the abrupt jumps of a highly quantized signal and may actually produce a nicer sound than a very quick speaker. The vintage computers and game consoles of the 80's took advantage of this to produce "realistic" audio. Jun 12 '16 at 1:28
• In the latest version of Audacity I downloaded, it appears here instead: Effects->Nyquist Prompt-> check the "use legacy (version 3) syntax" box -> type "(quantize s 8)". This would result in 8 levels above/including 0 and 8 levels below/including 0. This works out to about 16 levels total (actually 15) but it's approximately = 2**4 or 4 bits of audio depth. Sep 13 '17 at 15:37
• @horta, I found it strange that Decimator had gone away, so I checked. As it happens it's not a native Audacity plugin, but it' part of Audicity "sponsored" pack of additional plugins that can be found here fosshub.com/Audacity.html/LADSPA_plugins-win-0.4.15.exe . So doubly thanks for bringing that up (noticing the lack of Decimator and providing the Nyquist code for down quantizing). Sep 13 '17 at 19:00
• Np, your answer pointed me in the right direction. Sep 13 '17 at 22:44

Here's a solution I wrote in Liberty BASIC. It takes an 8-bit WAV file and converts it to any lower bit depth. Please note that it is merely for sound quality research; the lower bit-depth values are saved to the file in 8-bit form (no actual compression takes place).

bits=6

bits2cut = 8 - bits
open "C:\input_8bit_file.wav" for input as #file
open "C:\6bitwav.wav" for binary as #outfile

print #outfile, input$(#file,44) 'Copy the WAV header while eof(#file) = 0 byte = asc(input$(#file,1))
print #outfile, chr\$(int(byte/(2^bits2cut))*(2^bits2cut))
if bytes mod 1000 = 0 then scan 'Don't freeze when converting large files
wend

close #file
close #outfile
print "Done"
end


Just attenuate, save the file to wav and then import it anew and amplify. Every 6dB of attenuation is 1 bit less. So if you have an 8bit file and you want 4bits, attenuate by 24dB, save the file, then open it anew and amplify by 24dB.

There might be fancier ways to do it that would yield better noise performance though. And in practice you might want to low cut the source first because at lower bits the dynamic range is going to be really horrible.