[LAD] audio recording through pipe using mplayer and sox sometimes has incorrect speed

Paul Davis paul at linuxaudiosystems.com
Thu Apr 9 12:53:39 UTC 2009


On Thu, Apr 9, 2009 at 8:24 AM, Arnold Obdeijn <arnold.obdeijn at gmail.com> wrote:
> Hi all,
>
> I am using mplayer, sox and tee to capture streaming internet radio
> and send it both to an audio recognition program and to a file
> (recording).
> This is how I do it:
>
> mplayer -playlist {url}  -nocache -af volnorm -msglevel all=1 -nolirc
> -vc dummy -vo null -ao pcm:file={$fifo1} &
>
> sox -S {$fifo1} -c 1 -r 8000 -t wav - resample | tee {$recording} |
> tee {$fifo2} & ......
>
> $fifo1 and $fifo2 are named pipes, $fifo2 is processed by an audio
> recognition program. The idea is that the audio is converted to low
> quality wav (8000Hz mono) after which it is fed to the program and
> simultaneously recorded.

Not that I want to suggest anything to massively off-topic, but I hope
you realize that this is a perfect example of the kind of scenario
that JACK was designed to handle.

Sharing streaming data between programs via pipes is not a great idea
- the buffer associated with a pipe is rather small, and scheduling
delays for the programs reading from the pipe can cause data loss etc.
This doesn't matter if both the writer to the pipe and the reader can
both run "as needed", but when one of them is connected to an i/o
source (eg. the network , or an audio interface) which doesn't buffer
very much and has real deadlines, the whole design is almost destined
to fail or at least be very fragile.



More information about the Linux-audio-dev mailing list