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: Noise shaped dither in 8 bit audio (Read 11712 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Noise shaped dither in 8 bit audio

I have a project that uses short 8 bit audio samples, stored on EPROM or Flash chips, which are then 'replayed' using simple CMOS binary counters and a simple 8 bit DAC (TLC7524), all triggered from a simple momentary switch command.

When using speech as an audio source, then the use of analogue companding each side of the digital process can improve the perceived quality of replay quite a lot, compared to  listening to 'raw' (linear) 8 bit audio...and allows for reasonable results from simple (and cheap!) hardware.

Works fine for my purpose up until now.  I now have a requirement to replay very short, but very dynamic samples (audio recordings of percussion sounds).
For this application, the attack and release time constants of the analogue 'companding' technique pose a real problem....

So I looked at using a high sampling rate, and shaped dither noise instead.

Starting with a 16 or 24 bit recording of the percussion (drum) sound at a high sampling rate (96KHz) I then used my audio editor (an old version of Cool Edit - Audition) to add shaped dither noise, and reduce the resolution to 8 bits.
Seems to work very well --- the improvement in the quantisation noise problems at low level is pretty impressive.......and the noise shaping shifts most of the dither noise above 15KHz.

But of course, simply taking this new 8 bit file, and storing the data on Flash or EPROM to replay using a simple 8 bit linear DAC doesn't work.  The newly introduced 'shaped' noise simply gets 'replayed' as broad band noise at the level of the introduced dither amplitude (at about -24dB). Totally unusable.


What I can't get my head round is which part of my the 16 or 24 bit PC soundcard DAC is being used to replay the file so much more accurately. Replayed from the PC soundcard, the dither noise virtually disappears (apparently, of course!)

My reference 'silence' half level  is 80 .. which of course is totally silent - even to a simple 8 bit linear DAC!).
I'm guessing that the smallest negative change of 1 binary count to 7F, which causes the MSB to change from 1 to 0 is probably the culprit, so I probably need a much more accurate DAC to retain the accuracy of the shaped dither noise........and if so, what DAC can I use that can read an 8 bit parallel data input.... and which 8 bits do I choose to use, from a higher resolution DAC....

Unless I'm missing the point completely here?......

Any pointers gratefully received...... 


Noise shaped dither in 8 bit audio

Reply #1
What is the playback sampling rate ?

Is the TLC7524 DAC suitable for audio ?

Noise shaped dither in 8 bit audio

Reply #2
Thanks for replying...

Playback sampling rate is 96KHz......and no, the TLC7524 is not really a special audio device.....it's just a simple linear 8 bit R2R ladder DAC...
It works fine for larger amplitude signals. It just falls apart a bit, trying to resolve the dither noise masking of the lower amplitude signals

I can see that I shall probably need a more specialised higher resolution audio DAC... my question is what type, and which part of the data inputs do I select for replaying an 8 bit data word,  while retaining the benefits of the noise shaped dither .......

As I say, the file replays fine using my PC soundcard - which uses a 24 bit DAC - but which 8 bits are they using to retain the accuracy that allows the dither noise to work effectively......or are there extra processes involved?......


Noise shaped dither in 8 bit audio

Reply #4
Measure the thd and imd of your DAC. If its highly nonlinear noise shaping will work poorly.

Noise shaped dither in 8 bit audio

Reply #5
Thanks for the comments guys --  I think I've realised that I'm going to need a better DAC, my question is really --
which one, and which 8 bits to use from, say, a 16 bit parallel input DAC , to maintain the advantages of adding the dither noise?..

Noise shaped dither in 8 bit audio

Reply #6
Audio DACs are quite cheap, but will probably expect to be driven via a microcontroller with I2C, I2S, USB, or some other interface which it sounds like you don't have access to.  Maybe check with TI and see if they have a higher end model of the TLC7524?  You basically just want something with either more bits, or less nonlinearity.  This is easy enough to make, but its just less common to have higher quality outputs on devices so simple they lack a CPU.

Noise shaped dither in 8 bit audio

Reply #7
Audio DACs are quite cheap, but will probably expect to be driven via a microcontroller with I2C, I2S, USB, or some other interface which it sounds like you don't have access to.  Maybe check with TI and see if they have a higher end model of the TLC7524?  You basically just want something with either more bits, or less nonlinearity.  This is easy enough to make, but its just less common to have higher quality outputs on devices so simple they lack a CPU.


Thanks for your advice.... this is intended to be a very simple, cheap project. As you say, no microcontrollers! 
I now realise just how important the DAC linearity is for effective noise shaping. I was just a little surprised about just how yes/ no the results were.
An 8 bit file played back via my PC soundcard -- noise shaping is very effective.

The same 8 bit file played back using a (not very linear) external DAC -- noise shaping becomes unusable (the dither noise is reproduced as broad band white noise at an unacceptably high level.

I might find a little improvement operating the DAC in current mode, but I'm pretty sure the difference would be minimal.

Moving up to a 12 bit parallel input DAC - like the LTC1450 for example - and using the 8 LSBs of that device might make some improvement, but I suspect not enough.

Time for one more look at improving the analogue 'companding' option  -- or failing that, moving the whole project up a gear, which, sadly, will almost certainly kill it off. 
No budget for development involving SMD devices, and an ever dwindling number of DIP version of chips being available mean that, like so many electronic hobby projects, it's is now simply cheaper and easier to go and buy a commercial equivalent!

Thanks for all your input guys..... most grateful.


Noise shaped dither in 8 bit audio

Reply #8
I now realise just how important the DAC linearity is for effective noise shaping. I was just a little surprised about just how yes/ no the results were.
An 8 bit file played back via my PC soundcard -- noise shaping is very effective.


Yes, if there is much nonlinearity, you get intermodulation, where some of the noise downmixes other noise to lower frequencies. 


Noise shaped dither in 8 bit audio

Reply #9
Can you measure the nonlinearity of the DAC? Perhaps it it possible to pre-compensate the input signal?

-k

Noise shaped dither in 8 bit audio

Reply #10
Moving up to a 12 bit parallel input DAC - like the LTC1450 for example - and using the 8 LSBs of that device might make some improvement, but I suspect not enough.

As long as you use the 8 LSBs of any DAC you will probably see no improvement. What you want is the 8 MSBs.

Noise shaped dither in 8 bit audio

Reply #11
Thank you for the additional comments.... I had automatically assumed that the lower 8 LSBs would offer smaller step changes, and therefore less noise, so thanks for that correction.

It would appear that the majority of the extra 'non linear' noise comes in my present experiment, as expected , from the the transition from 7F to 80 -- (i.e. the transition to the MSB going from 0 to 1 )

This was verified by shifting a 1 bit noise sample negative by 1%, to ensure that the MSB threshold was not exceeded. Greatly improved results.

Not viable of course -- simply shifts the MSB change 'up the scale' by 1 bit, so to speak, so the 'nasty' threshold is crossed in a slightly different area..

I was wondering whether changing the output from a voltage mode to a differential current mode might maintain a more 'linear' MSB transition, if the currents are maintained as always being equal, regardless of any code change? 
Yet to experiment on that one...

As I mentioned, I do appreciate that this is really chasing rainbows, and that technology has moved on from using such crude DACs for audio.  But I do still enjoy experimenting..... it's just getting more difficult to be able to do that, without getting involved with either microcontrollers, or SMD --or both! 

And the latter gets expensive, with PCBS required just for a 'fun' project experiment.

In this case, it would probably be cheaper to go and buy something like an Alesis 'Sample Pad' at about £100....

.... Sort of feels a  bit like throwing  in the towel though.....

One more look at improving the analogue audio 'companding' option, I think.... that does actually work quite well .. especially on speech...

Thanks again for your comments and interest --- in what must seem a pretty pointless exercise to real audiophiles 

Noise shaped dither in 8 bit audio

Reply #12
Audio DACs are quite cheap, but will probably expect to be driven via a microcontroller with I2C, I2S, USB, or some other interface which it sounds like you don't have access to.

Thinking a bit more about your comment here made me wonder.... even if a modern audio DAC expects to be driven by a microcontroller, maybe it would be possible to configure one without using one... especially for a simple function like this?

Looking at the data sheet for the Wolfson WM8524 suggests that it may be possible (it has a hardware configuration mode)...and it is cheap!....

It would mean applying few unorthodox 'tweaks' to things, but it does look as if less than £2 (3$) worth of parts might help gain the benefit of noise shaped dither noise, when added to an 8 bit audio signal.

Audio recorded and prepared as a 16 bit .wav file would then need to be down-sampled and saved in a signed 8 bit format (8 bit normal .wav files are of course unsigned), as I'd need a 2s complement (signed) input format for the DAC.
That would automatically strip the wav header, and the raw signed 8 bit data stored in my 8 bit flash could then be serialised, using a cheap shift register like the 74HC165.
That would give me serial 8 bit 2's complement data as input for the DAC.  The unused LSBs from the 16 or 24 bit DAC input format would be ignored by the DAC, according to the data sheet.

It might work!..... I still need to decide whether I2S or left or right  justified is the best format for this configuration, and also hope that the DAC will function at a much lower clock speed during initial experiments (with much reduced quality of course!) to give me a chance to prove the concept before having to do a PCB layout that can cope with a high speed clock.

If it does work, I'll have got myself a reasonably priced hardware digital audio player for no more expense than adding analogue 'companding' components to my existing system!

Unless of course I've missed something vital here?.......and I know I still have to work on the clock sequence timing details......but it might be a bit of fun to try.......

Thanks for giving me the idea!..... 



Noise shaped dither in 8 bit audio

Reply #13
That might work actually.  You'll need a few Mhz oscillator, but provided you keep the traces very short that is doable.

Noise shaped dither in 8 bit audio

Reply #14
Further to your comments above, I've been looking at this a little more. I had hoped to have built something by now, but it keeps getting pushed back by more pressing matters --( I think I may need to reassess some priorities!  )

The most obvious solution to keep things simple would seem to be to use a Wolfson WM8762, in conjunction with a 74HC165 shift register, to convert my 8 bit parallel audio data to a left justified serial format for that DAC.
And then control the whole thing using several 74HC4040 counters, driven from a 12.288MHz oscillator.

What I can't quite  figure out is whether I can use the DAC in an 8 bit mode, which seems possible if the phrase on page 10 of the data sheet is correct (there's a copy here: http://www.wolfsonmicro.com/documents/uplo...s/en/WM8762.pdf ):

" The word length maybe any value up to 24 bits ".......Unfortunately, that follows immediately on from the phrase " the WM8762 supports word lengths of 16-24 bits"

I'm guessing they might mean any length between 16 and 24 --- but they don't actually say that?..and the drawing simply shows 'n' bits....
If I am obliged to use a minimum of 16 bits, then I'm not sure quite how to deal with the unused 8 LSBs in each word?  They would presumably all be the same as the last output from the shift register, whether that is either 0 or 1.
Not sure quite what the implication of that are?...

I think I shall probably just try it all out and see what happens, and if I can use 8 bit word lengths, and stick to a specified MCLK and LRC clock ratio (probably 128fs) then that would be the easier option.

The data sheet does seem a bit ambiguous though........unless of course I've just missed something fundamental in the timing concept (entirely possible  )

 

Noise shaped dither in 8 bit audio

Reply #15
Just clock your shift register 16 times. The last 8 bits will be whatever you are inputting on its serial input, such as zeros.

Noise shaped dither in 8 bit audio

Reply #16
Just clock your shift register 16 times. The last 8 bits will be whatever you are inputting on its serial input, such as zeros.


Thanks for that --as I'm importing my data via the parallel inputs, I hadn't realised that the serial input would be functional after the initial 8 bits had been shifted.... that should help keep things simple!

I have also asked Wolfson if I need a minimum of a 16 bit input, and they confirm that is the case, so hopefully I can now complete my prototype.

Thanks again for the advice.....

Noise shaped dither in 8 bit audio

Reply #17
Heck, you can build your own R2R DAC from precision resistors combined with an opamp. It will be large though, but for 8 bits, should be sufficient.
The tricky part is getting good resistors.
ruxvilti'a