Version: 0.21
Status: Under development
License: Custom Licence
Download: /files/project_builds/Audio 0_21.zip
This projects goal is to examine the possibilities to have “HIFI” audio quality and in the same time have a very low latency from the input to the output, meaning that the latency << 1 ms.
It might sound very easy to achieve, but it's not.
One group of converters is the SA-converters, they have a very small internal latency but uses at maximum 16-bits without noise-shaping. They also needs to have external minimum-phase anti-aliasing filters and maybe some extra circuits to add dither-noise.
It is possible to use it, but as far I know you will end up in a large BOM with a SNR that isn't what you want for frequencies > 5 kHz.
On the other hand there is a lot of low-price Audio-CODECs out there used for almost all Audio recording and playback. They are based on the Delta-Sigma converters inside instead of the SA-converter.
I will not explain why here, but they have several nice features for audio, but – they will have something between several to 512 samples of delay on both the A/D converter and the D/A converter which might add up to 2 ms delay @ 44.1 kHz to the system.
1-2 ms doesn't matter at all in a mp3 player or a CD player, but in some special fields of audio processing a very low latency is needed.
I have a system based on a DSP+FPGA+CPU+SA_converter + active anti-aliasing-filters with a HW-price tag of ~3000$, and it's large as a barebone PC that can fit a PCI-slot. To program all those things above you also need software for > 3000 $.
With the XMOS I believe it is possible to make an system with better SNR+D compared to the one above with a BOM cost of < 15 $, and a software license cost of 0 $. It will also only need a few square-inch of PCB-area and it can easily be an embedded system. Also, If you need more computational power - Add more XMOS chips!
One trick is to take a CODEC that has a small delay from the beginning and to run it at maximum speed - 192 kHz, thereafter down-sample the ADC-data to a more appropriate fs – then process it at the low fs –then up-sample it back to 192 kHz and put it out to the DAC.
The CODEC communication and up/down sampling is handled by one thread, the Left_channel Audio DATA is then sent to one thread and the Right_channel Audio DATA is sent to another thread. The last 2 threads are used for Audio processing.
The upper picture show the bandlimited square-wave input-signal (Blue) which is feed to the CODEC and its corresponding output (RED) when the DATA is just replicated in the two processing threads.
The latency thru "everything" is just about 70 us !
(If you try this on your non ASIO-soundcard under Windows you will probably end up with a latency >> 100 ms !, thus use line-in on your soundcard - process the Audio in realtime with a program/process running under Windows - send it to the Line-out.
If you have a soundcard for use with an electric guitar to add effects to the sound - you will have a latency that you hopefully can't easilly detect with your ear - but it will not be around 70 us at all ! )
The second picture shows an measurement of a DFII 2:nd order Butterworth filter with a cutoff freq. at 0.25 (½fs) running on the processing threads.
Images:
Low latency "HIFI" Audio on XMOS
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Low latency "HIFI" Audio on XMOS
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
So I have manage to use the card over USB in Win7 at different fs and it seems to work with a good SNR and low distortion. But USB is not the objective for this project, but I got some measurement results :)
Probably not the most confused programmer anymore on the XCORE forum.
-
- Respected Member
- Posts: 296
- Joined: Thu Dec 10, 2009 10:33 pm
Very interesting.
I would like to construct a digital crossover for use with my occasional loudspeaker construction projects.
Basically stereo in and stereo out in 3 frequency bands each. Input I would like from an audio line, SPDIF or even USB from the PC. Output to three audio lines per channel on their way to the power amp stages.
With a few switches or pots for control input and perhaps a small screen for crossover point display etc. This should all run with out a big, clumbsy, potential noisy PC in the room.
The crossover algorithms I have had running under Windows for a long while. I want to shrink everything into a 50 dollar board.
So I will be following your progress keenly.
I would like to construct a digital crossover for use with my occasional loudspeaker construction projects.
Basically stereo in and stereo out in 3 frequency bands each. Input I would like from an audio line, SPDIF or even USB from the PC. Output to three audio lines per channel on their way to the power amp stages.
With a few switches or pots for control input and perhaps a small screen for crossover point display etc. This should all run with out a big, clumbsy, potential noisy PC in the room.
The crossover algorithms I have had running under Windows for a long while. I want to shrink everything into a 50 dollar board.
So I will be following your progress keenly.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Heather - First I think that you should consider the largest drawback with the typically digital crossover design; the nonlinear distortion from the speaker typically increases > 10 dB in the region below the crossover point, including the 3:rd harmonic.
The reason for that has nothing todo with"digital", instead it is the problem that an electrodynamic loudspeaker should not directly be connected to an low-impedance voltage source as an power amplifier due to the distortion that the driver itself introduces.
Connected to a passive network, the speaker will be linearised by the passive electrical components, specially for those frequencies where the impedance of the network > driver impedance.
The lack of serial impedance with active crossovers can be solved in several ways. One way is to create a current-feedback loop that controls the current that runs in the voice-coil - which is equal to giving the PowerAmp an virtuel output impedance which is far from 0 Ohms.
Extra intresting is that the virtual output impedance also can get negative values, as in -3 ohm. That can not be achived with passive components.
To achive an virtual output impedance of a PowerAmp based on a closed loop design - some criterias must be fullfilled.
If the control system is made digital - the most important thing is to have a small phase/time delay in the control loop.
The reason for that has nothing todo with"digital", instead it is the problem that an electrodynamic loudspeaker should not directly be connected to an low-impedance voltage source as an power amplifier due to the distortion that the driver itself introduces.
Connected to a passive network, the speaker will be linearised by the passive electrical components, specially for those frequencies where the impedance of the network > driver impedance.
The lack of serial impedance with active crossovers can be solved in several ways. One way is to create a current-feedback loop that controls the current that runs in the voice-coil - which is equal to giving the PowerAmp an virtuel output impedance which is far from 0 Ohms.
Extra intresting is that the virtual output impedance also can get negative values, as in -3 ohm. That can not be achived with passive components.
To achive an virtual output impedance of a PowerAmp based on a closed loop design - some criterias must be fullfilled.
If the control system is made digital - the most important thing is to have a small phase/time delay in the control loop.
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Now it works for 44.1, 48, 88.2, 96 and 192 kHz (Not 176.4 kHz yet).
At 192 kHz a 4 time decimate can be choosen.
The two processing thread makes a dummy loop for each sample, just to test to add som burden to the threads. I had some problems to get the channel-com. correct without getting starved out of time at 192 kHz - resulting in glitches. But now it works :)
Next will be to add some filtering.
At 192 kHz a 4 time decimate can be choosen.
The two processing thread makes a dummy loop for each sample, just to test to add som burden to the threads. I had some problems to get the channel-com. correct without getting starved out of time at 192 kHz - resulting in glitches. But now it works :)
Next will be to add some filtering.
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
It worked at the first compilation, but this is the stuff I know a lot about :)
So, it's a 2:nd order Butterworth filter @ 0.25 ½fs, implemented with Direcrform II
One easy way to calculate the coef. in MATLAB is:
[B,A]=butter(2,0.25);B=int32(round(B*2^31));A=int32(round(-A*2^31));
A and B can now directly be used in XC.
BUT!! It only works when the absolute of the normalized filter coeff < 1. I have to change to TI-DSP form to correct that.
So, it's a 2:nd order Butterworth filter @ 0.25 ½fs, implemented with Direcrform II
One easy way to calculate the coef. in MATLAB is:
[B,A]=butter(2,0.25);B=int32(round(B*2^31));A=int32(round(-A*2^31));
A and B can now directly be used in XC.
BUT!! It only works when the absolute of the normalized filter coeff < 1. I have to change to TI-DSP form to correct that.
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
After some thinking about bitrev and unsigned or signed, the first FIR filter is up and running and it works as it should. I have been sick this week and mostly in beed - but with two laptops.
The second laptop runs a realtime spectrum measurement so I can directly se the result after doing Build+Run :)
The second laptop runs a realtime spectrum measurement so I can directly se the result after doing Build+Run :)
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Made the IIR filter compatible with the modified TDF-II
Probably not the most confused programmer anymore on the XCORE forum.
-
- Newbie
- Posts: 1
- Joined: Sat Jan 30, 2010 6:37 am
Could you cite a reference to this distortion mechanism please.
Given that the drive conditions as seen by the transducer(s) do not change with respect to frequency when using active crossovers it seems unlikely that there would be any change in distortion in "the region below the crossover point", wherever that might be.
It seems more likely that a poorly designed passive network would go wrong by providing less damping out of band.
I mean no critism here, I am simply interested in things I have never heard about in a field in which I have some experience.
cheers,
jon.
Given that the drive conditions as seen by the transducer(s) do not change with respect to frequency when using active crossovers it seems unlikely that there would be any change in distortion in "the region below the crossover point", wherever that might be.
It seems more likely that a poorly designed passive network would go wrong by providing less damping out of band.
I mean no critism here, I am simply interested in things I have never heard about in a field in which I have some experience.
cheers,
jon.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
I have a lot of swedish material, but i guess that doesn't help you much.
First, think about what would happend with the loudspeaker (without any crossover) if you would connect it to a current-source instead of a voltage-source.
With help of a equaliser prior the driving stage, you could (at least in theory) give the speaker the same (linear) frequency response.
If (and only if) the loudspeaker was a perfectly linear device, like a perfect speaker but still with mass and compliance , you could achive the same behaviour with voltage and current drive.
But the speaker isn't linear - so what will happen ?
(You can easly build an current Audio-amplifier, it's just a question about the feedback loop.
Do you feedback a signal that proportional to the voltage over the voicecoil, or the current thrue the voicecoil. Current amplifiers was used already in the 1960 to drive speakers.)
First, think about what would happend with the loudspeaker (without any crossover) if you would connect it to a current-source instead of a voltage-source.
With help of a equaliser prior the driving stage, you could (at least in theory) give the speaker the same (linear) frequency response.
If (and only if) the loudspeaker was a perfectly linear device, like a perfect speaker but still with mass and compliance , you could achive the same behaviour with voltage and current drive.
But the speaker isn't linear - so what will happen ?
(You can easly build an current Audio-amplifier, it's just a question about the feedback loop.
Do you feedback a signal that proportional to the voltage over the voicecoil, or the current thrue the voicecoil. Current amplifiers was used already in the 1960 to drive speakers.)
Probably not the most confused programmer anymore on the XCORE forum.