greatscottgadgets / python-usb-protocol

python library providing utilities, data structures, constants, parsers, and tools for working with USB data
BSD 3-Clause "New" or "Revised" License
55 stars 32 forks source link

Implement useable subset of USB Audio Class 2.0 #13

Closed hansfbaier closed 3 years ago

hansfbaier commented 3 years ago

This implements enough of USB Audio Class 2.0 for a real world audio interface. It also contains a small part of UAC3 (which I will probably not use/extend). I am not sure if the UAC3 part should be included, but I reckon it might not hurt to have it there in case someone might want to implement it and save that bit of effort. I tried to factor out common parts (shared between UAC1, 2 and 3) into its own file.

hansfbaier commented 3 years ago

This likely needs more work. I'll close this request and open another one if I have a working example luna device.

ktemkin commented 3 years ago

This does look awesome so far -- looking forward to reviewing this when you submit it. :)

hansfbaier commented 3 years ago

@ktemkin Thanks! When running an example I still get read descriptor errors, and I have no idea whats wrong and how to go about that.

ktemkin commented 3 years ago

When running an example with your custom descriptors? Out of curiosity, what's the total configuration descriptor length?

If it's greater than e.g. 64B, you might be running into this: https://github.com/greatscottgadgets/luna/issues/86

hansfbaier commented 3 years ago

@ktemkin Yes it is definitely bigger than that (172 Bytes IIRC), many thanks for the info. Will look into that issue.

hansfbaier commented 3 years ago

@ktemkin Yes the ticket mentioned above is a blocker to USB Audio, since UAC descriptors for a minimal real world interface (2 out 1 in, no MIDI) are already quite large (over 100 bytes). I'll reopen this pull request in case you feel like taking it on. Since my ability to test the code is blocked by the mentioned issue, the code still might need amendment. (And surely I still will need to implement MIDI streaming, which is totally missing, but I want to get audio working before that).

hansfbaier commented 3 years ago

Here is an example using the UAC2 descriptors: https://github.com/hansfbaier/luna/blob/uac2/examples/usb/usb2_audio.py

hansfbaier commented 3 years ago

I am currently adding MIDI support.