amixer controls won't get anything on my development board - linux

I am trying to set volume on the minilinux system with amixer controls in development board,but it won't get anything.
~ # amixer
~ #
~ # amixer controls
~ #
I have tried to create a plugin by create this file in "/etc/asound.conf"as this How_to_use_softvol_to_control_the_master_volumesaid ,by type in this
pcm.softvol {
type softvol
slave {
pcm "hw:0,0"
}
control {
name "softctl"
card 0
}
}
but when testing it ,give me this error:
/etc # speaker-test -D softvol -c 2 &
/etc #
speaker-test 1.1.5
Playback device is softvol
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM softvol
Playback open error: -2,No such file or directory
when I changed the asound.conf to something like this:
pcm.softvol {
type hw
card 0
device 0
}
then exac " speaker-test -D softvol -c 2 & " the headphone have that pink noise.
This is really weird that I can play and record excpet control the volume. New to this,no idea what to do next.

Related

.asoundrc ALSA configuration for webcam

I'm an ALSA beginner in the process of setting up my .asoundrc to record audio from my webcam.
Here is what I did to determine that my hardware is actually working:
I'm able to output sound using the following basic .asoundrc
defaults.pcm.!card Generic
defaults.pcm.!device 0
defaults.pcm.!ctl Generic
And I successfully recorded a test from my webcam with the following command
arecord --device=hw:0,0 --duration=5 --format=S16_LE /tmp/test.wav
Then, using a rudimentary knowledge of ALSA configuration, I wrote the following .asoundrc
pcm.!default {
type asym
playback.pcm {
type hw
card Generic
device 0
}
capture.pcm {
type hw
card 0
device 0
}
}
However, this results in no sound output or recording functionality. Please help me understand why this is not working.
output of aplay -l
output of arecord -l

Storing parameters in .asoundrc does not apply

I have a microphone and I can record voice like so:
arecord test.wav -r 22050 -f S32_LE -V mono
So far so good. However, when a third party software that I'm using (which I think uses ffmpeg internally), wants to use the microphone it fails, since it does not use the above described parameters.
I tried now to move those parameters into my .asoundrc so that they will be picked up by alsa.
The Alsa Wiki tells me that the plug plugin can be used in order to specify the rate and the format:
A more complex tool for conversion is the pcm type plug. the syntax
is:
type plug # Format adjusted PCM
slave STR # Slave name (see pcm_slave)
# or
slave { # Slave definition
pcm STR # Slave PCM name
# or
pcm { } # Slave PCM definition
[format STR] # Slave format (default nearest) or "unchanged"
[channels INT] # Slave channels (default nearest) or "unchanged"
[rate INT] # Slave rate (default nearest) or "unchanged"
}
route_policy STR # route policy for automatic ttable generation
# STR can be 'default', 'average', 'copy', 'duplicate'
# average: result is average of input channels
# copy: only first channels are copied to destination
# duplicate: duplicate first set of channels
# default: copy policy, except for mono capture - sum
ttable { # Transfer table (bidimensional compound of
# cchannels * schannels numbers)
CCHANNEL {
SCHANNEL REAL # route value (0.0 ... 1.0)
}
}
So I setup a plugin like so:
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "softvol"
}
capture.pcm {
type plug
slave {
pcm "plughw:0" # this works
rate 22050 # does not apply
format S32_LE # does not apply
}
}
}
The pcm "plughw:0" gets picked up however, the rate and the format fall back to 8 Bit and 8000Hz. Also I have to specify -V Mono so that I can record:
arecord test.wav -V mono
Recording WAVE 'test.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
############+ |
So unfortunately none of the required parameters can be added to my settings.
Update
I tried to record using ffmpeg in an attempt to mimic what :
ffmpeg -f alsa -ac 1 -i plughw:0 output.wav -ar 22050 -f S32_LE
The recording starts but no audio is recorded and the rate and format are mixed up again:
aplay output2.wav
Playing WAVE 'output2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
Update with asym plugin
I did try an asymmetric approach as suggested.
pcm.my_mic {
type hw
card 0
channels 1
format S32_LE
}
pcm.duplex {
type asym
playback.pcm "dmixer"
capture.pcm "my_mic"
}
pcm.!default {
type plug
slave.pcm "duplex"
}
However, when I enter arecord test.wav I'm asked for the format despite the fact that it's configured in the .asoundrc.
When I do enter a format I get the following error:
arecord -f S32_LE
Recording WAVE 'stdin' : Signed 32 bit Little Endian, Rate 8000 Hz, Mono
ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable
arecord: set_params:1270: Broken configuration for this PCM: no configurations available.
Update
With some ALSA magic by my friend Y.W. I was able to get arecord to work without parameters, however, it's still somehow using inferior settings when recording audio by default.
The key here it seems was to map the mono signal of my I2s card to a stereo signal.
This is the .asoundrc content:
# This section makes a reference to your I2S hardware, adjust the card name
# to what is shown in arecord -l after card x: before the name in []
# You may have to adjust channel count also but stick with default first
pcm.dmic_hw {
type hw
card raspisound
channels 2
format S32_LE
rate 48000
}
# This is the software volume control, it links to the hardware above and after
# saving the .asoundrc file you can type alsamixer, press F6 to select
# your I2S mic then F4 to set the recording volume and arrow up and down to adjust the volume
# After adjusting the volume - go for 50 percent at first, you can do something like
# arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v myfile.wav
pcm.dmic_sv {
type softvol
slave.pcm dmic_hw
control {
name "Boost Capture Volume"
card raspisound
}
min_dB -3.0
max_dB 30.0
}
# This plugin converts the mono input to stereo.
pcm.mono2stereo {
type route
slave.pcm dmic_sv
slave.channels 2
# ttable.input_channel.output_channel volume_gain
ttable.0.0 1
ttable.0.1 1
}
# The "plug" plugin converts channels, rate and format on request.
# In our case it converts the 32 format to whatever the application request.
pcm.convert {
type plug
slave {
pcm mono2stereo
}
}
pcm.convertplayback {
type plug
slave {
pcm "hw:0"
}
}
# Default capture and playback devices
pcm.!default {
type asym
capture.pcm convert
playback.pcm convertplayback
}
By specifying the slave PCM device as plughw:0, you have created a chain of two plug plugins. This means that the application can use whatever sample format it pleases, the upper plugin will convert it to 22 kHz with 32 bits, and the lower plugin will convert it to any format the hardware supports.
To force the hardware to use the specified format, use it directly as slave, with hw:0.
You cannot prevent programs like arecord from using a different format; that is the whole purpose of the plug plugin. To check what format is actually used by the hardware, add the -v parameter to the arecord call.

How to set default microphone on Raspberry Pi 3B with Raspbian Stretch?

So far I have not found any guides on how to set the default USB microphone for Stretch and so I've followed all of the guides for Wheezy and Jessie and they do not work.
Typing in the command arecord sound.wav does not record anything from the microphone. However, if I were to type in this command it would work arecord -f cd -D hw:1,0 -d 10 sound.wav.
Here is what appears when I enter in arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Headset [Plantronics Headset], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
I've edited this file /usr/share/alsa/alsa.conf and set the values to this
defaults.ctl.card 1
defaults.pcm.card 1
I've also edited the /etc/asoundrc file and changed it to this:
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "hw:0,0"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
}
ctl.!default {
type hw
card 0
}
and this:
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
and it still does not work.
I've been having headaches with this one for about a day, but I finally made it work.
Your .asoundrc should actually look like this:
pcm.!default {
type asym
playback.pcm "plughw:0"
capture.pcm "plughw:1"
}
ctl.!default {
type hw
card 1
}
Otherwise your settings are ok, but I think this command is wrong:
arecord sound.wav
The proper command for testing the mic (or at least the one that works for me) is this:
arecord -D plughw:1,0 --duration=3 test.wav && aplay test.wav
This is setup for a 3 seconds recording and after recording stops it automatically plays back to you (assuming your audio also works).
This part plughw:1,0 points to your mic, which I see is set to card 1.
I you have created this file /etc/modprobe.d/alsa-base.conf during your tests please delete it and reboot your pi.
sudo rm -f /etc/modprobe.d/alsa-base.conf
Also if you have tried this for the AlexaPi project, make sure the service is stopped before you try your mic and audio.
sudo systemctl stop AlexaPi.service

raspberry pi / aplay / default sound card

I purchased a the "Sound Blaster Play! 2" soundcard for my raspberry pi 3. The OS is raspbian jessie.
The audio on my raspberry pi works when I run
$ aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=S2
But only when I use -D. When I use
$ aplay /usr/share/sounds/alsa/Front_Center.wav
it shows:
aplay: set_params:1239: Channels count non available
I need this for node-speaker.
Here is the output of the ALSA Information script: http://www.alsa-project.org/db/?f=bdefa248fdedb34929d492e65ea941f2af40dcb2
OK, I found the solution..
My new ~/.asoundrc:
pcm.!default {
type plug
slave {
pcm "hw:0,0"
}
}
ctl.!default {
type hw
card 0
}
instead of
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
does the magic :)

alsa on embedded system CORE9G25

I have a CORE9G25-CON (256MBRAM) (http://armdevs.com/core9g25.html) device with embedded linux installed on it.
The version of linux is:
# uname -or
3.6.9 GNU/Linux
# cat /etc/os-release
NAME=Buildroot
VERSION=2012.11.1-dirty
ID=buildroot
VERSION_ID=2012.11.1
PRETTY_NAME="Buildroot 2012.11.1
The device is equipped with USB host connector in which I connected an USB-AUDIO interface
The USB interface is recognize by the system
# cat /proc/asound/cards
0 [Device ]: USB-Audio - USB PnP Sound Device
C-Media Electronics Inc. USB PnP Sound Device at usb-at91-1, full speed
# cat /proc/asound/devices
0: [ 0] : control
16: [ 0- 0]: digital audio playback
24: [ 0- 0]: digital audio capture
33: : timer
# ls /dev/snd
controlC0 pcmC0D0c pcmC0D0p timer
I would like to handle the AUDIO interface by using ALSA but this is the error shown on the console by using the simple command aplay -l
# aplay -l
**** List of PLAYBACK Hardware Devices ****
ALSA lib control.c:739:(snd_ctl_open_noupdate) Invalid CTL hw:0
aplay: device_list:226: control open (0): No such file or directory
aplay: conf.c:3095: snd_config_update_free: Assertion `update->count > 0 && update->finfo' failed.
Aborted
I googled for about a week trying to fix the problem but, up to now, i didn't find any solution.
Could you help me to fix the problem ?
Had you other similar experience about it ?
Thank you very much for your help and cooperation
best regards
What does your alsa.conf look like ? do this
locate alsa.conf
typically found at
/usr/share/alsa/alsa.conf
do a google on
audio sound alsa Invalid CTL hw:0
this might get you on the right path
#alsa.conf minimal configuration
ctl.hw {
#args [ CARD ]
#args.CARD {
type string
}
type hw
card $CARD #with 0 alsamixer work, with $CARD alsamixer lend to invalid argument
}

Resources