ref: 1ae3f8d97dcf3d2d8b5fd7f439ba6f28efafbb90
parent: 761307a4fc5635867b379102d5bee61a60b6a423
author: cbagwell <cbagwell>
date: Tue Dec 28 21:02:50 EST 1999
Initial support for return codes with effects.
--- a/Makefile.dos
+++ b/Makefile.dos
@@ -16,7 +16,7 @@
sndrtool.obj sunaudio.obj tx16w.obj voc.obj wav.obj wve.obj
EOBJ = avg.obj band.obj bandpass.obj breject.obj btrworth.obj chorus.obj \
- compand.obj copy.obj cut.obj deemphas.obj dyn.obj echo.obj \
+ compand.obj copy.obj cut.obj deemphas.obj echo.obj \
echos.obj filter.obj flanger.obj highp.obj highpass.obj lowp.obj \
lowpass.obj map.obj mask.obj phaser.obj pick.obj polyphas.obj \
rate.obj resample.obj reverb.obj reverse.obj split.obj \
--- a/Makefile.gcc
+++ b/Makefile.gcc
@@ -33,7 +33,7 @@
sf.o smp.o sndrtool.o sunaudio.o tx16w.o voc.o wav.o wve.o
EOBJ = avg.o band.o bandpass.o breject.o btrworth.o chorus.o compand.o \
- copy.o cut.o deemphas.o dyn.o echo.o echos.o filter.o flanger.o \
+ copy.o cut.o deemphas.o echo.o echos.o filter.o flanger.o \
highp.o highpass.o lowp.o lowpass.o map.o mask.o phaser.o pick.o \
polyphas.o rate.o resample.o reverb.o reverse.o split.o \
stat.o swap.o vibro.o
--- a/cut.c
+++ b/cut.c
@@ -29,7 +29,7 @@
/*
* Process options
*/
-void cut_getopts(effp, n, argv)
+int st_cut_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -38,12 +38,13 @@
/* parse it */
cut->which = 0; /* for now */
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void cut_start(effp)
+int st_cut_start(effp)
eff_t effp;
{
cut_t cut = (cut_t) effp->priv;
@@ -52,6 +53,7 @@
cut->where = 0;
cut->start = effp->loops[0].start;
cut->end = effp->loops[0].start + effp->loops[0].length;
+ return (ST_SUCCESS);
}
/*
@@ -59,7 +61,7 @@
* Return number of samples processed.
*/
-void cut_flow(effp, ibuf, obuf, isamp, osamp)
+int st_cut_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -73,7 +75,7 @@
*isamp = len;
*osamp = 0;
cut->where += len;
- return;
+ return (ST_SUCCESS);
}
*isamp = len; /* We will have processed all inputs */
if (cut->where < cut->start) {
@@ -89,6 +91,7 @@
*obuf++ = *ibuf++;
}
*osamp = len;
+ return (ST_SUCCESS);
}
/*
@@ -95,12 +98,13 @@
* Drain out remaining samples if the effect generates any.
*/
-void cut_drain(effp, obuf, osamp)
+int st_cut_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
{
*osamp = 0;
+ return (ST_SUCCESS);
}
/*
@@ -107,10 +111,11 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-void cut_stop(effp)
+int st_cut_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/dyn.c
+++ /dev/null
@@ -1,111 +1,0 @@
-#ifdef USE_DYN
-/*
- * July 5, 1991
- * Copyright 1991 Lance Norskog And Sundry Contributors
- * This source code is freely redistributable and may be used for
- * any purpose. This copyright notice must be maintained.
- * Lance Norskog And Sundry Contributors are not responsible for
- * the consequences of using this software.
- */
-
-/*
- * Sound Tools dynamic compander effect file.
- *
- * Compresses or expands dynamic range, i.e. range between
- * soft and loud sounds. U-law compression basically does this.
- *
- * Doesn't work. Giving up for now.
- */
-
-#include <math.h>
-#include "st.h"
-
-/* Private data for DYN.C file */
-typedef struct dyn{
- int rest; /* bytes remaining in current block */
-} *dyn_t;
-
-/*
- * Process options
- */
-void dyn_getopts(effp, n, argv)
-eff_t effp;
-int n;
-char **argv;
-{
- if (n)
- fail("Copy effect takes no options.");
-}
-
-/*
- * Prepare processing.
- */
-void dyn_start(effp)
-eff_t effp;
-{
- /* nothing to do */
- /* stuff data into delaying effects here */
-}
-
-/*
- * Processed signed long samples from ibuf to obuf.
- * Return number of samples processed.
- */
-
-void dyn_flow(effp, ibuf, obuf, isamp, osamp)
-eff_t effp;
-LONG *ibuf, *obuf;
-LONG *isamp, *osamp;
-{
- int len, done;
-
- LONG l;
- double d, tmp;
- int sign;
-
-#define NORMIT (65536.0)
-
- len = ((*isamp > *osamp) ? *osamp : *isamp);
- for(done = 0; done < len; done++) {
-
- d = *ibuf++;
- if (d == 0.0)
- l = 0;
- else {
- if (d < 0.0) {
- d *= -1.0;
- sign = -1;
- } else
- sign = 1;
- d /= NORMIT;
- tmp = log10(d);
- tmp = pow(8.0, tmp);
- tmp = tmp * NORMIT;
- l = tmp * sign;
- }
- *obuf++ = l;
- }
-}
-
-/*
- * Drain out remaining samples if the effect generates any.
- */
-
-void dyn_drain(effp, obuf, osamp)
-LONG *obuf;
-LONG *osamp;
-{
- *osamp = 0;
-}
-
-/*
- * Do anything required when you stop reading samples.
- * (free allocated memory, etc.)
- */
-void dyn_stop(effp)
-eff_t effp;
-{
- /* nothing to do */
-}
-
-#endif /* USE_DYN */
--- a/pick.c
+++ b/pick.c
@@ -31,8 +31,7 @@
/*
* Process options
*/
-void
-pick_getopts(effp, n, argv)
+int st_pick_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -43,25 +42,29 @@
switch (argv[0][1]) {
case 'l':
pick->chan = CHAN_1;
- return;
+ return (ST_SUCCESS);
case 'r':
pick->chan = CHAN_2;
- return;
+ return (ST_SUCCESS);
case '1':
pick->chan = CHAN_1;
- return;
+ return (ST_SUCCESS);
case '2':
pick->chan = CHAN_2;
- return;
+ return (ST_SUCCESS);
case '3':
pick->chan = CHAN_3;
- return;
+ return (ST_SUCCESS);
case '4':
pick->chan = CHAN_4;
- return;
+ return (ST_SUCCESS);
}
}
- pick->chan = -1; /* invalid option */
+ /* Invalid option given. Will give error when st_pick_stat()
+ * is called
+ */
+ pick->chan = -1;
+ return (ST_SUCCESS);
}
@@ -71,23 +74,35 @@
* channels selected, and that info is not available in pick_getopts()
* above.
*/
-void
-pick_start(effp)
+int st_pick_start(effp)
eff_t effp;
{
pick_t pick = (pick_t) effp->priv;
if (effp->outinfo.channels != 1) /* must be one output channel */
+ {
fail("Can't pick with other than 1 output channel.");
+ return (ST_EOF);
+ }
if (effp->ininfo.channels != 2 && effp->ininfo.channels != 4)
+ {
fail("Can't pick with other than 2 or 4 input channels.");
+ return (ST_EOF);
+ }
if (effp->ininfo.channels == 2) { /* check for valid option */
if (pick->chan == -1 || pick->chan == CHAN_3 || pick->chan == CHAN_4)
+ {
fail("Must specify channel to pick: '-l', '-r', '-1', or '-2'.");
+ return (ST_EOF);
+ }
}
else /* must be 4 channels; check for valid option */
if (pick->chan == -1)
+ {
fail("Must specify channel to pick: '-1', '-2', '-3', or '-4'.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -96,7 +111,7 @@
* while picking appropriate channels.
*/
-void pick_flow(effp, ibuf, obuf, isamp, osamp)
+int st_pick_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -124,6 +139,7 @@
*osamp = len;
break;
}
+ return (ST_SUCCESS);
}
/*
@@ -130,9 +146,10 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void pick_stop(effp)
+int st_pick_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/split.c
+++ b/split.c
@@ -25,21 +25,23 @@
/*
* Process options
*/
-void
-split_getopts(effp, n, argv)
+int st_split_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Split effect takes no options.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void
-split_start(effp)
+int st_split_start(effp)
eff_t effp;
{
switch (effp->ininfo.channels) {
@@ -47,18 +49,19 @@
switch(effp->outinfo.channels) {
case 2:
case 4:
- return;
+ return (ST_SUCCESS);
}
break;
case 2: /* 2 channels must split to 4 */
switch(effp->outinfo.channels) {
case 4:
- return;
+ return (ST_SUCCESS);
}
break;
}
fail("Can't split %d channels into %d channels",
effp->ininfo.channels, effp->outinfo.channels);
+ return (ST_EOF);
}
/*
@@ -67,7 +70,7 @@
* while splitting into appropriate channels.
*/
-void split_flow(effp, ibuf, obuf, isamp, osamp)
+int st_split_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -115,6 +118,7 @@
*osamp = len * 2;
break;
}
+ return (ST_SUCCESS);
}
/*
@@ -121,10 +125,9 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void split_stop(effp)
+int st_split_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
-
-
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -46,7 +46,7 @@
sf.o smp.o sndrtool.o tx16w.o voc.o wav.o wve.o
EOBJ = avg.o band.o bandpass.o breject.o btrworth.o chorus.o compand.o \
- copy.o cut.o deemphas.o dyn.o echo.o echos.o filter.o flanger.o \
+ copy.o cut.o deemphas.o echo.o echos.o filter.o flanger.o \
highp.o highpass.o lowp.o lowpass.o map.o mask.o phaser.o pick.o \
polyphas.o rate.o resample.o reverb.o reverse.o split.o \
stat.o swap.o vibro.o
--- a/src/avg.c
+++ b/src/avg.c
@@ -31,7 +31,7 @@
/*
* Process options
*/
-void avg_getopts(effp, n, argv)
+int st_avg_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -50,15 +50,19 @@
else if (!strcmp(argv[0], "-r"))
avg->mix = MIX_RIGHT;
else
+ {
fail("Usage: avg [ -l | -r ]");
+ return (ST_EOF);
+ }
}
+ return (ST_SUCCESS);
}
/*
* Start processing
*/
-void
-avg_start(effp)
+
+int st_avg_start(effp)
eff_t effp;
{
switch (effp->outinfo.channels)
@@ -67,7 +71,7 @@
{
case 2:
case 4:
- return;
+ return (ST_SUCCESS);
default:
break;
}
@@ -76,7 +80,7 @@
{
case 1:
case 4:
- return;
+ return (ST_SUCCESS);
default:
break;
}
@@ -85,7 +89,7 @@
{
case 1:
case 2:
- return;
+ return (ST_SUCCESS);
default:
break;
}
@@ -94,6 +98,7 @@
}
fail("Can't average %d channels into %d channels",
effp->ininfo.channels, effp->outinfo.channels);
+ return (ST_EOF);
}
/*
@@ -100,7 +105,7 @@
* Process either isamp or osamp samples, whichever is smaller.
*/
-void avg_flow(effp, ibuf, obuf, isamp, osamp)
+int st_avg_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -264,6 +269,7 @@
}
break;
} /* end switch out channels */
+ return (ST_SUCCESS);
}
/*
@@ -272,9 +278,9 @@
*
* Should have statistics on right, left, and output amplitudes.
*/
-void avg_stop(effp)
+int st_avg_stop(effp)
eff_t effp;
{
- /* nothing to do */
+ return (ST_SUCCESS); /* nothing to do */
}
--- a/src/band.c
+++ b/src/band.c
@@ -59,7 +59,7 @@
/*
* Process options
*/
-void band_getopts(effp, n, argv)
+int st_band_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -73,21 +73,31 @@
argv++;
}
if ((n < 1) || !sscanf(argv[0], "%f", &band->center))
+ {
fail("Usage: band [ -n ] center [ width ]");
+ return (ST_EOF);
+ }
band->width = band->center / 2;
if ((n >= 2) && !sscanf(argv[1], "%f", &band->width))
+ {
fail("Usage: band [ -n ] center [ width ]");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void band_start(effp)
+int st_band_start(effp)
eff_t effp;
{
band_t band = (band_t) effp->priv;
if (band->center > effp->ininfo.rate/2)
+ {
fail("Band: center must be < minimum data rate/2\n");
+ return (ST_EOF);
+ }
band->C = exp(-2*M_PI*band->width/effp->ininfo.rate);
band->B = -4*band->C/(1+band->C)*
@@ -98,6 +108,7 @@
else
band->A = sqrt(1-band->B*band->B/(4*band->C))*(1-band->C);
band->out1 = band->out2 = 0.0;
+ return (ST_SUCCESS);
}
/*
@@ -105,7 +116,7 @@
* Return number of samples processed.
*/
-void band_flow(effp, ibuf, obuf, isamp, osamp)
+int st_band_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -127,6 +138,7 @@
}
*isamp = len;
*osamp = len;
+ return(ST_SUCCESS);
}
/*
@@ -133,9 +145,9 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void band_stop(effp)
+int st_band_stop(effp)
eff_t effp;
{
- /* nothing to do */
+ return (ST_SUCCESS); /* nothing to do */
}
--- a/src/bandpass.c
+++ b/src/bandpass.c
@@ -36,10 +36,7 @@
#include "st.h"
#include "btrworth.h"
-
-
-void
-bandpass_getopts (effp, n, argv)
+int st_bandpass_getopts (effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -48,23 +45,26 @@
if (n != 2) {
fail("Usage: bandpass FREQUENCY BANDWIDTH");
+ return (ST_EOF);
}
- butterworth_start (effp);
+ st_butterworth_start (effp);
if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
fail("bandpass: illegal frequency");
+ return (ST_EOF);
}
if (!(sscanf (argv [1], "%lf", &butterworth->bandwidth))) {
fail("bandpass: illegal bandwidth");
+ return (ST_EOF);
}
+ return (ST_SUCCESS);
}
-void
-bandpass_start (effp)
+int st_bandpass_start (effp)
eff_t effp;
{
butterworth_t butterworth = (butterworth_t) effp->priv;
@@ -80,5 +80,6 @@
butterworth->b [0] = -c * d * butterworth->a [0];
butterworth->b [1] = (c - 1.0) * butterworth->a[0];
+ return (ST_SUCCESS);
}
--- a/src/breject.c
+++ b/src/breject.c
@@ -36,10 +36,7 @@
#include "st.h"
#include "btrworth.h"
-
-
-void
-bandreject_getopts (effp, n, argv)
+int st_bandreject_getopts (effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -48,23 +45,24 @@
if (n != 2) {
fail("Usage: bandreject FREQUENCY BANDWIDTH");
+ return (ST_EOF);
}
- butterworth_start (effp);
+ st_butterworth_start (effp);
if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
fail("bandreject: illegal frequency");
+ return (ST_EOF);
}
if (!(sscanf (argv [1], "%lf", &butterworth->bandwidth))) {
fail("bandreject: illegal bandwidth");
+ return (ST_EOF);
}
+ return (ST_SUCCESS);
}
-
-
-void
-bandreject_start (effp)
+int st_bandreject_start (effp)
eff_t effp;
{
butterworth_t butterworth = (butterworth_t) effp->priv;
@@ -80,5 +78,5 @@
butterworth->b [0] = butterworth->a[1];
butterworth->b [1] = (1.0 - c) * butterworth->a[0];
+ return (ST_SUCCESS);
}
-
--- a/src/btrworth.c
+++ b/src/btrworth.c
@@ -36,10 +36,7 @@
#include "st.h"
#include "btrworth.h"
-
-
-void
-butterworth_start (effp)
+int st_butterworth_start (effp)
eff_t effp;
{
butterworth_t butterworth = (butterworth_t) effp->priv;
@@ -48,12 +45,10 @@
butterworth->x [1] = 0.0;
butterworth->y [0] = 0.0;
butterworth->y [1] = 0.0;
+ return (ST_SUCCESS);
}
-
-
-void
-butterworth_flow (effp, ibuf, obuf, isamp, osamp)
+int st_butterworth_flow (effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -101,5 +96,6 @@
*isamp = len;
*osamp = len;
+ return (ST_SUCCESS);
}
--- a/src/btrworth.h
+++ b/src/btrworth.h
@@ -31,9 +31,9 @@
*/
-void butterworth_start (P1 (eff_t effp));
-void butterworth_flow (P5 (eff_t effp, LONG *ibuf, LONG *obuf,
- LONG *isamp, LONG *osamp));
+int st_butterworth_start (P1 (eff_t effp));
+int st_butterworth_flow (P5 (eff_t effp, LONG *ibuf, LONG *obuf,
+ LONG *isamp, LONG *osamp));
typedef struct butterworth {
double x [2];
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -90,7 +90,7 @@
/*
* Process options
*/
-void chorus_getopts(effp, n, argv)
+int st_chorus_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -102,13 +102,19 @@
i = 0;
if ( ( n < 7 ) || (( n - 2 ) % 5 ) )
+ {
fail("Usage: chorus gain-in gain-out delay decay speed depth [ -s | -t ]");
+ return (ST_EOF);
+ }
sscanf(argv[i++], "%f", &chorus->in_gain);
sscanf(argv[i++], "%f", &chorus->out_gain);
while ( i < n ) {
if ( chorus->num_chorus > MAX_CHORUS )
+ {
fail("chorus: to many delays, use less than %i delays", MAX_CHORUS);
+ return (ST_EOF);
+ }
sscanf(argv[i++], "%f", &chorus->delay[chorus->num_chorus]);
sscanf(argv[i++], "%f", &chorus->decay[chorus->num_chorus]);
sscanf(argv[i++], "%f", &chorus->speed[chorus->num_chorus]);
@@ -118,16 +124,20 @@
else if ( ! strcmp(argv[i], "-t"))
chorus->modulation[chorus->num_chorus] = MOD_TRIANGLE;
else
+ {
fail("Usage: chorus gain-in gain-out delay decay speed [ -s | -t ]");
+ return (ST_EOF);
+ }
i++;
chorus->num_chorus++;
}
+ return (ST_SUCCESS);
}
/*
* Prepare for processing.
*/
-void chorus_start(effp)
+int st_chorus_start(effp)
eff_t effp;
{
chorus_t chorus = (chorus_t) effp->priv;
@@ -137,11 +147,20 @@
chorus->maxsamples = 0;
if ( chorus->in_gain < 0.0 )
+ {
fail("chorus: gain-in must be positive!\n");
+ return (ST_EOF);
+ }
if ( chorus->in_gain > 1.0 )
+ {
fail("chorus: gain-in must be less than 1.0!\n");
+ return (ST_EOF);
+ }
if ( chorus->out_gain < 0.0 )
+ {
fail("chorus: gain-out must be positive!\n");
+ return (ST_EOF);
+ }
for ( i = 0; i < chorus->num_chorus; i++ ) {
chorus->samples[i] = (int) ( ( chorus->delay[i] +
chorus->depth[i] ) * effp->ininfo.rate / 1000.0);
@@ -149,26 +168,53 @@
effp->ininfo.rate / 1000.0);
if ( chorus->delay[i] < 20.0 )
+ {
fail("chorus: delay must be more than 20.0 msec!\n");
+ return (ST_EOF);
+ }
if ( chorus->delay[i] > 100.0 )
+ {
fail("chorus: delay must be less than 100.0 msec!\n");
+ return (ST_EOF);
+ }
if ( chorus->speed[i] < 0.1 )
+ {
fail("chorus: speed must be more than 0.1 Hz!\n");
+ return (ST_EOF);
+ }
if ( chorus->speed[i] > 5.0 )
+ {
fail("chorus: speed must be less than 5.0 Hz!\n");
+ return (ST_EOF);
+ }
if ( chorus->depth[i] < 0.0 )
+ {
fail("chorus: delay must be more positive!\n");
+ return (ST_EOF);
+ }
if ( chorus->depth[i] > 10.0 )
- fail("chorus: delay must be less than 10.0 msec!\n");
+ {
+ fail("chorus: delay must be less than 10.0 msec!\n");
+ return (ST_EOF);
+ }
if ( chorus->decay[i] < 0.0 )
+ {
fail("chorus: decay must be positive!\n" );
+ return (ST_EOF);
+ }
if ( chorus->decay[i] > 1.0 )
+ {
fail("chorus: decay must be less that 1.0!\n" );
+ return (ST_EOF);
+ }
chorus->length[i] = effp->ininfo.rate / chorus->speed[i];
if (! (chorus->lookup_tab[i] =
(int *) malloc(sizeof (int) * chorus->length[i])))
+ {
fail("chorus: Cannot malloc %d bytes!\n",
sizeof(int) * chorus->length[i]);
+ return (ST_EOF);
+ }
if ( chorus->modulation[i] == MOD_SINE )
st_sine(chorus->lookup_tab[i], chorus->length[i],
chorus->depth_samples[i] - 1,
@@ -193,13 +239,17 @@
if (! (chorus->chorusbuf =
(float *) malloc(sizeof (float) * chorus->maxsamples)))
+ {
fail("chorus: Cannot malloc %d bytes!\n",
sizeof(float) * chorus->maxsamples);
+ return (ST_EOF);
+ }
for ( i = 0; i < chorus->maxsamples; i++ )
chorus->chorusbuf[i] = 0.0;
chorus->counter = 0;
chorus->fade_out = chorus->maxsamples;
+ return (ST_SUCCESS);
}
/*
@@ -207,7 +257,7 @@
* Return number of samples processed.
*/
-void chorus_flow(effp, ibuf, obuf, isamp, osamp)
+int st_chorus_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -242,12 +292,13 @@
( chorus->phase[i] + 1 ) % chorus->length[i];
}
/* processed all samples */
+ return (ST_SUCCESS);
}
/*
* Drain out reverb lines.
*/
-void chorus_drain(effp, obuf, osamp)
+int st_chorus_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -284,12 +335,13 @@
}
/* samples played, it remains */
*osamp = done;
+ return (ST_SUCCESS);
}
/*
* Clean up chorus effect.
*/
-void chorus_stop(effp)
+int st_chorus_stop(effp)
eff_t effp;
{
chorus_t chorus = (chorus_t) effp->priv;
@@ -301,5 +353,5 @@
free((char *) chorus->lookup_tab[i]);
chorus->lookup_tab[i] = (int *) -1; /* guaranteed core dump */
}
+ return (ST_SUCCESS);
}
-
--- a/src/compand.c
+++ b/src/compand.c
@@ -38,7 +38,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-void compand_getopts(effp, n, argv)
+int st_compand_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -46,6 +46,7 @@
compand_t l = (compand_t) effp->priv;
if (n < 2 || n > 4)
+ {
fail("Wrong number of arguments for the compander effect\n"
"Use: {<attack_time>,<decay_time>}+ {<dB_in>,<db_out>}+ "
"[<dB_postamp>]\n"
@@ -53,6 +54,8 @@
"white-space-free list'\n"
"and [] indications possible omission. dB values are floating\n"
"point or `-inf'; times are in seconds.");
+ return (ST_EOF);
+ }
else { /* Right no. of args, but are they well formed? */
char *s;
int rates, tfers, i, commas;
@@ -64,7 +67,10 @@
if (commas % 2 == 0) /* There must be an even number of
attack/decay parameters */
+ {
fail("compander: Odd number of attack & decay rate parameters");
+ return (ST_EOF);
+ }
rates = 1 + commas/2;
if ((l->attackRate = malloc(sizeof(double) * rates)) == NULL ||
@@ -71,7 +77,10 @@
(l->decayRate = malloc(sizeof(double) * rates)) == NULL ||
(l->volume = malloc(sizeof(double) * rates)) == NULL ||
(l->lastSamp = calloc(rates, sizeof(LONG))) == NULL)
+ {
fail("Out of memory");
+ return (ST_EOF);
+ }
l->expectedChannels = rates;
/* Now tokenise the rates string and set up these arrays. Keep
@@ -91,13 +100,19 @@
if (commas % 2 == 0) /* There must be an even number of
transfer parameters */
+ {
fail("compander: Odd number of transfer function parameters\n"
"Each input value in dB must have a corresponding output value");
+ return (ST_EOF);
+ }
tfers = 3 + commas/2; /* 0, 0 at start; 1, 1 at end */
if ((l->transferIns = malloc(sizeof(double) * tfers)) == NULL ||
(l->transferOuts = malloc(sizeof(double) * tfers)) == NULL)
+ {
fail("Out of memory");
+ return (ST_EOF);
+ }
l->transferPoints = tfers;
l->transferIns[0] = 0.0; l->transferOuts[0] = 0.0;
l->transferIns[tfers-1] = 1.0; l->transferOuts[tfers-1] = 1.0;
@@ -104,16 +119,25 @@
s = strtok(argv[1], ","); i = 1;
do {
if (!strcmp(s, "-inf"))
+ {
fail("Input signals of zero level must always generate zero output");
+ return (ST_EOF);
+ }
l->transferIns[i] = pow(10.0, atof(s)/20.0);
if (l->transferIns[i] > 1.0)
+ {
fail("dB values are relative to maximum input, and, ipso facto, "
"cannot exceed 0");
+ return (ST_EOF);
+ }
if (l->transferIns[i] == 1.0) /* Final point was explicit */
--(l->transferPoints);
if (i > 0 && l->transferIns[i] <= l->transferIns[i-1])
+ {
fail("Transfer function points don't have strictly ascending "
"input amplitude");
+ return (ST_EOF);
+ }
s = strtok(NULL, ",");
l->transferOuts[i] = strcmp(s, "-inf") ?
pow(10.0, atof(s)/20.0) : 0;
@@ -133,6 +157,7 @@
l->volume[i] = v;
}
}
+ return (ST_SUCCESS);
}
/*
@@ -139,7 +164,7 @@
* Prepare processing.
* Do all initializations.
*/
-void compand_start(effp)
+int st_compand_start(effp)
eff_t effp;
{
compand_t l = (compand_t) effp->priv;
@@ -180,6 +205,7 @@
else
l->decayRate[i] = 1.0;
}
+ return (ST_SUCCESS);
}
/*
@@ -203,7 +229,7 @@
* Return number of samples processed.
*/
-void compand_flow(effp, ibuf, obuf, isamp, osamp)
+int st_compand_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
int *isamp, *osamp;
@@ -260,4 +286,5 @@
}
*isamp = len; *osamp = len;
+ return (ST_SUCCESS);
}
--- a/src/copy.c
+++ b/src/copy.c
@@ -16,23 +16,28 @@
/*
* Process options
*/
-void copy_getopts(effp, n, argv)
+int st_copy_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Copy effect takes no options.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Start processing
*/
-void copy_start(effp)
+int st_copy_start(effp)
eff_t effp;
{
/* nothing to do */
/* stuff data into delaying effects here */
+ return (ST_SUCCESS);
}
/*
@@ -42,7 +47,7 @@
* Return number of samples read.
*/
-void copy_flow(effp, ibuf, obuf, isamp, osamp)
+int st_copy_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -52,7 +57,7 @@
done = ((*isamp < *osamp) ? *isamp : *osamp);
memcpy(obuf, ibuf, done * sizeof(LONG));
*isamp = *osamp = done;
- return;
+ return (ST_SUCCESS);
}
/*
@@ -59,10 +64,11 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void copy_stop(effp)
+int st_copy_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -113,15 +113,22 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-void deemph_getopts(effp, n, argv)
+int st_deemph_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Deemphasis filtering effect takes no options.\n");
+ return (ST_EOF);
+ }
if (sizeof(double)*ST_MAX_PRIVSIZE < sizeof(struct deemphstuff))
+ {
fail("Internal error: PRIVSIZE too small.\n");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -128,7 +135,7 @@
* Prepare processing.
* Do all initializations.
*/
-void deemph_start(effp)
+int st_deemph_start(effp)
eff_t effp;
{
/* check the input format */
@@ -135,9 +142,13 @@
if (effp->ininfo.style != ST_ENCODING_SIGN2
|| effp->ininfo.rate != 44100
|| effp->ininfo.size != ST_SIZE_WORD)
+ {
fail("The deemphasis effect works only with audio cd like samples.\nThe input format however has %d Hz sample rate and %d-byte%s signed linearly coded samples.",
effp->ininfo.rate, effp->ininfo.size,
effp->ininfo.style != ST_ENCODING_SIGN2 ? ", but not" : "");
+ return (ST_EOF);
+ }
+ else
{
deemph_t deemph = (deemph_t) effp->priv;
@@ -144,6 +155,7 @@
deemph->lastin = 0;
deemph->lastout = 0.0;
}
+ return (ST_SUCCESS);
}
/*
@@ -156,7 +168,7 @@
#define b0 0.45995451989513153057
#define b1 -0.08782333709141937339
-void deemph_flow(effp, ibuf, obuf, isamp, osamp)
+int st_deemph_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -174,6 +186,7 @@
deemph->lastout + 0.5 :
deemph->lastout - 0.5;
}
+ return (ST_SUCCESS);
}
/*
@@ -180,11 +193,12 @@
* Drain out remaining samples if the effect generates any.
*/
-void deemph_drain(effp, obuf, osamp)
+int st_deemph_drain(effp, obuf, osamp)
LONG *obuf;
LONG *osamp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
/*
@@ -191,8 +205,9 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-void deemph_stop(effp)
+int st_deemph_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/src/echo.c
+++ b/src/echo.c
@@ -79,7 +79,7 @@
/*
* Process options
*/
-void echo_getopts(effp, n, argv)
+int st_echo_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -90,7 +90,10 @@
echo->num_delays = 0;
if ((n < 4) || (n % 2))
+ {
fail("Usage: echo gain-in gain-out delay decay [ delay decay ... ]");
+ return (ST_EOF);
+ }
i = 0;
sscanf(argv[i++], "%f", &echo->in_gain);
@@ -104,12 +107,13 @@
sscanf(argv[i++], "%f", &echo->decay[echo->num_delays]);
echo->num_delays++;
}
+ return (ST_SUCCESS);
}
/*
* Prepare for processing.
*/
-void echo_start(effp)
+int st_echo_start(effp)
eff_t effp;
{
echo_t echo = (echo_t) effp->priv;
@@ -119,28 +123,52 @@
echo->maxsamples = 0L;
if ( echo->in_gain < 0.0 )
+ {
fail("echo: gain-in must be positive!\n");
+ return (ST_EOF);
+ }
if ( echo->in_gain > 1.0 )
+ {
fail("echo: gain-in must be less than 1.0!\n");
+ return (ST_EOF);
+ }
if ( echo->out_gain < 0.0 )
+ {
fail("echo: gain-in must be positive!\n");
+ return (ST_EOF);
+ }
for ( i = 0; i < echo->num_delays; i++ ) {
echo->samples[i] = echo->delay[i] * effp->ininfo.rate / 1000.0;
if ( echo->samples[i] < 1 )
+ {
fail("echo: delay must be positive!\n");
+ return (ST_EOF);
+ }
if ( echo->samples[i] > DELAY_BUFSIZ )
+ {
fail("echo: delay must be less than %g seconds!\n",
DELAY_BUFSIZ / (float) effp->ininfo.rate );
+ return (ST_EOF);
+ }
if ( echo->decay[i] < 0.0 )
+ {
fail("echo: decay must be positive!\n" );
+ return (ST_EOF);
+ }
if ( echo->decay[i] > 1.0 )
+ {
fail("echo: decay must be less than 1.0!\n" );
+ return (ST_EOF);
+ }
if ( echo->samples[i] > echo->maxsamples )
echo->maxsamples = echo->samples[i];
}
if (! (echo->delay_buf = (double *) malloc(sizeof (double) * echo->maxsamples)))
+ {
fail("echo: Cannot malloc %d bytes!\n",
sizeof(long) * echo->maxsamples);
+ return (ST_EOF);
+ }
for ( j = 0; j < echo->maxsamples; ++j )
echo->delay_buf[j] = 0.0;
/* Be nice and check the hint with warning, if... */
@@ -151,6 +179,7 @@
warn("echo: warning >>> gain-out can cause saturation of output <<<");
echo->counter = 0;
echo->fade_out = echo->maxsamples;
+ return (ST_SUCCESS);
}
/*
@@ -158,7 +187,7 @@
* Return number of samples processed.
*/
-void echo_flow(effp, ibuf, obuf, isamp, osamp)
+int st_echo_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -191,12 +220,13 @@
echo->counter = ( echo->counter + 1 ) % echo->maxsamples;
}
/* processed all samples */
+ return (ST_SUCCESS);
}
/*
* Drain out reverb lines.
*/
-void echo_drain(effp, obuf, osamp)
+int st_echo_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -230,12 +260,13 @@
};
/* samples played, it remains */
*osamp = done;
+ return (ST_SUCCESS);
}
/*
* Clean up reverb effect.
*/
-void echo_stop(effp)
+int st_echo_stop(effp)
eff_t effp;
{
echo_t echo = (echo_t) effp->priv;
@@ -242,5 +273,5 @@
free((char *) echo->delay_buf);
echo->delay_buf = (double *) -1; /* guaranteed core dump */
+ return (ST_SUCCESS);
}
-
--- a/src/echos.c
+++ b/src/echos.c
@@ -69,7 +69,7 @@
/*
* Process options
*/
-void echos_getopts(effp, n, argv)
+int st_echos_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -80,7 +80,10 @@
echos->num_delays = 0;
if ((n < 4) || (n % 2))
+ {
fail("Usage: echos gain-in gain-out delay decay [ delay decay ... ]");
+ return (ST_EOF);
+ }
i = 0;
sscanf(argv[i++], "%f", &echos->in_gain);
@@ -91,16 +94,20 @@
sscanf(argv[i++], "%f", &echos->decay[echos->num_delays]);
echos->num_delays++;
if ( echos->num_delays > MAX_ECHOS )
+ {
fail("echos: to many delays, use less than %i delays",
MAX_ECHOS);
+ return (ST_EOF);
+ }
}
echos->sumsamples = 0;
+ return (ST_SUCCESS);
}
/*
* Prepare for processing.
*/
-void echos_start(effp)
+int st_echos_start(effp)
eff_t effp;
{
echos_t echos = (echos_t) effp->priv;
@@ -109,29 +116,53 @@
long j;
if ( echos->in_gain < 0.0 )
+ {
fail("echos: gain-in must be positive!\n");
+ return (ST_EOF);
+ }
if ( echos->in_gain > 1.0 )
+ {
fail("echos: gain-in must be less than 1.0!\n");
+ return (ST_EOF);
+ }
if ( echos->out_gain < 0.0 )
+ {
fail("echos: gain-in must be positive!\n");
+ return (ST_EOF);
+ }
for ( i = 0; i < echos->num_delays; i++ ) {
echos->samples[i] = echos->delay[i] * effp->ininfo.rate / 1000.0;
if ( echos->samples[i] < 1 )
+ {
fail("echos: delay must be positive!\n");
+ return (ST_EOF);
+ }
if ( echos->samples[i] > DELAY_BUFSIZ )
+ {
fail("echos: delay must be less than %g seconds!\n",
DELAY_BUFSIZ / (float) effp->ininfo.rate );
+ return (ST_EOF);
+ }
if ( echos->decay[i] < 0.0 )
+ {
fail("echos: decay must be positive!\n" );
+ return (ST_EOF);
+ }
if ( echos->decay[i] > 1.0 )
+ {
fail("echos: decay must be less than 1.0!\n" );
+ return (ST_EOF);
+ }
echos->counter[i] = 0;
echos->pointer[i] = echos->sumsamples;
echos->sumsamples += echos->samples[i];
}
if (! (echos->delay_buf = (double *) malloc(sizeof (double) * echos->sumsamples)))
+ {
fail("echos: Cannot malloc %d bytes!\n",
sizeof(double) * echos->sumsamples);
+ return(ST_EOF);
+ }
for ( j = 0; j < echos->sumsamples; ++j )
echos->delay_buf[j] = 0.0;
/* Be nice and check the hint with warning, if... */
@@ -140,6 +171,7 @@
sum_in_volume += echos->decay[i];
if ( sum_in_volume * echos->in_gain > 1.0 / echos->out_gain )
warn("echos: warning >>> gain-out can cause saturation of output <<<");
+ return (ST_SUCCESS);
}
/*
@@ -147,7 +179,7 @@
* Return number of samples processed.
*/
-void echos_flow(effp, ibuf, obuf, isamp, osamp)
+int st_echos_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -186,12 +218,13 @@
( echos->counter[j] + 1 ) % echos->samples[j];
}
/* processed all samples */
+ return (ST_SUCCESS);
}
/*
* Drain out reverb lines.
*/
-void echos_drain(effp, obuf, osamp)
+int st_echos_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -231,12 +264,13 @@
};
/* samples played, it remains */
*osamp = done;
+ return (ST_SUCCESS);
}
/*
- * Clean up reverb effect.
+ * Clean up echos effect.
*/
-void echos_stop(effp)
+int st_echos_stop(effp)
eff_t effp;
{
echos_t echos = (echos_t) effp->priv;
@@ -243,5 +277,6 @@
free((char *) echos->delay_buf);
echos->delay_buf = (double *) -1; /* guaranteed core dump */
+ return (ST_SUCCESS);
}
--- a/src/filter.c
+++ b/src/filter.c
@@ -59,7 +59,7 @@
/*
* Process options
*/
-void filter_getopts(effp, n, argv)
+int st_filter_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -84,24 +84,35 @@
}
/* fprintf(stderr,"freq: %d-%d\n", f->freq0, f->freq1);fflush(stderr); */
if (f->freq0 == 0 && f->freq1 == 0)
+ {
fail("Usage: filter low-high [ windowlength [ beta ] ]");
+ return (ST_EOF);
+ }
if ((n >= 2) && !sscanf(argv[1], "%ld", &f->Nwin))
+ {
fail("Usage: filter low-high [ windowlength ]");
+ return (ST_EOF);
+ }
else if (f->Nwin < 4) {
fail("filter: window length (%ld) <4 is too short", f->Nwin);
+ return (ST_EOF);
}
if ((n >= 3) && !sscanf(argv[2], "%lf", &f->beta))
+ {
fail("Usage: filter low-high [ windowlength [ beta ] ]");
+ return (ST_EOF);
+ }
report("filter opts: %d-%d, window-len %d, beta %f\n", f->freq0, f->freq1, f->Nwin, f->beta);
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void filter_start(effp)
+int st_filter_start(effp)
eff_t effp;
{
filter_t f = (filter_t) effp->priv;
@@ -116,8 +127,11 @@
f->freq1 = f->rate/2;
if ((f->freq0 < 0) || (f->freq0 > f->freq1))
+ {
fail("filter: low(%d),high(%d) parameters must satisfy 0 <= low <= high <= %d",
f->freq0, f->freq1, f->rate/2);
+ return (ST_EOF);
+ }
Xh = f->Nwin/2;
Fp0 = (Float *) malloc(sizeof(Float) * (Xh + 2)) + 1;
@@ -124,7 +138,10 @@
if (f->freq0 > f->rate/200) {
Xh0 = makeFilter(Fp0, Xh, 2.0*(double)f->freq0/f->rate, f->beta, 1, 0);
if (Xh0 <= 1)
+ {
fail("filter: Unable to make low filter\n");
+ return (ST_EOF);
+ }
} else {
Xh0 = 0;
}
@@ -133,7 +150,10 @@
if (f->freq1 < f->rate/2) {
Xh1 = makeFilter(Fp1, Xh, 2.0*(double)f->freq1/f->rate, f->beta, 1, 0);
if (Xh1 <= 1)
+ {
fail("filter: Unable to make high filter\n");
+ return (ST_EOF);
+ }
} else {
Fp1[0] = 1.0;
Xh1 = 1;
@@ -164,6 +184,7 @@
/* Need Xh zeros at beginning of X */
for (i = 0; i < Xh; i++)
f->X[i] = 0;
+ return (ST_SUCCESS);
}
/*
@@ -171,7 +192,7 @@
* Return number of samples processed.
*/
-void filter_flow(effp, ibuf, obuf, isamp, osamp)
+int st_filter_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -204,7 +225,7 @@
if (Nproc <= 0) {
f->Xt += Nx;
*osamp = 0;
- return;
+ return (ST_SUCCESS);
}
/* fprintf(stderr,"flow Nproc %d\n",Nproc); */
FiltWin(f, Nproc);
@@ -219,12 +240,13 @@
*obuf++ = f->Y[i] * ISCALE;
*osamp = Nproc;
+ return (ST_SUCCESS);
}
/*
* Process tail of input samples.
*/
-void filter_drain(effp, obuf, osamp)
+int st_filter_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -242,7 +264,7 @@
LONG Isamp, Osamp;
Isamp = isamp_res;
Osamp = osamp_res;
- filter_flow(effp, NULL, Obuf, &Isamp, &Osamp);
+ st_filter_flow(effp, NULL, Obuf, &Isamp, &Osamp);
/* fprintf(stderr,"DRAIN isamp,osamp (%d,%d) -> (%d,%d)\n",
* isamp_res,osamp_res,Isamp,Osamp); */
Obuf += Osamp;
@@ -253,6 +275,7 @@
/* fprintf(stderr,"DRAIN osamp %d\n", *osamp); */
if (isamp_res)
warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
+ return (ST_SUCCESS);
}
/*
@@ -259,7 +282,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void filter_stop(effp)
+int st_filter_stop(effp)
eff_t effp;
{
filter_t f = (filter_t) effp->priv;
@@ -266,6 +289,7 @@
free(f->Fp - 1);
free(f->X);
+ return (ST_SUCCESS);
}
static double jprod(Fp, Xp, ct)
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -79,7 +79,7 @@
/*
* Process options
*/
-void flanger_getopts(effp, n, argv)
+int st_flanger_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -87,7 +87,10 @@
flanger_t flanger = (flanger_t) effp->priv;
if (!((n == 5) || (n == 6)))
+ {
fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
+ return (ST_EOF);
+ }
sscanf(argv[0], "%f", &flanger->in_gain);
sscanf(argv[1], "%f", &flanger->out_gain);
@@ -101,14 +104,18 @@
else if ( ! strcmp(argv[5], "-t"))
flanger->modulation = MOD_TRIANGLE;
else
+ {
fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
+ return (ST_EOF);
+ }
}
+ return (ST_SUCCESS);
}
/*
* Prepare for processing.
*/
-void flanger_start(effp)
+int st_flanger_start(effp)
eff_t effp;
{
flanger_t flanger = (flanger_t) effp->priv;
@@ -117,23 +124,50 @@
flanger->maxsamples = flanger->delay * effp->ininfo.rate / 1000.0;
if ( flanger->in_gain < 0.0 )
+ {
fail("flanger: gain-in must be positive!\n");
+ return (ST_EOF);
+ }
if ( flanger->in_gain > 1.0 )
+ {
fail("flanger: gain-in must be less than 1.0!\n");
+ return (ST_EOF);
+ }
if ( flanger->out_gain < 0.0 )
+ {
fail("flanger: gain-out must be positive!\n");
+ return (ST_EOF);
+ }
if ( flanger->delay < 0.0 )
+ {
fail("flanger: delay must be positive!\n");
+ return (ST_EOF);
+ }
if ( flanger->delay > 5.0 )
+ {
fail("flanger: delay must be less than 5.0 msec!\n");
+ return (ST_EOF);
+ }
if ( flanger->speed < 0.1 )
+ {
fail("flanger: speed must be more than 0.1 Hz!\n");
+ return (ST_EOF);
+ }
if ( flanger->speed > 2.0 )
+ {
fail("flanger: speed must be less than 2.0 Hz!\n");
+ return (ST_EOF);
+ }
if ( flanger->decay < 0.0 )
+ {
fail("flanger: decay must be positive!\n" );
+ return (ST_EOF);
+ }
if ( flanger->decay > 1.0 )
+ {
fail("flanger: decay must be less that 1.0!\n" );
+ return (ST_EOF);
+ }
/* Be nice and check the hint with warning, if... */
if ( flanger->in_gain * ( 1.0 + flanger->decay ) > 1.0 / flanger->out_gain )
warn("flanger: warning >>> gain-out can cause saturation or clipping of output <<<");
@@ -142,14 +176,20 @@
if (! (flanger->flangerbuf =
(double *) malloc(sizeof (double) * flanger->maxsamples)))
+ {
fail("flanger: Cannot malloc %d bytes!\n",
sizeof(double) * flanger->maxsamples);
+ return (ST_EOF);
+ }
for ( i = 0; i < flanger->maxsamples; i++ )
flanger->flangerbuf[i] = 0.0;
if (! (flanger->lookup_tab =
(int *) malloc(sizeof (int) * flanger->length)))
+ {
fail("flanger: Cannot malloc %d bytes!\n",
sizeof(int) * flanger->length);
+ return(ST_EOF);
+ }
if ( flanger->modulation == MOD_SINE )
st_sine(flanger->lookup_tab, flanger->length,
@@ -162,6 +202,7 @@
flanger->counter = 0;
flanger->phase = 0;
flanger->fade_out = flanger->maxsamples;
+ return (ST_SUCCESS);
}
/*
@@ -169,7 +210,7 @@
* Return number of samples processed.
*/
-void flanger_flow(effp, ibuf, obuf, isamp, osamp)
+int st_flanger_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -200,12 +241,13 @@
flanger->phase = ( flanger->phase + 1 ) % flanger->length;
}
/* processed all samples */
+ return (ST_SUCCESS);
}
/*
* Drain out reverb lines.
*/
-void flanger_drain(effp, obuf, osamp)
+int st_flanger_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -238,12 +280,13 @@
}
/* samples playd, it remains */
*osamp = done;
+ return (ST_SUCCESS);
}
/*
* Clean up flanger effect.
*/
-void flanger_stop(effp)
+int st_flanger_stop(effp)
eff_t effp;
{
flanger_t flanger = (flanger_t) effp->priv;
@@ -252,5 +295,5 @@
flanger->flangerbuf = (double *) -1; /* guaranteed core dump */
free((char *) flanger->lookup_tab);
flanger->lookup_tab = (int *) -1; /* guaranteed core dump */
+ return (ST_SUCCESS);
}
-
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -447,164 +447,156 @@
/* Effects handlers. */
-extern LONG st_null_drain(); /* dummy drain routine */
+extern int st_null_drain(); /* dummy drain routine */
-extern void avg_getopts();
-extern void avg_start();
-extern void avg_flow();
-extern void avg_stop();
+extern int st_avg_getopts();
+extern int st_avg_start();
+extern int st_avg_flow();
+extern int st_avg_stop();
-extern void band_getopts();
-extern void band_start();
-extern void band_flow();
-extern void band_stop();
+extern int st_band_getopts();
+extern int st_band_start();
+extern int st_band_flow();
+extern int st_band_stop();
+extern int st_bandpass_getopts();
+extern int st_bandpass_start();
-extern void bandpass_getopts();
-extern void bandpass_start();
+extern int st_bandreject_getopts();
+extern int st_bandreject_start();
-extern void bandreject_getopts();
-extern void bandreject_start();
+extern int st_chorus_getopts();
+extern int st_chorus_start();
+extern int st_chorus_flow();
+extern int st_chorus_drain();
+extern int st_chorus_stop();
-extern void chorus_getopts();
-extern void chorus_start();
-extern void chorus_flow();
-extern void chorus_drain();
-extern void chorus_stop();
+extern int st_compand_getopts();
+extern int st_compand_start();
+extern int st_compand_flow();
-extern void compand_getopts();
-extern void compand_start();
-extern void compand_flow();
+extern int st_copy_getopts();
+extern int st_copy_start();
+extern int st_copy_flow();
+extern int st_copy_stop();
-extern void copy_getopts();
-extern void copy_start();
-extern void copy_flow();
-extern void copy_stop();
+extern int st_cut_getopts();
+extern int st_cut_start();
+extern int st_cut_flow();
+extern int st_cut_stop();
-extern void cut_getopts();
-extern void cut_start();
-extern void cut_flow();
-extern void cut_stop();
+extern int st_deemph_getopts();
+extern int st_deemph_start();
+extern int st_deemph_flow();
+extern int st_deemph_stop();
-extern void deemph_getopts();
-extern void deemph_start();
-extern void deemph_flow();
-extern void deemph_stop();
+extern int st_echo_getopts();
+extern int st_echo_start();
+extern int st_echo_flow();
+extern int st_echo_drain();
+extern int st_echo_stop();
-#ifdef USE_DYN
-extern void dyn_getopts();
-extern void dyn_start();
-extern void dyn_flow();
-extern void dyn_stop();
-#endif
+extern int st_echos_getopts();
+extern int st_echos_start();
+extern int st_echos_flow();
+extern int st_echos_drain();
+extern int st_echos_stop();
-extern void echo_getopts();
-extern void echo_start();
-extern void echo_flow();
-extern void echo_drain();
-extern void echo_stop();
+extern int st_filter_getopts();
+extern int st_filter_start();
+extern int st_filter_flow();
+extern int st_filter_drain();
+extern int st_filter_stop();
-extern void echos_getopts();
-extern void echos_start();
-extern void echos_flow();
-extern void echos_drain();
-extern void echos_stop();
+extern int st_flanger_getopts();
+extern int st_flanger_start();
+extern int st_flanger_flow();
+extern int st_flanger_drain();
+extern int st_flanger_stop();
-extern void filter_getopts();
-extern void filter_start();
-extern void filter_flow();
-extern void filter_drain();
-extern void filter_stop();
+extern int st_highp_getopts();
+extern int st_highp_start();
+extern int st_highp_flow();
+extern int st_highp_stop();
-extern void flanger_getopts();
-extern void flanger_start();
-extern void flanger_flow();
-extern void flanger_drain();
-extern void flanger_stop();
+extern int st_highpass_getopts();
+extern int st_highpass_start();
-extern void highp_getopts();
-extern void highp_start();
-extern void highp_flow();
-extern void highp_stop();
+extern int st_lowp_getopts();
+extern int st_lowp_start();
+extern int st_lowp_flow();
+extern int st_lowp_stop();
-extern void highpass_getopts();
-extern void highpass_start();
+extern int st_lowpass_getopts();
+extern int st_lowpass_start();
-extern void lowp_getopts();
-extern void lowp_start();
-extern void lowp_flow();
-extern void lowp_stop();
+extern int st_map_getopts();
+extern int st_map_start();
+extern int st_map_flow();
-extern void lowpass_getopts();
-extern void lowpass_start();
+extern int st_mask_getopts();
+extern int st_mask_flow();
-extern void map_getopts();
-extern void map_start();
-extern void map_flow();
+extern int st_phaser_getopts();
+extern int st_phaser_start();
+extern int st_phaser_flow();
+extern int st_phaser_drain();
+extern int st_phaser_stop();
-extern void mask_getopts();
-extern void mask_flow();
+extern int st_pick_getopts();
+extern int st_pick_start();
+extern int st_pick_flow();
+extern int st_pick_stop();
-extern void phaser_getopts();
-extern void phaser_start();
-extern void phaser_flow();
-extern void phaser_drain();
-extern void phaser_stop();
+extern int st_poly_getopts();
+extern int st_poly_start();
+extern int st_poly_flow();
+extern int st_poly_drain();
+extern int st_poly_stop();
-extern void pick_getopts();
-extern void pick_start();
-extern void pick_flow();
-extern void pick_stop();
+extern int st_rate_getopts();
+extern int st_rate_start();
+extern int st_rate_flow();
+extern int st_rate_stop();
-extern void poly_getopts();
-extern void poly_start();
-extern void poly_flow();
-extern void poly_drain();
-extern void poly_stop();
+extern int st_resample_getopts();
+extern int st_resample_start();
+extern int st_resample_flow();
+extern int st_resample_drain();
+extern int st_resample_stop();
-extern void rate_getopts();
-extern void rate_start();
-extern void rate_flow();
-extern void rate_stop();
+extern int st_reverb_getopts();
+extern int st_reverb_start();
+extern int st_reverb_flow();
+extern int st_reverb_drain();
+extern int st_reverb_stop();
-extern void resample_getopts();
-extern void resample_start();
-extern void resample_flow();
-extern void resample_drain();
-extern void resample_stop();
+extern int st_reverse_getopts();
+extern int st_reverse_start();
+extern int st_reverse_flow();
+extern int st_reverse_drain();
+extern int st_reverse_stop();
-extern void reverb_getopts();
-extern void reverb_start();
-extern void reverb_flow();
-extern void reverb_drain();
-extern void reverb_stop();
+extern int st_split_getopts();
+extern int st_split_start();
+extern int st_split_flow();
+extern int st_split_stop();
-extern void reverse_getopts();
-extern void reverse_start();
-extern void reverse_flow();
-extern void reverse_drain();
-extern void reverse_stop();
+extern int st_stat_getopts();
+extern int st_stat_start();
+extern int st_stat_flow();
+extern int st_stat_stop();
-extern void split_getopts();
-extern void split_start();
-extern void split_flow();
-extern void split_stop();
+extern int st_swap_getopts();
+extern int st_swap_start();
+extern int st_swap_flow();
+extern int st_swap_drain();
+extern int st_swap_stop();
-extern void stat_getopts();
-extern void stat_start();
-extern void stat_flow();
-extern void stat_stop();
+extern int st_vibro_getopts();
+extern int st_vibro_start();
+extern int st_vibro_flow();
+extern int st_vibro_stop();
-extern void swap_getopts();
-extern void swap_start();
-extern void swap_flow();
-extern void swap_drain();
-extern void swap_stop();
-
-extern void vibro_getopts();
-extern void vibro_start();
-extern void vibro_flow();
-extern void vibro_stop();
-
/*
* EFF_CHAN means that the number of channels can change.
* EFF_RATE means that the sample rate can change.
@@ -619,99 +611,94 @@
st_nothing, st_nothing, st_nothing,
st_null_drain, st_nothing},
{"avg", ST_EFF_CHAN | ST_EFF_MCHAN,
- avg_getopts, avg_start, avg_flow,
- st_null_drain, avg_stop},
+ st_avg_getopts, st_avg_start, st_avg_flow,
+ st_null_drain, st_avg_stop},
{"band", 0,
- band_getopts, band_start, band_flow,
- st_null_drain, band_stop},
+ st_band_getopts, st_band_start, st_band_flow,
+ st_null_drain, st_band_stop},
{"bandpass", 0,
- bandpass_getopts, bandpass_start, butterworth_flow,
+ st_bandpass_getopts, st_bandpass_start, st_butterworth_flow,
st_null_drain, st_nothing},
{"bandreject", 0,
- bandreject_getopts, bandreject_start, butterworth_flow,
+ st_bandreject_getopts, st_bandreject_start, st_butterworth_flow,
st_null_drain, st_nothing},
{"chorus", 0,
- chorus_getopts, chorus_start, chorus_flow,
- chorus_drain, chorus_stop},
+ st_chorus_getopts, st_chorus_start, st_chorus_flow,
+ st_chorus_drain, st_chorus_stop},
{"compand", ST_EFF_MCHAN,
- compand_getopts, compand_start, compand_flow,
+ st_compand_getopts, st_compand_start, st_compand_flow,
st_null_drain, st_nothing},
{"copy", ST_EFF_MCHAN,
- copy_getopts, copy_start, copy_flow,
+ st_copy_getopts, st_copy_start, st_copy_flow,
st_null_drain, st_nothing},
{"cut", ST_EFF_MCHAN,
- cut_getopts, cut_start, cut_flow,
+ st_cut_getopts, st_cut_start, st_cut_flow,
st_null_drain, st_nothing},
{"deemph", ST_EFF_MCHAN,
- deemph_getopts, deemph_start, deemph_flow,
- st_null_drain, deemph_stop},
-#ifdef USE_DYN
- {"dyn", 0,
- dyn_getopts, dyn_start, dyn_flow,
- st_null_drain, dyn_stop},
-#endif
+ st_deemph_getopts, st_deemph_start, st_deemph_flow,
+ st_null_drain, st_deemph_stop},
{"echo", 0,
- echo_getopts, echo_start, echo_flow,
- echo_drain, echo_stop},
+ st_echo_getopts, st_echo_start, st_echo_flow,
+ st_echo_drain, st_echo_stop},
{"echos", 0,
- echos_getopts, echos_start, echos_flow,
- echos_drain, echos_stop},
+ st_echos_getopts, st_echos_start, st_echos_flow,
+ st_echos_drain, st_echos_stop},
{ "filter", 0,
- filter_getopts, filter_start, filter_flow,
- filter_drain, filter_stop},
+ st_filter_getopts, st_filter_start, st_filter_flow,
+ st_filter_drain, st_filter_stop},
{"flanger", 0,
- flanger_getopts, flanger_start, flanger_flow,
- flanger_drain, flanger_stop},
+ st_flanger_getopts, st_flanger_start, st_flanger_flow,
+ st_flanger_drain, st_flanger_stop},
{"highp", 0,
- highp_getopts, highp_start, highp_flow,
- st_null_drain,highp_stop},
+ st_highp_getopts, st_highp_start, st_highp_flow,
+ st_null_drain, st_highp_stop},
{"highpass", 0,
- highpass_getopts, highpass_start, butterworth_flow,
+ st_highpass_getopts, st_highpass_start, st_butterworth_flow,
st_null_drain, st_nothing},
{"lowp", 0,
- lowp_getopts, lowp_start, lowp_flow,
- st_null_drain, lowp_stop},
+ st_lowp_getopts, st_lowp_start, st_lowp_flow,
+ st_null_drain, st_lowp_stop},
{"lowpass", 0,
- lowpass_getopts, lowpass_start, butterworth_flow,
+ st_lowpass_getopts, st_lowpass_start, st_butterworth_flow,
st_null_drain, st_nothing},
{"map", ST_EFF_REPORT,
- map_getopts, map_start, map_flow,
+ st_map_getopts, st_map_start, st_map_flow,
st_null_drain, st_nothing},
{"mask", ST_EFF_MCHAN,
- mask_getopts, st_nothing, mask_flow,
+ st_mask_getopts, st_nothing, st_mask_flow,
st_null_drain, st_nothing},
{"phaser", 0,
- phaser_getopts, phaser_start, phaser_flow,
- phaser_drain, phaser_stop},
+ st_phaser_getopts, st_phaser_start, st_phaser_flow,
+ st_phaser_drain, st_phaser_stop},
{"pick", ST_EFF_CHAN | ST_EFF_MCHAN,
- pick_getopts, pick_start, pick_flow,
- st_null_drain, pick_stop},
+ st_pick_getopts, st_pick_start, st_pick_flow,
+ st_null_drain, st_pick_stop},
{"polyphase", ST_EFF_RATE,
- poly_getopts, poly_start, poly_flow,
- poly_drain, poly_stop},
+ st_poly_getopts, st_poly_start, st_poly_flow,
+ st_poly_drain, st_poly_stop},
{"rate", ST_EFF_RATE,
- rate_getopts, rate_start, rate_flow,
+ st_rate_getopts, st_rate_start, st_rate_flow,
st_null_drain, st_nothing},
{"resample", ST_EFF_RATE,
- resample_getopts, resample_start, resample_flow,
- resample_drain, resample_stop},
+ st_resample_getopts, st_resample_start, st_resample_flow,
+ st_resample_drain, st_resample_stop},
{"reverb", 0,
- reverb_getopts, reverb_start, reverb_flow,
- reverb_drain, reverb_stop},
+ st_reverb_getopts, st_reverb_start, st_reverb_flow,
+ st_reverb_drain, st_reverb_stop},
{"reverse", 0,
- reverse_getopts, reverse_start,
- reverse_flow, reverse_drain, reverse_stop},
+ st_reverse_getopts, st_reverse_start,
+ st_reverse_flow, st_reverse_drain, st_reverse_stop},
{"split", ST_EFF_CHAN | ST_EFF_MCHAN,
- split_getopts, split_start, split_flow,
- st_null_drain,split_stop},
+ st_split_getopts, st_split_start, st_split_flow,
+ st_null_drain, st_split_stop},
{"stat", ST_EFF_MCHAN | ST_EFF_REPORT | ST_EFF_RATE | ST_EFF_CHAN,
- stat_getopts, stat_start, stat_flow,
- st_null_drain, stat_stop},
+ st_stat_getopts, st_stat_start, st_stat_flow,
+ st_null_drain, st_stat_stop},
{"swap", ST_EFF_MCHAN,
- swap_getopts, swap_start, swap_flow,
- swap_drain, swap_stop},
+ st_swap_getopts, st_swap_start, st_swap_flow,
+ st_swap_drain, st_swap_stop},
{"vibro", 0,
- vibro_getopts, vibro_start, vibro_flow,
+ st_vibro_getopts, st_vibro_start, st_vibro_flow,
st_null_drain, st_nothing},
{0, 0, 0, 0, 0, 0, 0}
};
--- a/src/highp.c
+++ b/src/highp.c
@@ -33,7 +33,7 @@
/*
* Process options
*/
-void highp_getopts(effp, n, argv)
+int st_highp_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -41,23 +41,31 @@
highp_t highp = (highp_t) effp->priv;
if ((n < 1) || !sscanf(argv[0], "%f", &highp->center))
+ {
fail("Usage: highp center");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void highp_start(effp)
+int st_highp_start(effp)
eff_t effp;
{
highp_t highp = (highp_t) effp->priv;
if (highp->center > effp->ininfo.rate*2)
+ {
fail("Highpass: center must be < minimum data rate*2\n");
+ return (ST_EOF);
+ }
highp->A = (M_PI * 2.0 * highp->center) / effp->ininfo.rate;
highp->B = exp(-highp->A / effp->ininfo.rate);
highp->in1 = 0.0;
highp->out1 = 0.0;
+ return (ST_SUCCESS);
}
/*
@@ -65,7 +73,7 @@
* Return number of samples processed.
*/
-void highp_flow(effp, ibuf, obuf, isamp, osamp)
+int st_highp_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -93,6 +101,7 @@
highp->out1 = d;
*isamp = len;
*osamp = len;
+ return (ST_SUCCESS);
}
/*
@@ -99,9 +108,10 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void highp_stop(effp)
+int st_highp_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/src/highpass.c
+++ b/src/highpass.c
@@ -37,9 +37,7 @@
#include "btrworth.h"
-
-void
-highpass_getopts (effp, n, argv)
+int st_highpass_getopts (effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -48,19 +46,21 @@
if (n != 1) {
fail("Usage: highpass FREQUENCY");
+ return (ST_EOF);
}
- butterworth_start (effp);
+ st_butterworth_start (effp);
if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
fail("highpass: illegal frequency");
+ return (ST_EOF);
}
+ return (ST_SUCCESS);
}
-void
-highpass_start (effp)
+int st_highpass_start (effp)
eff_t effp;
{
butterworth_t butterworth = (butterworth_t) effp->priv;
@@ -74,5 +74,5 @@
butterworth->b [0] = 2 * (c * c - 1.0) * butterworth->a[0];
butterworth->b [1] = (1.0 - sqrt(2.0) * c + c * c) * butterworth->a [0];
+ return (ST_SUCCESS);
}
-
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -33,7 +33,7 @@
/*
* Process options
*/
-void lowp_getopts(effp, n, argv)
+int st_lowp_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -41,22 +41,30 @@
lowp_t lowp = (lowp_t) effp->priv;
if ((n < 1) || !sscanf(argv[0], "%f", &lowp->center))
+ {
fail("Usage: lowp center");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void lowp_start(effp)
+int st_lowp_start(effp)
eff_t effp;
{
lowp_t lowp = (lowp_t) effp->priv;
if (lowp->center > effp->ininfo.rate*2)
+ {
fail("Lowpass: center must be < minimum data rate*2\n");
+ return (ST_EOF);
+ }
lowp->A = (M_PI * 2.0 * lowp->center) / effp->ininfo.rate;
lowp->B = exp(-lowp->A / effp->ininfo.rate);
lowp->in1 = 0.0;
+ return (ST_SUCCESS);
}
/*
@@ -64,7 +72,7 @@
* Return number of samples processed.
*/
-void lowp_flow(effp, ibuf, obuf, isamp, osamp)
+int st_lowp_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -90,6 +98,7 @@
}
*isamp = len;
*osamp = len;
+ return (ST_SUCCESS);
}
/*
@@ -96,9 +105,10 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void lowp_stop(effp)
+int st_lowp_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/src/lowpass.c
+++ b/src/lowpass.c
@@ -24,10 +24,7 @@
#include "st.h"
#include "btrworth.h"
-
-
-void
-lowpass_getopts (effp, n, argv)
+int st_lowpass_getopts (effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -36,19 +33,19 @@
if (n != 1) {
fail("Usage: lowpass FREQUENCY");
+ return (ST_EOF);
}
- butterworth_start (effp);
+ st_butterworth_start (effp);
if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
fail("lowpass: illegal frequency");
+ return (ST_EOF);
}
+ return (ST_SUCCESS);
}
-
-
-void
-lowpass_start (effp)
+int st_lowpass_start (effp)
eff_t effp;
{
butterworth_t butterworth = (butterworth_t) effp->priv;
@@ -62,5 +59,5 @@
butterworth->b [0] = 2 * (1.0 - c * c) * butterworth->a[0];
butterworth->b [1] = (1.0 - sqrt(2.0) * c + c * c) * butterworth->a [0];
+ return (ST_SUCCESS);
}
-
--- a/src/map.c
+++ b/src/map.c
@@ -20,19 +20,23 @@
/*
* Process options
*/
-void map_getopts(effp, n, argv)
+int st_map_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Map effect takes no options.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void map_start(effp)
+int st_map_start(effp)
eff_t effp;
{
int i;
@@ -52,6 +56,7 @@
fprintf(stderr, "MIDI note: %d\n", effp->instr.MIDInote);
fprintf(stderr, "MIDI low : %d\n", effp->instr.MIDIlow);
fprintf(stderr, "MIDI hi : %d\n", effp->instr.MIDIhi);
+ return (ST_SUCCESS);
}
/*
@@ -59,9 +64,10 @@
* Return number of samples processed.
*/
-void map_flow(effp, ibuf, obuf, isamp, osamp)
+int st_map_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
{
+ return (ST_SUCCESS);
}
--- a/src/mask.c
+++ b/src/mask.c
@@ -28,16 +28,20 @@
/*
* Process options
*/
-void mask_getopts(effp, n, argv)
+int st_mask_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Mask effect takes no options.");
+ return (ST_EOF);
+ }
/* should take # of bits */
st_initrand();
+ return (ST_SUCCESS);
}
/*
@@ -45,7 +49,7 @@
* Return number of samples processed.
*/
-void mask_flow(effp, ibuf, obuf, isamp, osamp)
+int st_mask_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -94,5 +98,5 @@
*isamp = done;
*osamp = done;
+ return (ST_SUCCESS);
}
-
--- a/src/oss.c
+++ b/src/oss.c
@@ -83,7 +83,7 @@
ioctl (fileno(ft->fp), SNDCTL_DSP_GETBLKSIZE, &ft->file.size);
if (ft->file.size < 4 || ft->file.size > 65536) {
fail("Invalid audio buffer size %d", ft->file.size);
- returen (ST_EOF);
+ return (ST_EOF);
}
ft->file.count = 0;
ft->file.pos = 0;
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -80,7 +80,7 @@
/*
* Process options
*/
-void phaser_getopts(effp, n, argv)
+int st_phaser_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -88,7 +88,10 @@
phaser_t phaser = (phaser_t) effp->priv;
if (!((n == 5) || (n == 6)))
+ {
fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
+ return (ST_EOF);
+ }
sscanf(argv[0], "%f", &phaser->in_gain);
sscanf(argv[1], "%f", &phaser->out_gain);
@@ -102,14 +105,18 @@
else if ( ! strcmp(argv[5], "-t"))
phaser->modulation = MOD_TRIANGLE;
else
+ {
fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
+ return (ST_EOF);
+ }
}
+ return (ST_SUCCESS);
}
/*
* Prepare for processing.
*/
-void phaser_start(effp)
+int st_phaser_start(effp)
eff_t effp;
{
phaser_t phaser = (phaser_t) effp->priv;
@@ -118,17 +125,35 @@
phaser->maxsamples = phaser->delay * effp->ininfo.rate / 1000.0;
if ( phaser->delay < 0.0 )
+ {
fail("phaser: delay must be positive!\n");
+ return (ST_EOF);
+ }
if ( phaser->delay > 5.0 )
+ {
fail("phaser: delay must be less than 5.0 msec!\n");
+ return (ST_EOF);
+ }
if ( phaser->speed < 0.1 )
+ {
fail("phaser: speed must be more than 0.1 Hz!\n");
+ return (ST_EOF);
+ }
if ( phaser->speed > 2.0 )
+ {
fail("phaser: speed must be less than 2.0 Hz!\n");
+ return (ST_EOF);
+ }
if ( phaser->decay < 0.0 )
+ {
fail("phaser: decay must be positive!\n" );
+ return (ST_EOF);
+ }
if ( phaser->decay >= 1.0 )
+ {
fail("phaser: decay must be less that 1.0!\n" );
+ return (ST_EOF);
+ }
/* Be nice and check the hint with warning, if... */
if ( phaser->in_gain > ( 1.0 - phaser->decay * phaser->decay ) )
warn("phaser: warning >>> gain-in can cause saturation or clipping of output <<<");
@@ -139,14 +164,20 @@
if (! (phaser->phaserbuf =
(double *) malloc(sizeof (double) * phaser->maxsamples)))
+ {
fail("phaser: Cannot malloc %d bytes!\n",
sizeof(double) * phaser->maxsamples);
+ return (ST_EOF);
+ }
for ( i = 0; i < phaser->maxsamples; i++ )
phaser->phaserbuf[i] = 0.0;
if (! (phaser->lookup_tab =
(int *) malloc(sizeof (int) * phaser->length)))
+ {
fail("phaser: Cannot malloc %d bytes!\n",
sizeof(int) * phaser->length);
+ return (ST_EOF);
+ }
if ( phaser->modulation == MOD_SINE )
st_sine(phaser->lookup_tab, phaser->length,
@@ -159,6 +190,7 @@
phaser->counter = 0;
phaser->phase = 0;
phaser->fade_out = phaser->maxsamples;
+ return (ST_SUCCESS);
}
/*
@@ -166,7 +198,7 @@
* Return number of samples processed.
*/
-void phaser_flow(effp, ibuf, obuf, isamp, osamp)
+int st_phaser_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -197,12 +229,13 @@
phaser->phase = ( phaser->phase + 1 ) % phaser->length;
}
/* processed all samples */
+ return (ST_SUCCESS);
}
/*
* Drain out reverb lines.
*/
-void phaser_drain(effp, obuf, osamp)
+int st_phaser_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -235,12 +268,13 @@
}
/* samples playd, it remains */
*osamp = done;
+ return (ST_SUCCESS);
}
/*
* Clean up phaser effect.
*/
-void phaser_stop(effp)
+int st_phaser_stop(effp)
eff_t effp;
{
phaser_t phaser = (phaser_t) effp->priv;
@@ -249,5 +283,6 @@
phaser->phaserbuf = (double *) -1; /* guaranteed core dump */
free((char *) phaser->lookup_tab);
phaser->lookup_tab = (int *) -1; /* guaranteed core dump */
+ return (ST_SUCCESS);
}
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -79,7 +79,7 @@
static int win_width = 1024;
static Float cutoff = 0.95;
-void poly_getopts(eff_t effp, int n, char **argv)
+int st_poly_getopts(eff_t effp, int n, char **argv)
{
/* 0: nuttall
1: hamming */
@@ -129,7 +129,9 @@
}
fail("Polyphase: unknown argument (%s %s)!", argv[0], argv[1]);
+ return (ST_EOF);
}
+ return (ST_SUCCESS);
}
/*
@@ -373,7 +375,7 @@
#define RIBLEN 2048
-void poly_start(eff_t effp)
+int st_poly_start(eff_t effp)
{
poly_t rate = (poly_t) effp->priv;
static int l1[MF], l2[MF];
@@ -462,6 +464,7 @@
s->window = (Float *) malloc(sizeof(Float) * size);
}
report("Poly: output samples %d, oskip %d",size, rate->oskip);
+ return (ST_SUCCESS);
}
/*
@@ -483,7 +486,7 @@
return sum;
}
-void polyphase(Float *output, polystage *s)
+static void polyphase(Float *output, polystage *s)
{
int mm;
int up = s->up;
@@ -519,7 +522,7 @@
}
-void poly_flow(eff_t effp, LONG *ibuf, LONG *obuf, LONG *isamp, LONG *osamp)
+int st_poly_flow(eff_t effp, LONG *ibuf, LONG *obuf, LONG *isamp, LONG *osamp)
{
poly_t rate = (poly_t) effp->priv;
polystage *s0,*s1;
@@ -609,6 +612,7 @@
}
}
+ return (ST_SUCCESS);
}
@@ -615,11 +619,12 @@
/*
* Process tail of input samples.
*/
-void poly_drain(eff_t effp, LONG *obuf, LONG *osamp)
+int st_poly_drain(eff_t effp, LONG *obuf, LONG *osamp)
{
LONG in_size;
/* Call "flow" with NULL input. */
- poly_flow(effp, NULL, obuf, &in_size, osamp);
+ st_poly_flow(effp, NULL, obuf, &in_size, osamp);
+ return (ST_SUCCESS);
}
/*
@@ -626,7 +631,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void poly_stop(eff_t effp)
+int st_poly_stop(eff_t effp)
{
poly_t rate = (poly_t) effp->priv;
polystage *s;
@@ -638,4 +643,5 @@
if (s->filt_array) free((void *) s->filt_array);
free((void *) s);
}
+ return (ST_SUCCESS);
}
--- a/src/rate.c
+++ b/src/rate.c
@@ -53,19 +53,23 @@
/*
* Process options
*/
-void rate_getopts(effp, n, argv)
+int st_rate_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Rate effect takes no options.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void rate_start(effp)
+int st_rate_start(effp)
eff_t effp;
{
rate_t rate = (rate_t) effp->priv;
@@ -72,10 +76,15 @@
ULONG incr;
if (effp->ininfo.rate >= 65535 || effp->outinfo.rate >= 65535)
+ {
fail("rate effect can only handle rates <= 65535");
+ return (ST_EOF);
+ }
if (effp->ininfo.size == ST_SIZE_DWORD ||
effp->ininfo.size == ST_SIZE_FLOAT)
- fail("rate effect does not work on data greater then 16 bits");
+ {
+ warn("rate effect reduces data to 16 bits");
+ }
rate->opos_frac=0;
rate->opos=0;
@@ -90,6 +99,7 @@
rate->ipos=0;
rate->ilast = 0;
+ return (ST_SUCCESS);
}
/*
@@ -97,7 +107,7 @@
* Return number of samples processed.
*/
-void rate_flow(effp, ibuf, obuf, isamp, osamp)
+int st_rate_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -149,6 +159,7 @@
*isamp = ibuf - istart;
*osamp = obuf - ostart;
rate->ilast = ilast;
+ return (ST_SUCCESS);
}
/*
@@ -155,10 +166,11 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void rate_stop(effp)
+int st_rate_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
#else /* USE_OLD_RATE */
@@ -226,19 +238,23 @@
/*
* Process options
*/
-void rate_getopts(effp, n, argv)
+int st_rate_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Rate effect takes no options.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void rate_start(effp)
+int st_rate_start(effp)
eff_t effp;
{
rate_t rate = (rate_t) effp->priv;
@@ -252,6 +268,7 @@
rate->outskip = rate->lcmrate / effp->outinfo.rate;
rate->total = rate->intot = rate->outtot = 0;
rate->lastsamp = 0;
+ return (ST_SUCCESS);
}
/*
@@ -259,7 +276,7 @@
* Return number of samples processed.
*/
-void rate_flow(effp, ibuf, obuf, isamp, osamp)
+int st_rate_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
int *isamp, *osamp;
@@ -315,6 +332,7 @@
*isamp = ibuf - istart;
*osamp = len;
rate->lastsamp = last;
+ return (ST_SUCCESS);
}
/*
@@ -321,9 +339,10 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void rate_stop(effp)
+int st_rate_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
#endif /* USE_OLD_RATE */
--- a/src/resample.c
+++ b/src/resample.c
@@ -110,7 +110,7 @@
/*
* Process options
*/
-void resample_getopts(effp, n, argv)
+int st_resample_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -144,12 +144,21 @@
}
if ((n >= 1) && !sscanf(argv[0], "%lf", &r->rolloff))
+ {
fail("Usage: resample [ rolloff [ beta ] ]");
+ return (ST_EOF);
+ }
else if ((r->rolloff <= 0.01) || (r->rolloff >= 1.0))
+ {
fail("resample: rolloff factor (%f) no good, should be 0.01<x<1.0", r->rolloff);
+ return(ST_EOF);
+ }
if ((n >= 2) && !sscanf(argv[1], "%lf", &r->beta))
+ {
fail("Usage: resample [ rolloff [ beta ] ]");
+ return (ST_EOF);
+ }
else if (r->beta <= 2.0) {
r->beta = 0;
report("resample opts: Nuttall window, cutoff %f\n", r->rolloff);
@@ -156,13 +165,13 @@
} else {
report("resample opts: Kaiser window, cutoff %f, beta %f\n", r->rolloff, r->beta);
}
-
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void resample_start(effp)
+int st_resample_start(effp)
eff_t effp;
{
resample_t r = (resample_t) effp->priv;
@@ -198,7 +207,10 @@
/* returns error # <=0, or adjusted wing-len > 0 */
i = makeFilter(r->Imp, r->Nwing, r->rolloff, r->beta, r->Nq, 1);
if (i <= 0)
+ {
fail("resample: Unable to make filter\n");
+ return (ST_EOF);
+ }
/*report("Nmult: %ld, Nwing: %ld, Nq: %ld\n",r->Nmult,r->Nwing,r->Nq);*/
@@ -227,7 +239,10 @@
}
i = BUFFSIZE - 2*Xoff;
if (i < r->Factor + 1.0/r->Factor) /* Check input buffer size */
+ {
fail("Factor is too small or large for BUFFSIZE");
+ return (ST_EOF);
+ }
r->Xsize = 2*Xoff + i/(1.0+r->Factor);
r->Ysize = BUFFSIZE - r->Xsize;
@@ -239,6 +254,7 @@
/* Need Xoff zeros at beginning of sample */
for (i=0; i<Xoff; i++)
r->X[i] = 0;
+ return (ST_SUCCESS);
}
/*
@@ -246,7 +262,7 @@
* Return number of samples processed.
*/
-void resample_flow(effp, ibuf, obuf, isamp, osamp)
+int st_resample_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -265,7 +281,10 @@
Nx = Nproc - r->Xread; /* space for right-wing future-data */
if (Nx <= 0)
+ {
fail("Nx not positive: %d", Nx);
+ return (ST_EOF);
+ }
if (Nx > *isamp)
Nx = *isamp;
/*fprintf(stderr,"Nx %d\n",Nx);*/
@@ -285,7 +304,7 @@
r->Xread = last;
/* leave *isamp alone, we consumed it */
*osamp = 0;
- return;
+ return (ST_SUCCESS);
}
if (r->quadr < 0) { /* exact coeff's method */
LONG creep;
@@ -340,12 +359,13 @@
*osamp = Nout;
}
+ return (ST_SUCCESS);
}
/*
* Process tail of input samples.
*/
-void resample_drain(effp, obuf, osamp)
+int st_resample_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -352,6 +372,7 @@
{
resample_t r = (resample_t) effp->priv;
LONG isamp_res, *Obuf, osamp_res;
+ int rc;
/* fprintf(stderr,"Xoff %d, Xt %d <--- DRAIN\n",r->Xoff, r->Xt); */
@@ -363,7 +384,9 @@
LONG Isamp, Osamp;
Isamp = isamp_res;
Osamp = osamp_res;
- resample_flow(effp, NULL, Obuf, &Isamp, &Osamp);
+ rc = st_resample_flow(effp, NULL, Obuf, &Isamp, &Osamp);
+ if (rc)
+ return rc;
/* fprintf(stderr,"DRAIN isamp,osamp (%d,%d) -> (%d,%d)\n",
isamp_res,osamp_res,Isamp,Osamp); */
Obuf += Osamp;
@@ -374,6 +397,7 @@
/* fprintf(stderr,"DRAIN osamp %d\n", *osamp); */
if (isamp_res)
warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
+ return (ST_SUCCESS);
}
/*
@@ -380,7 +404,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void resample_stop(effp)
+int st_resample_stop(effp)
eff_t effp;
{
resample_t r = (resample_t) effp->priv;
@@ -388,6 +412,7 @@
free(r->Imp - 1);
free(r->X);
/* free(r->Y); Y is in same block starting at X */
+ return (ST_SUCCESS);
}
/* over 90% of CPU time spent in this iprodUD() function */
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -114,7 +114,7 @@
/*
* Process options
*/
-void reverb_getopts(effp, n, argv)
+int st_reverb_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -126,11 +126,17 @@
reverb->maxsamples = 0;
if ( n < 3 )
+ {
fail("Usage: reverb gain-out reverb-time delay [ delay ... ]");
+ return (ST_EOF);
+ }
if ( n - 2 > MAXREVERBS )
+ {
fail("reverb: to many dalays, use less than %i delays",
MAXREVERBS);
+ return (ST_EOF);
+ }
i = 0;
sscanf(argv[i++], "%f", &reverb->out_gain);
@@ -140,12 +146,13 @@
sscanf(argv[i++], "%f", &reverb->delay[reverb->numdelays]);
reverb->numdelays++;
}
+ return (ST_SUCCESS);
}
/*
* Prepare for processing.
*/
-void reverb_start(effp)
+int st_reverb_start(effp)
eff_t effp;
{
reverb_t reverb = (reverb_t) effp->priv;
@@ -154,18 +161,30 @@
reverb->in_gain = 1.0;
if ( reverb->out_gain < 0.0 )
+ {
fail("reverb: gain-out must be positive");
+ return (ST_EOF);
+ }
if ( reverb->out_gain > 1.0 )
warn("reverb: warnig >>> gain-out can cause saturation of output <<<");
if ( reverb->time < 0.0 )
+ {
fail("reverb: reverb-time must be positive");
+ return (ST_EOF);
+ }
for(i = 0; i < reverb->numdelays; i++) {
reverb->samples[i] = reverb->delay[i] * effp->ininfo.rate / 1000.0;
if ( reverb->samples[i] < 1 )
+ {
fail("reverb: delay must be positive!\n");
+ return (ST_EOF);
+ }
if ( reverb->samples[i] > DELAY_BUFSIZ )
+ {
fail("reverb: delay must be less than %g seconds!\n",
DELAY_BUFSIZ / (float) effp->ininfo.rate );
+ return(ST_EOF);
+ }
/* Compute a realistic decay */
reverb->decay[i] = (float) pow(10.0,(-3.0 * reverb->delay[i] / reverb->time));
if ( reverb->samples[i] > reverb->maxsamples )
@@ -172,8 +191,11 @@
reverb->maxsamples = reverb->samples[i];
}
if (! (reverb->reverbbuf = (float *) malloc(sizeof (float) * reverb->maxsamples)))
+ {
fail("reverb: Cannot malloc %d bytes!\n",
sizeof(float) * reverb->maxsamples);
+ return(ST_EOF);
+ }
for ( i = 0; i < reverb->maxsamples; ++i )
reverb->reverbbuf[i] = 0.0;
reverb->pppl = reverb->ppl = reverb->pl = 0x7fffff; /* fade-outs */
@@ -182,6 +204,7 @@
for ( i = 0; i < reverb->numdelays; i++ )
reverb->in_gain *=
( 1.0 - ( reverb->decay[i] * reverb->decay[i] ));
+ return (ST_SUCCESS);
}
/*
@@ -189,7 +212,7 @@
* Return number of samples processed.
*/
-void reverb_flow(effp, ibuf, obuf, isamp, osamp)
+int st_reverb_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -220,12 +243,13 @@
}
reverb->counter = i;
/* processed all samples */
+ return (ST_SUCCESS);
}
/*
* Drain out reverb lines.
*/
-void reverb_drain(effp, obuf, osamp)
+int st_reverb_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -258,12 +282,13 @@
((abs(reverb->pl) + abs(reverb->ppl) + abs(reverb->pppl)) > REVERB_FADE_THRESH));
reverb->counter = i;
*osamp = done;
+ return (ST_SUCCESS);
}
/*
* Clean up reverb effect.
*/
-void reverb_stop(effp)
+int st_reverb_stop(effp)
eff_t effp;
{
reverb_t reverb = (reverb_t) effp->priv;
@@ -270,5 +295,5 @@
free((char *) reverb->reverbbuf);
reverb->reverbbuf = (float *) -1; /* guaranteed core dump */
+ return (ST_SUCCESS);
}
-
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -35,13 +35,17 @@
* Process options: none in our case.
*/
-void reverse_getopts(effp, n, argv)
+int st_reverse_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Reverse effect takes no options.");
+ return (ST_EOF);
+ }
+ return(ST_SUCCESS);
}
/*
@@ -48,14 +52,18 @@
* Prepare processing: open temporary file.
*/
-void reverse_start(effp)
+int st_reverse_start(effp)
eff_t effp;
{
reverse_t reverse = (reverse_t) effp->priv;
reverse->fp = tmpfile();
if (reverse->fp == NULL)
+ {
fail("Reverse effect can't create temporary file\n");
+ return (ST_EOF);
+ }
reverse->phase = WRITING;
+ return (ST_SUCCESS);
}
/*
@@ -63,7 +71,7 @@
* don't generate any output samples.
*/
-void reverse_flow(effp, ibuf, obuf, isamp, osamp)
+int st_reverse_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -71,11 +79,18 @@
reverse_t reverse = (reverse_t) effp->priv;
if (reverse->phase != WRITING)
+ {
fail("Internal error: reverse_flow called in wrong phase");
+ return(ST_EOF);
+ }
if (fwrite((char *)ibuf, sizeof(LONG), *isamp, reverse->fp)
!= *isamp)
+ {
fail("Reverse effect write error on temporary file\n");
+ return(ST_EOF);
+ }
*osamp = 0;
+ return(ST_SUCCESS);
}
/*
@@ -82,7 +97,7 @@
* Effect drain: generate the actual samples in reverse order.
*/
-void reverse_drain(effp, obuf, osamp)
+int st_reverse_drain(effp, obuf, osamp)
eff_t effp;
LONG *obuf;
LONG *osamp;
@@ -97,7 +112,10 @@
fseek(reverse->fp, 0L, SEEK_END);
reverse->pos = ftell(reverse->fp);
if (reverse->pos % sizeof(LONG) != 0)
+ {
fail("Reverse effect finds odd temporary file\n");
+ return(ST_EOF);
+ }
reverse->phase = READING;
}
len = *osamp;
@@ -109,7 +127,10 @@
reverse->pos -= nbytes;
fseek(reverse->fp, reverse->pos, SEEK_SET);
if (fread((char *)obuf, sizeof(LONG), len, reverse->fp) != len)
+ {
fail("Reverse effect read error from temporary file\n");
+ return(ST_EOF);
+ }
for (i = 0, j = len-1; i < j; i++, j--) {
temp = obuf[i];
obuf[i] = obuf[j];
@@ -116,16 +137,17 @@
obuf[j] = temp;
}
*osamp = len;
+ return(ST_SUCCESS);
}
/*
* Close and unlink the temporary file.
*/
-void reverse_stop(effp)
+int st_reverse_stop(effp)
eff_t effp;
{
reverse_t reverse = (reverse_t) effp->priv;
fclose(reverse->fp);
+ return (ST_SUCCESS);
}
-
--- a/src/silence.c
+++ b/src/silence.c
@@ -33,13 +33,16 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-void silence_getopts(effp, n, argv)
+int st_silence_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
{
if (n)
+ {
fail("Silence effect takes no options.");
+ return (ST_EOF);
+ }
}
/*
@@ -46,7 +49,7 @@
* Prepare processing.
* Do all initializations.
*/
-silence_start(effp)
+int st_silence_start(effp)
eff_t effp;
{
silence_t silence = (silence_t) effp->priv;
@@ -58,6 +61,7 @@
silence.begin = silence.end = 0;
silence.begin_skip = silence.end_skip = 0;
silence.begin_count = silence.end_count = 0;
+ return (ST_SUCCESS);
}
/*
@@ -65,7 +69,7 @@
* Return number of samples processed.
*/
-void silence_flow(effp, ibuf, obuf, isamp, osamp)
+int st_silence_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -86,6 +90,7 @@
}
*isamp =
*osamp =
+ return (ST_SUCCESS);
}
/*
@@ -92,11 +97,12 @@
* Drain out remaining samples if the effect generates any.
*/
-void skel_drain(effp, obuf, osamp)
+int st_skel_drain(effp, obuf, osamp)
LONG *obuf;
LONG *osamp;
{
*osamp = 0;
+ return (ST_SUCCESS);
}
/*
@@ -103,10 +109,11 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-void skel_stop(effp)
+int st_skel_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/src/skel.c
+++ b/src/skel.c
@@ -26,7 +26,7 @@
* size and style of samples,
* mono/stereo/quad.
*/
-skelstartread(ft)
+int st_skelstartread(ft)
ft_t ft;
{
skel_t sk = (skel_t) ft->priv;
@@ -33,7 +33,10 @@
/* If you need to seek around the input file. */
if (! ft->seekable)
+ {
fail("SKEL input file must be a file, not a pipe");
+ return (ST_EOF);
+ }
/*
* If your format specifies or your file header contains
@@ -44,6 +47,7 @@
ft->info.style = UNSIGNED or SIGN2 ...;
ft->info.channels = 1 or 2 or 4;
ft->comment = any comment in file header.
+ return (ST_SUCCESS);
}
/*
@@ -53,7 +57,7 @@
* Return number of samples read.
*/
-skelread(ft, buf, len)
+LONG st_skelread(ft, buf, len)
ft_t ft;
LONG *buf, len;
{
@@ -85,12 +89,13 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-skelstopread(ft)
+int skelstopread(ft)
ft_t ft;
{
+ return (ST_SUCCESS);
}
-skelstartwrite(ft)
+int st_skelstartwrite(ft)
ft_t ft;
{
skel_t sk = (skel_t) ft->priv;
@@ -97,7 +102,10 @@
/* If you have to seek around the output file */
if (! ft->seekable)
+ {
fail("Output .skel file must be a file, not a pipe");
+ return (ST_EOF);
+ }
/* If your format specifies any of the following info. */
ft->info.rate =
@@ -106,10 +114,11 @@
ft->info.channels = 1 or 2 or 4;
/* Write file header, if any */
/* Write comment field, if any */
+ return(ST_SUCCESS);
}
-skelwrite(ft, buf, len)
+LONG st_skelwrite(ft, buf, len)
ft_t ft;
LONG *buf, len;
{
@@ -122,14 +131,17 @@
putc((*buf++ >> 24) ^ 0x80, ft->fp);
/* If you cannot write out all of the supplied samples, */
/* fail("SKEL: Can't write all samples to %s", ft->filename); */
+ /* return (ST_EOF); */
+ return (ST_SUCCESS);
}
-skelstopwrite(ft)
+int st_skelstopwrite(ft)
ft_t ft;
{
/* All samples are already written out. */
/* If file header needs fixing up, for example it needs the */
/* the number of samples in a field, seek back and write them here. */
+ return (ST_SUCCESS);
}
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -24,7 +24,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-void skeleff_getopts(effp, n, argv)
+int st_skeleff_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -36,8 +36,10 @@
if (n != 1)
{
fail("Usage: skeleff [option]");
+ return (ST_EOF);
}
}
+ return (ST_SUCCESS);
}
/*
@@ -44,11 +46,15 @@
* Prepare processing.
* Do all initializations.
*/
-void skeleff_start(effp)
+int st_skeleff_start(effp)
eff_t effp;
{
if (effp->outinfo.channels == 1)
+ {
fail("Can't run skeleff on mono data.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -56,7 +62,7 @@
* Return number of samples processed.
*/
-void skeleff_flow(effp, ibuf, obuf, isamp, osamp)
+int st_skeleff_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -86,6 +92,7 @@
break;
}
+ return (ST_SUCCESS);
}
/*
@@ -92,11 +99,12 @@
* Drain out remaining samples if the effect generates any.
*/
-void skeleff_drain(effp, obuf, osamp)
+int st_skeleff_drain(effp, obuf, osamp)
LONG *obuf;
LONG *osamp;
{
*osamp = 0;
+ return (ST_SUCCESS);
}
/*
@@ -103,8 +111,9 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-void skeleff_stop(effp)
+int st_skeleff_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/src/stat.c
+++ b/src/stat.c
@@ -37,7 +37,7 @@
/*
* Process options
*/
-void stat_getopts(effp, n, argv)
+int st_stat_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -57,13 +57,19 @@
double scale;
if (n <= 1)
+ {
fail("-s option: invalid argument");
+ return (ST_EOF);
+ }
if (!strcmp(argv[1],"rms")) {
stat->srms=1;
goto did2;
}
if (!sscanf(argv[1], "%lf", &scale))
+ {
fail("-s option: invalid argument");
+ return (ST_EOF);
+ }
stat->scale = scale;
goto did2;
}
@@ -70,7 +76,10 @@
if (!(strcmp(argv[0], "-rms"))) {
double scale;
if (n <= 1 || !sscanf(argv[1], "%lf", &scale))
+ {
fail("-s option expects float argument");
+ return(ST_EOF);
+ }
stat->srms = 1;
goto did2;
}
@@ -79,16 +88,20 @@
goto did1;
}
else
+ {
fail("Summary effect: unknown option");
+ return(ST_EOF);
+ }
did2: --n; ++argv;
did1: --n; ++argv;
}
+ return (ST_SUCCESS);
}
/*
* Prepare processing.
*/
-void stat_start(effp)
+int st_stat_start(effp)
eff_t effp;
{
stat_t stat = (stat_t) effp->priv;
@@ -107,6 +120,7 @@
for (i = 0; i < 4; i++)
stat->bin[i] = 0;
+ return (ST_SUCCESS);
}
/*
@@ -114,7 +128,7 @@
* Return number of samples processed.
*/
-void stat_flow(effp, ibuf, obuf, isamp, osamp)
+int st_stat_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -125,7 +139,7 @@
count = 0;
len = ((*isamp > *osamp) ? *osamp : *isamp);
- if (len==0) return;
+ if (len==0) return (ST_SUCCESS);
if (stat->read == 0) /* 1st sample */
stat->min = stat->max = stat->last = (*ibuf)/stat->scale;
@@ -172,6 +186,7 @@
}
stat->read += len;
/* Process all samples */
+ return (ST_SUCCESS);
}
/*
@@ -178,8 +193,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void
-stat_stop(effp)
+int st_stat_stop(effp)
eff_t effp;
{
stat_t stat = (stat_t) effp->priv;
@@ -213,7 +227,7 @@
/* Just print the volume adjustment */
if (stat->volume == 1 && amp > 0) {
fprintf(stderr, "%.3f\n", MAXLONG/(amp*scale));
- return;
+ return (ST_SUCCESS);
}
if (stat->volume == 2) {
fprintf(stderr, "\n");
@@ -250,11 +264,11 @@
{
if (effp->ininfo.style == ST_ENCODING_UNSIGNED)
{
- printf ("\nTry: -t raw -b -s \n");
+ fprintf (stderr,"\nTry: -t raw -b -s \n");
}
else
{
- printf ("\nTry: -t raw -b -u \n");
+ fprintf (stderr,"\nTry: -t raw -b -u \n");
}
}
@@ -266,11 +280,11 @@
{
if (effp->ininfo.style == ST_ENCODING_ULAW)
{
- printf ("\nTry: -t raw -b -u \n");
+ fprintf (stderr,"\nTry: -t raw -b -u \n");
}
else
{
- printf ("\nTry: -t raw -b -U \n");
+ fprintf (stderr,"\nTry: -t raw -b -U \n");
}
}
else
@@ -278,5 +292,6 @@
fprintf (stderr, "\nCan't guess the type\n");
}
}
+ return (ST_SUCCESS);
}
--- a/src/swap.c
+++ b/src/swap.c
@@ -24,7 +24,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-void swap_getopts(effp, n, argv)
+int st_swap_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -37,6 +37,7 @@
if (n != 4)
{
fail("Usage: swap [1 2 3 4]");
+ return (ST_EOF);
}
else
{
@@ -46,6 +47,7 @@
sscanf(argv[3],"%d",&swap->order[3]);
}
}
+ return (ST_SUCCESS);
}
/*
@@ -52,11 +54,15 @@
* Prepare processing.
* Do all initializations.
*/
-void swap_start(effp)
+int st_swap_start(effp)
eff_t effp;
{
if (effp->outinfo.channels == 1)
+ {
fail("Can't swap channels on mono data.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -64,7 +70,7 @@
* Return number of samples processed.
*/
-void swap_flow(effp, ibuf, obuf, isamp, osamp)
+int st_swap_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
int *isamp, *osamp;
@@ -122,6 +128,7 @@
break;
}
+ return (ST_SUCCESS);
}
/*
@@ -128,11 +135,12 @@
* Drain out remaining samples if the effect generates any.
*/
-void swap_drain(effp, obuf, osamp)
+int st_swap_drain(effp, obuf, osamp)
LONG *obuf;
int *osamp;
{
*osamp = 0;
+ return (ST_SUCCESS);
}
/*
@@ -139,8 +147,9 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-void swap_stop(effp)
+int st_swap_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -41,7 +41,7 @@
/*
* Process options
*/
-void vibro_getopts(effp, n, argv)
+int st_vibro_getopts(effp, n, argv)
eff_t effp;
int n;
char **argv;
@@ -51,14 +51,22 @@
vibro->depth = 0.5;
if ((n == 0) || !sscanf(argv[0], "%f", &vibro->speed) ||
((n == 2) && !sscanf(argv[1], "%f", &vibro->depth)))
+ {
fail("Usage: vibro speed [ depth ]");
+ return (ST_EOF);
+ }
if ((vibro->speed <= 0.001) || (vibro->speed > 30.0) ||
(vibro->depth < 0.0) || (vibro->depth > 1.0))
+ {
fail("Vibro: speed must be < 30.0, 0.0 < depth < 1.0");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/* This was very painful. We need a sine library. */
/* SJB: this is somewhat different than st_sine() */
+/* FIXME: move to misc.c */
static void sine(buf, len, depth)
short *buf;
int len;
@@ -78,7 +86,7 @@
/*
* Prepare processing.
*/
-void vibro_start(effp)
+int st_vibro_start(effp)
eff_t effp;
{
vibro_t vibro = (vibro_t) effp->priv;
@@ -85,11 +93,15 @@
vibro->length = effp->ininfo.rate / vibro->speed;
if (! (vibro->sinetab = (short*) malloc(vibro->length * sizeof(short))))
+ {
fail("Vibro: Cannot malloc %d bytes",
vibro->length * sizeof(short));
+ return (ST_EOF);
+ }
sine(vibro->sinetab, vibro->length, vibro->depth);
vibro->counter = 0;
+ return (ST_SUCCESS);
}
/*
@@ -97,7 +109,7 @@
* Return number of samples processed.
*/
-void vibro_flow(effp, ibuf, obuf, isamp, osamp)
+int st_vibro_flow(effp, ibuf, obuf, isamp, osamp)
eff_t effp;
LONG *ibuf, *obuf;
LONG *isamp, *osamp;
@@ -120,6 +132,7 @@
}
vibro->counter = counter;
/* processed all samples */
+ return (ST_SUCCESS);
}
/*
@@ -126,9 +139,10 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-void vibro_stop(effp)
+int st_vibro_stop(effp)
eff_t effp;
{
/* nothing to do */
+ return (ST_SUCCESS);
}