You are not logged in.
Kay so I live in an older apartment where my AC bombards my eardrums every ten minutes. My stereo master slider on my mixer is my best friend for overcoming this inaudible catastrophe! Men, I need you to help me link my microphone to my audio output gain so one of my arms doesn't get very strong compared to the other. I've been working out my other arm on a daily basis, but it's coming to the degree where I can't walk in a straight line. To prevent the repetitive volume increases and decreases and keep me from walking in circles, is there some software I can use to auto-adjust the gain from my machine?
Offline
It seems you need what is called an audio compressor, there are several ladspa plugins for that, but i think you need to be more specific.
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline
I am actually running my mpd server into a hardware compressor atm since my mixer makes that really easy to do. But I want it to monitor the ambient noise of the room via a microphone, and when it notices a consistant increased db input, it'll turn the audio outputs' gains up ![]()
Offline
Ok,
Looked simple, but fun, so I did it. Where you go
#!/bin/bash
MAX=20.0
MULT=1.0
TIME=5
function volume(){
arecord -f S16_LE -r44100 -d $TIME 2>/dev/null|sox -t wav - -t raw /dev/null \
stats 2>&1 |awk '/RMS lev dB/ {print $NF}'
}
level=$(volume)
while true; do
new_level=$(volume)
diff=$(echo $new_level - $level|bc -l)
level=$new_level
adjust=$(echo "
v=$diff*$MULT;
if (v < $MAX && v > $MAX*-1){
if (v > 0) {
print v,\"%+\"
} else {
print -v,\"%-\"
}
} else {
print \"0%+\"
}"|bc -l)
echo $diff,$adjust
amixer set Master -i $adjust >/dev/null
doneIts use arecord and sox to calculate the noise and bc to do some math (because bash is dumb =[). Some parameters MAX is the maximum absolute adjustment that can be made, MULT is a multiplicative factor applicated to the difference of dB measured, and TIME is how much seconds to record in each pass.
TIME can be used to adjuste the reaction time, a small value (like 1) react nearly instantaneous but a bigger value like 6 give some margin for rapid pops in the noise and only adjust if the noise difference existed in much part of TIME window.
When I use pulseaudio MULT=1 works ok, but with alsa I need MULT=5.
About pulseaudio, I started using it this week, and I really think that using pulse audio you have a lot more clear/cool/functional solution, but I need to explore it...
I dont know much about sound theory, so I dont know if I choose the best 'volume' description, but you can look at sox man pages and look for something more adequate (look for stats and stat).
PS. I hate bash... zsh is so much better (but, python is better than all) I only used bash because, uhhh I dont know the reason... masochism?
Last edited by kazuo (2010-05-31 10:31:07)
Offline
Nice!
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline
That is so awesome! I am recording a show right now so I can't mess with the gains atm, but I'm going to try it tomorrow afternoon!
Offline
1. Switch off AC.
2. Open windows. (Glass ones!)
No more ear bombardment.
Fresh air.
Planet (slightly) saved.
Offline
1. Switch off AC.
2. Open windows. (Glass ones!)No more ear bombardment.
Fresh air.
Planet (slightly) saved.
I live in Atlanta and today is the first of June ... ![]()
Offline