|
NAMErawrec - buffered raw audio recording/playingSYNOPSISrawrec [option]... [file]rawplay [option]... [file] DESCRIPTIONrawrec reads raw audio data from a digital signal processor (DSP) and writes it to the given file, or to standard output if no file is given.rawplay reads raw audio data from the given file, or from standard input if no file is given, and writes it to a DSP. The user of this program will almost certainly want some program to set the mixer device parameters for their sound card, rawrec/rawplay don't make any attempt to do so. OPTIONSThere are many options, but most users will probably only be interested in -t, -s, -f, -c, and possibly -v. Options may appear multiple times; those without arguments act as toggles, those with arguments have the values of their arguments overwritten by successive occurences. Any option requiring an argument may be given the special argument 'dflt', which restores the default behavior (causes rawrec/rawplay to behave exactly as if that option had not yet appeared on the command line at all). When options interact, the interaction is between the final values arrived at after all overwriting and toggling is finished. This arrangement allows full customization via alias or shell variable mechanisms without any sacrifice in flexibility.In the following discussion, unless otherwise noted, the term "sample" is taken to mean one full set of digitized bits_per_sample-bit values, one for each channel. For example, when recording stereo (2 channel) sound in a 16 bit format, one full sample is 32 bits long. SECS arguments can have fractional parts, all other numerical arguments need to be integral.
s16_le Signed 16 bit little endian.
s16_be Signed 16 bit big endian.
u16_le Unsigned 16 bit little endian.
u16_be Unsigned 16 bit big endian.
s8 Signed eight bit.
u8 Unsigned eight bit.
Not all format are supported by all sound cards. The default is s16_le.
USING RAWREC/RAWPLAY TO OR FROM STANDARD IOrawrec/rawplay can be used effectively in pipelines to act as the sound card interface for a wide variety of other programs. However, unlike many classical command line utilities, rawrec and rawplay place soft real time demands on the programs they connect to. There is no way for rawrec/rawplay to ensure that these programs will behave well in this capacity, or perform consistently if the system is heavily loaded.SIGNAL HANDLINGrawrec and rawplay respond to most signals by aborting immediately. This means that anything that the command line invocation indicated should happen at the end of the run (silent padding with -e or -E, end pausing with -z or -Z) won't. The job control signal SIGTSTP (normally associated with terminal input Ctrl-Z) is ignored, as there is no reasonable way to handle it until Linux Threads become fully POSIX conformant with respect to signal handling. There can be a significant delay (like one second or more) between the time a process-terminating signal is delivered to a rawrec or rawplay process and the time that the threads spawned by that process finally die. This would only be irritating if it wasn't for the fact that the process in which the initial thread runs reports itself as having died immediatly, even though child threads are still happilly playing or recording away and hogging the dsp device. Special handling is in place for the SIGTERM and SIGINT signals which corrects this problem.RESOURCESrawrec/rawplay obviously needs access to a dsp device. It is best if the rawrec executable is installed setuid root; if it isn't, it can't lock down important parts of its memory space or modify the priority or scheduling policy of time critical threads, in other words, it can't provide any good gaurantee of decent performance if the system load is high or fluctuates. rawrec uses root authority only while doing the above things, and never uses strcpy at all.DIAGNOSTICSrawrec/rawplay will complain and die on a variety of resource errors. If the -v option is used, warnings will also be issued for a variety of non-fatal conditions of potential interest.If when playing the ring buffer used to move data between the argument file or stdio and the audio device becomes empty, the audio output may halt momentarily, but this is not considered a fatal error. rawrec always aborts immediately with a diagnostic if it finds that the ring buffer has become full. If you are trying to play data from standard input, and rawplay dies complaining about 'too many empty ring buffer segments', it means that the standard input didn't provide enough data fast enough for rawplay to play at the requested rate, sample resolution, and number of channels. This could for example happen if you try to run some really expensive (normal gunzip works fine) decompression algorithm as the input to rawplay, or if the system load got heavy and caused a normally affordable decompression algorithm to get slow (since the decompression probably isn't running at elevated priority). EXAMPLESThese examples assume that you have your mixer channels set up correctly (i.e. set up so that you can record from some live source and can audibly play back sampled streams).Record CD quality (44100 sample per second, 2 channel signed 16 bit little endian) audio into foo.raw until interrupted: rawrec foo.raw Record 100 seconds of half speed unsigned 8 bit mono data, and issue a warning if the sampling rate can't be set exactly as desired or some other unexpected thing happens: rawrec -t 100 -s 22050 -f u8 -c 1 -v bar.raw Play back the data just recorded, at a speed that will make us sound like maniacal chipmunks (the point here being that rawrec and rawplay deal in raw data, its up to the user to make it make sense): rawplay -s 44100 -f u8 -c 1 -v bar.raw Record some CD quality sound, then have the sox program pack it up as a .cdr file, ready for CD mastering with cdrecord or the like: rawrec -t 100 | sox -t sw -r 44100 -c 2 - -t cdr foobar.cdr Play back the .cdr file: sox -t cdr foobar.cdr -t sw -r 44100 -c 2 - | rawplay -t 100 SEE ALSOaumix(1), cdrecord(1), sox(1)COPYRIGHTrawrec/rawplay are Copyright (C) 2006 Britton Leo KerinThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. BUGSWhen playing, if the exact sample rate can't be set as desired, the rate may get adjusted up, possibly causing there to suddenly not be enough data in the data file to play for the length of time and with the jump requested, even if the math on the command line is correct. This is not really a bug so much as an unfortunate consequence of sound card inconsistency. The use of -v can help explain this behavior.The situation where the standard output of rawrec gets connected to the standard input of some really slow process has not been investigated properly. AUTHORBritton Leo Kerin (fsblk@aurora.alaska.edu)
Visit the GSP FreeBSD Man Page Interface. |