Custom i2s in with simultaneous S/PDIF & USB out

Technical questions regarding the XTC tools and programming with XMOS.
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

I did that in audio.xc


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

Post by Ross »

Try samplesIn_0
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

thanks mate

i now get

incompatible type for argument 2 of `__builtin_out_uint' audio.xc /module_usb_audio line 703 C/C++ Problem
incompatible type for argument 2 of `__builtin_out_uint' audio.xc /module_usb_audio line 702 C/C++ Problem

those two lines of code are as follows

outuint(c_spd_out, samplesIn_0); /* Forward left sample to S/PDIF Tx thread */
outuint(c_spd_out, samplesIn_1); /* Forward right sample to S/PDIF Tx thread */
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

Any more suggestions guys? Would be much appreciated if I can get this SPDIF out copy working.

Many thanks

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

Post by infiniteimprobability »

Hi - take a look at the declaration of the buffers which are used to store the samples as they go from the device up to the host:

Code: Select all

/* Two buffers for ADC data to allow for DAC and ADC ports being offset */
static unsigned samplesIn_0[NUM_USB_CHAN_IN];
static unsigned samplesIn_1[I2S_CHANS_ADC];
They are arrays of unsigned ints..

So you will need to access them with an array index, rather than referencing the start of the array as you have done..

Code: Select all

samplesIn_0[0] 
samplesIn_0[1]
Try that..
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

Some progress made!

Now when I play music I see data coming out the SPDIF socket. However when I connect this to my very un-fussy SPDIF input (JBL LSR4326 monitors) all I get are sporadic loud pops and no actual music.

I can verify XMOS is receiving the I2S audio just fine as it comes through as clean audio on the USB host computer.

The popping SPDIF output stays the same whether or not the USB is connected and whether or not I am playing music from the I2S. The SPDIF signal coming out doesn't look completely idle when nothing is playing but the USB host has no problem with hearing the I2s.

Is there any chance that the SPDIF side of things does not like my external MCLK (11.2MHz) or that the I2s is too dirty of a signal for it (but USB is happy)?

Strangely I am getting a 11.2MHz clock out of my source whether it's playing at 44.1 or 48k and I've set it to 256 x fs. anyhow I get the same results either way around.
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

I have a separate but relevant question:

Can this x200 xmos board / system generate it's own MCLK using the 3 wire i2s approach?

So I feed it the data, bit clock and word clock and it generates the MCLK? That might simplify things.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Is there any chance that the SPDIF side of things does not like my external MCLK (11.2MHz) or that the I2s is too dirty of a signal for it (but USB is happy)?
SPDIF output will be fine with a 11.2896MHz MCLK - it will only support 88.2KHz (or 44.1KHz) though..

Not sure what you mean about I2S too dirty?
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

Well I'm flying I2S and clock over loose jumper wires from another board. But the USB seems happy with it.

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

Post by infiniteimprobability »

I have had some success with using 20cm jump cables for I2S - sometimes OK but there have been cases where signal integrity causes noise.. Often this noise improves when you grab the cable (dampen down the SI issues)..
Generally jump cables for 24MHz signals not a good idea :(