Add SRC into the USB Audio 2.0 Reference Software Topic is solved

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
Post Reply
ffomich
Experienced Member
Posts: 119
Joined: Mon Sep 15, 2014 1:32 pm

Add SRC into the USB Audio 2.0 Reference Software

Post by ffomich »

Hi,
I try to add SRC to the S/PDIF input in the USB Audio 2.0 Reference Software.
For example I want to receive S/PDIF@44100 input while all board works at 96000.

Please correct me if I am wrong.
Reference Design clocking scheme is:

Code: Select all

S/PDIF input -> SpdifReceive() -> ClockGen() -> (data) -> audio()
                                            |-> (clock) -> output port -> PLL
In the firmware I can select Clock Source: Internal or S/PDIF input.
1. Clock source = S/PDIF input, S/PDIF data is valid
In this case ClockGen() extracts clock from the input digital stream and all board CLKs is sync to the S/PDIF input.

2. (Clock source = Internal) or (Clock source = S/PDIF input, S/PDIF data is NOT valid)
In this case ClockGen() outputs clock from the internal clock generator and all board CLKs is sync to the internal clock.

Now I try to add SRC between SpdifReceive() and ClockGen(). Question is what to use: SSRC or ASRC?

Code: Select all

S/PDIF input -> SpdifReceive() -> SRC() -> ClockGen() -> (data) -> audio()
                                                     |-> (clock) -> output port -> PLL
1. Clock source = S/PDIF input, S/PDIF data is valid
In this case I think I need to use SSRC because SpdifReceive and ClockGen are sync to the same clock.

2. (Clock source = Internal) or (Clock source = S/PDIF input, S/PDIF data is NOT valid)
In this case I think I need to use ASRC like in the example AN00231_ASRC_SPDIF_TO_DAC. SpdifReceive and ClockGen are sync to the diferent clock.

Is my reasoning correct?


View Solution
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

If the S/PDIF input is invalid why would you be applying sample rate conversion? It seems to me that the code is designed so that if you are using S/PDIF input the system master clock must be synchronized to the S/PDIF stream through the ClockGen controlling the PLL (i.e. clock source = S/PDIF input). It would probably be desirable to implement idea 2 (ASRC) if you want to output the audio to a DAC on your board, in this case ClockGen wouldn't need to drive a PLL I suppose if the ASRC can estimate the input clock frequency from the average data rate on a streaming channel.
ffomich
Experienced Member
Posts: 119
Joined: Mon Sep 15, 2014 1:32 pm

Post by ffomich »

Hi akp,

you are right, I don't need SRC when S/PDIF stream is invalid. But in this case ClockGen() starts to output clock to PLL from internal source. So this mode is equal to the (Clock source = Internal) mode.

Thanks for idea to estimate the input clock frequency in the ASRC() not in the ClockGen(). I think Rate Manager from the AN00231_ASRC_SPDIF_TO_DAC example already do this.
ffomich
Experienced Member
Posts: 119
Joined: Mon Sep 15, 2014 1:32 pm

Post by ffomich »

Hi,
I have succeeded in adding SRC.
The scheme is the following:

SpdifHandler() makes a copy of the input digital stream and sends it to the SRC wrapper.
ClockGen() receives 2 data streams and
- extracts sync clock from the original stream
- gets data from the stream copy after the SRC

Code: Select all

S/PDIF input -> SpdifReceive() -> SpdifHandler() ---------------------------------------------------------------> ClockGen() -> (clock) -> output port -> PLL
                                               |-> Serial2Block() ->[ASRC() + rate_server()] -> Block2Serial() ->|          |-> (data) -> audio()
N.B.
Using AN00231_ASRC_SPDIF_TO_DAC example code for SRC wrapper don't forget to set correct ASRC_N_OUT_IN_RATIO_MAX in the app_config.h
Default value is 3, so my project worked in the 44.1/48 -> 96 mode, but it didh't work in the 44.1/48 -> 192 mode.
For the 44.1/48 -> 192 mode you must set ASRC_N_OUT_IN_RATIO_MAX = 5.
maqu67
Member++
Posts: 22
Joined: Tue Jan 23, 2018 3:26 pm

Post by maqu67 »

Hello,

if I measure the frequency at PIN PLL_SYNC (PIN 5 CLKIN of CS2100-CP) with oscilloscope it doens't change if I input SPDIF signal or not.
In the ClockGen.xc I've selected "Clock source = S/PDIF input" and I've usb cable disconnected.

Is'it normal? I would expect a change in the clock frequency of PLL_SYNC in case when I plug RCA DIGITAL cable (from CD player) or when I non plug RCA DIGITAL cable (from CD player).

Massimiliano
Post Reply