1.1?????? USB Audio Adapter GPIO - Linux
?
The tricky part is that the single physical USB adapter shows up as separate audio and HID (human interaction) devices.?? Dire Wolf includes a utility application, called cm108, to help you make sense of it all.?
?
This is some of what we see for a single USB Audio Adapter:
?
?
?
VID is Vendor ID.?? 0d8c is C-Media.
PID is Product ID.? This is not a good way to distinguish different chips because it is often programmable.
?
A single USB audio adapter shows up as multiple sound devices:
?
¡¤???????? pcmC1D0c?????????? Card 1, Device 0, ¡°c¡± for capture (i.e. input)
¡¤???????? pcmC1D0p????????? Card 1, Device 0, ¡°p¡± for playback (i.e. output)
¡¤???????? controlC1???????????? Card 1, volume control, etc.
?
The first ADEVICE column has what you would normally use for ADEVICE in the configuration file.? The ¡°1¡± and ¡°0¡± correspond to the ¡°card¡± and ¡°device¡±.?? ¡°Device¡± is an unfortunate term because it has too many different meanings.? But that is the terminology used by ALSA.
?
Ignore the second ADEVICE column for now.? We will get back to it later.
?
Finally HID is the corresponding GPIO device in the same chip.? There is not a simple relationship between the names.? The same USB audio adapter is Sound Card 1 and HID 3.
?
In this case, your direwolf configuration file would contain:
?
ADEVICE plughw:1,0
CHANNEL 0
PTT cm108
?
When direwolf is started up, important configuration settings are displayed as a help in troubleshooting.
?
?
It automatically figures out which HID corresponds to the soundcard.? You could optionally override the automatic mapping but you would probably end up ¡°shooting yourself in the foot¡± as we will see later.? All of the products and homebrew projects, that I have seen, all use GPIO 3 so that is the default if you don¡¯t specify a different GPIO bit number.
?
Now let¡¯s add two more USB audio adapters.
?

?
?
Put this in our configuration file to use 3 radios:
?
ADEVICE plughw:1,0
CHANNEL 0
PTT cm108
?
ADEVICE1 plughw:3,0
CHANNEL 2
PTT cm108
?
ADEVICE2 plughw:2,0
CHANNEL 4
PTT cm108
?
Once again, it automatically matches up the soundcard number with the corresponding HID.
?

?
?
Note that the third USB Audio Adapter does not have a C-Media chip so attempts to use the GPIO pins will probably fail.? I can¡¯t test it to find out.? I pried one of the adapters open and the chip was buried under a blob so there were no pins to probe.
?
?
Next, we will unplug this keyboard and mouse then reboot.?? We don¡¯t need them because I¡¯m logging in with ssh over the network.
?
?
?
What happened?
?
The soundcards are listed in the same order, but the numbers have changed.
?
¡¤???????? The soundcard numbers are now 1, 2, 3 rather than 1, 3, 2.
¡¤???????? The HID numbers are now 0, 1, 2 rather than 3, 5, 4.
?
That¡¯s why you should not specify explicit HID numbers.?? They change when you add or remove USB devices and reboot.? Let direwolf figure out the relationship.
?
The soundcard numbers have also changed.? Suppose you had
?
¡¤???????? plughw:3,0 connected to the radio for the APRS frequency.?
¡¤???????? plughw:2,0 connected to the radio for the Packet BBS frequency.
?
After rebooting they have been reversed!
?
Don¡¯t despair because there is an easy solution.
?
I¡¯ve only been showing you part of the cm108 utility results.? Here is the rest of it
?

?
Follow the instructions.? Copy/paste the last section into /etc/udev/rules.d/85-my-usb-audio.rules then reboot
?
We can now turn our attention to the second ADEVICE column.
?

?
?
I can now put this in my configuration file, using a name rather than a number which can change.
?
ADEVICE plughw:Fred,0
?
?
The same technique could be used to assign names based on the VID/PID but that would not help with multiple identical adapters.
?
Names can be assigned based on serial numbers but these adapters don¡¯t have serial numbers.
?
So, we are left with assigning names based on the physical USB socket on the computer.
?
The keyboard will be plugged in again, and the second USB Audio Adapter (PID 000c) removed.? After rebooting again, we see:
?
?
?
Once again, the numbers hav shifted around but the name remains associated with the same USB Audio Adapter.?? Or more accurately, the USB socket that it is plugged into.
?
So for our final experiment, swap the two USB Audio Adapters.? We don¡¯t even need to reboot.? We see that the name is associated with the USB socket on the Raspberry Pi, not what is plugged into it.
?
?
?
?
?
?
?
?
?
1.2?????? USB Audio Adapter GPIO - Windows
?
You might find it helpful to read the preceding Linux section first, to compare how these are different.
?
All of this magic is performed by the ¡°udev¡± device manager on Linux.? The Windows equivalent is drastically different so an entirely new implementation needs to be created.?
?
At the current time, I know how to get a list of the HIDs and set the GPIO pins but so far have not been able to figure out how to find the relationship between HID and sound devices in the same package.
?
I would really like to provide the same completeness and convenience as on Linux, but so far I have not been able to figure out how to do it.?? (Hint, hint, to any Windows programming experts.)
?
Reluctantly I¡¯m providing a half-baked implementation.? It should be fine for those using a single USB Audio Adapter but would be real annoying when trying to use multiple adapters.
?
First, let¡¯s consider the case of a single USB Audio Adapter.?
?
Your configuration file could contain this:
?
ADEVICE USB
CHANNEL 0
PTT cm108
?
There is only a single USB audio device so it all works well.
?
?
Things get more complicated when there are multiple USB Audio Adapters.
?
?
?
?
The good news is that the paths are still there after a reboot.?
?
?
?
When you have more than one USB Audio device, there is no automatic linking of the sound device with the gpio HID for PTT.?? You must explicitly specify the desired PTT HID like this:
PTT cm108? ¡°°À°À?°À³ó¾±»å#±¹¾±»å³å0»å8³¦&²¹³¾±è;±è¾±»å³å000³¦&²¹³¾±è;³¾¾±³å03#8&²¹³¾±è;2±ð»å³¦3781&²¹³¾±è;0&²¹³¾±è;0000#µ÷4»å1±ð55²ú2-´Ú16´Ú-11³¦´Ú-88³¦²ú-001111000030°¨¡±
?