Use Reference Audio design or custom code design?

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
dweeb4
Active Member
Posts: 52
Joined: Mon Jan 19, 2015 12:47 pm

Use Reference Audio design or custom code design?

Post by dweeb4 »

I'm intending to use an XMOS design as a USB audio interface on custom hardware (to be designed). Over time, I will be interfacing it to different DACs, not all of which accept I2S input. I will only use the XMOS interface with one particular DAC at a time so I intend adjusting the XMOS firmware for that particular output format i.e the XMOS code doesn't have to support all the formats in the same firmware, there will be different firmwares for each DAC interface

The interfaces will involve:
- some odd data to LRCLK ratios i.e LRCLK of 16 bitclcks but datawords can be 24bits. LRCLK of 8 bitclks but dataword can be 16bits
- splitting Left & Right channels to dual mono DACs
- inverting every odd word sample and/or inverting one data channel
- probably SPDIF &/or DSD output
- other miscellaneous interfaces

I'm suspecting that it will be easier to follow this path by starting with custom code but my question is how much of the reference audio design code can be used or what are the includes I need to include in my main.xc program?

Am I best taking the existing I2S_master & modifying it for my needs or is there a better way?

Any help greatly appreciated.


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

Post by Ross »

Unless you have a lot of experience developing USB Audio devices from scratch I would start from the reference design.

We have learnt a lot in the 8 or so years developing it.
dweeb4
Active Member
Posts: 52
Joined: Mon Jan 19, 2015 12:47 pm

Post by dweeb4 »

Thanks Ross
I take your point that the reference files have code in there which represents accumulated knowledge of USB audio built up over 8 years but from my research & reading here I find that there are many layers of interrelated files & definitions with precedence considerations. So that changing anything often requires knowing these interrelations/precedences & involves changing definitions in more than one place - it just gets confusing & a bit robotic - I would prefer to have a streamlined code where I know where I know where to change port mappings, channel assignments, behaviour of a channel. I don't need a lot of the extra feature coded into the reference subroutines, support for TDM, ADC, SPDIF, DSD so these are taking up valuable resources which might restrict me in other like number of channels, cores needed, etc

I have begun to look at all the includes & analyse what is being done in each - as I say they often overlap.
User avatar
tuck1s
Active Member
Posts: 32
Joined: Thu Sep 25, 2014 1:19 am

Post by tuck1s »

I've not looked in detail at the USB code. However one of the great things about XMOS devices, is you can use channels to connect audio sources and consumers together. So how I'd go about it:
- Get the reference design working as-is, with a standard DAC
- Get comfortable with using the IDE and debugger. Check you can add debug statements (use -fxscope compile time switch)
- Replace the DAC (consumer) code with a "debug" task that stores the incoming samples into a buffer, then prints them out. It's important for timing reasons on XMOS to buffer, then print .. as printing takes time and disrupts the real-time handling
- Ensure that you have a stable source of data (channels are 32-bits wide, so decide on your scheme for consuming variable widths of this, and how DSD vs PCM data looks in your channel)
- Then try making different I2S consumer tasks according to your original needs.

Hope this helps!

Oh - one other thought - you can simplify further, by having an 'alternative' task to the USB source. Just use a little debug task that plays a 1kHz sinewave into your channel. Pre-calculate the sinewave values using some code on your PC ,or Excel, whatever ..
dweeb4
Active Member
Posts: 52
Joined: Mon Jan 19, 2015 12:47 pm

Post by dweeb4 »

Thanks tucks1, much appreciate your advice
I'll be doing most of what you suggest