USB Audio 2.0: Device to host volume control

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
osch
Member
Posts: 12
Joined: Sun Sep 03, 2017 10:12 pm

USB Audio 2.0: Device to host volume control

Postby osch » Fri Apr 20, 2018 12:24 pm

Hi! I am working on a custom board used for USB audio(reference design 6.15.2).
I want to be able to use the device to control Windows volume using absolute values. I have gotten it to work the other way around with the "OUTPUT_VOLUME_CONTROL" and that works great, but now i want to control it the other way like i said.

Currently i have just tried to hack up something over HID that does a number of increments/decrements based on what volume is chosen on the device,
but this doesnt work too great in all situations, so i would like to be able to send absolute volume levels to the host somehow. We are using USB audio class 2.0 on the custom device.

Does anyone have experience doing this(Or know if it is even possible)? Any help would be appreciated.
User avatar
infiniteimprobability
XCore Legend
Posts: 1120
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Mon Apr 23, 2018 2:25 pm

The answer will probably be in the depths of the UAC2 spec but *I think* that what you are asking is not supported. Everything is host-centric and so the host is not expecting or checking the volume for device side changes.
Sure, you could close the loop using HID.. That would make sense.
Possibly implement an interrupt endpoint to notify the host of a change?

Can you describe what you mean by absolute volume? You mean a multipiler (if so what format?) or a dB?
osch
Member
Posts: 12
Joined: Sun Sep 03, 2017 10:12 pm

Postby osch » Tue Apr 24, 2018 11:15 am

infiniteimprobability wrote:The answer will probably be in the depths of the UAC2 spec but *I think* that what you are asking is not supported. Everything is host-centric and so the host is not expecting or checking the volume for device side changes.
Sure, you could close the loop using HID.. That would make sense.
Possibly implement an interrupt endpoint to notify the host of a change?

Can you describe what you mean by absolute volume? You mean a multipiler (if so what format?) or a dB?
I have been looking more into endpoints and usb communications but i found it hard to start with.
Our product has a volume range of 0-100 "%" totally independent of xmos. Xmos just sends raw data via i2s and we do all the volume control further down the line. What i mean by absolute volume is that i want windows to be able to read this volume over USB somehow and adjust the slider in windows (which also shows 0-100) so that the volume on the product and in windows would be the same. I have already modified the Volume range that the xmos communicates with windows so i get the 0-100 values when adjusting the windows slider, but now i am trying to get it to work the other way around.

We had to adjust the MIN and MAX volume in devicedefines.h like this to get the volume from windows to "show up" as the correct values when moving the slider on Windows/Mac.
#ifndef MIN_VOLUME
#define MIN_VOLUME (0x0000)
#endif
#ifndef MAX_VOLUME
#define MAX_VOLUME (0x0064)
#endif

When experimenting with the HID-loop i found that i can probably get it to work like that, so i wont need to send absolute values, it just is a bit more fiddly.
tilde
Member++
Posts: 17
Joined: Fri Nov 07, 2014 9:03 am

Postby tilde » Thu Apr 18, 2019 2:24 pm

Control USB Audio Class microphone volume/mute by external buttons

Hello,

In USB Audio Class tutorial for xCore-200 MC Audio board, the speaker volume, mute are controllable by Hw buttons(HID device),
but, I can not find controllable values in HID (Consumer)device specification for microphone.

So I would like to control Microphone volume, mute by hw buttons, and has these params synchronized by Windows configuration, too.

Are there any way to control the microphone volume/mute/agc params from HID by HW buttons, or another way?

Writing own windows driver for HID, is not a usable way for me.

From previous part of topic, I get an info, than requests from usb audio class device are not handled by usb host, so I cant send request by USB audio class to host.
But I found that code part in USB Audio tutorial(audiorequests.xc). What is it for?

Code: Select all

case FU_VOLUME_CONTROL:

                            if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D)
                            {
                               ......
                            }
                            else /* Direction: Device-to-host */
                            {
                                if(unitID == FU_USBOUT)
                                {
                                    if ((sp.wValue & 0xff) <= NUM_USB_CHAN_OUT)
                                    {
                                        buffer[0] = volsOut[ sp.wValue&0xff ];
                                        buffer[1] = volsOut[ sp.wValue&0xff ] >> 8;
                                        return XUD_DoGetRequest(ep0_out, ep0_in, buffer, 2,  sp.wLength);
                                    }
                                }
                                else
                                {
                                    if ((sp.wValue & 0xff) <= NUM_USB_CHAN_IN)
                                    {
                                        buffer[0] = volsIn[ sp.wValue&0xff ];
                                        buffer[1] = volsIn[ sp.wValue&0xff ] >> 8;
                                        return XUD_DoGetRequest(ep0_out, ep0_in, buffer, 2,  sp.wLength);
                                    }
                                }
                            }
                            break; /* FU_VOLUME_CONTROL */
With kind regards
Tilde
User avatar
Wavelength
Member++
Posts: 21
Joined: Mon Sep 24, 2018 9:56 pm

Postby Wavelength » Thu May 23, 2019 5:14 pm

I have done this in the past as follows:
Enable an HID with parameters to do volume up, down, mute, track control etc.
When someone hits say a key on your device you send the HID report which then comes down and changes the volume and everyone is happy.
~~~
I do remember the Apple USB Audio goddess reminding me there was another way, so I just looked it up. Not sure if Windows or Linux supports this:
Status Interrupts

A status interrupt pipe can be used to inform the host that a setting has changed on the device. This feedback maintains synchronization between the Mac’s user interface and the device state. Currently, AppleUSBAudio updates certain audio controls on the Mac for interrupts originating from Feature, Selector and Clock units as described in Table 6.

Table 6 Types of status interrupts that AppleUSBAudio supports and example device and Mac behavio

Feature unit Volume and mute: User turns volume knob->Volume is updated in AMS and Sound Preferences UI
~~~

I have never done this so I would not know if it works in all OS's.

If you want my HID setup, that was done on the TAS1020 decade ago but I could look it up and post it here if you are interested.

Thanks,
Gordon
Wavelength Audio, ltd.
tilde
Member++
Posts: 17
Joined: Fri Nov 07, 2014 9:03 am

Postby tilde » Fri May 31, 2019 9:28 am

Thanks for repply,

"Enable an HID with parameters to do volume up, down, mute, track control etc."

I checked the whole documentation for HID, and I cant found support for microfon volume up/down or mute. I have found support only for speaker parameters, which I has been implemented allready. So I think it is not supported by Windows. Correct me if I m wrong.

Anyway we closed this issue currently. So we controlling usb Mic only from Windows, and we can signalise the state of mic mute and mic volume params by our usb device LEDs(it is available from Audio Class device).
With kind regards
Tilde

Who is online

Users browsing this forum: No registered users and 0 guests