Skip to main content
Kneepatch
Senior
Nov 23, 2021 11:59 AM UTC
Question

BSP_AUDIO_OUT_Play() Buffer Size Parameter

I am programming an SMT32F69I-DISCO board to output a SINE wave. I am having trouble with the Size parameter of the BSP_AUDIO_OUT_Play() function. I have a buffer of 100 that I am filling with my SINE values:

int16_t dataI2S[100];

Here are my calls of the functions to initialize and play audio @48 KHz:

BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_BOTH, 80, 48);

BSP_AUDIO_OUT_Play(dataI2S, (uint32_t)200);

Here is what it looks like when I put 128 as the Size parameter:

0693W00000GYZcRQAX.bmpWhen I set it to 100:

0693W00000GYZdKQAX.bmpWhen I set to 200:

0693W00000GYZgsQAH.bmp 

According to the function definition I put below, it sounds like it should be set to 200 because it's the size in bytes.

/**

 * @brief Starts playing audio stream from a data buffer for a determined size.

 * @param pBuffer: Pointer to the buffer

 * @param Size: Number of audio data BYTES.

 * @retval AUDIO_OK if correct communication, else wrong communication

 */

uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size)

Anyone have any ideas what I am doing wrong here? Many thanks!

This topic has been closed for replies.

2 replies

TDK
Nov 23, 2021 1:11 PM UTC

The period is consistent for each data length. How do you know the data you're sending isn't what is displayed? How are you initializing the array?

"If you feel a post has answered your question, please click ""Accept as Solution""."
Kneepatch
KneepatchAuthor
Senior
Nov 24, 2021 12:09 PM UTC

Yes, it seems that I only have 64 values in my array, not 100! Can't believe I did not catch that. Thank you!

//Sine Wave variables

sample_dt = F_OUT/F_SAMPLE;

sample_N = F_SAMPLE/F_OUT;

uint16_t dataI2S[sample_N*2];

//Build Sine wave

for(uint16_t i=0; i<sample_N; i++)

{

mySinVal = sinf(i*2*PI*sample_dt);

dataI2S[i*2] = (mySinVal )*8000+4000;  //Right data

dataI2S[i*2 + 1] =(mySinVal )*8000+4000; //Left data 

}

-Kneepatch