respeaker / usb_4_mic_array

ReSpeaker 4 Mic Array with builtin VAD, DOA, AEC, Beamforming & NS
https://www.seeedstudio.com/ReSpeaker-Mic-Array-v2.0-p-3053.html
Apache License 2.0
137 stars 64 forks source link

Add simple volume control for jack #39

Open flatsiedatsie opened 4 years ago

flatsiedatsie commented 4 years ago

I support a number of addons for the Mozilla WebThings Gateway, a user friendly open source smart home controller.

I'm trying to use this USB ReSpeaker v2 with the addons, but I'm running into an issue: I can't change the volume for the headphone jack in the ways I normally would.

When I run amixer -c 1 scontrols there is no output. Unlike my other USB sound cards, this ReSpeaker USB doesn't seem to have any 'simple' control options to change the volume.

So following this forum post I found this example page, which lead me to believe that changing the volume required a complex control. The device seems to have three of those:

amixer -c 1 contents gives:

numid=3,iface=CARD,name='Keep Interface'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=2,iface=PCM,name='Capture Channel Map'
  ; type=INTEGER,access=r----R--,values=6,min=0,max=36,step=0
  : values=3,4,7,8,9,10
  | container
    | chmap-fixed=FL,FR,FC,LFE,SL,SR

numid=1,iface=PCM,name='Playback Channel Map'
  ; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
  : values=0,0
  | container
    | chmap-fixed=FL,FR

However, after impementing this more complex way of changing the volume, it didnt work.

amixer -c 1 cset numid=1 13,13 should change the volume, but it results in an error:

amixer: Control hw:1 element write error: Operation not permitted

Sudo doesn't help either. It seems these basic controls are read-only.

From what I've learnt, one way around is to install Pulse Audio. But the system I'm using (the Mozilla WebThings Gateway) doesn't support this, and addons are not allowed to install new software either. So I cannot install Pulse Audio. Similarly, addons are also not allowed to change or create an asound.conf file either.

Would it be possible to implement (simple) volume control in ALSA? Other ReSpeaker hardware seems to support this (I also have a ReSpeaker Pi Hat), so it would be great if this USB device could do the same.

soominjung commented 3 years ago

I also think it would be really helpful if it was possible to control the volume with ALSA...