FX3 UAC Example : Uncertain Streamed Audio Data | Cypress Semiconductor
FX3 UAC Example : Uncertain Streamed Audio Data
We are using the Cypress FX3 UAC firmware example as a starting-point for streaming audio data to an Isochronous endpoint as a standard USB audio class device. The example relies on 16-bit PCM audio data being read from SPI flash. As a test we've modified this example to use data buffers obtained via CyU3PDmaChannelGetBuffer() and set them with fixed patterns in memory instead (ultimately the actual audio data will be delivered via Slave FIFO interface). We are successful in streaming the data to the host PC and recording it in Audacity. However, the recorded data doesn't seem to match what we're expecting.
For example if we use a signed 16-bit audio data sample fixed at a value of 16384, we're expecting a recorded floating-point counterpart to have a corresponding value of 0.5 (i.e. 16384 / 2^15). The data below does not result in a recorded value of 0.5:
*(dmaBuffer.buffer+8) = 0x00;
*(dmaBuffer.buffer+9) = 0x40; // a sample of 0x4000 (16384)
However, if we right-shift the data by 5 before committing it then the recorded data is essentially our 0.5 result. This seems to hold true for other values between +32767 and -32768.
*(dmaBuffer.buffer+12) = 0x00;
*(dmaBuffer.buffer+13) = 0x02; // a sample of 0x0200 (512)
We're able to see that we can record left/right channel pairs that seem to correspond to our data buffers, but don't yet understand why we need to shift the data in order to get the expected result (with loss of precision due to the shifted lower bits). Is the data expected to be 16-bit signed linear PCM? We didn't change the USB audio descriptors from the example. Any ideas as to what might be occurring here? Is there somewhere we can locate the SPI flash audio data referenced in the UAC example? Perhaps there is something basic that we're missing. Any suggestions you have would be appreciated.