Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Sep 2002 11:01:11 -0700
From:      Tim Pozar <pozar@lns.com>
To:        Baldur Gislason <baldur@foo.is>
Cc:        multimedia@FreeBSD.ORG
Subject:   Re: Recording 16 bit samples
Message-ID:  <20020916110111.A65614@lns.com>
In-Reply-To: <20020914195234.094E227A0@tesla.foo.is>; from baldur@foo.is on Sat, Sep 14, 2002 at 07:51:59PM %2B0000
References:  <20020914195234.094E227A0@tesla.foo.is>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 14, 2002 at 07:51:59PM +0000, Baldur Gislason wrote:
> I'm having trouble recording 16 bit samples with sox in FreeBSD, the 
> recordings skip and do other weird stuff. I've tried this with 4 different 
> sound cards, and with both the pcm and the old snd kernel drivers. Anyone 
> else having the same problem?

I have actually had pretty good luck with an "archiving" box I built
for an outdoor music fest I was working on.  I used FreeBSD 4.6
with 4Front's sound drivers.  The case was a small foot print, about
2" heigh by 8" wide and 12" deep.  I stuck a 160GB drive in it.  It
also had on-board sound (Yamaha YMF724F) with two PCI/ISA slots
that I populated with an ESS Allegro (ESS1998) card (PCI) and a
Creative SB AWE64 (ISA) card.  This gave me three sources that I
could record from.

The first source was the sound board mix, the second source was
two-way traffic and the third was a second stage feed.  We actually
had 4 stages at this event.

To archive I used a quick little perl script (see below) to open
the /dev/dsp port with another program I wrote (catdsp - available
at: http://www.lns.com/papers/catdsp) that opens /dev/dsp and sets
the right modes and bit rates and then starts to shove data to
STDOUT.  EsounD has a simular program called "esdrec".

What was nice about the size of the computer and perl script was I
could just bury the computer under the sound board and not touch
it for the 4 days of the event.  The show went from Thursday at
noon until Monday (Labor Day) at noon.  For a 44.1KHz 16bit stereo
file it would be about a 61GB file.  I put a signal handler in the
script so if I sent it a "kill HUP" it would close the current file
and reopen a new file without dropping any data.  A couple of times
a day I did this.

The down side was monitoring levels.  Fortunately, we had some soft
limiting via a Manley limiter just before the sound cards so I just
needed to set the levels at the start of the show and forget it.
But to QC the audio, I did write another perl script that would
tail the raw PCM file, MP3 encode it via LAME and then send it to
an icecast relay (also running on this box) so I could listen to
the audio with about a 15 second delay.

I did end up with a problem with ground loops between the two-way
audio and the program feeds.  I had to drop the two-way archiving
as conneting to it created a hum about -20dB.  Next fest, I will
be looking at putting in cards that can support S/PIDF and balanced
audio.

Hope this helps and gives you some ideas on what you can do.

Tim
--
#!/usr/bin/perl

$bufsize = 176400; # 176400 = 1 second at 44.1KHz stereo 16 bit word

$SIG{'HUP'} = \&sig_hup;
$SIG{'INT'} = \&sig_int;

# $device = "dspW0";            # Yamaha YMF724F
$device = "dspW8";              # ESS Allegro (ESS1998)
# $device = "dspW10";   # Creative SB AWE64
$devdevice = "/dev/" . $device;

$bitrate = 44100;

# Year/Month/Day/Hour/Minute/Second...
$date =`date "+%Y%m%d%H%M%S"`;
chop $date;

open(DSP, "catdsp -d $devdevice -r $bitrate |");
# To do a wave file...
# open(AUDIOFILE, "| sox -t raw -r $bitrate -s -w -c 2 - $date.$device.wav");
# To do a raw PCM file...
open(AUDIOFILE, "> /usr/local/hog/archive/program.$date.$device.raw");

while(1) {
        $readresult = read(DSP, $buffer, $bufsize);
        print AUDIOFILE "$buffer";
        $readresult = 0;
}

sub sig_hup {       # 1st argument is signal name
        $olddate = $date;
        $date=`date`; chop($date);
        my($sig) = @_;
        print "$date: Caught a SIG$sig\n";
        close(AUDIOFILE);
        $date =`date "+%Y%m%d%H%M%S"`;
        chop $date;
        print "Closing $olddate.raw and opening $date.raw\n";
        open(AUDIOFILE, "> /usr/local/hog/archive/progam.$date.$device.raw");
        return;
}
 
sub sig_int {       # 1st argument is signal name
        $date=`date`; chop($date);
        my($sig) = @_;
        print "$date: Caught a SIG$sig\n";
        close(AUDIOFILE);
        exit;
}

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020916110111.A65614>