Audio slicekit Tone Generation

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
kecericksen
Junior Member
Posts: 5
Joined: Tue Nov 18, 2014 6:36 pm

Audio slicekit Tone Generation

Post by kecericksen »

Hello,



I've been trying to modify a bit of the provided code for the audio-slice kit, but I've simply cannot figure out how to generate tones, ultimately a sine sweep out of the slice kit. Using the "app_slicekit_i2s_master_demo," which is a simple audio i/o loop, what would be the best way to modify it to generate a tone? I've tried overwriting the channel and array values inside the i2s_master_loop and in the i2s_masterloop, but to no avail. I've also tried a few other things. Can anyone give me a few pointers, or at least where I should look?



Thanks in advance!


User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Hi,
certainly! Some pointers for you.

app_slicekit_i2s_master_demo is a good place to start. That invokes the i2s_master component that talks to the adc/dac and does the hw setup (pokes around the I2C registers). It also has a 2-core main (each task runs in parallel), one of them being a loopback.

I would not recommend modifying i2s_master at this stage - it's basically your I2S peripheral (written in software). No need to mess with this as it does exactly what is needed - gets samples from the adc and sends samples to the dac in real time.

The place to add tone generation is loopback. It's probably better to copy this and rename, and use it as a basis for your tone generation.

In the source where it says "do some processing" - thats probably a good place to add your sine lookup table based tone generation. Keep in mind the amount of time you have to do process so that you don't drop samples (about 20us at 48KHz - about 1250 cycles even with all 8 cores running...loads)

Don't forget that I2S requires a certain channel protocol - ie get all samples from ADC, send all samples to DAC etc. looping. So even if you only output, you still need to get the ADC samples and discard them. If you don't do this the channel will likely cause an exception (you'll be writing to the channel and so will I2S). It's easy to see in the debugger where this sort of thing happens..

Hope this helps - Let us know how you get on. What you want to do is very doable!
kecericksen
Junior Member
Posts: 5
Joined: Tue Nov 18, 2014 6:36 pm

Post by kecericksen »

Thank you! It worked perfectly; I was just butchering I2S protocol it turns out. Sorry for the late reply, I've been studying for finals.

I was wondering if you had any sources for expanding the I2S to include multiple channels in and out?

Thanks in advance, and thanks for your help again.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Glad it worked. Thanks for the feedback. Regarding....
I was wondering if you had any sources for expanding the I2S to include multiple channels in and out?
It's just a #define. So for example, you could make it 4 channels in/out by changing to the following:

Code: Select all

// Set this define to control the number of input
// channels the I2S master component implements
#define I2S_MASTER_NUM_CHANS_ADC 4

// Set this define to control the number of output channels the
// I2S master component implements
#define I2S_MASTER_NUM_CHANS_DAC 4