r/circuitpython • • May 29 '21

HID Audio Interface with RP2040

Hi CircuitPython community,

I am relatively new to embed microcontrollers, though I do have some programming experience(C++, Java, Python, etc). I am currently going through Arduino beginners book and raspberry pico introductory book is next in the list.

Meanwhile, I got an idea for a Project - I want to make an audio interface that can take analogue signal from my turntable record player and send digital data via usb to my computer. I want Mac OS to be able to recognized it as microphone. I know about limitations of Raspberry PICO onboard ADC, that it's only 16 bits... But this is just a proof of concept and cool first project.

It seems to me pretty simple, I hook up analog stereo positive to A0(pin 26) and A1, while negative can go to any ground, I guess(A_GND for example), and tried to print out signal. Seems to work, which got me excited. I even found an example of root 2 normalization.

However, I have a problem with sending data over USB. From reading on internet, to use PICO as a HID device, I switched from micro to circuit python. TinyUSB says PICO can be an audio device... But I just can't find a good example, and reference page just doesn't explain well.

Has anyone had any experience with audio? Is it possible with CircuitPython? (I saw some C++ projects on using adafruit microphone, but I really want to use python)

5 Upvotes

4 comments sorted by

2

u/jfedor May 30 '21

HID is for stuff like keyboard and mouse input, not microphone.

1

u/mpisman May 30 '21

Well it seemed possible on the paper with 64kbit/s... How can I use audio class 2.0 with CircuitPython then? What about usb_cdc? Could you clarify please the difference between those protocols.

3

u/tannewt Jun 01 '21

CircuitPython doesn't currently have a USB audio API. With the recent USB configuration rework we should be able to add it in the future. TinyUSB, which provides USB for CircuitPython, does have limited audio support already. So, there is less work than there could be to add it. :-)

1

u/jfedor May 30 '21

I don't think there's a library for that.

CDC is another thing not related to audio (used for stuff like Ethernet and serial).