0
votes

I'd like to have program which would record from PC audio card's microphone. The main idea is to prevent clipping (cut of amplitude):

  • set optimal gain (e.x. -6db)
  • when gain is over optimal, set microphone volume to be the optimal or just lower volume a bit.

I've tried to look for some free already made solution, but I didn't find any. (Maybe I'm just searching wrong words).

If there is nothing already made, I'd like to program something myself, but If i somebody willing to give me the first impulse I'd be happy.

For that I need:

  • get actual gain of input
  • control input volume (basically I could use some command line utility amixer, pactl, ...)
  • save data to file

I wonder if I could use gstreamer (it could be something else). The best language should be python (3.x).

If there is another better solution, I'd be happy :-)

Thanks everyone :D

1

1 Answers

0
votes

Sox is a useful utility. Record a sample file, ask sox to advise how much the level can be boosted without clipping, then do the main recording.

> sox mytest.wav -n stat
Samples read:            532480
Length (seconds):      5.546667
Scaled by:         2147483647.0
Maximum amplitude:     0.375702
Minimum amplitude:    -0.277344
Midline amplitude:     0.049179
...
Rough   frequency:          845
Volume adjustment:        2.662

Caution is advisable since Pulseaudio may try to adjust the volume for you?