我需要在linux中监听我的音频line-in,并且在播放音频的情况下,必须将声音记录并保存到文件中。熟悉如何motion监视视频源。监听音频线
是否有可能用bash做到这一点?
#!/bin/bash
# audio device
device=/dev/audio-line-in
# below this threshold audio will not be recorded.
noise_threshold=10
# folder where recordings are stored
storage_folder=~/recordings
# run indefenitly, until Ctrl-C is pressed
while true; do
# noise_level() represents a function to determine
# the noise level from device
if noise_level($device) > $noise_threshold; then
# stream from device to file, can be encoded to mp3 later.
cat $device > $storage_folder/$(date +%FT%T).raw
fi;
done;
编辑:沿东西线的流动,我想从这项计划中得到的是
a. when noise > threshold, start recording
b. stop recording when noise < threshold for 10 seconds
c. save recorded piece to separate file
以前从未听说过议案,不错 – 2010-04-10 11:38:08
'date'的默认输出中有空格。最好使用'$(date +%FT%T)',看起来像:“2010-04-10T08:55:56”,因此它是可排序的并且没有空格。 [ISO 8601](http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/date_and_time_format.htm)(和[here](http://en.wikipedia.org/wiki/ISO_8601)) – 2010-04-10 14:00:09
@ Dennis,thanx,改变了这一点。 – Stefan 2010-04-10 14:38:33