Apply EQ to audio in and monitor audio out? - audio

I am trying to make it possible to take the microphone input, have the input be filtered by the ALSA EQ plugin (or any other controllable EQ), and hear the live filtered output through headphones. I am using a RPI on Raspbain Buster. How might I accomplish this?

You can use the ALSA equal plugin to have a equaliser on by default.
First you have to install the plugin :
sudo apt-get install libasound2-plugin-equal
Then you should setup your asoundrc to set it to the default route, save the following to ~/.asoundrc :
#hooks [
{
func load
files [
"~/.asoundrc"
]
errors false
}
]
pcm.!default {
type plug
slave.pcm plugequal;
}
ctl.equal {
type equal
}
pcm.plugequal {
type equal
slave.pcm "plughw:ALSA,0"
}
pcm.equal {
type plug
slave.pcm plugequal
}
Finally you can alter the eq like so :
alsamixer -D equal
You can listen to the sound while you are adjusting the EQ by playing audio at the sample time :
aplay audioFile.wav
Now if you want to route your microphone to the output through the equaliser, then you probably want to pipe arecord to aplay like so :
arecord -Dplughw:mic -f cd | aplay
NOTE: Change "plughw:mic" above to the actual microphone you are using.
For example if I use my Audio Injector stereo or Ultra soundcard (which both have electret microphones on board) then I would setup their mixers to caputre using the onboard mirophones using alsamixer
alsamixer -Dhw:0
Then I would replace plughw:mic with plughw:0 as they are always the 0 card on my system.
arecord -Dplughw:0 -f cd | aplay

Related

How do I get amixer PCM numid=3 to work on Raspberry Pi 4?

I have a Raspberry Pi 4 with speakers connected to the 3.5mm jack. I have no HDMI connected, but I have the standard 7 inch monitor connected. It runs raspbian.
Edit: I found out that this was normal behaviour due to an OS update, se my comment below.
If I run amixer cset numid=3 1 I get the error amixer: Cannot find the given element from control default.
If I run amixer contents there are no numid=3, I only get:
numid=2,iface=MIXER,name='Headphone Playback Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=1,iface=MIXER,name='Headphone Playback Volume'
; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0
: values=0
| dBscale-min=-102.39dB,step=0.01dB,mute=1
So PCM playback route with numid=3 is missing, and 1+2 say Headphone instead of PCM, that is the normal as far as I can tell from the interweb.
I can still play things with aplay and omxplayer (I'm not sure if it is mono or stereo).
But some other things fails, which I thought might be because of this. If I run espeak, and similar with pyttsx3 in python, I get screens full of errors, a few of the lines are:
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
Cannot connect to server socket err = No such file or directory
jack server is not running or cannot be started
And that is what I actually would want to get to work.
If that is caused by the first error I don't know. But when I search for rPi sound problems, the cset-numid=3 "solution" seems to appear everywhere, and I can't use that...
Edit: So that turns out not to be the reason, the espeak problem is still there even if I revert to the old way with options in boot.txt.
I needed three days to find out how to use it on Raspberry Pi. I created an Shell Command. When you want to use Audio via 3.5mm Jack just write. You can let the HDMI Cable connected.
sudo bash -c 'echo -e " defaults.pcm.card 1 \ndefaults.ctl.card 1" > /etc/asound.conf'
if you want to use the HDMI Audio output just change the number 1 to 0.
sudo bash -c 'echo -e " defaults.pcm.card 0 \ndefaults.ctl.card 0" > /etc/asound.conf'

Piping output from aplay to arecord in centos

I am trying to automate some tests for a websocket client. This client connects to a server on command and the server is basically a speech to text engine. The client supports audio streaming from a microphone, such that people can record themselves in real time and transmitting it to the engine. I am running the client in a centos VM which does not have a physical sound card so I decided to simulate one using
modprobe snd-dummy
My plan is to pipe the output of
aplay audioFile.raw
to the input of
arecord test.raw -r 8000 -t raw
so that I can use that simulate the microphone feature. I read online that the file plugin for ALSA can pipe the results of one command to the next so I made the following modifications to the .asoundrc file in my root directory:
pcm.!default {
type hw
card 0
}
pcm.Ted {
type file
slave mySlave
file "| arecord test.raw -r 8000 -t raw"
}
pcm_slave.mySlave {
pcm "hw:0,0"
}
ctl.!default {
type hw
card 0
}
When I try the following command:
aplay audioFile.raw -D Ted
It seems to run fine but the output of test.raw seems to contain only silence... Does anyone know what I am doing wrong, I am very new to ALSA so if anyone can point me in the right direction, it would be greatly appreciated. Thanks!
Issue Fixed, instead of using snd-dummy I used snd-aloop and audio correctly pipes refer to this question:
Is it possible to arecord output from dummy card?

Record video in background with mencoder

I have an USB tv stick Sundtek MediaTV Pro III which has an analog input.
with the following command, recording works perfectly.
mencoder tv:// -tv driver=v4l2:width=720:height=576:outfmt=uyvy:device=/dev/video0:input=1:fps=25:adevice=/dev/dsp0:audiorate=48000:amode=1:forceaudio:immediatemode=0 -ffourcc DX50 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:turbo:vbitrate=1200:keyint=15 -oac mp3lame -noskip -o video1.avi
The only problem I have is, that I can hear the sound while recording.
This is kind of annoying because I want to be able to watch a move (a file, not with the usb stick), while I am recoding the analog tv stream.
How can I record without hearing the sound?
Try this:
/opt/bin/mediaclient -c external -d /dev/video0
this is telling the driver not to play back audio via the speaker

ffmpeg get all sound devices(input/output)

I have downloaded the static build of ffmpeg for Windows and am trying to get all my sound devices (input/output) I have googled and found this command to retrieve audio devices , but when I use it ffmpeg arecord -l, it shows this error
Unrecognized option 'l'.
Error splitting the argument list: Option not found
what am missing here?
arecord is the command-line sound recorder and player for the ALSA soundcard driver which is available on Linux.
On Windows you can list the dshow devices with:
ffmpeg -list_devices true -f dshow -i dummy
See the Windows section of https://trac.ffmpeg.org/wiki/Capture/Desktop

Confusion in aplay Command.

Here i want to understand this commmand.
aplay -D hw:0,0 /opt/WL1271_demo_01/gallery/Pop.wav
Why we used asound.conf file.
we have to need update bluetooth address of hands free device in this file to play audio in handsfree device?
Can anybody Explain me aplay command and how its works?
why we used here -D hw:0,0 in this?
why we not used here -Dplug:bluetooth hw:0,0 ?
==================================================================
Here is my /etc/asound.conf file
pcm.!bluetooth {
type bluetooth
device 00:23:78:41:AB:9F
playback_ports {
0 alsa_pcm:playback_1
1 alsa_pcm:playback_2
}
capture_ports {
0 alsa_pcm:capture_1
1 alsa_pcm:capture_2
}
}
pcm.!default {
type plug
slave.pcm bluetooth
}
pcm.jack {
type jack
playback_ports {
0 alsa_pcm:playback_1
1 alsa_pcm:playback_2
}
capture_ports {
0 alsa_pcm:capture_1
1 alsa_pcm:capture_2
}
}
You are pointing aplay directly to some piece of hardware (hw:0,1 – second output of the first sound device) instead of letting it use your asound.conf definition. Try this instead:
aplay -D bluetooth -c 2 -f S16_LE abc.wav
Please note, that if you are using the ALSA interface this way anything else using that device (e.g. the Pulse Audio daemon) make this not work. You could probably use Pulse Audio instead of 'raw' ALSA, but I cannot help with that.
Update:
why we used here -D hw:0,0 in this?
How can we know? You provided the command. This means: use directly (this means: ignoring the aliases in asound.conf file) the first output of the first audio hardware (this usually means the output of your primary sound card).
why we not used here -Dplug:bluetooth hw:0,0 ?
Because the '-D' option accepts a single parameter. This can be 'hw:0,0', this can be 'plug:bluetooth', this can be any alias defined in the asound.conf file (like 'jack' or 'bluetooth' defined in your file), but it must be one parameter. 'plug:bluetooth hw:0,0' would be two parameters.
Why we used asound.conf file.
Not to have to provide a specific device address directly to each command. You may set the default in asound.conf and omit the '-D something' option all toghether
To provide more sophisticated configuration for the audio output
http://www.alsa-project.org/main/index.php/Asoundrc#The_naming_of_PCM_devices
Looks like you have a problem with your pulse audio setup. Here is a manual for ubuntu to troubleshoot bluetooth setups including aplay. Here is the manual for bluetooth setup for ubuntu.
From your configuration I see that you are missing the device name, namely "aplay -D default hw:0,1 -c 2 -f S16_LE abc.wav &". For my headset I have used an example here, and it works for me so far.

Resources