-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UAC2: Implement feedback by fifo counting. #2328
base: master
Are you sure you want to change the base?
Conversation
476a593
to
65225c0
Compare
Test welcomed @Protoxy22 @Lurcy38 @kf6gpe @PanRe |
Wow great work, I will have time to test this next week on an STM32H743 Eval Board with USB HS Thank you |
a48a5bd
to
db6b822
Compare
This is interesting. I'm curious where can I find audio_debug.py. Any ideas? Thanks a lot! |
Just in the PR examples/device/uac2_speaker_fb/src/audio_debug.py |
Ah, so not in main yet. Ok, thanks! |
great :) , I will be very happy to test this implementation in my app, but i cannot reach the branch rx_fb , how to do ? |
@Lurcy38 it's under my user space |
@hathach After more tests this PR is ready. |
Hi, what is the status of this PR? what is missing for it to be approved? |
Hi, great work, Could this be due to the fact that macOS does not accept this feedback method or some other reason such as incorrect descriptors for the MAC? Thanks! |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Back from holiday...
No it's not how it works... |
@Marcus2060 What do you mean crash, does the kernel panic or having popping sound or something else ? You can try to change tinyusb/src/class/audio/audio_device.h Line 196 in 2720392
From other people's experience it seems this format incompatibility issue exist.
I see there are 3 solutions:
|
Hi, I've done other experiments and I get the impression that the usbd_edpt_xfer() function on low-level stack doesn't work well when we try to send 3 bytes. MAC:
Windows:
Also: So, could the problem be on the low level of the Tinyusb stack when we try to send 3 bytes feedback via usbd_edpt_xfer() to Host ??? Thanks! |
No it can't be, you also tested 3 bytes works on MAC.
It's true.
Pico use UAC 1.0 while TUSB uses UAC 2.0, you can see their descriptors are quite different. |
Hi,
No, my previous comment is precisely because I tested that the 3 bytes don't seem to work (see my pont 1, 2 about MAC):
I highlighted the 3 bytes sent problem because: Thanks anyway for your attention. |
Sorry I've some problem understanding, you mean |
Below 4 different tests on MAC using 10.14 format:
Below the function to send feedback (feedback value is an uint32_t) : |
Testing this feature with ESP32-S3 has been very successful. The device plays sound without any noise, and the FIFO consistently maintains a stable intermediate level. |
@Marcus2060 @rhysmorgan134 So I'm curious about why it doesn't work in your cases. Anyone interested can find the code: |
Thanks for looking into this so much! I will take a look though your implementation and match buffer sizes and then feedback. |
@HiFiPhile Seems you are right, setting my DMA buffers to 64 samples, 128bytes in my case, works fine with 3 bytes set in the transmit function and maxPacketBytes==3. Are you using the tusb_config.h and descriptors from the example? If not would you mind sharing your ones you used for your test, would be nice for me to just sanity check mine. Also did you run into any difficulties getting the python script running on OSX? |
Yes they are from stack example, only difference is enable correction and set wMaxPacketSize=3: diff --git a/examples/device/uac2_speaker_fb/src/tusb_config.h b/examples/device/uac2_speaker_fb/src/tusb_config.h
index 1cc1031c1..1a1cebca8 100644
--- a/examples/device/uac2_speaker_fb/src/tusb_config.h
+++ b/examples/device/uac2_speaker_fb/src/tusb_config.h
@@ -123,7 +123,7 @@ extern "C" {
#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN TUD_AUDIO_SPEAKER_STEREO_FB_DESC_LEN
// Enable if Full-Speed on OSX, also set feedback EP size to 3
-#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION 0
+#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION 1
// Audio format type I specifications
#if defined(__RX__)
diff --git a/examples/device/uac2_speaker_fb/src/usb_descriptors.c b/examples/device/uac2_speaker_fb/src/usb_descriptors.c
index fa307674d..5d84024ea 100644
--- a/examples/device/uac2_speaker_fb/src/usb_descriptors.c
+++ b/examples/device/uac2_speaker_fb/src/usb_descriptors.c
@@ -150,7 +150,7 @@ uint8_t const desc_configuration[] =
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, byte per sample, bit per sample, EP Out, EP size, EP feedback, feedback EP size,
- TUD_AUDIO_SPEAKER_STEREO_FB_DESCRIPTOR(0, 4, CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX, CFG_TUD_AUDIO_FUNC_1_RESOLUTION_RX, EPNUM_AUDIO_OUT, CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX, EPNUM_AUDIO_FB | 0x80, 4),
+ TUD_AUDIO_SPEAKER_STEREO_FB_DESCRIPTOR(0, 4, CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX, CFG_TUD_AUDIO_FUNC_1_RESOLUTION_RX, EPNUM_AUDIO_OUT, CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX, EPNUM_AUDIO_FB | 0x80, 3),
#if CFG_AUDIO_DEBUG
// Interface number, string index, protocol, report descriptor len, EP In address, size & polling interval
There are some dependencies needs install:
|
Last commit optimized debug interface fifo count, it's not the real count inside UAC class but a replication, it was less accurate. |
Describe the PR
Finally I had time to integrate my feedback work into UAC2 class :)
Compared to other methods the only thing needed is add a callback to set sample rate, all calculations are done inside the class.
A new example
uac2_speaker_fb
has been added to show how the mechanism work with a stereo speaker. Both FS (STM32F429) and HS (LPC55S69) configs are tested and FIFO level is well maintained half filled.A HID debug interface can be enabled by setting
CFG_AUDIO_DEBUG=1
which export UAC class information and can be read byaudio_debug.py
.