Modify/reset audio samples

Discussions about USB Audio on XMOS devices
tom3
Member++
Posts: 16
Joined: Mon Jun 19, 2023 9:32 pm

Modify/reset audio samples

Post by tom3 »

Hello

I am working on an Audio project using the software reference design. I tried and managed to add a DSP effect on my audio samples. I want now to add differents effects depending of the data i receive. By putting the function " dsp_filters_biquads", in the function " GetSamplesFromDevice" i manage to get the desired effcet once, but when i send the new data (coefficients), the samples do not change .

I would like to reset all samples or to restart the function "GetSamplesFromDevice" by receiving some new data, but i don't really know where i have to add the modifications as the basis is a reference design and i can't move the " GetSamplesFromDevice" correctly in the code

Does anyone know how i could do that ? As i said, i just want to be able to restart indefinitely the process of adding an DSP effcect to a sample instead of doing it just once. The code seems to be bypassing the new data and always keep the old samples stored. I'm not sure of where i should add another while loop, as everything in the code was already predetermined.(All my changes led to errors)

Thank you in advance
User avatar
Ross
Verified
XCore Expert
Posts: 981
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

You should add this code to UserBufferManagement() - at this point you have access to all incoming/outgoing samples to/from the devices interfaces
User avatar
Ross
Verified
XCore Expert
Posts: 981
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Attached is a preview of a undated application note you should find useful - it will make it's way to xmos.com soon (replaces AN01008)
You do not have the required permissions to view the files attached to this post.
User avatar
Ross
Verified
XCore Expert
Posts: 981
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Moved to USB Audio section
User avatar
fabriceo
XCore Addict
Posts: 213
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi
this is a good document Ross!
the UserBufferManagement routine called in the middle of the data transfert between i2s and decouple is a great and simple solution to extend the code easily.

I just share my personal approach where I m using 1 core for I2S and up to 7 cores for DSP (multichannel crossover and delays and parametric equalization).
Even if the mips per core are reduced, it can be easier to spread the dsp workload over 7 tasks : in my case I have 1 task to prepare the stereo channels and to do headphones correction and then 1 task per output channel (2x4 ways+center+lfe or 2x6ways). this gives the possibility to do some good 4th order crossover job up to 192khz (xu216), but I prefer to limit MAXFREQ at 96kz in order to have more biquads available for peak correction in each channels.

Then each dsp tasks works with the same buffer in shared memory (same tile, no channel communication) and they are synchronized by a global flag which turns 0/1 at each samples. (this can typically be done in UserBufferManagement)
I have doubled the samplein and sampleout buffers in the usb_audio source code, which gives a simple way to store or load intermediate dsp samples in memories as if it was an additional channel. this way the dsp preparation task can easily feed the other tasks by putting its result in the second part of sampleout table, the cost being just 1 sample delay.

cheers
User avatar
Ross
Verified
XCore Expert
Posts: 981
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Just a quick reply to say the document is on xmos.com here: https://www.xmos.com/an01008-extending- ... ion=latest

Linked from https://www.xmos.com/develop/usb-multichannel-audio/