2021-11-23 03:59 AM
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:
When I set it to 100:
When I set to 200:
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!
2021-11-23 05:11 AM
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?
2021-11-24 04:09 AM
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
}