Tiny Core Base > TCB Q&A Forum
ALSA volume control with a DAC
squeezypeas:
I have a raspberry pi B+ board with an IQaudIODAC+ installed, to which I have added a rotary encoder to control the volume. I have compiled a c++ routine from the IQaudIO site that uses an API call that needs the device name for the volume control. Without the DAC the volume control is "PCM". Using alsamixer I can manipulate the volume by changing the values for the PCM control and the rotary encoder works as it should. However, with the DAC, the volume control should be "Digital". I can use alsamixer, select the IQaudioDAC card and manipulate the volume by changing the values for the Digital control. Compiling with "Digital" instead of "PCM" just gives an error:
Runs with error:IQ_rot: simple.c:282: snd_mixer_selem_get_playback_volume_range: Assertion `elem' failed.
This means ALSA cannot find the control called "Digital". The only control visible to ALSA is "PCM" but modifying this has no effect on the volume. I'm stumped and I'd be grateful for any suggestions.
squeezypeas:
I think the problem is that the onboard and DAC cards are both defined as default so the control name is only matched to the first. Either the cards need to be reordered or the explicit card name should be used in the code but the latter doesn't seem to work based on the names in /car/proc/asound/cards, i.e. IQaudIODAC.
bmarkus:
What is the /car directory?
gordon64:
Hi I hope you don't mind me jumping in, before I slink away as I don't have a RPi
I think OP means cat and he is probably looking to show the output to this command,
and suggest he also shows the aplay -l result please?
--- Code: ---cat /proc/asound/pcm
(my example)
00-00: ALC887-VD Analog : ALC887-VD Analog : playback 1 : capture 1
00-01: ALC887-VD Digital : ALC887-VD Digital : playback 1
00-02: ALC887-VD Alt Analog : ALC887-VD Alt Analog : capture 1
aplay -l
--- End code ---
squeezypeas:
You are indeed correct. My apologies for the confusion but I was in a bit of a nervous panic.
I had some help and have this working by removing "audio=on" from the config.txt file. The IQaudioDAC is now the only default and the "Digital" control name works. It is a workaround though as I'd like to modify the code to pass the card name and control name as command line parameters without having to remove that line from the config file. I'll also add gpio pins and volume increments as parameters as I imagine no two rotary encoders are alike.
To answer your question directly though.... Without removing "audio = on" I get:
tc@piCorePlayer:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: IQaudIODAC [IQaudIODAC], device 0: IQaudIO DAC HiFi pcm512x-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0
also...
tc@piCorePlayer:~$ cat /proc/asound/cards
0 [ALSA ]: bcm2835 - bcm2835 ALSA
bcm2835 ALSA
1 [IQaudIODAC ]: IQaudIODAC - IQaudIODAC
IQaudIODAC
tc@piCorePlayer:~$ cat /proc/asound/pcm
00-00: bcm2835 ALSA : bcm2835 ALSA : playback 8
00-01: bcm2835 ALSA : bcm2835 IEC958/HDMI : playback 1
01-00: IQaudIO DAC HiFi pcm512x-hifi-0 : : playback 1
The program is currently hardcoded with the card name as "default" (but both cards are marked as default), and the control name as "Digital". This doesn't work because I believe that the first "default" is used. Removing "audio=on" removes that card completely and the code works. I've also tried hard coding the card name as "IQaudIODAC" but that didn't work.
Thanks for your help.
Navigation
[0] Message Index
[#] Next page
Go to full version