EmbeddedRelated.com
Forums
Memfault Beyond the Launch

How well is an 8-bits audio?

Started by pozz May 22, 2015
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?
pozz <pozzugno@gmail.com> 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.
at 10bit how does it sound?
> 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?
what you can do is to interpolate the 8bit signal in the cortex to get a 10bit signal (since the DAC is 10bit). It should improve the quality a little bit. Also you can try to reduce the sampling rate (from 44.1kHz to 22kHz) instead of reducing the resolution of the signal. And is more or less useless to convert the audio on your computer and test how it sounds with good speakers. It makes much more sense to test the audio with the shitty speaker you want to connect to your system, so you will see (ehm hear) how reducing quality, sampling rate,... affect the sound that comes out from the speaker... Bye Jack -- Yoda of Borg am I! Assimilated shall you be! Futile resistance is, hmm?
On 2015-05-22, pozz <pozzugno@gmail.com> wrote:


> 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
Huh? Why convert back to 16 bits?
> There are a big difference in quality between the original file and > the converted file.
I'm sure.
> 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?
I guess it depends on what you mean by "medium-quality".
> Is there something I can do to improve the conversion from 16- to > 8-bits?
If you're only using 8-bits, you're probably not going to be happy with a linear encoding. Have you tried something like mu-law or A-law encoding? You'd probably also be far better off with 16 bits and 22KHz than you will with 8 bits and 44KHz. But, since you're DAC is 10 bits, maybe you should think about using 10 bit samples? -- Grant Edwards grant.b.edwards Yow! Are we THERE yet? at My MIND is a SUBMARINE!! gmail.com
On 5/22/2015 11:04 AM, 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. > > 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?
What frequency response are you looking for? You can greatly reduce the bit rate by reducing the sample rate. High quality phone calls are just 64 kbps using uLaw or A-law. They use real voice compression to get bit rates of 16 kbps and lower with fairly good reproduction including non-voice signals. -- Rick
"pozz"  wrote in message news:mjngg9$74h$1@dont-email.me...
> 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. > Is there something I can do to improve the conversion from 16- to 8-bits?
Yes, look at A-law (or &#4294967295;-law) compression. See http://en.wikipedia.org/wiki/A-law_algorithm. Basically an audio signal requires a finer resolution in low amplitudes than in high amplitudes, therefore a constant step digitizer (as an ADC) is far from optimal. An A-law compressor is basically just a table-based log-shaped translator. The process is the following : - Use a 16bit source (or a 16-bit ADC) - Convert the 16 bits to 8 bits using a A-law compressor - Transmit the 8 bits - Uncompress the 8 bits to 16 bits - and send the result to the loudspeaker. Cheers, Robert Lacoste www.alciom.com
On 5/22/2015 8:04 AM, 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 the experiment you cite below, are you driving the speaker with the same electronics in each case? I.e., are you sure the D/AC version isn't introducing distortions that the "original" is not? (How can you reproduce the 16b signal from your 10b D/AC? I.e., the signal path is probably *different* in these two cases)
> 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 suspect the original file has a bit more dynamic range than your 10b (8b?) D/AC can accommodate.
> 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?
As only *you* can determine what the "adequate' level of fidelity is for your application, start by determining what the "best" signal from your D/AC will be. Start with a simple waveform that has no amplitude envelope -- something periodic (sine wave). Set the generator to produce a signal that will use almost *all* of your 10b available. See what this sounds like. If acceptable, try more complex waveforms (varying amplitude envelopes) always seeking to utilize the full 10b available in your D/AC until the dynamic range in your signal introduces too much "crud" for your taste. Then, try the same signal after running it through a compressor (which will change the character of the sound, to some extent). The goal always being to use the full range of outputs that your D/AC can provide. If you can create a suitable set of sounds (in a previous post, you suggested you only needed a handful), your next issue will be to sort out how to get variable *gain* without losing bits in your D/AC (or, are you handling gain with a "volume control knob")?
On Fri, 22 May 2015 17:04:48 +0200, pozz <pozzugno@gmail.com> 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.
Standard digital telephony uses 8 bit samples at 8 kHz sample rate. However, each 8 bit sample is in fact a floating point representation of 1 sign bit, 3 exponent bits and 4 bit mantissa with either A-law or &#4294967295;-law conversion. When converted to linear (integer) representation, 12 bit DACs are required, so your 10 bit DAC is not very good. Of course, you could oversample it to give 12 effective bits. In the early days of digital telephony various diode/resistor networks were used to create the A or &#4294967295;-law companding curve. A more modern (1970's) approach was to use a low resolution DAC followed by an op-amp, in which the feedback resistor was switched in by an 8 input analog CMOS switch controlled by the 3 exponent bits of the sample. These days with plenty of processing power, it would make more sense to store the samples as differential-PCM or some better compression method and use oversampling to get a few extra bits out of the 10 bit linear DAC.
On 22/05/2015 18:27, Robert Lacoste wrote:
> - Use a 16bit source (or a 16-bit ADC) > - Convert the 16 bits to 8 bits using a A-law compressor > - Transmit the 8 bits > - Uncompress the 8 bits to 16 bits > - and send the result to the loudspeaker.
Hi Robert ! I'm sorry but you can't :"Uncompress the 8bits to 16bits" because as many voice codecs the &#4294967295;/A laws compression is destructive. I mean the compression process from 16bits linear to 8bits is irreversible. Aside from this you're right the venerable G.711 ... G.726 (A/&#4294967295;, ADPCM ... Laws compression) are really good but nowadays the speex/opus codec outperforms these, even the G.729 standard. Habib.
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. 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. -- Les Cargill
Il 22/05/2015 17:24, Jack ha scritto:
> pozz <pozzugno@gmail.com> 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. > > at 10bit how does it sound?
Better and acceptable.
>> 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? > > what you can do is to interpolate the 8bit signal in the cortex to get a > 10bit signal (since the DAC is 10bit). > It should improve the quality a little bit.
I'll try.
> Also you can try to reduce the sampling rate (from 44.1kHz to 22kHz) > instead of reducing the resolution of the signal.
Indeed I learned it's better to sacrifice higher frequencies instead of sample bits.
> And is more or less useless to convert the audio on your computer and > test how it sounds with good speakers. It makes much more sense to test > the audio with the shitty speaker you want to connect to your system, so > you will see (ehm hear) how reducing quality, sampling rate,... affect > the sound that comes out from the speaker...
This is what I'm actually doing.

Memfault Beyond the Launch