Audio Streaming PSoC 4

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
shRe_2888731
Level 3
Level 3
5 likes given First like received First like given

Dear msur​,

Following up from the discussion at Audio Streaming and Signal Processing using DMA​, I had the same mistake in a custom board using PSoC 4 Chip (CY8C4248LQI-BL583) when I was trying to stream audio from an external codec. However, implementing the suggestion that worked for PSoC 6 does not work for PSoC 4 and feel like I am not setting up the DMA properly for this case since for the given sampling rate and sample size, I should have at least about 8 ms for signal processing. I have attached a part of the project without the code for codec that I am using. As before I added a delay to imitate some signal processing but adding this introduces echoes and corrupts that audio. Any help would be appreciated.

Kind regards,

Shams

0 Likes
1 Solution
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello shams_2888731​,

Sorry for a delay in response, was away and then had some login issues the past 2 days.

To your query, note that PSoC 4 I2S component has only one FIFO element (i.e. FIFO level 1). In case of PSoC 6, it has a huge buffer (255 bytes). Now when you stop your RX and start it again, you are literally cutting out 2 ms worth of Audio every 10 ms approx (if 8 ms is the 64 sample period ==> 8 ms data > 2 ms delay/no data > 8 ms data ... ). This is like 20% audio loss. Not sure how that translates to echo but definitely you should hear clipped audio because of that.

In order for a better output, you should implement a ping-pong buffer configuration (2 buffers) as I explained earlier for capturing the audio. Use two descriptors and chain them together. The first descriptor takes care of transferring data from I2S to first SRAM buffer and generate interrupt after completion (64 bytes). At this point pass the control (chain) to descriptor 1 (which transfers I2S to the second buffer). During the descriptor 1 transfer, you process descriptor 0 transferred data (make sure you complete within the time). Note that both descriptors will trigger the same interrupt - read the descriptor status (Invalid ==> just completed) before setting the appropriate flag. Invalidate a descriptor after transfer is complete and validate it after processing the data transferred by that descriptor.

Let me know if you have any queries about this implementation. The example project that Ankita shared should give an example of this implementation.

Regards,

Meenakshi Sundaram R

View solution in original post

9 Replies