Subject: Re: How to capture sound from an application?
To: Michael Core <520079546242-0001@t-online.de>
From: None <collver1@attbi.com>
List: netbsd-help
Date: 06/24/2002 12:41:19
On Mon, Jun 24, 2002 at 04:17:04PM +0200, Michael Core wrote:
> jtb@diantre.net (Julien Rampon) wrote:
> 
> Hi, 
> 
> > "Michael Core" <520079546242-0001@t-online.de> wrote:
> > > I want to capture the sound output from some applications and
> > > redirect it to a file. How can this be done?
> 
> > You can use sox (/usr/pkgsrc/audio/sox), like that :
> > sox -t ossdsp -c 2 -r 44100 -w -s /dev/dsp -t wav example.wav
> 
> Thanks for you help but it doesn't work.

I think you were given bad advice and I wouldn't expect it to work.

But finding a solution to this problem interests me.  If the application
generating audio comes with source code, it should be trivial to modify the
application to write to a normal file instead of a device file.

If you are using some proprietary application, then I only have ideas.  I
have tried using a named pipe, but that typically fails because it doesn't
provide the ioctl's an audio application expects.

One solution could be to use ktrace and write a script to parse the output.
The question is, can ktrace capture all of the data, or is it possible to
write a larger chunk of data than ktrace will log.

Another solution would be to write a device driver that provides the audio
ioctl's, but sends the data to a buffer instead of to a dsp.  A problem
could be reading the buffer frequently enough to ensure you have all the
data and don't run out of kernel memory.  Or maybe it could be done where
you set up some space in a file, and use a utility similar to vnconfig, to
have the kernel write the audio data to disk itself.  I haven't learned or
experimented with these ideas.

Let me know if you have other ideas.

Cheers,

Ben