2025-10-30 12:17 PM
This branches off from the second question I asked in here.
Using the example code (Ux_Device_Audio2.0_PlayBack) right off the bat does not work, and this is what I've done so far.
@FBL also suggested an approach, which I will test tomorrow:
I implemented a double-buffering approach where we clear (zero out) one half of the SAI audio buffer while writing to the other half, then swap the operation accordingly. This ensures that old audio data is removed before new data is processed, minimizing unwanted noise. It works on my end ! Add between /* USER CODE BEGIN 1 */ and /* USER CODE END1 */
uint32_t half = AUDIO_TOTAL_BUF_SIZE/2;
void BSP_AUDIO_OUT_HalfTransfer_CallBack(uint32_t Instance)
{
memset(&BufferCtl.buff[0], 0, AUDIO_TOTAL_BUF_SIZE/2);
}
void BSP_AUDIO_OUT_TransferComplete_CallBack(uint32_t Instance)
{
memset(&BufferCtl.buff[AUDIO_TOTAL_BUF_SIZE/2], 0, AUDIO_TOTAL_BUF_SIZE/2);
}
2025-11-21 11:28 AM
Side note: @FBL - I am trying to understand what this is about:
I'm here because I wanted to see if the noise issue was fixed, but the FSBL and USBPD is new (or to me at least) so wanted to ask you.
2025-11-21 1:14 PM
Okay I had noticed that the two projects (UX_Device_Audio_2.0Playback on H743i-EVAL and UX_Device_Audio_2.0 on N6570-Discovery) are not the same project whatsoever.
I'm going to see how they do it there (N6) and implement it here (H7) and will update soon, hopefully that'll solve the noise and the usb feedback support (N6 has this already).
To support above, notice the USBD_AUDIO_PlaybackStreamFrameDone() function is different in N6 and H7. N6 handles the write pointer correctly whereas the H7 did not and I had to fix that myself.
2025-11-25 12:10 PM
I am being stalled due to the lack of answers I'm getting here. I am not sure what to do about the media player hanging and the screeching sound, and I need support ASAP. It's not good that I haven't updated my team as I am still trying to solve this issue.
Your solution did not solve the issue as it brought up a new issue, and even with the feedback support active, it still hangs.
2025-11-26 8:11 AM
Hi @audio
Sorry to hear that ! I hope this will help you now ! Updates concern :
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-11-26 1:19 PM
This update solved the media hanging, which is great news!
However, it did not solve the screeching issue right at 4-5 seconds every first playback. Meaning, if I reset the board, and play audio, right at 4-5 seconds, it screeches. Any other playback is fine.
Lastly, it introduced a very low hum right at the end of the playback when the stream is complete. Do you know what that is? The hum doesn't appear if I pause the stream.
I wonder if the screeching is due to a clock drift between the USB rate and SAI rate?
2025-11-28 8:48 AM
Hi @audio
At this level I don't get your point about screeching or hum noise? Can you provide a proper waveform ;
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-12-01 11:34 AM - edited 2025-12-01 12:10 PM
Hello @FBL
The first track is what's being played, and the second track is what's recorded out of the headphone jack.
2025-12-02 1:54 AM - edited 2025-12-02 5:50 AM
Hi @audio
Do you reproduce the issue using this example already provided? It is not implementing recording!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-12-02 2:51 AM
Hello,
@FBL, X CUBE AUDIO KIT is not integrating UX so I don't think it will help here. However, the github link you gave toward the N6 project is a good starting point.
STM32CubeN6/Projects/STM32N6570-DK/Applications/USBX/Ux_Device_Audio_2.0
Br
Jonathan
2025-12-02 5:57 AM
Hello @FBL and @JonathanC
Over the last few weeks, I’ve spent a significant amount of time reviewing X-CUBE-AUDIO. Unfortunately, I haven’t been able to integrate it easily as suggested. I’ve paused that for now since I still need to build the recording path.
Regarding the N6 standalone project, I did review it carefully. I also spent the last few days comparing it against @FBL's H757 standalone project. There are only minor differences between the two, and I’m still evaluating them, but I’m not yet sure how to proceed.
@FBL - I noticed something in ux_user.h:
You selected host instead of device for the feedback path, even though the preprocessor defines it correctly. When I disable feedback (both in ux_user.h and in preprocessor), I expected the media player to hang, but it doesn’t - playback starts immediately.
This leads me to believe the Ux_Device Audio implementation for H7 has several issues and likely requires an update ASAP.
Based on debugging, the ring-buffer logic appears to be incorrect:
wr_ptr is advanced before copying data.
There is no wrap-around handling for wr_ptr, which leads to memory corruption.
rd_ptr never advances - it stays at 0 permanently.
I was able to eliminate the humming by calling: BSP_AUDIO_OUT_Stop(0); as you previously mentioned. When alternate-setting = 0, it stops the output, although there is still an audible click.
I still don’t know the cause of the screeching sound at 4–5 seconds, and I haven’t found a reliable solution yet.
Any guidance on these issues, especially regarding the buffer logic and the screeching noise, would be greatly appreciated.