Non- linear adc dac, and floating point audio library?

Status
Not open for further replies.

cebersp

Well-known member
Hi, I am thinking about something and would be glad to hear some input about it.

I have done some project which uses teensy 3.6 together with the audio board for guitar effects.
It turns out, that 16bit is not good enough, if you want to do overdrive sound with DSP. It can be used, if you put a compressor or a high pass filter in front of it and if you take very good care about signal strength.

So the idea is to use a resistor and two antiparallel diodes as a non linear voltage divider before the adc. This is done quite often in guitar electronics to achieve distorted overdrive sound.
The non- linearity of the diode is described by the https://en.wikipedia.org/wiki/Shockley_diode_equation .

The idea is to take then the distorted sound after digitalisation and calculate back the linear values. (Calibration needed) This means, that then numbers are in a bigger range than 16 bits. The floating point audio library will be needed here.
After DSP, the values have to be compressed again with math, put through the DAC and be expanded again.

1. Well, yes it would be more straight away, if there was a 24bit audio card with a good price available, that can be connected to teensy 3.6 and/or 4.1 and has a driver. - I cannot solder too small parts and have doubts that I can write a device driver. So that is the first question, what can I buy?
2. Is the floating point audio library already working with teensy 3.6 and 4.1?
3. What are your thoughts about the non - linear setup as described?

The following picture shall give an impression of the both analog parts of compression and expansion.
Compr-Exp.jpg

Thank you very much. Christof
 
There are plenty of 24 bit I2S ADCs and most can be configured just in hardware, so no driver needed as I2S is supported. However
finding one on a convenient breakout seems tricky - the Sparkfun PCM1803 seems to be discontinued, and my favorite Wolfson
Micro chips are all long gone too... The PCM186x series from TI seem to be reasonable though.
 
I'm curious as to why 16 bit linear isn't enough - it's all the range you can hear in most environments.

If you do non-linear analog->digital, make sure the processing is stable and sufficiently distortion free to be accurately reversed. Diodes aren't stable.
 
To specifically try to answer your 3 questions:

1: The reality of most audio ADC chips is a noise floor which means you get about 15 to 17 noise-free bits. Or maybe a little more, but not much, if you're willing to consider the spectral content of those noisy low bits (notice almost all audio ADC noise specs are A-weighted). Some high-end parts can do about 18 bits, but to not mess it up with other analog noise (especially insidious problems like ground loops) also requires pretty intense analog design work. Consumer 24 bit audio is a myth, or a dishonest exaggeration on the part of audio gear vendors, depending on your point of view. To answer directly about what you can buy that will really give you 24 bits, the answer is nothing. Literally nothing is that good, not even close. Almost everything will give you about 15 to 17 noise free bits and 9 to 7 bits which might as well be a random number generator.

2: Chip Audette created a fork of the library using floats. I'm sure you'll find it by searching for his name.

3: Forward biased diode junctions can be a significant source of 1/f noise. Even if noise free, the I-V curve has a strong dependency on temperature. Even at a fixed (or carefully measured and calibrated temperature) the actual curve won't exactly match an ideal diode equation, because the current also flows through the rest of the silicon body, (maybe) a region of more heavily doped silicon needed to make an omhic contact to the bond wire, and of course the bond wire and any metal frame inside the diode package. That's 3 or 4 different types of material, each with their own resistance and (perhaps not so linear) resistance temperature coefficient. While those deviations from the ideal I-V diode curve will be tiny, so is resolving an analog signal to 1 part 65536.
 
There are many ADC on the market with 127dB noise floor, which counts to more than noise free 21 bits.
And even DAC with 135 dB or more are massively available within budget price range.

Noise is not exactly nonexistent information nor a disturbing and worthless part of an audio signal, it is part of it and the shape of it gives character to sound and has a relation to the lower bits, still transporting a statistically worthy and audible information below noise floor. That is why some converters with less perfect numbers sound better than others with the mathematically perfect numbers.

The problem using 16 bit in processing audio is that of loss of dynamic due decrease of dynamic range with each operation. A multiply effectively can cut the dynamic range into fractions, an addition cuts it into half, due to overflow. These losses sum up for each stage and because some effects require multiple stages or even operate multiple stages themselves, the loss of dynamic is audible quite quickly.

There are remedies like sidechaining, but there comes the phase error due to stage delays.

The easiest and fastest way would be to just add bits. The DSP gives this power, it is just not yet used.
 
1. Well, yes it would be more straight away, if there was a 24bit audio card with a good price available, that can be connected to teensy 3.6 and/or 4.1 and has a driver. - I cannot solder too small parts and have doubts that I can write a device driver. So that is the first question, what can I buy?

My project consists of DAC and ADC parts that can handle 24 (or 16, or 32) bits. I have custom PCB designs for PCM5242 and TLV320ADC6140. I'm working on the drivers, and it's going fairly well so far. When they are completed, my goal is to have a part that I can interest this community to purchase for other projects. I will also be working on getting my parts working with Chip Audette's Floating point library (OpenAudio_ArduinoLibrary), to get an increased quality of sound during processing. I'll do that once I have full control over it with the 16 bit library.

I did some research on how to connect a guitar to my project. The TLV320ADCx140 ADC has options for 2.5-kΩ, 10-kΩ, or 20-kΩ input impedance. According to this article "A minimum value is typically 470kΩ, but many are over 1MΩ". So an input stage is necessary, I think. But I've included 5v and 3.3v pins along the input pins so that it should be pretty easy to create one. I don't think the circuitry is terribly difficult to imagine with an op-amp and some passives.

Sorry, it's not ready yet (almost!!). But if you wanted to follow my thread, and help me iron out bugs that would be helpful. I've been trying to find others who have similar needs as I do.
 
There are many ADC on the market with 127dB noise floor, which counts to more than noise free 21 bits.

Its not that simple with noise. Noise is typically measured per Hz, ie as a power spectral density, and -127dB per Hz could be -105dB
noise power if sampled at 44kHz, which is about 17.5 bits.

You have to understand the subtleties of noise power v. power spectral density, and be sure what the 0dB reference is (hopefully
full scale sine wave, but are you sure?)

A random FFT plot showing a sine tone and a noise floor is problematic, as the dB scale is usually set for a peak spectrum, not spectral
density, so the noise floor level is basically meaningless.
The mapping between the two (peak spectrum v. spectral density) needs knowledge of the sample rate, number of points in the FFT
and the sampling window's noise bandwidth...

Essential reading I found: https://holometer.fnal.gov/GH_FFT.pdf
 
@MarkT
Thank you for going more into the theory behind this.
I guessed this is far more than necessary to discuss the subject.
Actually, the '6dB a bit'-rule is a good estimate for audio in the human hearable range and common sample rates.
 
@MarkT
Thank you for going more into the theory behind this.
I guessed this is far more than necessary to discuss the subject.
Actually, the '6dB a bit'-rule is a good estimate for audio in the human hearable range and common sample rates.

Its 6.02 * bits + 1.76 dB for (theoretical) rms quantization noise across the whole Nyquist frequency span. If you sample
at a higher rate the noise power in the audio spectrum is less as its spread out more thinly. It makes sense to quote noise
as a spectral density so it can be calculated for the signal of interest without having to know the sampling rate. Real devices
have more noise than the theoretical quantization noise of course, hence the effective number of bits being lower.

And ENOB is just an alternate description of signal to noise ratio, which is only meaningful if the bandwidth is indicated - for
an audio ADC you might assume the bandwidth of interest is 20--20kHz, or you might just use the whole Nyquist bandwidth,
so its important to know which, as the ENOB for a 20kHz bandwidth is different from a 96kHz bandwidth for instance.
 
mind to elaborate? is 20 kHz BW not equiv to 43 dB (10log10(BW))?

Whoops, did I work in volts instead of power by mistake? Sorry, I'm mainly working with noise voltages in nV/√Hz
and probably multiplied by √20000 (141) by mistake...
 
Hi,
Thank you very much for all the replies!
Gives me input to think.
The signal of an electric guitar has a very wide range of voltages. The amplitude can be up to perhaps 1V. And if you want to have the sustain of a lead guitar, you will have to amplify a very small signal of <1mV to full output level. So here you have to have an amplification factor of 1000, which will drive the 1V into massive overdrive. Especially well made tube circuits can do this sort of compression by overdrive still sounding "nice".
So if you want to do the overdrive digitally, you need more than 16bits to have enough resolution for low level and most of the time. I am perfectly clear, that 24 bit is not really possible, but a few more bits would help. And of course guitar players are always fighting hum and noise. As noise can be heard especially, when there is no music played, a "noise gate" is used often, to switch off the signal.

"I did some research on how to connect a guitar to my project. The TLV320ADCx140 ADC has options for 2.5-kΩ, 10-kΩ, or 20-kΩ input impedance. According to this article "A minimum value is typically 470kΩ, but many are over 1MΩ". So an input stage is necessary, I think. But I've included 5v and 3.3v pins along the input pins so that it should be pretty easy to create one. I don't think the circuitry is terribly difficult to imagine with an op-amp and some passives."

- Yes, a buffer for high input impedance can be done quiet easily using a jfet: http://www.muzique.com/lab/buffers.htm. These small circuits for guitars usually work with 9V.

Best regards,
Christof
 
A JFET input opamp is the obvious choice for a buffer(*), something like the OPA1641/OPA1642 would be suitable, although it
doesn't need to be anything like that specification, but they are cheap enough. The AD743/AD745 has the edge on noise,
but much more expensive and harder to source.

(*) Low noise discrete JFETs are getting harder and harder to source, especially in SMT, the relevant opamps are mainstream
and not going away any time soon.
 
If noise is a concern, make it fully differential (preamplifier and ADC). Treat both lines exactly the same (actives, passives, routing, etc). Actually achieving > 16 bits is not so easy.

The TLV320ADCx140 ADC has PGA, AGC and DRE (dynamic range enhancement) which might be useful.

On the other hand, I still don't get > 16 bits ADC (not later processing) when the source signal is far less than that (< 80 dB for guitar pickups?).
 
Last edited:
(*) Low noise discrete JFETs are getting harder and harder to source, especially in SMT, the relevant opamps are mainstream
and not going away any time soon.

Yes, that is a shame, also as paralleling FETs could bring noise down to really sub nV/√Hz.
so we must stick with opamps
At the moment I try to test a AD8656 stereo piezo-preamp for a TLV320ADC6140 ADC, will see how it turns out
 
Yes, that is a shame, also as paralleling FETs could bring noise down to really sub nV/√Hz.
so we must stick with opamps
At the moment I try to test a AD8656 stereo piezo-preamp for a TLV320ADC6140 ADC, will see how it turns out

Noise created by devices isn't just voltage noise, its current noise too, and for high impedance sources like a
guitar pickup (lots of inductance, high impedance at high audio frequencies), current noise can dominate.

Current noise is made worse by paralleling devices, so that might make things worse. But JFETs are usually
very low current noise so this might be OK - do the math basically.

Since a pickup is a coil of wire on a core, its got resistance (which generates Johnson noise) and inductance
the net impedance multiplies the current noise to make a second noise contribution, and then there's actual
voltage noise of the amp too. The effect of the inductance on the impedance means that noise rises with frequency
and unless the current noise is low you get blue noise, not white (blue noise is very hissy).

Its the rms sum of these three noise sources that gives the final amount of noise. You can also low-pass filter
the signal to the bandwidth of interest and lose a whole load of high frequency noise that way.

In practice I'd just bung in a JFET audio opamp and it'll likely be fine.
 
Noise created by devices isn't just voltage noise, its current noise too, and for high impedance sources like a
guitar pickup (lots of inductance, high impedance at high audio frequencies), current noise can dominate.
OK, I should have be more specific, my piezos are piezoceramic hydrophones, there is some inductance, but mostly capacitance.
Yes, I'm aware of all the noise sources, including reverse current of protecting diodes, sometimes needed fore piezoceramics.
 
Status
Not open for further replies.
Back
Top