1. For a given size of audio data block and assuming it is a two-channel (stereo) recording with

16-bit resolution determine the minimum number of DMA transfers required to implement
playback. Show your work.

Audio Data Block Size = 4144240 bytes

3 answers

Each sample of audio data is 16 bits (2 bytes) for each channel in a stereo recording. Therefore, the size of each stereo sample is 4 bytes (2 bytes for left channel + 2 bytes for right channel).

Given that the Audio Data Block Size is 4144240 bytes, we can calculate the number of stereo samples in the block by dividing the block size by the size of each stereo sample:

Number of Stereo Samples = Audio Data Block Size / Size of Each Stereo Sample
Number of Stereo Samples = 4144240 bytes / 4 bytes
Number of Stereo Samples = 1036060

Since each transfer can only move a fixed number of bytes at a time, we need to determine the minimum number of DMA transfers required to transfer all the stereo samples.

Assuming the DMA transfer size is 1024 bytes, the number of transfers required can be calculated as follows:

Number of Transfer Required = Number of Stereo Samples * Size of Each Stereo Sample / DMA Transfer Size
Number of Transfer Required = 1036060 * 4 bytes / 1024 bytes
Number of Transfer Required = 4144240 bytes / 1024 bytes
Number of Transfer Required = 4045

Therefore, the minimum number of DMA transfers required to implement playback of the given size of audio data block in a stereo recording with 16-bit resolution is 4045 transfers.
2. If the amount of data per a DMA transfer is initially set to maximum (DMA_CNDTR register is set to 0xffff) determine the amount of data (number of samples N) in the last transfer for your audio block (use data from question 1). Show your work.
Given that the DMA transfer size is initially set to the maximum of 0xffff (65535) and the total number of DMA transfers required is 4045 (as calculated in question 1), we can calculate the amount of data (number of samples N) in the last transfer by subtracting the total transferred data from the total amount of data in the audio block and then converting it to the number of samples.

Total Transferred Data = Number of Transfers * DMA Transfer Size
Total Transferred Data = 4045 transfers * 65535 bytes
Total Transferred Data = 265105575 bytes

Amount of Data in the Last Transfer = Audio Data Block Size - Total Transferred Data
Amount of Data in the Last Transfer = 4144240 bytes - 265105575 bytes
Amount of Data in the Last Transfer = 3904785 bytes

Number of Samples in the Last Transfer = Amount of Data in the Last Transfer / Size of Each Stereo Sample
Number of Samples in the Last Transfer = 3904785 bytes / 4 bytes
Number of Samples in the Last Transfer = 976196.25

Therefore, in the last DMA transfer with the DMA transfer size initially set to the maximum (0xffff), there would be approximately 976196 stereo samples transferred for the given audio block.