How to get access to the frame count / sof callback ? #2997
Replies: 4 comments
-
Which MCU you are using ? |
Beta Was this translation helpful? Give feedback.
-
@HiFiPhile I'm using a STM32H750. I hacked around by adding a stray By the way, since you're here and given you seem very knowledgeable about USB audio as most of what I use there seems to have been written by you - many thanks for that - I have a few questions I would really appreciate if you could shed light on. In particular I'm a little confused about the role of the feedback endpoint. What will the host truly do in response to such an 'adjustment request' ? Say a video game is playing a cutscene, I can't well imagine it slowing down the cutscene - that has hard video sync requirements - because audio is going too fast for the sake of the audio peripheral streamed to. |
Beta Was this translation helpful? Give feedback.
-
Yes
For purely audio playback (no video) what the host does is very simple, if you are slower the host will send less samples, if your are quicker then it will send more. The host is allowed to send +-1 samples each frame, more details you can read Using 48kHz on full-speed as example, host will send 47-49 samples per ms. For 44.1kHz it becomes 44-45 samples per ms.
In this case it's called Implicit Feedback. You can set the But it's not supported by every host driver, like Windows built-in driver.
Yep, then you are making a
Yes
Cheaper USB DACs chips have their PLL locked into USB clock so they are perfectly in sync. |
Beta Was this translation helpful? Give feedback.
-
But to keep frequency correctness it's not just a matter of adjusting the speed at which the audio data is transferred, but the audio data natural rate itself. Or do you mean that it would just take the 48kHz audio data stream, and send it at 47.99kHz without changing the stream values i.e without resampling from 48kHz to 47.99kHz ? Well I guess if the difference in clock frequency is so small that won't have much impact on audio quality anyway... |
Beta Was this translation helpful? Give feedback.
-
I am confused about how to get access to the sof callback. I see there's a
void tud_sof_cb(uint32_t frame_count)
defined as a weak symbol, and thattud_sof_cb_enable
is part of the application API, but even after callingtud_sof_cb_enable
(or the more hiddenusbd_sof_enable
to specify the rhport & user consumer), no calls happen to my callback (or the weak symbol).For context I want to use the sof to adjust audio rate before audio streaming begins, i.e for audio purposes but not to implement feedback in the UAC 2 sense.
Beta Was this translation helpful? Give feedback.
All reactions