From owner-freebsd-multimedia Mon Sep 16 11: 1:21 2002 Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 62D4737B400 for ; Mon, 16 Sep 2002 11:01:18 -0700 (PDT) Received: from kumr.lns.com (kumr.lns.com [63.198.122.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 95E4B43E72 for ; Mon, 16 Sep 2002 11:01:17 -0700 (PDT) (envelope-from pozar@kumr.lns.com) Received: (from pozar@localhost) by kumr.lns.com (8.11.6/8.9.3) id g8GI1BZ68734; Mon, 16 Sep 2002 11:01:11 -0700 (PDT) (envelope-from pozar) Date: Mon, 16 Sep 2002 11:01:11 -0700 From: Tim Pozar To: Baldur Gislason Cc: multimedia@FreeBSD.ORG Subject: Re: Recording 16 bit samples Message-ID: <20020916110111.A65614@lns.com> References: <20020914195234.094E227A0@tesla.foo.is> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020914195234.094E227A0@tesla.foo.is>; from baldur@foo.is on Sat, Sep 14, 2002 at 07:51:59PM +0000 Sender: owner-freebsd-multimedia@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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