2

How can I convert an 8-bit raw sound file into 2 bit sound? I want to test a 2-bit DAC I made with some real speech recording.

Here is what I have currently:

0x7e, 0x7e, 0x7b, 0x7b, 0x7b, 0x7b, 0x7a, 0x7a, 0x77, 0x77, 0x76, 0x76,
0x78, 0x78, 0x79, 0x79, 0x79, 0x79, 0x7b, 0x7b, 0x7d, 0x7d, 0x7e, 0x7e,
0x80, 0x80, 0x82, 0x82, 0x82, 0x82, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x80, 0x80, 0x7e, 0x7e, 0x7d, 0x7d, 0x7c, 0x7c, 0x7a, 0x7a, 0x7a, 0x7a, ...

This is the 8-bit data of raw format converted into a hexadecimal string. Is taking the 2 MSBs of this data okay(for 7 it is 01(binary) and for 8 it is 10(binary) Is that okay?)? or do I have to somehow normalize this? Is there any program(I couldn't find 2-bit exports anywhere I looked) that can convert a sound (in whatever format) to 2-bit raw binary?

Edit: I found a related question which approaches this problem from a different angle.

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

2

Taking the 2 MSBs should be just what you're after. The way I think of it is that 1 bit (1 or 0) simply tells it the signal is above or below the middle value - and since we're talking audio, that would be the zero line.

So, 2 bits would do the same, but subdivide the range into 4 'zones'. 3 bits into 4 'zones' and generally, x bits = 2^x 'zones'.

  • 1
    I was trying to do the same thing but it wasn't working. Turns out the waveform was mostly located below the middle and was being rounded to zero. After amplifying the audio signal in audacity to cover the full range it should work. Thanks for the insight. – Nirav May 3 '18 at 4:35
  • If you want the full range, use 'Normalize" instead of tweaking the volume yourself. – Schizomorph May 4 '18 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.