-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Choppy transmit audio when using Dire Wolf on macOS #13
Comments
Seems like my $10 RTLSDR dongle + SDRAngel is doing significantly better than my AIOC + Baofeng + Direwolf at decoding packets, so I'm also suspicious there's something going wrong with the input audio also. But I'm not sure how to debug this. |
Odd! Do you happen to know, that the message "PTT is on ... too long" is supposed to mean? For now I cannot make sense of those lines. Regarding the choppy audio: Have you programmed the firmware file v1.0.0 from the GitHub release page or do you have one of the beta devices I sent out a while ago? If the latter, can you try updating the firmware to v1.0.0. I remember there being some issues very similar to choppy audio that I also noticed (although only on very few of my AIOCs). |
I'm not sure what it's supposed to mean. But I suspect what's happening is that the audio is slow to output (and thus sounds choppy), making the whole packet take too long, and that's why this error is firing. I'm running on firmware SHA I ordered my boards from jlcpcb on 1/2, so I was probably on commit |
FWIW, I ran into this same issue on MacOS, switched over to Ubuntu, and didn't have the issue. Same AIOC, same firmware (1.0.0), so I doubt the issue is the AIOC itself. More likely a driver or library issue. |
@lysol thanks for the note. Setting up a arm64 Ubuntu VM in UTM.app and running Direwolf there worked just fine. Took a beat to find the right device names but after that it's been flawlessly. I needed:
It's a little clunkier perhaps then running natively on macOS since you have to configure/start a VM, but it worked flawlessly. So this bug could be in |
There shouldn't be any difference. It may be possible that it could be related to your build environment being different, but that is just a long shot. Though confirming that the problem is present with the exact binary that I built could be somewhat helpful in narrowing down the problem. Gotta find a macOS machine first though.
Thanks! Helps to know that the problem is not isolated but general. Do you both have M1/M2 Macs by any chance (since you mention arm64 Ubuntu VM). Maybe it could be related? Although I doubt it. I found this page in the mean time:
Yeah, also a good idea! EDIT: Can you try setting direwolf |
I have activated However can you test this firmware just to check if this is the issue? |
I'm having the same issue with choppy transmit on macOS, and I just tried this firmware and it doesn't seem to help. Reducing the sample rate doesn't help either. One new data point: I'm on an x86-64 mac, not an ARM mac, so that's not the issue at least. I'm happy to try out any changes you think of. I'll be poking around too, although I don't have much hope since I'm unfamiliar with the systems. |
Thanks a bunch for checking the firmware. I assume the regular 1.1.1 firmware has the same issue right? That's probably the one you tried before. Did you work with direwolf? Can you confirm that the issue is actually the AIOC? Do you have another USB soundcard laying around? Is the stuttering in play and/or recording? Can you use some kind of recording software and just try to record something using the AIOC soundcard? I am wondering what the issue is. I need to get my hands on a MacOS or maybe try to run it in a libvirt VM under Linux... One thing you could try is recording a wireshark dump of the usb transactions from plugging it in to playing something. But it's kind of advanced unfortunately. |
I was using 1.1.0 -- I can upgrade to 1.1.1 and try that, if you think it might make a difference. Yeah, I was using direwolf. I've used direwolf with a digirig before with no issues. Recording from the AIOC in Audacity appears to work just fine, and I'm decoding packets in direwolf. I don't have an easy way to test playback right now, but I'll dig out an oscilloscope and see what I can do later. I'll also try this in linux, just to confirm that this is macOS only and not some problem with my board in particular. It's only for convenience that I tested it on my mac laptop first! I've used wireshark before, though not for USB. If I can work out how to do that, I'll post the dump here. Unfortunately I don't know enough about USB for a dump to be any use to me. |
The difference between 1.1.0 and 1.1.1 is minor, that should not be it. The AIOC uses USB Audio Class 2.0, its pretty recent and very common with higher performance external sound units (studio class devices). It's only available since USB 2.0 (although the AIOC is a Full-Speed device and not High-Speed but that should not be important). I looked around again and found interesting articles like this one. (they refer to USB2.0 but it could very well mean USB Audio Class 2, since USB1.1 devices, i.e. fullspeed only can only use USB Audio Class 1, which is fine). Since the problem only seems to be in combination with direwolf. Here someone is reporting the issue where changing the audio library (that the application uses) was changed from SDL to PortAudio. No idea what direwolf uses, but could be a lead also. What MacOS version do you (all) have? Apparently the problems started with Big Sur (macOS 11.3) If you can get USB capturing with Wireshark to work, you can just send me the pcap file. But at least on Linux you need to load a kernel module for that, not sure if it's even possible on mac. EDIT: It might be worth opening an issue with direwolf. Seeing if other people with higher performance USB 2.0 audio interfaces on macOS have the same issue as we have with the AIOC. |
I'm on macOS Monterey (12.4). On macs, direwolf uses portaudio. I'm using the version of direwolf 1.6 provided by macports, should that become relevant. For my reference, here's a list of things I'll try soon:
If this ends up being a direwolf issue, I'll be sure to open one over there. I'd be a little bit surprised -- lots of things use PortAudio, and I feel like somebody would have noticed. But macs surface bugs like nobody's business. |
Yeah, let me know how it turns out. I am not sure where the issue exactly is with MacOS, is it USB2.0 or is it the use of UAC2 (USB Audio Class 2)? Most direwolf users very probably don't have a UAC2 soundcard (CM108 is UAC1). UAC2 is mostly used on multi-channel studio grade stuff. I think it's a combination of UAC2 and maybe the library that direwolf uses (if it turns out, that other applications don't have this issue). If the problem is USB2.0, I can make a firmware where the device enumerates as a USB1.1 device. However, UAC2 with USB1.1 is somewhat out of spec, so it may not work at all. But maybe this way we can narrow down how a workaround for macOS could look like. EDIT: Can you maybe also try using a lower samplerate such as 24000 or 12000? |
I can confirm, it works absolutely fine on linux. Changing the sample rate in direwolf doesn't help. I've hooked up my scope today. I see the choppy in/out in Chrome and VLC as well as direwolf. I've attached a picture of my scope when playing a 440 Hz sine wave -- it looks like it'll play about 60ms and then nothing for 80ms or so. VLC was much more intermittent. It also holds the last value for a while, before resetting to 0. (It's also noisy, but I think that's just how it is). I left the sine wave running for a while, and eventually it became continuous and worked fine. Other applications then worked fine as well! I can't reproduce it at all, however. It's possible I was plugging in other USB things and somehow that kicked macOS into behaving, I don't know. Right now, it looks like the problem isn't direwolf. Something about the AIOC is confusing macOS. |
A few more data points, though none is enlightening:
|
Thanks for all the details... Very odd if I might say. Where did you measure those signals? At the TRS connector output (i.e. after or before the DC blocking cap?). From the voltage level I assume its after. Yeah, last thing I can think of is maybe a USB dump. Other than that I am currently at a loss. I am also not aware how many MacOS AIOC users are out there, that don't have any issues? Is this just a random issue or is it systematic? |
I measured at the TRS connector. I'll look in to a USB dump. I wish I had another mac around to test with. I might just be very unlucky with a hardware/OS combination. |
Just a note to say I'm happy to try things if someone could write up a test sequence. I have access to a M1 Max on macOS 13, and M1 Air on macOS 12, and an older Intel Mac, probably on macOS 12. I've only tested so far on the macOS M1 Max. |
Hello! I got distracted there for a few months, but I installed wireshark today and convinced it to capture USB traffic. Here's a dump of me connecting the AIOC, starting direwolf, and then "transmitting" a position beacon once. Then I close direwolf and disconnect the AIOC. As far as I know, nothing else is happening on this bus at the time. As before, audio in seems to work fine but audio out seems to stutter and break apart into pieces with empty space in between, causing the whole thing to take longer to play than it should. It looks like the AIOC is device 20.8.*, but beyond that I don't know enough about USB to really get a handle on this dump. Hopefully it might mean something to you! Getting these dumps is pretty easy, so if there's anything else you'd like me to record, I'd be happy to. |
Thanks a lot, I will have a look in the next days and see if there is something obvious. |
I just want to add a +1 to this issue still being there. |
Seeing choppy audio as well on MacOS. Any sample rate seems to reproduce the problem. Direwolf log:
Mac in question:
|
I'm also seeing the same. Direwolf 1.7, M3 Max 2023, Sonoma 14.5.
|
I updated to aioc-fw-fb10-14.bin.zip Both the restore firmware and upgrade failed with
|
The kernel have plenty of options about the usb device, you can see them if you have a Mac with:
it looks like this when failure happens:
|
@lha I believe the version of the firmware you flashed was before the DFU programming stuff was added. On those earlier firmwares, you need to short the outer pins on the programming header to enter DFU mode, as described in the initial programming section of the README. Thanks for posting the log -- I don't know exactly what to make of the details, but it looks like MacOS is occasionally running in to a communication error with the AIOC and completely resetting the audio device, which is causing the issue. It's still not clear whether the communication error is MacOS misbehaving or the AIOC. Edit: a brief search seems to indicate that a USB 'babble' error means the device is sending more bytes during a transaction than the host is asking for, and usually indicates a bug in the device itself (although sometimes it's a bug in the driver.) |
Yep, exactly. Probably shouldn't use the old firmware from above anyway
I also tried to briefly look for the babble error.. Does the error only occur, once Direwolf starts transmitting? (Sound output is active) Or is it also, when Direwolf is just listening? (Sound input is active). EDIT: If the issue is confirmed to be only during transmission (audio output), then the following could be a possible culprit. It's related to the transmission of the feedback value (from AIOC to PC) so the PC knows how fast the AIOC is outputting the audio (i.e. samplerate).
(USB2.0 Spec 5.12.4.2) We are currently sending the 16.16 format always (despite being a full speed device). I can make a test firmware to test explicit 10.14 feedback value with exactly 3 bytes as required by the spec to see if this is indeed the issue. |
Update: Pulling this into here, from the reply I got in the issue hathach/tinyusb#1234 hathach/tinyusb#2328 (comment) |
As I remember it, the issue is only when playing audio out of the AIOC. Audio input works fine. If I get the time I'll double-check, but it sounds like this lines up with this expected issue. Excellent find! I'm still reading, but it sounds like it's possible to make the endpoint work on MacOS or Windows, but not both, is that correct? If so, how much code change would be needed to lock the MacOS behavior behind an |
Recving audio (reading from the host seed) works fine, it the transmit that is causing issue, I have similar issues on linux btw |
It's impossible for this to be related to this issue. The Linux kernel driver doesn't care about this particular issue with the feedback endpoint. To be honest you are the first person with Linux issues, what distro are you using? Pipewire or pulseaudio? It's probably best if you open a separate issue |
It could be possible. In that case I would like to get the linked pull request in tiny USB merged and update my submodule reference to tinyusb. Then we can also use their new feedback mechanism and the MacOS/Rest Switch. |
It looks like the PR hathach/tinyusb#2328 was merged. It also looks like they might try some OS detection to work around this bug, although it might be fragile. |
Yeah, interesting. I have to check deeper on how well the OS detection works and how he solves the issue with altering the configuration Descriptor (after it has possibly been sent to the host already?). I am planning a AIOC firmware session in my holidays end of September for doing all the changes, updating tinyusb and finally getting the settings interface to work on Windows. |
File #84 about is. Using Ubuntu server, I'll try lower power and switch to use a jpole further away and slap on some torrids on the usb cable. |
Took me a while to figure out the pull request hathach/tinyusb#2328 but in the end it was not a lot to implement. Here is a test firmware that should now theoretically work on Windows, Linux and MacOS. From what I can tell, Linux seems to be working fine. Can everyone test this thing under Linux, Windows and especially MacOS? |
I found the time today to find my AIOC and flash it, and I can verify that the new firmware works just great on MacOS 12.7.5. Before testing, I verified that the old firmware still exhibits the same buggy behavior, and flashing the new firmware immediately fixed it. I also tested it out on an old Debian bullseye install I had around and it worked fine there as well. Unfortunately I can't easily test on windows -- somebody else will have to give it a go. Thank you so much for your help on this! This ended up being quite a rabbit hole. I have an AIOC now that I can use with my normal laptop! |
Thanks a bunch for testing. Yeah, was a wild ride after we got some details on what the problem is and stumbling upon the issue in the tinyusb repo. Have fun 😁 |
I have tested the
Audio works as previous under Linux (sometimes it sounds like sigle input samples are lost, could be a PipeWire problem or my radio though) On MacOS it does work I do not hear any dropped samples. Perhaps this is a me problem. On both systems I get huge QRM +35dB from N0 on 2m when the AOIC is active streaming audio. The QRM is measured with a TinySA some meters away. I have also measured it with the 1.2.0 firmware. Perhaps I burned one of my pins. I will test this with a friends AIOC. |
Running Dire Wolf 7d3c1d1 on macOS 13.1 with AIOC c65a3f3, most transmitted packets are choppy. A clear error is thrown in Dire Wolf when this happens
Transmit timing error: PTT is on 3558 mSec too long.
:And sure enough the radio output looks (and sounds) weird and choppy:
Possible this is a Dire Wolf bug but I don't get this same thing when using my built-in soundcard. My relevant Dire Wolf config is:
The text was updated successfully, but these errors were encountered: