EmbeddedRelated.com
Forums
Memfault Beyond the Launch

How well is an 8-bits audio?

Started by pozz May 22, 2015
pozz wrote:
> Il 23/05/2015 20:52, Les Cargill ha scritto: >> pozz wrote: >>> Il 23/05/2015 04:01, Les Cargill ha scritto: >>>> pozz wrote: >>>>> As I stated in a previous post, I'm trying to use an embedded 10-bits >>>>> DAC peripheral of a Cortex-M3 MCU to generate some good audio on a >>>>> simple 8-ohm speaker. >>>>> >>>>> In order to reduce the audio memory space (it must be saved in >>>>> internal >>>>> Flash of MCU), I tried to reduce the bit-depth to 8-bits and I had bad >>>>> results. >>>>> >>>>> I used sox application to make the conversion of poweron.ogg file >>>>> (it's >>>>> a simple audio installed in Samsung Android phones). >>>>> >>>>> sox poweron.ogg -b8 -r 44100 poweron_b8.u8 >>>>> >>>>> Now I converted back to 16 bits: >>>>> >>>>> sox -b 8 -r 44100 poweron_b8.u8 poweron.wav >>>>> >>>>> There are a big difference in quality between the original file and >>>>> the >>>>> converted file. I can hear a clear background noise. >>>>> >>>> >>>> So round-trip the 8 bit file back to 16 bits and look at it. >>> >>> This is what I did and the result is bad. Too much noise. >>> >>> >>>> When I convert a 1 kHZ tone from 16 to 8 and back in CoolEdit96, >>>> the noise floor is somewhat audible - on full-range "monitors" >>>> ( Tannoy Reveals ) . It's not obvious. It is very much there. >>>> >>>> When I do this with dither, it's a lot harder to hear. >>>> >>>> Dither randomizes the quantization noise. >>>> >>>>> I think it's the quantization noise. So my conclusion is: 8-bits audio >>>>> waveforms can't be used for medium-quality (not hi-fi) music. Do you >>>>> agree with me? >>>>> >>>> >>>> It depends. >>>> >>>>> Is there something I can do to improve the conversion from 16- to >>>>> 8-bits? >>>> >>>> You may be able to dither it. Look to the options in sox. I think this >>>> is spelled "sox... dither ... " from Google searches. >>>> >>> >>> I tried with dither, but the noise is audible, even if lower. >> >> So with CoolEdit96, I genned an 8 bit, 1kHZ tone @ 8k sampling rate. >> The noise floor is somewhere between -66dB and -72dB. You can hear it >> but it's not obnoxious. >> >> That should be good enough. So I don't understand... > > I think the problem isn't with simple tone waveforms that use the > full-scale everywhere. The bad effect raises when you use an audio > waveform with different levels in different time. If it is simply > normalized on the maximum level, most of the audio will be quantized > with insufficient bits (less than 8 bits). >
I am not sure I believe that :) Singe tones should show up noise artifacts better. IMO, -66dB should be just fine for the alleged application. Let's presume you're using it in a busy pubic space. Room tone plus the hum of activity should be more than 50-60dB. If you make the beeps 90dB, then the noise is -20 relative to room tone. That is not enough to be completely masked, but it's close.
> >> I don't think you'll get high fidelity out of a Coretex. > > This is sure. > >
-- Les Cargill
In article <mjngg9$74h$1@dont-email.me>, pozzugno@gmail.com says...
> As I stated in a previous post, I'm trying to use an embedded 10-bits > DAC peripheral of a Cortex-M3 MCU to generate some good audio on a > simple 8-ohm speaker. > > In order to reduce the audio memory space (it must be saved in internal > Flash of MCU), I tried to reduce the bit-depth to 8-bits and I had bad > results. > > I used sox application to make the conversion of poweron.ogg file (it's > a simple audio installed in Samsung Android phones). > > sox poweron.ogg -b8 -r 44100 poweron_b8.u8 > > Now I converted back to 16 bits: > > sox -b 8 -r 44100 poweron_b8.u8 poweron.wav > > There are a big difference in quality between the original file and the > converted file. I can hear a clear background noise. > > I think it's the quantization noise. So my conclusion is: 8-bits audio > waveforms can't be used for medium-quality (not hi-fi) music. Do you > agree with me? > > Is there something I can do to improve the conversion from 16- to 8-bits? >
Use one of the many ADPCM routines. If you use the 4 bit version, you can pack 2 12 bit samples into one 8 bit memory location, obviously there are other routines that leave you with various bit depth return values, but the one I have used for years is a 12 bit result, so I'm a bit partial to it.
On Sat, 23 May 2015 08:28:49 +0200, pozz <pozzugno@gmail.com> wrote:

> >> But, since you're DAC is 10 bits, maybe you should think about using >> 10 bit samples? > >10 bits values are difficult to manage in a 32-bits MCU. I will waste >always 16-bits for a sample. Maybe I can try to pack 10 bits samples >together... > >Byte 0: LSBits of sample 1 >Byte 1: LSBits of sample 2 >Byte 2: LSBits of sample 3 >Byte 3: LSBits of sample 4 >Byte 4: MSBits of samples 1-4 >... > >uint16_t s1 = byte[0] + ((byte[4] & 0x03) << 8); >uint16_t s2 = byte[1] + ((byte[4] & 0x0C) << 6); >uint16_t s3 = byte[2] + ((byte[4] & 0x30) << 4); >uint16_t s4 = byte[3] + ((byte[4] & 0xC0) << 2); >...
Put three 10 bit samples into a 32 bit word with just 2 bits lost for every three samples. You could even use the two spare bits as a primitive NICAM as a common range multiplier for the three samples :-)

Memfault Beyond the Launch