ref: 588d6473c6a822af95a4e288f6a66de4fe5c0082
parent: 0c5ec6b8a3ac24530f9e88e9a719e0726f946f5b
author: cbagwell <cbagwell>
date: Tue Dec 11 17:29:27 EST 2001
Updates to docs. Improvements to VOC routines.
--- a/Changelog
+++ b/Changelog
@@ -60,6 +60,10 @@
o Added uninstall rules to Makefile. Added new ststdint.h to define
*int*_t typedefs.
o Added internal strcasecmp for OS/2.
+ o Annonymous patch submitted to fix types and spelling problems in
+ various files. Also, updated VOC files to have u-law and A-law
+ support as well as able to read in VOC files using a pipe. More
+ examples added to soxexam file.
sox-12.17.2
-----------
--- a/INSTALL
+++ b/INSTALL
@@ -1,16 +1,16 @@
SoX: Sound eXchange Installation
-This distribution will compile and run on most Unix systems.
-It was originally developed on a Unix/386 machine running AT&T V.3.2
+This distribution will compile and run on most UNIX systems.
+It was originally developed on a UNIX/386 machine running AT&T V.3.2
but its currently developed under Linux. With little work it should
-work with most SVR4 systems, BSD-derived Unix's and DOS systems that
-use the GNU tool set.
+work with most SVR4 systems, BSD-derived UNIX's and DOS/Windows systems
+that use the GNU tool set.
Compiling
---------
-The prefered method for compiling sox is to use the "configure" scripts
-compatible with most unix systems that contain "/bin/sh" or equivalent
+The preferred method for compiling SoX is to use the "configure" scripts
+compatible with most UNIX systems that contain "/bin/sh" or equivalent
(even the Win95/NT Cygwin setup will work with this).
To compile SoX on these platforms run the following commands:
@@ -19,7 +19,7 @@
make
make install
-You should then have a working version of sox in the directory. There
+You should then have a working version of SoX in the directory. There
are several optional parameters that you may pass to the configure
script to customize SoX for your applications. Run "./configure --help"
for a complete list of options.
@@ -40,7 +40,7 @@
this file to reflect your environment.
After that, copy either Makefile.dos or Makefile.gcc to a file
-called Makefile. This needs to be done in both the main sox directory
+called Makefile. This needs to be done in both the main SoX directory
and the ./gsm directory. This file also needs to be modified to reflect
your environment.
@@ -52,14 +52,14 @@
If this library fails to compile on your system, you can specify
--disable-gsm to prevent it from being compiled in.
-SoX can make use of Ogg Vorbis librarys to play and record Ogg
+SoX can make use of Ogg Vorbis libraries to play and record Ogg
Vorbis files. If this library is installed in a non-standard location
in your system then you can use --with-ogg-vorbislib=path and
--with-ogg-vorbisinc=path to allow configure to find this library.
-If you're not processing lots of u-law or a-law files and would
+If you're not processing lots of u-law or A-law files and would
like to save around 64K of memory when SoX is executed then you
-can use runtime routines to perform u-law/a-law conversions.
+can use runtime routines to perform u-law/A-law conversions.
This is slower then the default lookup tables but results in the
same answers. To save this memory, specify --disable-fast-ulaw and
--disable-fast-alaw.
@@ -67,7 +67,7 @@
Testing
-------
-After successfully compiling SOX, try translating a sound file.
+After successfully compiling SoX, try translating a sound file.
If you can play one of the supported sound file formats,
translate 'monkey.voc' to your format (we'll use 'xxx'):
@@ -81,7 +81,7 @@
If monkey.xxx plays properly (it's a very short monkey screech),
congratulations! SoX works. Now you should run the "tests.sh"
-shell script if your running under a unix varient to exercise
+shell script if your running under a UNIX variant to exercise
various test scenarios. It should print nothing out. You can also
run tests.bat under DOS for similar tests.
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-SoX: Sound eXchange
+Sox: Sound eXchange
-------------------
SoX (also known as Sound eXchange) translates sound files between different
@@ -14,13 +14,13 @@
o Amiga 8svx files
o Apple/SGI AIFF files
o SUN .au style files
- o PCM, u-law, a-law
+ o PCM, u-law, A-law
o G7xx ADPCM files (read only)
o mutant DEC .au files
o NeXT .snd files
o AVR files
o CD-R (music CD format)
- o CVS and VMS files (continous variable slope)
+ o CVS and VMS files (continuous variable slope)
o GSM files.
o Macintosh HCOM files
o Amiga MAUD files
@@ -31,12 +31,12 @@
o Yamaha TX-16W sampler files.
o Sound Blaster .VOC files
o Microsoft .WAV files
- o PCM, u-law, a-law
+ o PCM, u-law, A-law
o MS ADPCM, IMA ADPCM
o GSM
o Psion (palmtop) A-law WVE files
- o Pseudo-file fomats that allow direct playing/recording
- from some audio devices under unix.
+ o Pseudo-file formats that allow direct playing/recording
+ from some audio devices under UNIX.
o Pseudo-nul file that reads and writes from/to nowhere
The sound effects include:
@@ -60,7 +60,7 @@
o Apply a phaser effect
o Convert from stereo to mono
o Change sampling rates using several different algorithms. A
- 'resample' and 'poyphase' effect use high-grade signal rate
+ 'resample' and 'polyphase' effect use high-grade signal rate
changes using real signal theory!
o Apply a reverb effect
o Reverse the sound samples (to search for Satanic messages ;-)
@@ -80,11 +80,11 @@
This is release 12.17.3 of SoX and its companion library Sound Tools.
SoX was originally written and maintained by Lance Norskog but is
-currently mantained by Chris Bagwell (cbagwell@users.sourceforge.net).
+currently maintained by Chris Bagwell (cbagwell@users.sourceforge.net).
Installing:
-Unless your using a precompiled binary version, you will need to compile
+Unless your using a pre-compiled binary version, you will need to compile
SoX as described in the INSTALL file. Please read that file for further
instructions.
@@ -94,7 +94,7 @@
another file format and how to apply sound effects.
SoX has an auto-detect feature that attempts to figure out
-the nature of an sound file. It does this by looking for 'magic values'
+the nature of a sound file. It does this by looking for 'magic values'
in the header of the audio file. If it is unable to detect the format
of the sound file then the user must use command line options to
inform SoX.
--- a/play.1
+++ b/play.1
@@ -1,4 +1,4 @@
-.TH NAME SECTION
+.TH play 1 "December 11, 2001"
.\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection
.\" other parms are allowed: see man(7), man(1)
.SH NAME
@@ -12,42 +12,44 @@
.B rec
.I "[fopts] outfile [effect]"
.SH "DESCRIPTION"
-This manual page documents briefly the
+This manual page briefly documents the
.B play and rec
-command.
+commands.
.PP
.B play
and
.B rec
-are programs that allows you to play and record different types of sound files. It is
-a frontend to the more general sox package. Normally the play command
-will detect the type and other parameters of the soundfile. If it can't do
+are programs that allow you to play and record different types of sound files
+from the command line. They are front ends to the more general
+.B sox(1)
+package. Normally, the play command will automatically detect the
+type and other parameters of the soundfile. If it can't do
so, the parameters can be changed through options.
.SH OPTIONS
A summary of common options are included below.
-For a complete description of options and thier values, see
+For a complete description of options and their values, see
the
.B sox(1)
man page.
.TP
.B \-c [channels], \-\-channels=[channels]
-Define the number of channels of the file.
+Define the number of channels in the file.
.TP
.B \-d [device], \-\-device=[device]
Specify a different device to play the sound file to.
.TP
.B \-f [format], \-\-format=[format]
-Specifies bit format of sample. One of s, u, U, A, a, or g.
+Specify bit format of the sample. One of s, u, U, A, a, or g.
.TP
.B \-r [rate], \-\-rate=[rate]
-Define the samplerate of the audio data.
+Specify the sample rate of the audio data (samples per second).
.TP
.B \-s [size], \-\-size=[size]
-interpret size of sample. One of b, w, l, f, d, or D.
+Specify the width of each sample. One of b, w, l, f, d, or D.
.TP
.B \-t [type], \-\-type=[type]
-Specifies audio file format to use. Useful if it can not be determined
-on its own.
+Specify audio file format to use. Useful if it can not be
+automatically determined.
.TP
.B \-v [volume], \-\-volume=[volume]
Change the audio volume
@@ -62,12 +64,17 @@
Show version of play/rec.
.TP
-Description of effects are described in the sox man page.
+Description of effects are described in the
+.B sox(1)
+man page.
.SH "SEE ALSO"
sox(1)
+ soxexam(1)
.SH AUTHOR
This manual page was written by Guenter Geiger <geiger@iem.mhsg.ac.at>,
-for the Debian GNU/Linux system.
+for the Debian GNU/Linux system.
+.P
+Updates by Anonymous.
--- a/sox.1
+++ b/sox.1
@@ -9,7 +9,7 @@
.if t .sp .5v
.if n .sp
..
-.TH SoX 1 "July 24, 2000"
+.TH SoX 1 "December 11, 2001"
.SH NAME
sox \- Sound eXchange : universal sound sample translator
.SH SYNOPSIS
@@ -156,7 +156,7 @@
contain a header that completely describe the characteristics of
the audio data that follows.
.P
-The second type are headerless data, or sometimes called raw data. A
+The second type are header-less data, or sometimes called raw data. A
user must pass enough information to
.I SoX
on the command line so that it knows what type of data it contains.
@@ -178,13 +178,13 @@
.P
Please refer to the
.B soxexam(1)
-manual page for a long description with examples on how to use sox with
+manual page for a long description with examples on how to use SoX with
various types of file formats.
.SH OPTIONS
The option syntax is a little grotty, but in essence:
.P
.br
- sox file.au file.wav
+ sox File.au file.wav
.P
.br
translates a sound file in SUN Sparc .AU format
@@ -207,12 +207,12 @@
.PP
\fBFormat options:\fR
.PP
-Format options effect the audio samples that they immediately preceed. If
+Format options effect the audio samples that they immediately precede. If
they are placed before the input file name then they effect the input
data. If they are placed before the output file name then they will
effect the output data. By taking advantage of this, you can override
a input file's corrupted header or produce an output file that is totally
-different style then the input file. It is also how sox is informed about
+different style then the input file. It is also how SoX is informed about
the format of raw input data.
.TP 10
\fB-t \fIfiletype\fR
@@ -227,11 +227,11 @@
If the input and output files have
different rates then a sample rate change effect must be ran. If a
sample rate changing effect is not specified then a default one will internally
-be ran by sox using its default parameters.
+be ran by SoX using its default parameters.
.TP 10
\fB-s/-u/-U/-A/-a/-i/-g/-f\fR
The sample data encoding is signed linear (2's complement),
-unsigned linear, U-law (logarithmic), A-law (logarithmic),
+unsigned linear, u-law (logarithmic), A-law (logarithmic),
ADPCM, IMA_ADPCM, GSM, or Floating-point.
.br
U-law (actually shorthand for mu-law) and A-law are the U.S. and
@@ -246,7 +246,7 @@
G.726, MS ADPCM, and IMA ADPCM. The \fB-a\fR flag has different meanings
in different file handlers. In \fB.wav\fR files it represents MS ADPCM
files, in all others it means G.726 ADPCM.
-IMA ADPCM is a specific form of adpcm compression, slightly simpler
+IMA ADPCM is a specific form of ADPCM compression, slightly simpler
and slightly lower fidelity than Microsoft's flavor of ADPCM.
IMA ADPCM is also called DVI ADPCM.
.br
@@ -288,7 +288,7 @@
.TP 10
\fB-p\fR
Run in preview mode and run fast. This will somewhat speed up
-sox when the output format has a different number of channels and
+SoX when the output format has a different number of channels and
a different rate than the input file. Currently, this defaults to
using the \fBrate\fR effect instead of the \fBresample\fR effect for sample
rate changes.
@@ -297,7 +297,7 @@
Change amplitude (floating point);
less than 1.0 decreases, greater than 1.0 increases. May use a negative
number to invert the phase of the audio data. It is interesting to note
-that we percieve volume
+that we perceive volume
logarithmically but this adjusts the amplitude linearly.
.br
Note: see the \fBstat\fR effect for information on finding the maximum
@@ -307,7 +307,7 @@
\fB-V\fR
Print a description of processing phases.
Useful for figuring out exactly how
-.I sox
+.I SoX
is mangling your sound samples.
.SH FILE TYPES
.I SoX
@@ -398,7 +398,7 @@
It is rather CPU intensive.
.br
GSM in
-.B sox
+.B SoX
is optional and requires access to an external GSM library. To see
if there is support for gsm run \fBsox -h\fR
and look for it under the list of supported file formats.
@@ -431,15 +431,15 @@
.B .ogg
Ogg Vorbis Compressed Audio.
.br
-Ogg Vorbis is a open, patent-free codec designed for compressing music
+Ogg Vorbis is a open, patent-free CODEC designed for compressing music
and streaming audio. It is similar to MP3, VQF, AAC, and other lossy
formats.
-.B sox
+.B SoX
can decode all types of Ogg Vorbis files, but can only encode at 128 kbps.
Decoding is somewhat CPU intensive and encoding is very CPU intensive.
.br
Ogg Vorbis in
-.B sox
+.B SoX
is optional and requires access to external Ogg Vorbis libraries. To
see if there is support for Ogg Vorbis run \fBsox -h\fR
and look for it under the list of supported file formats as "vorbis".
@@ -447,11 +447,11 @@
.B ossdsp
OSS /dev/dsp device driver
.br
-This is a pseudo-file type and can be optionally compiled into Sox. Run
+This is a pseudo-file type and can be optionally compiled into SoX. Run
.B sox -h
to see if you have support for this file type. When this driver is used
it allows you to open up the OSS /dev/dsp file and configure it to
-use the same data format as passed in to /fBSoX.
+use the same data format as passed in to \fBSoX\fR.
It works for both playing and recording sound samples. When playing sound
files it attempts to set up the OSS driver to use the same format as the
input file. It is suggested to always override the output values to use
@@ -469,9 +469,9 @@
SPHERE (SPeech HEader Resources) is a file format defined by NIST
(National Institute of Standards and Technology) and is used with
speech audio. SoX can read these files when they contain
-ulaw and PCM data. It will ignore any header information that
+u-law and PCM data. It will ignore any header information that
says the data is compressed using \fIshorten\fR compression and
-will treat the data as either ulaw or PCM. This will allow SoX
+will treat the data as either u-law or PCM. This will allow SoX
and the command line \fIshorten\fR program to be ran together using
pipes to uncompress the data and then pass the result to SoX for processing.
.TP 10
@@ -496,12 +496,12 @@
.B sunau
Sun /dev/audio device driver
.br
-This is a pseudo-file type and can be optionally compiled into Sox. Run
+This is a pseudo-file type and can be optionally compiled into SoX. Run
.B sox -h
to see if you have support for this file type. When this driver is used
it allows you to open up a Sun /dev/audio file and configure it to
use the same data type as passed in to
-.B Sox.
+.B SoX.
It works for both playing and recording sound samples. When playing sound
files it attempts to set up the audio driver to use the same format as the
input file. It is suggested to always override the output values to use
@@ -534,6 +534,8 @@
and sample data with a new sample rate is rejected.
Silence with a different sample rate is generated appropriately.
On output, silence is not detected, nor are impossible sample rates.
+Note, this version now supports playing VOC files with multiple
+blocks and supports playing files containing u-law and A-law samples.
.TP 10
.B vorbis
See
@@ -556,15 +558,15 @@
You had better know what you are doing! Output format
options will cause a format conversion, and the \fB.wav\fR
will written appropriately.
-Sox currently can read PCM, ULAW, ALAW, MS ADPCM, and IMA (or DVI) ADPCM.
+SoX currently can read PCM, ULAW, ALAW, MS ADPCM, and IMA (or DVI) ADPCM.
It can write all of these formats including
.B (NEW!)
the ADPCM encoding.
.TP 10
.B .wve
-Psion 8-bit alaw
+Psion 8-bit A-law
.br
-These are 8-bit a-law 8khz sound files used on the
+These are 8-bit A-law 8khz sound files used on the
Psion palmtop portable computer.
.TP 10
.B .raw
@@ -580,7 +582,7 @@
a shorthand for raw files with a given size and encoding.
Thus, \fBub, sb, uw, sw, ul\fR and \fBsl\fR
correspond to "unsigned byte", "signed byte",
-"unsigned word", "signed word", "ulaw" (byte), "alaw" (byte),
+"unsigned word", "signed word", "u-law" (byte), "A-law" (byte),
and "signed long".
The sample rate defaults to 8000 hz if not explicitly set,
and the number of channels (as always) defaults to 1.
@@ -675,7 +677,7 @@
delay/decay/speed/depth gives the delay in milliseconds
and the decay (relative to gain-in) with a modulation
speed in Hz using depth in milliseconds.
-The modulation is either sinodial (-s) or triangular
+The modulation is either sinusoidal (-s) or triangular
(-t). Gain-out is the volume of the output.
.TP
compand \fIattack1,decay1\fR[,\fIattack2,decay2\fR...]
@@ -699,7 +701,7 @@
latter may be overridden, but the former may not.
The third
-(optional) parameter is a postprocessing gain in dB which is applied
+(optional) parameter is a post-processing gain in dB which is applied
after the compression has taken place; the fourth (optional) parameter
is an initial volume to be assumed for each channel when the effect
starts. This permits the user to supply a nominal level initially, so
@@ -721,7 +723,7 @@
sampling rate.
.TP 10
dcshift \fIshift\fR [ \fIlimitergain\fR ]
-DC Shift the audio data, with basic linear amplitudate formula.
+DC Shift the audio data, with basic linear amplitude formula.
This is most useful if your audio data tends to not be centered around
a value of 0. Shifting it back will allow you to get the most volume
adjustments without clipping audio data.
@@ -814,7 +816,7 @@
See \fBfilter\fR for a highpass effect with sharper cutoff.
.TP 10
highpass \fIfrequency\fB
-Butterworth highpass filter. Description comming soon!
+Butterworth highpass filter. Description coming soon!
.TP 10
lowp \fIfrequency\fR
Apply a single pole recursive low-pass filter.
@@ -864,7 +866,7 @@
.TP 10
pick [ \fI-1\fR | \fI-2\fR | \fI-3\fR | \fI-4\fR | \fI-l\fR | \fI-r\fR ]
Select the left or right channel of a stereo sample,
-or one of four channels in a quadrophonic sample. The \fI-l\fR and \fI-r\fR
+or one of four channels in a quadraphonic sample. The \fI-l\fR and \fI-r\fR
options represent either the left or right channel. It is required that
you use the \fB-c 1\fR command line option in order to force the output file to
contain only 1 channel.
@@ -962,7 +964,7 @@
at the cost of lower execution speed. It is optional to specify
rolloff and beta parameters when using the \fI-q*\fR options.
-Following is a table of the reasonable defaults which are built-in to sox:
+Following is a table of the reasonable defaults which are built-in to SoX:
.br
\fBOption Window rolloff beta interpolation\fR
@@ -1065,7 +1067,7 @@
.br
When trimming silence from the beginning of a sound file, you specify a duration of audio that is above a given silence threshold before audio data is processed. You can also specify the count of periods of none silence you want to detect before processing audio data. Specify a period of 0 if you do not want to trim data from the front of the sound file.
.br
-When optionally trimming silence form the end of a sound file, you specify the duration of audio that must be below a given threshold before stopping to process audio data. A count of periods that occur below the threshold may also be speficied. If this options are not specified then data is not trimmed from the end of the audio file.
+When optionally trimming silence form the end of a sound file, you specify the duration of audio that must be below a given threshold before stopping to process audio data. A count of periods that occur below the threshold may also be specified. If this options are not specified then data is not trimmed from the end of the audio file.
.br
Duration counts may be in the format of time, hh:mm:ss.frac, or in the exact count of samples.
.br
@@ -1120,7 +1122,7 @@
that will print out a hex dump of the
sound file from the internal buffer that is in 32-bit signed PCM data.
This is mainly only of use in tracking down endian problems that
-creep in to sox on cross-platform versions.
+creep in to SoX on cross-platform versions.
.TP 10
stretch \fIfactor [window fade shift fading]\fB
@@ -1235,7 +1237,7 @@
.SH BUGS
The syntax is horrific. Thats the breaks when trying to handle all things from the command line.
.P
-Please report any bugs found in this version of sox to Chris Bagwell (cbagwell@sprynet.com)
+Please report any bugs found in this version of SoX to Chris Bagwell (cbagwell@sprynet.com)
.SH FILES
.SH SEE ALSO
.BR play (1),
@@ -1242,7 +1244,11 @@
.BR rec (1),
.BR soxexam(1)
.SH NOTICES
-The version of Sox that accompanies this manual page is support by
+The version of SoX that accompanies this manual page is support by
Chris Bagwell (cbagwell@users.sourceforge.net). Please refer any questions
regarding it to this address. You may obtain the latest version at the
the web site http://sox.sourceforge.net/
+.SH AUTHOR
+Chris Bagwell (cbagwell@users.sourceforge.net).
+.P
+Updates by Anonymous
--- a/soxexam.1
+++ b/soxexam.1
@@ -9,30 +9,30 @@
.if t .sp .5v
.if n .sp
..
-.TH SoX 1 "December 10, 1999"
+.TH SoX 1 "December 11, 2001"
.SH NAME
soxexam - SoX Examples (CHEAT SHEET)
.SH CONVERSIONS
.B Introduction
.P
-In general, sox will attempt to take an input sound file format and
-convert it to a new file format using a similar data type and sample
+In general, SoX will attempt to take an input sound file format and
+convert it into a new file format using a similar data type and sample
rate. For instance, "sox monkey.au monkey.wav" would try and convert
-the mono 8000Hz u-law sample .au file that comes with sox to a 8000Hz
+the mono 8000Hz u-law sample .au file that comes with SoX to a 8000Hz
u-law .wav file.
.P
If an output format doesn't support the same data type as the input file
-then sox will generally select a default data type to save it in.
+then SoX will generally select a default data type to save it in.
You can override the default data type selection by using command line
-options. This is also useful for producing a output file with higher
+options. This is also useful for producing an output file with higher
or lower precision data and/or sample rate.
.P
Most file formats that contain headers can automatically be read in.
-When working with headerless file formats then a user must manually
-tell sox the data type and sample rate using command line options.
+When working with header-less file formats then a user must manually
+tell SoX the data type and sample rate using command line options.
.P
-When working with headerless files (raw files), you may take advantage of
-they pseudo-file types of .ub, .uw, .sb, .sw, .ul, and .sl. By using these
+When working with header-less files (raw files), you may take advantage of
+the pseudo-file types of .ub, .uw, .sb, .sw, .ul, and .sl. By using these
extensions on your filenames you will not have to specify the corresponding
options on the command line.
.P
@@ -56,7 +56,7 @@
.br
u-law 14-bit
.br
- a-law 13-bit
+ A-law 13-bit
.br
unsigned word 16-bit
.br
@@ -92,6 +92,32 @@
.br
sox -r 8000 -u -b -c 1 filename.raw filename.wav
.P
+SoX may even be used to convert sample rates. Downconverting will
+reduce the bandwidth of a sample, but will reduce storage space on
+your disk. All such conversions are lossy and will introduce some noise.
+You should really pass your sample through a low pass filter
+prior to downconverting as this will prevent alias signals (which
+would sound like additional noise). For example to convert from a
+sample recorded at 11025 Hz to a u-law file at 8000 Hz sample rate:
+.P
+.br
+ sox infile.wav -t au -r 8000 -U -b -c 1 outputfile.au
+.P
+To add a low-pass filter (note use of stdout for output of
+the first stage and stdin for input on the second stage):
+.P
+.br
+ sox infile.wav -t raw -s -w -c 1 - lowpass 3700 |
+ sox -t raw -r 11025 -s -w -c 1 - -t au -r 8000 -U -b -c 1 ofile.au
+.P
+If you hear some clicks and pops when converting to u-law or A-law,
+reduce the output level slightly, for example this will decrease
+it by 20%:
+.P
+.br
+ sox infile.wav -t au -r 8000 -U -b -c 1 -v .8 outputfile.au
+.P
+
.I SoX
is great to use along with other command line programs by passing data
between the programs using pipelines. The most common example is to use
@@ -103,7 +129,7 @@
.P
When working with totally unknown audio data then the "auto" file format may
be of use. It attempts to guess what the file type is and then you may
-save it in to a known audio format.
+save it into a known audio format.
.P
.br
sox -V -t auto filename.snd filename.wav
@@ -111,17 +137,17 @@
It is important to understand how the internals of
.I SoX
work with
-compressed audio including u-law, a-law, ADPCM, or GSM.
+compressed audio including u-law, A-law, ADPCM, or GSM.
.I SoX
takes ALL input data types and converts them to uncompressed 32-bit
signed data. It will then convert this internal version into the
-requested output format. This means unneeded noise can be introduced
+requested output format. This means additional noise can be introduced
from decompressing data and then recompressing. If applying multiple
-effects to audio data it is best to save the intermediate data as PCM
-data. After the final effect is performed then you can specify it as
+effects to audio data, it is best to save the intermediate data as PCM
+data. After the final effect is performed, then you can specify it as
a compressed output format. This will keep noise introduction to a minimum.
.P
-The following example is to apply various effects to an 8000 Hz ADPCM input
+The following example applies various effects to an 8000 Hz ADPCM input
file and then end up with the final file as 44100 Hz ADPCM.
.P
.br
@@ -157,33 +183,34 @@
that can be used to understand the theory by listening to the sound file
with the added effect.
.P
-Using multiple effects in parallel or in sequel can result either
-in very perfect sound or ( mostly ) in a dramatic overloading in
+Using multiple effects in parallel or in series can result either
+in a very nice sound or (mostly) in a dramatic overloading in
variations of sounds such that your ear may follow the sound but
you will feel unsatisfied. Hence, for the first time using effects
-try to compose them as less as possible. We don't regard the
-composition of effects in the examples because to many combinations
+try to compose them as minimally as possible. We don't regard the
+composition of effects in the examples because too many combinations
are possible and you really need a very fast machine and a lot of
memory to play them in real-time.
.P
-And real-time playing of sounds will speed up learning the parameter
-setting.
+However, real-time playing of sounds will greatly speed up learning
+and/or tuning the parameter settings for your sounds in order to
+get that "perfect" effect.
.P
-Basically, we will use the "play" front-end of SOX since it is easier
+Basically, we will use the "play" front-end of SoX since it is easier
to listen sounds coming out of the speaker or earphone instead
of looking at cryptic data in sound files.
.P
-For easy listening of file.xxx ( "xxx" is any sound format ):
+For easy listening of file.xxx ("xxx" is any sound format):
.P
.BR
play file.xxx effect-name effect-parameters
.P
-Or more SOX-like ( for "dsp" output ):
+Or more SoX-like (for "dsp" output on a UNIX/Linux computer):
.P
.BR
sox file.xxx -t ossdsp -w -s /dev/dsp effect-name effect-parameters
.P
-or ( for "au" output ):
+or (for "au" output):
.P
.BR
sox file.xxx -t sunau -w -s /dev/audio effect-name effect-parameters
@@ -202,7 +229,7 @@
Linux 2.0.30 using a self-recorded sample ( 3:15 min long in "wav"
format with 44.1 kHz sample rate and stereo 16 bit ).
The sample should not contain any of the effects. However,
-if you take any recording of a sound track from radio or tape or cd,
+if you take any recording of a sound track from radio or tape or CD,
and it sounds like a live concert or ten people are playing the same
rhythm with their drums or funky-grooves, then take any other sample.
(Typically, less then four different instruments and no synthesizer
@@ -215,30 +242,31 @@
.P
An echo effect can be naturally found in the mountains, standing somewhere
on a mountain and shouting a single word will result in one or more repetitions
-of the word ( if not, turn a bit around ant try next, or climb to the next
-mountain ).
+of the word (if not, turn a bit around and try again, or climb to the next
+mountain).
.P
However, the time difference between shouting and repeating is the delay
(time), its loudness is the decay. Multiple echos can have different delays and
decays.
.P
-Very popular is using echos to play an instrument with itself together, like
-some guitar players ( Brain May from Queen ) or vocalists are doing.
+It is very popular to use echos to play an instrument with itself together,
+like some guitar players (Brain May from Queen) or vocalists are doing.
For music samples of more than one instrument, echo can be used to add a
second sample shortly after the original one.
.P
-This will sound as doubling the number of instruments playing the same sample:
+This will sound as if you are doubling the number of instruments playing
+in the same sample:
.P
.BR
play file.xxx echo 0.8 0.88 60.0 0.4
.P
-If the delay is very short then it sound like a (metallic) robot playing
+If the delay is very short, then it sound like a (metallic) robot playing
music:
.P
.BR
play file.xxx echo 0.8 0.88 6.0 0.4
.P
-Longer delay will sound like a open air concert in the mountains:
+Longer delay will sound like an open air concert in the mountains:
.P
.BR
play file.xxx echo 0.8 0.9 1000.0 0.3
@@ -253,7 +281,7 @@
Like the echo effect, echos stand for "ECHO in Sequel", that is the first echos
takes the input, the second the input and the first echos, the third the input
and the first and the second echos, ... and so on.
-Care should be taken using many echos ( see introduction ); a single echos
+Care should be taken using many echos (see introduction); a single echos
has the same effect as a single echo.
.P
The sample will be bounced twice in symmetric echos:
@@ -266,7 +294,7 @@
.BR
play file.xxx echos 0.8 0.7 700.0 0.25 900.0 0.3
.P
-The sample will sound as played in a garage:
+The sample will sound as if played in a garage:
.P
.BR
play file.xxx echos 0.8 0.7 40.0 0.25 63.0 0.3
@@ -281,7 +309,7 @@
The delay is varied using a sinusoidal or triangular modulation. The modulation
depth defines the range the modulated delay is played before or after the
delay. Hence the delayed sound will sound slower or faster, that is the delayed
-sound tuned around the original one, like in a chorus where some vocal are
+sound tuned around the original one, like in a chorus where some vocals are
a bit out of tune.
.P
The typical delay is around 40ms to 60ms, the speed of the modulation is best
@@ -297,7 +325,7 @@
.BR
play file.xxx chorus 0.6 0.9 50.0 0.4 0.25 2.0 -t 60.0 0.32 0.4 1.3 -s
.P
-A big chorus of the sample is ( three additional samples ):
+A big chorus of the sample is (three additional samples):
.P
.BR
play file.xxx chorus 0.5 0.9 50.0 0.4 0.25 2.0 -t 60.0 0.32 0.4 2.3 -t \
@@ -337,23 +365,26 @@
.P
.B Reverb
.P
-The reverb effect is often used in audience hall which are to small or to many
-visitors disturb the reflection of sound at the walls to make the sound played
-more monumental. You can try the reverb effect in your bathroom or garage or
+The reverb effect is often used in audience hall which are to small or contain
+too many many visitors which disturb (dampen) the reflection of sound at
+the walls. Reverb will make the sound be perceived as if it were in
+a large hall. You can try the reverb effect in your bathroom or garage or
sport halls by shouting loud some words. You'll hear the words reflected from
the walls.
.P
The biggest problem in using the reverb effect is the correct setting of the
-(wall) delays such that the sound is realistic an doesn't sound like music
-playing in a tin or overloaded feedback destroys any illusion of any big hall.
-To help you for much realistic reverb effects, you should decide first, how
+(wall) delays such that the sound is realistic and doesn't sound like music
+playing in a tin can or has overloaded feedback which destroys any illusion
+of playing in a big hall.
+To help you obtain realistic reverb effects, you should decide first how
long the reverb should take place until it is not loud enough to be registered
-by your ears. This is be done by the reverb time "t", in small halls 200ms in
-bigger one 1000ms, if you like. Clearly, the walls of such a hall aren't far
+by your ears. This is be done by varying the reverb time "t". To simulate
+small halls, use 200ms. To simulate large halls, use 1000ms. Clearly,
+the walls of such a hall aren't far
away, so you should define its setting be given every wall its delay time.
However, if the wall is to far away for the reverb time, you won't hear the
-reverb, so the nearest wall will be best "t/4" delay and the farthest "t/2".
-You can try other distances as well, but it won't sound very realistic.
+reverb, so the nearest wall will be best at "t/4" delay and the farthest
+at "t/2". You can try other distances as well, but it won't sound very realistic.
The walls shouldn't stand to close to each other and not in a multiple integer
distance to each other ( so avoid wall like: 200.0 and 202.0, or something
like 100.0 and 200.0 ).
@@ -379,28 +410,28 @@
.BR
play file.xxx reverb 1.0 600.0 180.0 200.0 220.0 240.0 280.0 300.0
.P
-If you run out of machine power or memory, then stop as much applications
-as possible ( every interrupt will consume a lot of CPU time which for
-bigger halls is absolutely necessary ).
+If you run out of machine power or memory, then stop as many applications
+as possible (every interrupt will consume a lot of CPU time which for
+bigger halls is absolutely necessary).
.P
.B Phaser
.P
The phaser effect is like the flanger effect, but it uses a reverb instead of
an echo and does phase shifting. You'll hear the difference in the examples
-comparing both effects ( simply change the effect name ).
-The delay modulation can be done sinusoidal or triangular, preferable is the
-later one for multiple instruments playing. For single instrument sounds
+comparing both effects (simply change the effect name).
+The delay modulation can be sinusoidal or triangular, preferable is the
+later for multiple instruments. For single instrument sounds,
the sinusoidal phaser effect will give a sharper phasing effect.
The decay shouldn't be to close to 1.0 which will cause dramatic feedback.
A good range is about 0.5 to 0.1 for the decay.
.P
-We will take a parameter setting as for the flanger before ( gain-out is
-lower since feedback can raise the output dramatically ):
+We will take a parameter setting as for the flanger before (gain-out is
+lower since feedback can raise the output dramatically):
.P
.BR
play file.xxx phaser 0.8 0.74 3.0 0.4 0.5 -t
.P
-The drunken loudspeaker system ( now less alcohol ):
+The drunken loudspeaker system (now less alcohol):
.P
.BR
play file.xxx phaser 0.9 0.85 4.0 0.23 1.3 -s
@@ -449,22 +480,50 @@
with a bit of silence, and the delay of 0.2 has the effect of causing
the compander to react a bit more quickly to sudden volume changes.
.P
-.B Other effects ( copy, rate, avg, stat, vibro, lowp, highp, band, reverb )
+.B Changing the Rate of Playback
.P
+You can use stretch to change the rate of playback of an audio sample
+while preserving the pitch. For example to play at 1/2 the speed:
+.P
+.BR
+ play file.wav stretch 2
+.P
+To play a file at twice the speed:
+.P
+.BR
+ play file.wav stretch .5
+.P
+Other related options are "speed" to change the speed of play
+(and changing the pitch accordingly), and pitch, to alter the
+pitch of a sample. For example to speed a sample so it plays in
+1/2 the time (for those Mickey Mouse voices):
+.P
+.BR
+ play file.wav speed 2
+.P
+To raise the pitch of a sample 1 while note (100 cents):
+.P
+.BR
+ play file.wav pitch 100
+.P
+
+.P
+.B Other effects (copy, rate, avg, stat, vibro, lowp, highp, band, reverb)
+.P
The other effects are simple to use. However, an "easy to use manual" should
be given here.
.P
-.B More effects ( to do ! )
+.B More effects (to do !)
.P
There are a lot of effects around like noise gates, compressors, waw-waw,
-stereo effects and so on. They should be implemented making SOX to be more
+stereo effects and so on. They should be implemented, making SoX more
useful in sound mixing techniques coming together with a great variety of
different sound effects.
.P
-Combining effects by using them in parallel or sequence on different channels
-needs some easy mechanism which is real-time stable.
+Combining effects by using them in parallel or serially on different channels
+needs some easy mechanism which is stable for use in real-time.
.P
-Really missing, is the changing of the parameters, starting and stopping of
+Really missing are the the changing of the parameters and starting/stopping of
effects while playing samples in real-time!
.P
Good luck and have fun with all the effects!
@@ -473,3 +532,7 @@
.SH SEE ALSO
sox(1), play(1), rec(1)
+.SH AUTHOR
+Juergen Mueller (jmueller@uia.ua.ac.be)
+.P
+Updates by Anonymous.
--- a/src/voc.c
+++ b/src/voc.c
@@ -15,6 +15,21 @@
* files. Added support for saving stereo files and 16-bit files.
* Added VOC format info from audio format FAQ so I don't have to keep
* looking around for it.
+ *
+ * February 5, 2001
+ * For sox-12-17 by Annonymous (see notes ANN)
+ * Added comments and notes for each procedure.
+ * Fixed so this now works with pipes, input does not have to
+ * be seekable anymore (in st_vocstartread() )
+ * Added support for uLAW and aLaw (aLaw not tested).
+ * Fixed support of multi-part VOC files, and files with
+ * block 9 but no audio in the block....
+ * The following need to be tested: 16-bit, 2 channel, and aLaw.
+ *
+ * December 10, 2001
+ * For sox-12-17-3 by Annonymous (see notes ANN)
+ * Patch for sox-12-17 merged with sox-12-17-3-pre3 code.
+ *
*/
/*
@@ -67,7 +82,9 @@
06 Repeat 2 Count# (2 bytes)
07 End repeat 0 (NONE)
08 Extended 4 ***
+ 09 New Header 16 see below
+
*Sound Info Format: **Silence Info Format:
--------------------- ----------------------------
00 Sample Rate 00-01 Length of silence - 1
@@ -112,7 +129,7 @@
Data is stored left, right
BLOCK 9 - data block that supersedes blocks 1 and 8.
- Used for stereo, 16 bit.
+ Used for stereo, 16 bit (and uLaw, aLaw).
BYTE bBlockID; // = 9
BYTE nBlockLen[3]; // length 12 plus length of sound
@@ -136,22 +153,27 @@
Data is stored left, right
+ ANN: Multi-byte quantities are in Intel byte order (Little Endian).
+
------------------------------------------------------------------------*/
#include "st_i.h"
+#include "g711.h"
#include <string.h>
/* Private data for VOC file */
typedef struct vocstuff {
- long rest; /* bytes remaining in current block */
- long rate; /* rate code (byte) of this chunk */
- int silent; /* sound or silence? */
- long srate; /* rate code (byte) of silence */
- long blockseek; /* start of current output block */
- long samples; /* number of samples output */
- int size; /* word length of data */
- unsigned char channels; /* number of sound channels */
- int extended; /* Has an extended block been read? */
+ long rest; /* bytes remaining in current block */
+ long rate; /* rate code (byte) of this chunk */
+ int silent; /* sound or silence? */
+ long srate; /* rate code (byte) of silence */
+ long blockseek; /* start of current output block */
+ long samples; /* number of samples output */
+ uint16_t format; /* VOC audio format */
+ int size; /* word length of data */
+ unsigned char channels; /* number of sound channels */
+ long total_size; /* total size of all audio in file */
+ int extended; /* Has an extended block been read? */
} *vs_t;
#define VOC_TERM 0
@@ -165,18 +187,40 @@
#define VOC_EXTENDED 8
#define VOC_DATA_16 9
+/* ANN: Format encoding types */
+#define VOC_FMT_LIN8U 0 /* 8 bit unsigned linear PCM */
+#define VOC_FMT_CRLADPCM4 1 /* Creative 8-bit to 4-bit ADPCM */
+#define VOC_FMT_CRLADPCM3 2 /* Creative 8-bit to 3-bit ADPCM */
+#define VOC_FMT_CRLADPCM2 3 /* Creative 8-bit to 2-bit ADPCM */
+#define VOC_FMT_LIN16 4 /* 16-bit signed PCM */
+#define VOC_FMT_ALAW 6 /* CCITT a-Law 8-bit PCM */
+#define VOC_FMT_MU255 7 /* CCITT u-Law 8-bit PCM */
+#define VOC_FMT_CRLADPCM4A 0x200 /* Creative 16-bit to 4-bit ADPCM */
+
#define min(a, b) (((a) < (b)) ? (a) : (b))
+/* Prototypes for internal functions */
static int getblock(ft_t);
static void blockstart(ft_t);
static void blockstop(ft_t);
-int st_vocstartread(ft_t ft)
+/* Conversion macros (from raw.c) */
+#define ST_ALAW_BYTE_TO_SAMPLE(d) ((st_sample_t)(st_alaw2linear16(d)) << 16)
+#define ST_ULAW_BYTE_TO_SAMPLE(d) ((st_sample_t)(st_ulaw2linear16(d)) << 16)
+
+/* public VOC functions for SOX */
+/*-----------------------------------------------------------------
+ * st_vocstartread() -- start reading a VOC file
+ *-----------------------------------------------------------------*/
+int st_vocstartread(ft_t ft)
{
+ int rtn = ST_SUCCESS;
char header[20];
vs_t v = (vs_t) ft->priv;
unsigned short sbseek;
int rc;
+ int ii; /* for getting rid of lseek */
+ unsigned char uc;
/* VOC is in Little Endian format. Swap bytes read in on */
/* Big Endian mahcines. */
@@ -186,12 +230,6 @@
}
- if (! ft->seekable)
- {
- st_fail_errno(ft,ST_EOF,"VOC input file must be a file, not a pipe");
- return(ST_EOF);
- }
-
if (fread(header, 1, 20, ft->fp) != 20)
{
st_fail_errno(ft,ST_EHDR,"unexpected EOF in VOC header");
@@ -203,15 +241,26 @@
return(ST_EOF);
}
+ /* read the offset to data, from start of file */
+ /* after this read we have read 20 bytes of header + 2 */
st_readw(ft, &sbseek);
- fseek(ft->fp, sbseek, 0);
+ /* ANN: read to skip the header, instead of lseek */
+ /* this should allow use with pipes.... */
+ for (ii=22; ii<sbseek; ii++)
+ st_readb(ft, &uc);
+
v->rate = -1;
v->rest = 0;
+ v->total_size = 0; /* ANN added */
v->extended = 0;
+
+ /* read until we get the format information.... */
rc = getblock(ft);
if (rc)
return rc;
+
+ /* get rate of data */
if (v->rate == -1)
{
st_fail_errno(ft,ST_EOF,"Input .voc file had no sound!");
@@ -218,10 +267,46 @@
return(ST_EOF);
}
+ /* setup word length of data */
ft->info.size = v->size;
- ft->info.encoding = ST_ENCODING_UNSIGNED;
- if (v->size == ST_SIZE_WORD)
+
+ /* ANN: Check VOC format and map to the proper ST format value */
+ switch (v->format) {
+ case VOC_FMT_LIN8U: /* 0 8 bit unsigned linear PCM */
+ ft->info.encoding = ST_ENCODING_UNSIGNED;
+ break;
+ case VOC_FMT_CRLADPCM4: /* 1 Creative 8-bit to 4-bit ADPCM */
+ st_warn ("Unsupported VOC format CRLADPCM4 %d", v->format);
+ rtn=ST_EOF;
+ break;
+ case VOC_FMT_CRLADPCM3: /* 2 Creative 8-bit to 3-bit ADPCM */
+ st_warn ("Unsupported VOC format CRLADPCM3 %d", v->format);
+ rtn=ST_EOF;
+ break;
+ case VOC_FMT_CRLADPCM2: /* 3 Creative 8-bit to 2-bit ADPCM */
+ st_warn ("Unsupported VOC format CRLADPCM2 %d", v->format);
+ rtn=ST_EOF;
+ break;
+ case VOC_FMT_LIN16: /* 4 16-bit signed PCM */
ft->info.encoding = ST_ENCODING_SIGN2;
+ break;
+ case VOC_FMT_ALAW: /* 6 CCITT a-Law 8-bit PCM */
+ ft->info.encoding = ST_ENCODING_ALAW;
+ break;
+ case VOC_FMT_MU255: /* 7 CCITT u-Law 8-bit PCM */
+ ft->info.encoding = ST_ENCODING_ULAW;
+ break;
+ case VOC_FMT_CRLADPCM4A: /*0x200 Creative 16-bit to 4-bit ADPCM */
+ printf ("Unsupported VOC format CRLADPCM4A %d", v->format);
+ rtn=ST_EOF;
+ break;
+ default:
+ printf ("Unknown VOC format %d", v->format);
+ rtn=ST_EOF;
+ break;
+ }
+
+ /* setup number of channels */
if (ft->info.channels == -1)
ft->info.channels = v->channels;
@@ -228,14 +313,20 @@
return(ST_SUCCESS);
}
-st_ssize_t st_vocread(ft_t ft, st_sample_t *buf, st_ssize_t len)
+/*-----------------------------------------------------------------
+ * st_vocread() -- read data from a VOC file
+ * ANN: Major changes here to support multi-part files and files
+ * that do not have audio in block 9's.
+ *-----------------------------------------------------------------*/
+st_ssize_t st_vocread(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
vs_t v = (vs_t) ft->priv;
int done = 0;
- int rc;
+ int rc = 0;
int16_t sw;
- unsigned char uc;
+ unsigned char uc;
+ /* handle getting another cont. buffer */
if (v->rest == 0)
{
rc = getblock(ft);
@@ -243,44 +334,83 @@
return 0;
}
+ /* if no more data, return 0, i.e., done */
if (v->rest == 0)
return 0;
+ /* if silence, fill it in with 0's */
if (v->silent) {
/* Fill in silence */
for(;v->rest && (done < len); v->rest--, done++)
*buf++ = 0x80000000L;
- } else {
- for(;v->rest && (done < len); v->rest--, done++) {
- switch(v->size)
+ }
+ /* else, not silence, read the block */
+ else {
+ /* read len samples of audio from the file */
+
+ /* for(;v->rest && (done < len); v->rest--, done++) { */
+ for(; (done < len); done++) {
+
+ /* IF no more in this block, get another */
+ if (v->rest == 0) {
+
+ /* DO until we have either EOF or a block with data */
+ while (v->rest == 0) {
+ rc = getblock(ft);
+ if (rc)
+ break;
+ }
+ /* ENDDO ... */
+
+ /* IF EOF, break out, no more data, next will return 0 */
+ if (rc)
+ break;
+ }
+ /* ENDIF no more data in block */
+
+ /* Read the data in the file */
+ switch(v->size) {
+ case ST_SIZE_BYTE:
+ if (st_readb(ft, &uc) == ST_EOF) {
+ st_warn("VOC input: short file");
+ v->rest = 0;
+ return done;
+ }
+ /* IF uLaw,alaw, expand to linear, else convert??? */
+ /* ANN: added uLaw and aLaw support */
+ if (v->format == VOC_FMT_MU255) {
+ *buf++ = ST_ULAW_BYTE_TO_SAMPLE(uc);
+ } else if (v->format == VOC_FMT_ALAW) {
+ *buf++ = ST_ALAW_BYTE_TO_SAMPLE(uc);
+ } else {
+ *buf++ = ST_UNSIGNED_BYTE_TO_SAMPLE(uc);
+ }
+ break;
+ case ST_SIZE_WORD:
+ st_readw(ft, &sw);
+ if (feof(ft->fp))
{
- case ST_SIZE_BYTE:
- if (st_readb(ft, &uc) == ST_EOF) {
- st_warn("VOC input: short file");
- v->rest = 0;
- return done;
- }
- *buf++ = ST_UNSIGNED_BYTE_TO_SAMPLE(uc);
- break;
- case ST_SIZE_WORD:
- st_readw(ft, &sw);
- if (feof(ft->fp))
- {
- st_warn("VOC input: short file");
- v->rest = 0;
- return done;
- }
- *buf++ = ST_SIGNED_WORD_TO_SAMPLE(sw);
- v->rest--; /* Processed 2 bytes so update */
- break;
- }
- }
- }
+ st_warn("VOC input: short file");
+ v->rest = 0;
+ return done;
+ }
+ *buf++ = ST_SIGNED_WORD_TO_SAMPLE(sw);
+ v->rest--; /* Processed 2 bytes so update */
+ break;
+ }
+ /* decrement count of processed bytes */
+ v->rest--; /* Processed 2 bytes so update */
+ }
+ }
+ v->total_size+=done;
return done;
}
-/* nothing to do */
-int st_vocstopread(ft_t ft)
+/*-----------------------------------------------------------------
+ * st_vocstartread() -- start reading a VOC file
+ * nothing to do
+ *-----------------------------------------------------------------*/
+int st_vocstopread(ft_t ft)
{
return(ST_SUCCESS);
}
@@ -292,11 +422,13 @@
* If a 16-bit sample (either stereo or mono) then save with a
* VOC_DATA_16 header.
*
+ * ANN: Not supported: uLaw and aLaw output VOC files....
+ *
* This approach will cause the output to be an its most basic format
* which will work with the oldest software (eg. an 8-bit mono sample
* will be able to be played with a really old SB VOC player.)
*/
-int st_vocstartwrite(ft_t ft)
+int st_vocstartwrite(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
@@ -309,7 +441,8 @@
if (! ft->seekable)
{
- st_fail_errno(ft,ST_EOF,"Output .voc file must be a file, not a pipe");
+ st_fail_errno(ft,ST_EOF,
+ "Output .voc file must be a file, not a pipe");
return(ST_EOF);
}
@@ -331,7 +464,10 @@
return(ST_SUCCESS);
}
-st_ssize_t st_vocwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
+/*-----------------------------------------------------------------
+ * st_vocstartread() -- start reading a VOC file
+ *-----------------------------------------------------------------*/
+st_ssize_t st_vocwrite(ft_t ft, st_sample_t *buf, st_ssize_t len)
{
vs_t v = (vs_t) ft->priv;
unsigned char uc;
@@ -357,15 +493,23 @@
return done;
}
-int st_vocstopwrite(ft_t ft)
+/*-----------------------------------------------------------------
+ * st_vocstopwrite() -- stop writing a VOC file
+ *-----------------------------------------------------------------*/
+int st_vocstopwrite(ft_t ft)
{
blockstop(ft);
return(ST_SUCCESS);
}
-/* Voc-file handlers */
+/*-----------------------------------------------------------------
+ * Voc-file handlers (static, private to this module)
+ *-----------------------------------------------------------------*/
-/* Read next block header, save info, leave position at start of data */
+/*-----------------------------------------------------------------
+ * getblock() -- Read next block header, save info,
+ * leave position at start of dat
+ *-----------------------------------------------------------------*/
static int getblock(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
@@ -377,14 +521,23 @@
uint32_t trash;
v->silent = 0;
+ /* DO while we have no audio to read */
while (v->rest == 0) {
+ /* IF EOF, return EOF
+ * ANN: was returning SUCCESS */
if (feof(ft->fp))
- return ST_SUCCESS;
+ return ST_EOF;
+
+ /* IF TERM block (end of file), return EOF
+ * ANN: was returning SUCCESS */
st_readb(ft, &block);
if (block == VOC_TERM)
- return ST_SUCCESS;
+ return ST_EOF;
+
+ /* IF EOF after reading block type, return EOF
+ * ANN: was returning SUCCESS */
if (feof(ft->fp))
- return ST_SUCCESS;
+ return ST_EOF;
/*
* Size is an 24-bit value. Currently there is no util
* func to read this so do it this cross-platform way
@@ -396,6 +549,9 @@
sblen |= ((uint32_t) uc) << 8;
st_readb(ft, &uc);
sblen |= ((uint32_t) uc) << 16;
+
+ /* Based on VOC block type, process the block */
+ /* audio may be in one or multiple blocks */
switch(block) {
case VOC_DATA:
st_readb(ft, &uc);
@@ -404,12 +560,14 @@
if (!v->extended) {
if (uc == 0)
{
- st_fail_errno(ft,ST_EFMT,"File %s: Sample rate is zero?");
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: Sample rate is zero?");
return(ST_EOF);
}
if ((v->rate != -1) && (uc != v->rate))
{
- st_fail_errno(ft,ST_EFMT,"File %s: sample rate codes differ: %d != %d",
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: sample rate codes differ: %d != %d",
ft->filename,v->rate, uc);
return(ST_EOF);
}
@@ -420,7 +578,8 @@
st_readb(ft, &uc);
if (uc != 0)
{
- st_fail_errno(ft,ST_EFMT,"File %s: only interpret 8-bit data!",
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: only interpret 8-bit data!",
ft->filename);
return(ST_EOF);
}
@@ -432,12 +591,14 @@
st_readdw(ft, &new_rate_32);
if (new_rate_32 == 0)
{
- st_fail_errno(ft,ST_EFMT,"File %s: Sample rate is zero?",ft->filename);
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: Sample rate is zero?",ft->filename);
return(ST_EOF);
}
if ((v->rate != -1) && (new_rate_32 != v->rate))
{
- st_fail_errno(ft,ST_EFMT,"File %s: sample rate codes differ: %d != %d",
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: sample rate codes differ: %d != %d",
ft->filename, v->rate, new_rate_32);
return(ST_EOF);
}
@@ -449,16 +610,16 @@
case 8: v->size = ST_SIZE_BYTE; break;
case 16: v->size = ST_SIZE_WORD; break;
default:
- st_fail_errno(ft,ST_EFMT,"Don't understand size %d", uc);
- return(ST_EOF);
+ st_fail_errno(ft,ST_EFMT,
+ "Don't understand size %d", uc);
+ return(ST_EOF);
}
st_readb(ft, &(v->channels));
- st_readb(ft, (unsigned char *)&trash); /* unknown */
+ st_readw(ft, &(v->format)); /* ANN: added format */
st_readb(ft, (unsigned char *)&trash); /* notused */
st_readb(ft, (unsigned char *)&trash); /* notused */
st_readb(ft, (unsigned char *)&trash); /* notused */
st_readb(ft, (unsigned char *)&trash); /* notused */
- st_readb(ft, (unsigned char *)&trash); /* notused */
v->rest = sblen - 12;
return (ST_SUCCESS);
case VOC_CONT:
@@ -472,7 +633,8 @@
st_readb(ft, &uc);
if (uc == 0)
{
- st_fail_errno(ft,ST_EFMT,"File %s: Silence sample rate is zero");
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: Silence sample rate is zero");
return(ST_EOF);
}
/*
@@ -494,10 +656,21 @@
/* Falling! Falling! */
case VOC_TEXT:
{
- int i;
- /* Could add to comment in SF? */
- for(i = 0; i < sblen; i++)
- st_readb(ft, (unsigned char *)&trash);
+ int i;
+ /* Could add to comment in SF? */
+ for(i = 0; i < sblen; i++) {
+ st_readb(ft, (unsigned char *)&trash);
+ /* uncomment lines below to display text */
+ /* Note, if this is uncommented, studio */
+ /* will not be able to read the VOC file */
+ /* ANN: added verbose dump of text info */
+ /* */
+ if (verbose) {
+ if ((trash != '\0') && (trash != '\r'))
+ putc (trash, stderr);
+ }
+ /* */
+ }
}
continue; /* get next block */
case VOC_LOOP:
@@ -515,12 +688,14 @@
st_readw(ft, &new_rate_16);
if (new_rate_16 == 0)
{
- st_fail_errno(ft,ST_EFMT,"File %s: Sample rate is zero?");
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: Sample rate is zero?");
return(ST_EOF);
}
if ((v->rate != -1) && (new_rate_16 != v->rate))
{
- st_fail_errno(ft,ST_EFMT,"File %s: sample rate codes differ: %d != %d",
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: sample rate codes differ: %d != %d",
ft->filename, v->rate, new_rate_16);
return(ST_EOF);
}
@@ -528,7 +703,8 @@
st_readb(ft, &uc);
if (uc != 0)
{
- st_fail_errno(ft,ST_EFMT,"File %s: only interpret 8-bit data!",
+ st_fail_errno(ft,ST_EFMT,
+ "File %s: only interpret 8-bit data!",
ft->filename);
return(ST_EOF);
}
@@ -537,7 +713,8 @@
ft->info.channels = 2; /* Stereo */
/* Needed number of channels before finishing
compute for rate */
- ft->info.rate = (256000000L/(65536L - v->rate))/ft->info.channels;
+ ft->info.rate = (256000000L/(65536L - v->rate))/
+ ft->info.channels;
/* An extended block must be followed by a data */
/* block to be valid so loop back to top so it */
/* can be grabed. */
@@ -552,7 +729,9 @@
return ST_SUCCESS;
}
-/* Start an output block. */
+/*-----------------------------------------------------------------
+ * vlockstart() -- start an output block
+ *-----------------------------------------------------------------*/
static void blockstart(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
@@ -606,8 +785,11 @@
}
}
-/* End the current data or silence block. */
-static void blockstop(ft_t ft)
+/*-----------------------------------------------------------------
+ * blockstop() -- stop an output block
+ * End the current data or silence block.
+ *-----------------------------------------------------------------*/
+static void blockstop(ft_t ft)
{
vs_t v = (vs_t) ft->priv;
st_sample_t datum;