ref: 924db4eba84e9c490633964febb73f306f914874
parent: dd86c4d4eea52c6da1221a238204312f6eb8a491
author: rrt <rrt>
date: Sun May 27 11:04:24 EDT 2007
API update
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,7 +2,7 @@
RM = rm -f
-AM_CPPFLAGS = -DPKGLIBDIR="\"$(pkglibdir)\""
+AM_CPPFLAGS = -DLADSPA_PATH="\"@LADSPA_PATH@\"" -DPKGLIBDIR="\"$(pkglibdir)\""
AM_CFLAGS = $(LTDLINCL) -Wconversion
AM_LDFLAGS = $(LIBLTDL)
@@ -172,7 +172,7 @@
effects = band.h biquad.c biquad.h biquads.c chorus.c compand.c \
compandt.c compandt.h dcshift.c dither.c earwax.c echo.c echos.c \
- fade.c FFT.c FFT.h filter.c flanger.c mcompand.c \
+ fade.c FFT.c FFT.h filter.c flanger.c ladspa.c mcompand.c \
mixer.c noiseprof.c noisered.c noisered.h pad.c pan.c \
phaser.c pitch.c polyphas.c rabbit.c rate.c repeat.c \
resample.c reverb.c reverse.c silence.c skeleff.c speed.c \
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -16,6 +16,8 @@
snd_pcm_t *pcm_handle;
char *buf;
sox_size_t buf_size;
+ snd_pcm_uframes_t period_size;
+ snd_pcm_uframes_t frames_this_period;
} *alsa_priv_t;
static int get_format(ft_t ft, snd_pcm_format_mask_t *fmask, int *fmt)
@@ -365,6 +367,8 @@
}
alsa->buf_size = buffer_size * ft->signal.size * ft->signal.channels;
+ alsa->period_size = period_size;
+ alsa->frames_this_period = 0;
alsa->buf = xmalloc(alsa->buf_size);
return (SOX_SUCCESS);
@@ -645,6 +649,9 @@
}
}
+ /* keep track of how many frames have been played this period, so we know
+ * how many frames of silence to append at the end of playback */
+ alsa->frames_this_period = (alsa->frames_this_period + nsamp / ft->signal.channels) % alsa->period_size;
return nsamp;
}
@@ -652,6 +659,27 @@
static int sox_alsastopwrite(ft_t ft)
{
alsa_priv_t alsa = (alsa_priv_t)ft->priv;
+
+ /* Append silence to fill the rest of the period, because alsa provides
+ * whole periods to the hardware */
+ snd_pcm_uframes_t frames_of_silence = alsa->period_size - alsa->frames_this_period;
+
+ memset(alsa->buf, 0, frames_of_silence * ft->signal.size * ft->signal.channels);
+
+ while (0 && frames_of_silence > 0) {
+ int err;
+ err = snd_pcm_writei(alsa->pcm_handle,
+ alsa->buf,
+ frames_of_silence);
+ if (err < 0) {
+ if (xrun_recovery(alsa->pcm_handle, err) < 0) {
+ sox_fail_errno(ft, SOX_EPERM, "ALSA write error");
+ /* FIXME: return a more suitable error code */
+ return SOX_EOF;
+ }
+ } else
+ frames_of_silence -= err;
+ }
snd_pcm_drain(alsa->pcm_handle);
snd_pcm_close(alsa->pcm_handle);
--- a/src/biquad.c
+++ b/src/biquad.c
@@ -31,7 +31,7 @@
static char const all_width_types[] = "hboqs";
-int sox_biquad_getopts(sox_effect_t effp, int n, char **argv,
+int sox_biquad_getopts(sox_effect_t * effp, int n, char **argv,
int min_args, int max_args, int fc_pos, int width_pos, int gain_pos,
char const * allowed_width_types, filter_t filter_type)
{
@@ -55,7 +55,7 @@
}
-int sox_biquad_start(sox_effect_t effp)
+int sox_biquad_start(sox_effect_t * effp)
{
biquad_t p = (biquad_t) effp->priv;
@@ -113,7 +113,7 @@
}
-int sox_biquad_flow(sox_effect_t effp, const sox_ssample_t *ibuf,
+int sox_biquad_flow(sox_effect_t * effp, const sox_ssample_t *ibuf,
sox_ssample_t *obuf, sox_size_t *isamp, sox_size_t *osamp)
{
biquad_t p = (biquad_t) effp->priv;
--- a/src/biquad.h
+++ b/src/biquad.h
@@ -74,11 +74,11 @@
assert_static(sizeof(struct biquad) <= SOX_MAX_EFFECT_PRIVSIZE,
/* else */ biquad_PRIVSIZE_too_big);
-int sox_biquad_getopts(sox_effect_t effp, int n, char **argv,
+int sox_biquad_getopts(sox_effect_t * effp, int n, char **argv,
int min_args, int max_args, int fc_pos, int width_pos, int gain_pos,
char const * allowed_width_types, filter_t filter_type);
-int sox_biquad_start(sox_effect_t effp);
-int sox_biquad_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+int sox_biquad_start(sox_effect_t * effp);
+int sox_biquad_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp);
#undef sox_fail
--- a/src/biquads.c
+++ b/src/biquads.c
@@ -64,13 +64,13 @@
#include <math.h>
-static int hilo1_getopts(sox_effect_t effp, int n, char **argv) {
+static int hilo1_getopts(sox_effect_t * effp, int n, char **argv) {
return sox_biquad_getopts(effp, n, argv, 1, 1, 0, 1, 2, "",
*effp->handler.name == 'l'? filter_LPF_1 : filter_HPF_1);
}
-static int hilo2_getopts(sox_effect_t effp, int n, char **argv) {
+static int hilo2_getopts(sox_effect_t * effp, int n, char **argv) {
biquad_t p = (biquad_t) effp->priv;
if (n != 0 && strcmp(argv[0], "-1") == 0)
return hilo1_getopts(effp, n - 1, argv + 1);
@@ -82,7 +82,7 @@
}
-static int bandpass_getopts(sox_effect_t effp, int n, char **argv) {
+static int bandpass_getopts(sox_effect_t * effp, int n, char **argv) {
filter_t type = filter_BPF;
if (n != 0 && strcmp(argv[0], "-c") == 0)
++argv, --n, type = filter_BPF_CSG;
@@ -90,12 +90,12 @@
}
-static int bandrej_getopts(sox_effect_t effp, int n, char **argv) {
+static int bandrej_getopts(sox_effect_t * effp, int n, char **argv) {
return sox_biquad_getopts(effp, n, argv, 2, 2, 0, 1, 2, "hqob", filter_notch);
}
-static int allpass_getopts(sox_effect_t effp, int n, char **argv) {
+static int allpass_getopts(sox_effect_t * effp, int n, char **argv) {
filter_t type = filter_APF;
int m;
if (n != 0 && strcmp(argv[0], "-1") == 0)
@@ -107,7 +107,7 @@
}
-static int tone_getopts(sox_effect_t effp, int n, char **argv) {
+static int tone_getopts(sox_effect_t * effp, int n, char **argv) {
biquad_t p = (biquad_t) effp->priv;
p->width = 0.5;
p->fc = *effp->handler.name == 'b'? 100 : 3000;
@@ -116,12 +116,12 @@
}
-static int equalizer_getopts(sox_effect_t effp, int n, char **argv) {
+static int equalizer_getopts(sox_effect_t * effp, int n, char **argv) {
return sox_biquad_getopts(effp, n, argv, 3, 3, 0, 1, 2, "qoh", filter_peakingEQ);
}
-static int band_getopts(sox_effect_t effp, int n, char **argv) {
+static int band_getopts(sox_effect_t * effp, int n, char **argv) {
filter_t type = filter_BPF_SPK;
if (n != 0 && strcmp(argv[0], "-n") == 0)
++argv, --n, type = filter_BPF_SPK_N;
@@ -129,7 +129,7 @@
}
-static int deemph_getopts(sox_effect_t effp, int n, char **argv) {
+static int deemph_getopts(sox_effect_t * effp, int n, char **argv) {
biquad_t p = (biquad_t) effp->priv;
p->fc = 5283;
p->width = 0.4845;
@@ -138,7 +138,7 @@
}
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
biquad_t p = (biquad_t) effp->priv;
double w0 = 2 * M_PI * p->fc / effp->ininfo.rate;
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -90,7 +90,7 @@
/*
* Process options
*/
-static int sox_chorus_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_chorus_getopts(sox_effect_t * effp, int n, char **argv)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
@@ -134,7 +134,7 @@
/*
* Prepare for processing.
*/
-static int sox_chorus_start(sox_effect_t effp)
+static int sox_chorus_start(sox_effect_t * effp)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
@@ -241,7 +241,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_chorus_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_chorus_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
chorus_t chorus = (chorus_t) effp->priv;
@@ -279,7 +279,7 @@
/*
* Drain out reverb lines.
*/
-static int sox_chorus_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_chorus_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
chorus_t chorus = (chorus_t) effp->priv;
sox_size_t done;
@@ -322,7 +322,7 @@
/*
* Clean up chorus effect.
*/
-static int sox_chorus_stop(sox_effect_t effp)
+static int sox_chorus_stop(sox_effect_t * effp)
{
chorus_t chorus = (chorus_t) effp->priv;
int i;
--- a/src/compand.c
+++ b/src/compand.c
@@ -59,7 +59,7 @@
int delay_buf_full; /* Shows buffer situation (important for drain) */
} * compand_t;
-static int getopts(sox_effect_t effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int n, char * * argv)
{
compand_t l = (compand_t) effp->priv;
char * s;
@@ -126,7 +126,7 @@
return SOX_SUCCESS;
}
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
compand_t l = (compand_t) effp->priv;
unsigned i, j;
@@ -175,7 +175,7 @@
*v += delta * l->channels[chan].attack_times[1];
}
-static int flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
compand_t l = (compand_t) effp->priv;
@@ -236,7 +236,7 @@
return (SOX_SUCCESS);
}
-static int drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
compand_t l = (compand_t) effp->priv;
sox_size_t chan, done = 0;
@@ -256,7 +256,7 @@
return l->delay_buf_cnt > 0 ? SOX_SUCCESS : SOX_EOF;
}
-static int stop(sox_effect_t effp)
+static int stop(sox_effect_t * effp)
{
compand_t l = (compand_t) effp->priv;
@@ -264,7 +264,7 @@
return SOX_SUCCESS;
}
-static int kill(sox_effect_t effp)
+static int kill(sox_effect_t * effp)
{
compand_t l = (compand_t) effp->priv;
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -28,7 +28,7 @@
/*
* Process options: dcshift (double) type (amplitude, power, dB)
*/
-static int sox_dcshift_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_dcshift_getopts(sox_effect_t * effp, int n, char **argv)
{
dcs_t dcs = (dcs_t) effp->priv;
dcs->dcshift = 1.0; /* default is no change */
@@ -70,7 +70,7 @@
/*
* Start processing
*/
-static int sox_dcshift_start(sox_effect_t effp)
+static int sox_dcshift_start(sox_effect_t * effp)
{
dcs_t dcs = (dcs_t) effp->priv;
@@ -99,7 +99,7 @@
/*
* Process data.
*/
-static int sox_dcshift_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_dcshift_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
dcs_t dcs = (dcs_t) effp->priv;
@@ -166,7 +166,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-static int sox_dcshift_stop(sox_effect_t effp)
+static int sox_dcshift_stop(sox_effect_t * effp)
{
dcs_t dcs = (dcs_t) effp->priv;
--- a/src/dither.c
+++ b/src/dither.c
@@ -23,7 +23,7 @@
assert_static(sizeof(struct dither) <= SOX_MAX_EFFECT_PRIVSIZE,
/* else */ dither_PRIVSIZE_too_big);
-static int getopts(sox_effect_t effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int n, char * * argv)
{
dither_t dither = (dither_t) effp->priv;
@@ -48,7 +48,7 @@
return SOX_SUCCESS;
}
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
dither_t dither = (dither_t) effp->priv;
@@ -65,7 +65,7 @@
return SOX_EFF_NULL; /* Dithering not needed at >= 24 bits */
}
-static int flow(sox_effect_t effp, const sox_ssample_t * ibuf,
+static int flow(sox_effect_t * effp, const sox_ssample_t * ibuf,
sox_ssample_t * obuf, sox_size_t * isamp, sox_size_t * osamp)
{
dither_t dither = (dither_t)effp->priv;
--- a/src/earwax.c
+++ b/src/earwax.c
@@ -73,7 +73,7 @@
/*
* Prepare for processing.
*/
-static int sox_earwax_start(sox_effect_t effp)
+static int sox_earwax_start(sox_effect_t * effp)
{
earwax_t earwax = (earwax_t) effp->priv;
int i;
@@ -100,7 +100,7 @@
* Return number of samples processed.
*/
-static int sox_earwax_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_earwax_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
earwax_t earwax = (earwax_t) effp->priv;
@@ -132,7 +132,7 @@
/*
* Drain out taps.
*/
-static int sox_earwax_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_earwax_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
earwax_t earwax = (earwax_t) effp->priv;
int i,j;
@@ -153,7 +153,7 @@
/*
* Clean up taps.
*/
-static int sox_earwax_stop(sox_effect_t effp)
+static int sox_earwax_stop(sox_effect_t * effp)
{
earwax_t earwax = (earwax_t) effp->priv;
--- a/src/echo.c
+++ b/src/echo.c
@@ -80,7 +80,7 @@
/*
* Process options
*/
-static int sox_echo_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_echo_getopts(sox_effect_t * effp, int n, char **argv)
{
echo_t echo = (echo_t) effp->priv;
int i;
@@ -111,7 +111,7 @@
/*
* Prepare for processing.
*/
-static int sox_echo_start(sox_effect_t effp)
+static int sox_echo_start(sox_effect_t * effp)
{
echo_t echo = (echo_t) effp->priv;
int i;
@@ -178,7 +178,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_echo_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_echo_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
echo_t echo = (echo_t) effp->priv;
@@ -214,7 +214,7 @@
/*
* Drain out reverb lines.
*/
-static int sox_echo_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_echo_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
echo_t echo = (echo_t) effp->priv;
double d_in, d_out;
@@ -254,7 +254,7 @@
/*
* Clean up reverb effect.
*/
-static int sox_echo_stop(sox_effect_t effp)
+static int sox_echo_stop(sox_effect_t * effp)
{
echo_t echo = (echo_t) effp->priv;
--- a/src/echos.c
+++ b/src/echos.c
@@ -70,7 +70,7 @@
/*
* Process options
*/
-static int sox_echos_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_echos_getopts(sox_effect_t * effp, int n, char **argv)
{
echos_t echos = (echos_t) effp->priv;
int i;
@@ -105,7 +105,7 @@
/*
* Prepare for processing.
*/
-static int sox_echos_start(sox_effect_t effp)
+static int sox_echos_start(sox_effect_t * effp)
{
echos_t echos = (echos_t) effp->priv;
int i;
@@ -170,7 +170,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_echos_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_echos_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
echos_t echos = (echos_t) effp->priv;
@@ -212,7 +212,7 @@
/*
* Drain out reverb lines.
*/
-static int sox_echos_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_echos_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
echos_t echos = (echos_t) effp->priv;
double d_in, d_out;
@@ -258,7 +258,7 @@
/*
* Clean up echos effect.
*/
-static int sox_echos_stop(sox_effect_t effp)
+static int sox_echos_stop(sox_effect_t * effp)
{
echos_t echos = (echos_t) effp->priv;
--- a/src/effects.c
+++ b/src/effects.c
@@ -18,11 +18,11 @@
#include "sox_i.h"
-sox_effect_t sox_effects[SOX_MAX_EFFECTS];
+sox_effect_t * sox_effects[SOX_MAX_EFFECTS];
unsigned sox_neffects;
-int sox_add_effect(sox_effect_t e, sox_signalinfo_t * in, sox_signalinfo_t * out, int * effects_mask)
+int sox_add_effect(sox_effect_t * e, sox_signalinfo_t * in, sox_signalinfo_t * out, int * effects_mask)
{
unsigned f, flows;
@@ -83,9 +83,9 @@
int ret = SOX_SUCCESS;
for (i = 0; i < sox_neffects; ++i) {
- sox_effect_t e = &sox_effects[i][0];
+ sox_effect_t * e = &sox_effects[i][0];
sox_bool is_always_null = (e->handler.flags & SOX_EFF_NULL) != 0;
- int (*start)(sox_effect_t effp) = e->handler.start;
+ int (*start)(sox_effect_t * effp) = e->handler.start;
if (is_always_null)
sox_report("'%s' has no effect (is a proxy effect)", e->handler.name);
@@ -111,7 +111,7 @@
}
}
for (i = 0; i < sox_neffects; ++i) {
- sox_effect_t e = &sox_effects[i][0];
+ sox_effect_t * e = &sox_effects[i][0];
sox_report("Effects chain: %-10s %uHz %u channels %s",
e->handler.name, e->ininfo.rate, e->ininfo.channels,
(e->handler.flags & SOX_EFF_MCHAN)? "(multi)" : "");
--- a/src/fade.c
+++ b/src/fade.c
@@ -43,7 +43,7 @@
* The 'info' fields are not yet filled in.
*/
-static int sox_fade_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_fade_getopts(sox_effect_t * effp, int n, char **argv)
{
fade_t fade = (fade_t) effp->priv;
@@ -122,7 +122,7 @@
* Prepare processing.
* Do all initializations.
*/
-static int sox_fade_start(sox_effect_t effp)
+static int sox_fade_start(sox_effect_t * effp)
{
fade_t fade = (fade_t) effp->priv;
@@ -195,7 +195,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_fade_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_fade_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
fade_t fade = (fade_t) effp->priv;
@@ -276,7 +276,7 @@
/*
* Drain out remaining samples if the effect generates any.
*/
-static int sox_fade_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_fade_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
fade_t fade = (fade_t) effp->priv;
int len;
@@ -317,7 +317,7 @@
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
*/
-static int kill(sox_effect_t effp)
+static int kill(sox_effect_t * effp)
{
fade_t fade = (fade_t) effp->priv;
--- a/src/filter.c
+++ b/src/filter.c
@@ -52,7 +52,7 @@
/*
* Process options
*/
-static int sox_filter_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_filter_getopts(sox_effect_t * effp, int n, char **argv)
{
filter_t f = (filter_t) effp->priv;
@@ -102,7 +102,7 @@
/*
* Prepare processing.
*/
-static int sox_filter_start(sox_effect_t effp)
+static int sox_filter_start(sox_effect_t * effp)
{
filter_t f = (filter_t) effp->priv;
double *Fp0, *Fp1;
@@ -180,7 +180,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_filter_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_filter_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
filter_t f = (filter_t) effp->priv;
@@ -233,7 +233,7 @@
/*
* Process tail of input samples.
*/
-static int sox_filter_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_filter_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
filter_t f = (filter_t) effp->priv;
long isamp_res, osamp_res;
@@ -270,7 +270,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-static int sox_filter_stop(sox_effect_t effp)
+static int sox_filter_stop(sox_effect_t * effp)
{
filter_t f = (filter_t) effp->priv;
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -132,7 +132,7 @@
-static int sox_flanger_getopts(sox_effect_t effp, int argc, char *argv[])
+static int sox_flanger_getopts(sox_effect_t * effp, int argc, char *argv[])
{
flanger_t f = (flanger_t) effp->priv;
@@ -181,7 +181,7 @@
-static int sox_flanger_start(sox_effect_t effp)
+static int sox_flanger_start(sox_effect_t * effp)
{
flanger_t f = (flanger_t) effp->priv;
int c, channels = effp->ininfo.channels;
@@ -234,7 +234,7 @@
-static int sox_flanger_flow(sox_effect_t effp, sox_ssample_t const * ibuf,
+static int sox_flanger_flow(sox_effect_t * effp, sox_ssample_t const * ibuf,
sox_ssample_t * obuf, sox_size_t * isamp, sox_size_t * osamp)
{
flanger_t f = (flanger_t) effp->priv;
@@ -289,7 +289,7 @@
-static int sox_flanger_stop(sox_effect_t effp)
+static int sox_flanger_stop(sox_effect_t * effp)
{
flanger_t f = (flanger_t) effp->priv;
int c, channels = effp->ininfo.channels;
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -16,6 +16,7 @@
/* File format handlers. */
#ifdef HAVE_LTDL_H
+/* FIXME: Use a vector, not a fixed-size array */
#define MAX_FORMATS 256
unsigned sox_formats = 0;
sox_format_tab_t sox_format_fns[MAX_FORMATS];
@@ -33,6 +34,7 @@
/* Effects handlers. */
+/* FIXME: Generate this list automatically */
sox_effect_fn_t sox_effect_fns[] = {
sox_allpass_effect_fn,
sox_avg_effect_fn,
@@ -54,6 +56,9 @@
sox_flanger_effect_fn,
sox_highpass_effect_fn,
sox_highp_effect_fn,
+#ifdef HAVE_LADSPA_H
+ sox_ladspa_effect_fn,
+#endif
sox_lowpass_effect_fn,
sox_lowp_effect_fn,
sox_mask_effect_fn,
--- /dev/null
+++ b/src/ladspa.c
@@ -1,0 +1,140 @@
+/*
+ * LADSPA effectsupport for sox
+ * (c) Reuben Thomas <rrt@sc3d.org> 2007
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, write to the Free Software
+ * Foundation, Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301,
+ * USA. */
+
+#include "sox_i.h"
+
+#ifdef HAVE_LADSPA_H
+
+#include <ltdl.h>
+#include <ladspa.h>
+
+static sox_effect_handler_t sox_ladspa_effect;
+
+/* Private data for resampling */
+typedef struct {
+ char *name; /* Plugin name */
+ lt_dlhandle lth;
+} *ladspa_t;
+
+/*
+ * Process options
+ */
+static int sox_ladspa_getopts(sox_effect_t * effp, int n, char **argv)
+{
+ ladspa_t l_st = (ladspa_t)effp->priv;
+ char *path;
+ LADSPA_Descriptor *l_desc;
+ LADSPA_Descriptor_Function l_fn;
+
+ /* Get module name */
+ if (n >= 1) {
+ l_st->name = argv[0];
+ n--; argv++;
+ }
+
+ /* Load module */
+ path = getenv("LADSPA_PATH");
+ if (path == NULL)
+ path = LADSPA_PATH;
+ lt_dlsetsearchpath(path);
+ if ((l_st->lth = lt_dlopenext(l_st->name)) == NULL) {
+ sox_fail("could not open LADSPA plugin %s", l_st->name);
+ return SOX_EOF;
+ }
+
+ /* Get descriptor function */
+ if ((l_fn = lt_dlsym(l_st->lth, "ladspa_descriptor") == NULL)) {
+ sox_fail("could not find ladspa_descriptor");
+ return SOX_EOF;
+ }
+
+ /* If more than one plugin, next argument is plugin name */
+// if (ladspa_descriptor
+
+ /* Stop if we have any unused arguments */
+ if (n > 0) {
+ sox_fail(sox_ladspa_effect.usage);
+ return SOX_EOF;
+ }
+
+ return SOX_SUCCESS;
+}
+
+/*
+ * Prepare processing.
+ */
+static int sox_ladspa_start(sox_effect_t * effp)
+{
+ ladspa_t l_st = (ladspa_t)effp->priv;
+
+ return SOX_SUCCESS;
+}
+
+/*
+ * Process one bufferful of data.
+ */
+static int sox_ladspa_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf UNUSED,
+ sox_size_t *isamp, sox_size_t *osamp)
+{
+ ladspa_t l_st = (ladspa_t)effp->priv;
+
+ return SOX_SUCCESS;
+}
+
+/*
+ * Close down the effect.
+ */
+static int sox_ladspa_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
+{
+ ladspa_t l_st = (ladspa_t)effp->priv;
+
+ *osamp = 0;
+
+ return SOX_SUCCESS;
+}
+
+/*
+ * Do anything required when you stop reading samples.
+ * Don't close input file!
+ */
+static int sox_ladspa_stop(sox_effect_t * effp)
+{
+ ladspa_t l_st = (ladspa_t)effp->priv;
+
+ return SOX_SUCCESS;
+}
+
+static sox_effect_handler_t sox_ladspa_effect = {
+ "ladspa",
+ "Usage: ladspa MODULE [PLUGIN] [ARGUMENT...]",
+ SOX_EFF_RATE | SOX_EFF_MCHAN,
+ sox_ladspa_getopts,
+ sox_ladspa_start,
+ sox_ladspa_flow,
+ sox_ladspa_drain,
+ sox_ladspa_stop,
+ NULL
+};
+
+const sox_effect_handler_t *sox_ladspa_effect_fn(void)
+{
+ return &sox_ladspa_effect;
+}
+
+#endif /* HAVE_LADSPA */
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -123,7 +123,7 @@
return (SOX_SUCCESS);
}
-static int lowpass_flow(sox_effect_t effp, butterworth_crossover_t butterworth, sox_size_t nChan, sox_ssample_t *ibuf, sox_ssample_t *lowbuf, sox_ssample_t *highbuf,
+static int lowpass_flow(sox_effect_t * effp, butterworth_crossover_t butterworth, sox_size_t nChan, sox_ssample_t *ibuf, sox_ssample_t *lowbuf, sox_ssample_t *highbuf,
sox_size_t len) {
sox_size_t chan;
double in, out;
@@ -300,7 +300,7 @@
return SOX_SUCCESS;
}
-static int sox_mcompand_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_mcompand_getopts(sox_effect_t * effp, int n, char **argv)
{
char *subargv[6], *cp;
sox_size_t subargc, i, len;
@@ -348,7 +348,7 @@
* Prepare processing.
* Do all initializations.
*/
-static int sox_mcompand_start(sox_effect_t effp)
+static int sox_mcompand_start(sox_effect_t * effp)
{
compand_t c = (compand_t) effp->priv;
comp_band_t l;
@@ -407,7 +407,7 @@
*v += delta * l->decayRate[chan];
}
-static int sox_mcompand_flow_1(sox_effect_t effp, compand_t c, comp_band_t l, const sox_ssample_t *ibuf, sox_ssample_t *obuf, sox_size_t len, sox_size_t filechans)
+static int sox_mcompand_flow_1(sox_effect_t * effp, compand_t c, comp_band_t l, const sox_ssample_t *ibuf, sox_ssample_t *obuf, sox_size_t len, sox_size_t filechans)
{
sox_size_t done, chan;
@@ -477,7 +477,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_mcompand_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_mcompand_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp) {
compand_t c = (compand_t) effp->priv;
comp_band_t l;
@@ -529,7 +529,7 @@
return SOX_SUCCESS;
}
-static int sox_mcompand_drain_1(sox_effect_t effp, compand_t c, comp_band_t l, sox_ssample_t *obuf, sox_size_t maxdrain)
+static int sox_mcompand_drain_1(sox_effect_t * effp, compand_t c, comp_band_t l, sox_ssample_t *obuf, sox_size_t maxdrain)
{
sox_size_t done;
double out;
@@ -553,7 +553,7 @@
/*
* Drain out compander delay lines.
*/
-static int sox_mcompand_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_mcompand_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
sox_size_t band, drained, mostdrained = 0;
compand_t c = (compand_t)effp->priv;
@@ -578,7 +578,7 @@
/*
* Clean up compander effect.
*/
-static int sox_mcompand_stop(sox_effect_t effp)
+static int sox_mcompand_stop(sox_effect_t * effp)
{
compand_t c = (compand_t) effp->priv;
comp_band_t l;
@@ -603,7 +603,7 @@
return SOX_SUCCESS;
}
-static int sox_mcompand_kill(sox_effect_t effp)
+static int sox_mcompand_kill(sox_effect_t * effp)
{
compand_t c = (compand_t) effp->priv;
comp_band_t l;
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -47,7 +47,7 @@
/*
* Process options
*/
-static int getopts(sox_effect_t effp, int n, char **argv)
+static int getopts(sox_effect_t * effp, int n, char **argv)
{
mixer_t mixer = (mixer_t) effp->priv;
double* pans = &mixer->sources[0][0];
@@ -115,7 +115,7 @@
/*
* Start processing
*/
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
/*
Hmmm, this is tricky. Lemme think:
@@ -508,7 +508,7 @@
* Process either isamp or osamp samples, whichever is smaller.
*/
-static int flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
mixer_t mixer = (mixer_t) effp->priv;
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -37,7 +37,7 @@
/*
* Get the filename, if any. We don't open it until sox_noiseprof_start.
*/
-static int sox_noiseprof_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_noiseprof_getopts(sox_effect_t * effp, int n, char **argv)
{
profdata_t data = (profdata_t) effp->priv;
@@ -55,7 +55,7 @@
* Prepare processing.
* Do all initializations.
*/
-static int sox_noiseprof_start(sox_effect_t effp)
+static int sox_noiseprof_start(sox_effect_t * effp)
{
profdata_t data = (profdata_t) effp->priv;
unsigned channels = effp->ininfo.channels;
@@ -108,7 +108,7 @@
/*
* Grab what we can from ibuf, and process if we have a whole window.
*/
-static int sox_noiseprof_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_noiseprof_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
profdata_t data = (profdata_t) effp->priv;
@@ -150,7 +150,7 @@
* Finish off the last window.
*/
-static int sox_noiseprof_drain(sox_effect_t effp, sox_ssample_t *obuf UNUSED, sox_size_t *osamp)
+static int sox_noiseprof_drain(sox_effect_t * effp, sox_ssample_t *obuf UNUSED, sox_size_t *osamp)
{
profdata_t data = (profdata_t) effp->priv;
int tracks = effp->ininfo.channels;
@@ -179,7 +179,7 @@
/*
* Print profile and clean up.
*/
-static int sox_noiseprof_stop(sox_effect_t effp)
+static int sox_noiseprof_stop(sox_effect_t * effp)
{
profdata_t data = (profdata_t) effp->priv;
sox_size_t i;
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -51,7 +51,7 @@
* Get the options. Default file is stdin (if the audio
* input file isn't coming from there, of course!)
*/
-static int sox_noisered_getopts(sox_effect_t effp, int argc, char **argv)
+static int sox_noisered_getopts(sox_effect_t * effp, int argc, char **argv)
{
reddata_t this = (reddata_t) effp->priv;
@@ -77,7 +77,7 @@
* Prepare processing.
* Do all initializations.
*/
-static int sox_noisered_start(sox_effect_t effp)
+static int sox_noisered_start(sox_effect_t * effp)
{
reddata_t data = (reddata_t) effp->priv;
sox_size_t fchannels = 0;
@@ -219,7 +219,7 @@
/* Do window management once we have a complete window, including mangling
* the current window. */
-static int process_window(sox_effect_t effp, reddata_t data, unsigned chan_num, unsigned num_chans,
+static int process_window(sox_effect_t * effp, reddata_t data, unsigned chan_num, unsigned num_chans,
sox_ssample_t *obuf, unsigned len) {
int j;
float* nextwindow;
@@ -257,7 +257,7 @@
/*
* Read in windows, and call process_window once we get a whole one.
*/
-static int sox_noisered_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_noisered_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
reddata_t data = (reddata_t) effp->priv;
@@ -307,7 +307,7 @@
* We have up to half a window left to dump.
*/
-static int sox_noisered_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_noisered_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
reddata_t data = (reddata_t)effp->priv;
unsigned i;
@@ -324,7 +324,7 @@
/*
* Clean up.
*/
-static int sox_noisered_stop(sox_effect_t effp)
+static int sox_noisered_stop(sox_effect_t * effp)
{
reddata_t data = (reddata_t) effp->priv;
sox_size_t i;
--- a/src/pad.c
+++ b/src/pad.c
@@ -35,7 +35,7 @@
assert_static(sizeof(struct pad) <= SOX_MAX_EFFECT_PRIVSIZE,
/* else */ pad_PRIVSIZE_too_big);
-static int parse(sox_effect_t effp, char * * argv, sox_rate_t rate)
+static int parse(sox_effect_t * effp, char * * argv, sox_rate_t rate)
{
pad_t p = (pad_t) effp->priv;
char const * next;
@@ -62,7 +62,7 @@
return SOX_SUCCESS;
}
-static int create(sox_effect_t effp, int n, char * * argv)
+static int create(sox_effect_t * effp, int n, char * * argv)
{
pad_t p = (pad_t) effp->priv;
p->pads = xcalloc(p->npads = n, sizeof(*p->pads));
@@ -69,7 +69,7 @@
return parse(effp, argv, SOX_MAXRATE); /* No rate yet; parse with dummy */
}
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
pad_t p = (pad_t) effp->priv;
unsigned i;
@@ -82,7 +82,7 @@
return SOX_EFF_NULL;
}
-static int flow(sox_effect_t effp, const sox_ssample_t * ibuf, sox_ssample_t * obuf,
+static int flow(sox_effect_t * effp, const sox_ssample_t * ibuf, sox_ssample_t * obuf,
sox_size_t * isamp, sox_size_t * osamp)
{
pad_t p = (pad_t) effp->priv;
@@ -111,7 +111,7 @@
return SOX_SUCCESS;
}
-static int drain(sox_effect_t effp, sox_ssample_t * obuf, sox_size_t * osamp)
+static int drain(sox_effect_t * effp, sox_ssample_t * obuf, sox_size_t * osamp)
{
static sox_size_t isamp = 0;
pad_t p = (pad_t) effp->priv;
@@ -120,7 +120,7 @@
return flow(effp, 0, obuf, &isamp, osamp);
}
-static int stop(sox_effect_t effp)
+static int stop(sox_effect_t * effp)
{
pad_t p = (pad_t) effp->priv;
if (p->pads_pos != p->npads)
@@ -128,7 +128,7 @@
return SOX_SUCCESS;
}
-static int kill(sox_effect_t effp)
+static int kill(sox_effect_t * effp)
{
pad_t p = (pad_t) effp->priv;
unsigned i;
--- a/src/pan.c
+++ b/src/pan.c
@@ -28,7 +28,7 @@
/*
* Process options
*/
-static int sox_pan_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_pan_getopts(sox_effect_t * effp, int n, char **argv)
{
pan_t pan = (pan_t) effp->priv;
@@ -47,7 +47,7 @@
/*
* Start processing
*/
-static int sox_pan_start(sox_effect_t effp)
+static int sox_pan_start(sox_effect_t * effp)
{
if (effp->outinfo.channels==1)
sox_warn("PAN onto a mono channel...");
@@ -71,7 +71,7 @@
/*
* Process either isamp or osamp samples, whichever is smaller.
*/
-static int sox_pan_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_pan_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
pan_t pan = (pan_t) effp->priv;
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -79,7 +79,7 @@
/*
* Process options
*/
-static int sox_phaser_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_phaser_getopts(sox_effect_t * effp, int n, char **argv)
{
phaser_t phaser = (phaser_t) effp->priv;
@@ -112,7 +112,7 @@
/*
* Prepare for processing.
*/
-static int sox_phaser_start(sox_effect_t effp)
+static int sox_phaser_start(sox_effect_t * effp)
{
phaser_t phaser = (phaser_t) effp->priv;
unsigned int i;
@@ -177,7 +177,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_phaser_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_phaser_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
phaser_t phaser = (phaser_t) effp->priv;
@@ -211,7 +211,7 @@
/*
* Drain out reverb lines.
*/
-static int sox_phaser_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_phaser_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
phaser_t phaser = (phaser_t) effp->priv;
sox_size_t done;
@@ -250,7 +250,7 @@
/*
* Clean up phaser effect.
*/
-static int sox_phaser_stop(sox_effect_t effp)
+static int sox_phaser_stop(sox_effect_t * effp)
{
phaser_t phaser = (phaser_t) effp->priv;
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -244,7 +244,7 @@
/*
* Process options
*/
-static int sox_pitch_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_pitch_getopts(sox_effect_t * effp, int n, char **argv)
{
pitch_t pitch = (pitch_t) effp->priv;
@@ -327,7 +327,7 @@
/*
* Start processing
*/
-static int sox_pitch_start(sox_effect_t effp)
+static int sox_pitch_start(sox_effect_t * effp)
{
pitch_t pitch = (pitch_t) effp->priv;
register int sample_rate = effp->outinfo.rate;
@@ -439,7 +439,7 @@
/* Processes input.
*/
-static int sox_pitch_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_pitch_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
pitch_t pitch = (pitch_t) effp->priv;
@@ -516,7 +516,7 @@
/* at the end...
*/
-static int sox_pitch_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_pitch_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
pitch_t pitch = (pitch_t) effp->priv;
sox_size_t i;
@@ -560,7 +560,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-static int sox_pitch_stop(sox_effect_t effp)
+static int sox_pitch_stop(sox_effect_t * effp)
{
pitch_t pitch = (pitch_t) effp->priv;
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -63,7 +63,7 @@
/*
* Process options
*/
-static int sox_poly_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_poly_getopts(sox_effect_t * effp, int n, char **argv)
{
poly_t rate = (poly_t) effp->priv;
@@ -340,7 +340,7 @@
#define RIBLEN 2048
-static int sox_poly_start(sox_effect_t effp)
+static int sox_poly_start(sox_effect_t * effp)
{
poly_t rate = (poly_t) effp->priv;
static int l1[MF], l2[MF];
@@ -488,7 +488,7 @@
}
-static int sox_poly_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_poly_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
poly_t rate = (poly_t) effp->priv;
@@ -591,7 +591,7 @@
/*
* Process tail of input samples.
*/
-static int sox_poly_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_poly_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
sox_size_t in_size;
/* Call "flow" with NULL input. */
@@ -603,7 +603,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-static int sox_poly_stop(sox_effect_t effp)
+static int sox_poly_stop(sox_effect_t * effp)
{
poly_t rate = (poly_t)effp->priv;
sox_size_t k;
--- a/src/rabbit.c
+++ b/src/rabbit.c
@@ -44,7 +44,7 @@
/*
* Process options
*/
-static int sox_rabbit_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_rabbit_getopts(sox_effect_t * effp, int n, char **argv)
{
rabbit_t r = (rabbit_t) effp->priv;
@@ -80,7 +80,7 @@
/*
* Prepare processing.
*/
-static int sox_rabbit_start(sox_effect_t effp)
+static int sox_rabbit_start(sox_effect_t * effp)
{
rabbit_t r = (rabbit_t) effp->priv;
@@ -109,7 +109,7 @@
/*
* Read all the data.
*/
-static int sox_rabbit_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf UNUSED,
+static int sox_rabbit_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf UNUSED,
sox_size_t *isamp, sox_size_t *osamp)
{
rabbit_t r = (rabbit_t) effp->priv;
@@ -139,7 +139,7 @@
/*
* Process samples and write output.
*/
-static int sox_rabbit_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_rabbit_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
rabbit_t r = (rabbit_t) effp->priv;
int channels = effp->ininfo.channels;
@@ -184,7 +184,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-static int sox_rabbit_stop(sox_effect_t effp)
+static int sox_rabbit_stop(sox_effect_t * effp)
{
rabbit_t r = (rabbit_t) effp->priv;
--- a/src/rate.c
+++ b/src/rate.c
@@ -7,12 +7,12 @@
#include "sox_i.h"
-int sox_resample_getopts(sox_effect_t effp, int n, char **argv);
-int sox_resample_start(sox_effect_t effp);
-int sox_resample_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+int sox_resample_getopts(sox_effect_t * effp, int n, char **argv);
+int sox_resample_start(sox_effect_t * effp);
+int sox_resample_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp);
-int sox_resample_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp);
-int sox_resample_stop(sox_effect_t effp);
+int sox_resample_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp);
+int sox_resample_stop(sox_effect_t * effp);
static sox_effect_handler_t sox_rate_effect = {
"rate",
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -32,7 +32,7 @@
int repeats;
} *repeat_t;
-static int sox_repeat_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_repeat_getopts(sox_effect_t * effp, int n, char **argv)
{
repeat_t repeat = (repeat_t)effp->priv;
@@ -54,7 +54,7 @@
return (SOX_SUCCESS);
}
-static int sox_repeat_start(sox_effect_t effp)
+static int sox_repeat_start(sox_effect_t * effp)
{
repeat_t repeat = (repeat_t)effp->priv;
@@ -71,7 +71,7 @@
return (SOX_SUCCESS);
}
-static int sox_repeat_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf UNUSED,
+static int sox_repeat_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf UNUSED,
sox_size_t *isamp, sox_size_t *osamp)
{
repeat_t repeat = (repeat_t)effp->priv;
@@ -87,7 +87,7 @@
return (SOX_SUCCESS);
}
-static int sox_repeat_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_repeat_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
size_t read = 0;
sox_ssample_t *buf;
@@ -185,7 +185,7 @@
return SOX_SUCCESS;
}
-static int sox_repeat_stop(sox_effect_t effp)
+static int sox_repeat_stop(sox_effect_t * effp)
{
repeat_t repeat = (repeat_t)effp->priv;
--- a/src/resample.c
+++ b/src/resample.c
@@ -139,7 +139,7 @@
/*
* Process options
*/
-int sox_resample_getopts(sox_effect_t effp, int n, char **argv)
+int sox_resample_getopts(sox_effect_t * effp, int n, char **argv)
{
resample_t r = (resample_t) effp->priv;
@@ -190,7 +190,7 @@
/*
* Prepare processing.
*/
-int sox_resample_start(sox_effect_t effp)
+int sox_resample_start(sox_effect_t * effp)
{
resample_t r = (resample_t) effp->priv;
long Xoff, gcdrate;
@@ -278,7 +278,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int sox_resample_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+int sox_resample_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
resample_t r = (resample_t) effp->priv;
@@ -383,7 +383,7 @@
/*
* Process tail of input samples.
*/
-int sox_resample_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+int sox_resample_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
resample_t r = (resample_t) effp->priv;
long isamp_res, osamp_res;
@@ -423,7 +423,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-int sox_resample_stop(sox_effect_t effp)
+int sox_resample_stop(sox_effect_t * effp)
{
resample_t r = (resample_t) effp->priv;
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -113,7 +113,7 @@
/*
* Process options
*/
-static int sox_reverb_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_reverb_getopts(sox_effect_t * effp, int n, char **argv)
{
reverb_t reverb = (reverb_t) effp->priv;
int i;
@@ -148,7 +148,7 @@
/*
* Prepare for processing.
*/
-static int sox_reverb_start(sox_effect_t effp)
+static int sox_reverb_start(sox_effect_t * effp)
{
reverb_t reverb = (reverb_t) effp->priv;
size_t i;
@@ -201,7 +201,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_reverb_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_reverb_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
reverb_t reverb = (reverb_t) effp->priv;
@@ -234,7 +234,7 @@
/*
* Drain out reverb lines.
*/
-static int sox_reverb_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_reverb_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
reverb_t reverb = (reverb_t) effp->priv;
float d_in, d_out;
@@ -271,7 +271,7 @@
/*
* Clean up reverb effect.
*/
-static int sox_reverb_stop(sox_effect_t effp)
+static int sox_reverb_stop(sox_effect_t * effp)
{
reverb_t reverb = (reverb_t) effp->priv;
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -34,7 +34,7 @@
* Prepare processing: open temporary file.
*/
-static int sox_reverse_start(sox_effect_t effp)
+static int sox_reverse_start(sox_effect_t * effp)
{
reverse_t reverse = (reverse_t) effp->priv;
reverse->fp = tmpfile();
@@ -51,7 +51,7 @@
* Effect flow: a degenerate case: write input samples on temporary file,
* don't generate any output samples.
*/
-static int sox_reverse_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf UNUSED,
+static int sox_reverse_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf UNUSED,
sox_size_t *isamp, sox_size_t *osamp)
{
reverse_t reverse = (reverse_t) effp->priv;
@@ -75,7 +75,7 @@
* Effect drain: generate the actual samples in reverse order.
*/
-static int sox_reverse_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_reverse_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
reverse_t reverse = (reverse_t) effp->priv;
sox_size_t len, nbytes;
@@ -121,7 +121,7 @@
/*
* Close and unlink the temporary file.
*/
-static int sox_reverse_stop(sox_effect_t effp)
+static int sox_reverse_stop(sox_effect_t * effp)
{
reverse_t reverse = (reverse_t) effp->priv;
--- a/src/silence.c
+++ b/src/silence.c
@@ -65,7 +65,7 @@
char mode;
} *silence_t;
-static void clear_rms(sox_effect_t effp)
+static void clear_rms(sox_effect_t * effp)
{
silence_t silence = (silence_t) effp->priv;
@@ -78,7 +78,7 @@
silence->rms_sum = 0;
}
-static int sox_silence_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_silence_getopts(sox_effect_t * effp, int n, char **argv)
{
silence_t silence = (silence_t) effp->priv;
int parse_count;
@@ -248,7 +248,7 @@
return(SOX_SUCCESS);
}
-static int sox_silence_start(sox_effect_t effp)
+static int sox_silence_start(sox_effect_t * effp)
{
silence_t silence = (silence_t) effp->priv;
@@ -301,7 +301,7 @@
return(SOX_SUCCESS);
}
-static int aboveThreshold(sox_effect_t effp, sox_ssample_t value, double threshold, int unit)
+static int aboveThreshold(sox_effect_t * effp, sox_ssample_t value, double threshold, int unit)
{
double ratio;
int rc;
@@ -340,7 +340,7 @@
return rc;
}
-static sox_ssample_t compute_rms(sox_effect_t effp, sox_ssample_t sample)
+static sox_ssample_t compute_rms(sox_effect_t * effp, sox_ssample_t sample)
{
silence_t silence = (silence_t) effp->priv;
double new_sum;
@@ -355,7 +355,7 @@
return (rms);
}
-static void update_rms(sox_effect_t effp, sox_ssample_t sample)
+static void update_rms(sox_effect_t * effp, sox_ssample_t sample)
{
silence_t silence = (silence_t) effp->priv;
@@ -370,7 +370,7 @@
/* Process signed long samples from ibuf to obuf. */
/* Return number of samples processed in isamp and osamp. */
-static int sox_silence_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_silence_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
silence_t silence = (silence_t) effp->priv;
@@ -657,7 +657,7 @@
return (SOX_SUCCESS);
}
-static int sox_silence_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_silence_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
silence_t silence = (silence_t) effp->priv;
sox_size_t i;
@@ -693,7 +693,7 @@
return SOX_SUCCESS;
}
-static int sox_silence_stop(sox_effect_t effp)
+static int sox_silence_stop(sox_effect_t * effp)
{
silence_t silence = (silence_t) effp->priv;
@@ -703,7 +703,7 @@
return(SOX_SUCCESS);
}
-static int kill(sox_effect_t effp)
+static int kill(sox_effect_t * effp)
{
silence_t silence = (silence_t) effp->priv;
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -34,7 +34,7 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-static int getopts(sox_effect_t effp, int n, char **argv)
+static int getopts(sox_effect_t * effp, int n, char **argv)
{
skeleff_t skeleff = (skeleff_t)effp->priv;
@@ -50,7 +50,7 @@
* Prepare processing.
* Do all initializations.
*/
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
if (effp->outinfo.channels == 1) {
sox_fail("Can't run skeleff on mono data.");
@@ -64,7 +64,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
skeleff_t skeleff = (skeleff_t)effp->priv;
@@ -97,7 +97,7 @@
/*
* Drain out remaining samples if the effect generates any.
*/
-static int drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
*osamp = 0;
/* Help out application and return SOX_EOF when drain
@@ -110,7 +110,7 @@
/*
* Do anything required when you stop reading samples.
*/
-static int stop(sox_effect_t effp)
+static int stop(sox_effect_t * effp)
{
return SOX_SUCCESS;
}
@@ -119,7 +119,7 @@
* Do anything required when you kill an effect.
* (free allocated memory, etc.)
*/
-static int kill(sox_effect_t effp)
+static int kill(sox_effect_t * effp)
{
return SOX_SUCCESS;
}
--- a/src/sox.c
+++ b/src/sox.c
@@ -24,6 +24,7 @@
#include "sox_i.h"
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
@@ -133,7 +134,7 @@
* a resample effect, a channel mixing effect, the input, and the output.
*/
#define MAX_USER_EFF (SOX_MAX_EFFECTS - 4)
-static struct sox_effect user_efftab[MAX_USER_EFF];
+static sox_effect_t user_efftab[MAX_USER_EFF];
static unsigned nuser_effects;
static char *myname = NULL;
@@ -196,9 +197,12 @@
}
#ifdef HAVE_LTDL_H
- if (plugins_initted && (ret = lt_dlexit()) != 0) {
- sox_fail("lt_dlexit failed with %d error(s): %s", ret, lt_dlerror());
- exit(1);
+ {
+ int ret;
+ if (plugins_initted && (ret = lt_dlexit()) != 0) {
+ sox_fail("lt_dlexit failed with %d error(s): %s", ret, lt_dlerror());
+ exit(1);
+ }
}
#endif
}
@@ -429,7 +433,7 @@
static void parse_effects(int argc, char **argv)
{
for (nuser_effects = 0; optind < argc; ++nuser_effects) {
- struct sox_effect * e = &user_efftab[nuser_effects];
+ sox_effect_t *e = &user_efftab[nuser_effects];
int i;
if (nuser_effects >= MAX_USER_EFF) {
@@ -437,7 +441,8 @@
exit(1);
}
- sox_get_effect(e, argv[optind++]); /* Cannot fail */
+ /* Name should always be correct! */
+ sox_create_effect(e, sox_find_effect(argv[optind++]));
for (i = 0; i < argc - optind && !sox_find_effect(argv[optind + i]); ++i);
if (e->handler.getopts(e, i, &argv[optind]) == SOX_EOF)
@@ -446,7 +451,7 @@
optind += i; /* Skip past the effect arguments */
if (e->handler.flags & SOX_EFF_DEPRECATED)
- sox_warn("Effect `%s' is deprecated and may be removed in a future release; please refer to the manual sox(1) for an alternative effect", e->handler.name);
+ sox_warn("Effect `%s' is deprecated; see sox(1) for an alternative", e->handler.name);
}
}
@@ -842,12 +847,12 @@
combine_method = sox_merge;
break;
- case 'R': /* Useful for regression testing. */
+ case 'R': /* Useful for regression testing. */
repeatable_random = sox_true;
break;
case 'e': case 'n':
- return sox_true; /* I.e. is null file. */
+ return sox_true; /* i.e. is null file. */
break;
case 'h': case '?':
@@ -1094,7 +1099,7 @@
assert_static(sizeof(struct input_combiner) <= SOX_MAX_EFFECT_PRIVSIZE,
/* else */ input_combiner_PRIVSIZE_too_big);
-static int combiner_start(sox_effect_t effp)
+static int combiner_start(sox_effect_t *effp)
{
input_combiner_t z = (input_combiner_t) effp->priv;
sox_size_t ws, i;
@@ -1113,7 +1118,7 @@
return SOX_SUCCESS;
}
-static int combiner_drain(sox_effect_t effp, sox_ssample_t * obuf, sox_size_t * osamp)
+static int combiner_drain(sox_effect_t *effp, sox_ssample_t * obuf, sox_size_t * osamp)
{
input_combiner_t z = (input_combiner_t) effp->priv;
sox_size_t ws, s, i;
@@ -1163,7 +1168,7 @@
return olen? SOX_SUCCESS : SOX_EOF;
}
-static int combiner_stop(sox_effect_t effp)
+static int combiner_stop(sox_effect_t *effp)
{
input_combiner_t z = (input_combiner_t) effp->priv;
sox_size_t i;
@@ -1185,7 +1190,7 @@
return &handler;
}
-static int output_flow(sox_effect_t effp UNUSED, sox_ssample_t const * ibuf,
+static int output_flow(sox_effect_t *effp UNUSED, sox_ssample_t const * ibuf,
sox_ssample_t * obuf UNUSED, sox_size_t * isamp, sox_size_t * osamp)
{
size_t len;
@@ -1210,11 +1215,12 @@
return &handler;
}
-static void add_default_effect(char const * name, int * effects_mask)
+static void add_default_effect(char const *name, int *effects_mask)
{
- struct sox_effect e;
+ sox_effect_t e;
- sox_get_effect(&e, name); /* Find effect and update initial pointers */
+ /* Default name should always be correct! */
+ sox_create_effect(&e, sox_find_effect(name));
if (e.handler.getopts(&e, 0, NULL) == SOX_EOF) /* Set up with default opts */
exit(2);
sox_add_effect(&e, &combiner, &ofile->desc->signal, effects_mask);
@@ -1229,7 +1235,7 @@
sox_bool need_chan = combiner.channels != ofile->desc->signal.channels;
int user_mchan = -1;
sox_size_t channels = combiner.channels;
- struct sox_effect eff;
+ sox_effect_t eff;
{ /* Check if we have to add effects to change rate/chans or if the
user has specified effects to do this, in which case, check if
--- a/src/sox.h
+++ b/src/sox.h
@@ -19,7 +19,7 @@
/* The following is the API version of libSoX. It is not meant
* to follow the version number of SoX but it has historically.
- * Please do not count of these numbers being in sync.
+ * Please do not count on these numbers being in sync.
* The following is at 13.0.0
*/
#define SOX_LIB_VERSION_CODE 0x0d0000
@@ -372,7 +372,7 @@
* Handler structure for each effect.
*/
-typedef struct sox_effect * sox_effect_t;
+typedef struct sox_effect sox_effect_t;
typedef struct {
char const * name;
@@ -379,13 +379,13 @@
char const * usage;
unsigned int flags;
- int (*getopts)(sox_effect_t effp, int argc, char *argv[]);
- int (*start)(sox_effect_t effp);
- int (*flow)(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+ int (*getopts)(sox_effect_t * effp, int argc, char *argv[]);
+ int (*start)(sox_effect_t * effp);
+ int (*flow)(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp);
- int (*drain)(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp);
- int (*stop)(sox_effect_t effp);
- int (*kill)(sox_effect_t effp);
+ int (*drain)(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp);
+ int (*stop)(sox_effect_t * effp);
+ int (*kill)(sox_effect_t * effp);
} sox_effect_handler_t;
struct sox_effect {
@@ -421,16 +421,15 @@
#define SOX_SEEK_SET 0
extern int sox_seek(ft_t ft, sox_size_t offset, int whence);
-sox_effect_handler_t const * sox_find_effect(char const * name);
-int sox_create_effect(sox_effect_t effp, sox_effect_handler_t const * e);
-int sox_get_effect(sox_effect_t effp, const char * name);
-int sox_update_effect(sox_effect_t effp, const sox_signalinfo_t *in, const sox_signalinfo_t *out, int effect_mask);
+sox_effect_handler_t const *sox_find_effect(char const * name);
+int sox_create_effect(sox_effect_t * effp, sox_effect_handler_t const *e);
+int sox_update_effect(sox_effect_t * effp, const sox_signalinfo_t *in, const sox_signalinfo_t *out, int effect_mask);
/* Effects chain */
#define SOX_MAX_EFFECTS 20
-extern sox_effect_t sox_effects[SOX_MAX_EFFECTS];
+extern sox_effect_t * sox_effects[SOX_MAX_EFFECTS];
extern unsigned sox_neffects;
-int sox_add_effect(sox_effect_t e, sox_signalinfo_t * in, sox_signalinfo_t * out, int * effects_mask);
+int sox_add_effect(sox_effect_t * e, sox_signalinfo_t * in, sox_signalinfo_t * out, int * effects_mask);
int sox_start_effects(void);
int sox_flow_effects(void (* update_status)(sox_bool), sox_bool * user_abort);
void sox_stop_effects(void);
@@ -450,8 +449,8 @@
* wants to trim and use a sox_seek() operation instead. After
* sox_seek()'ing, you should set the trim option to 0.
*/
-sox_size_t sox_trim_get_start(sox_effect_t effp);
-void sox_trim_clear_start(sox_effect_t effp);
+sox_size_t sox_trim_get_start(sox_effect_t * effp);
+void sox_trim_clear_start(sox_effect_t * effp);
extern char const * sox_message_filename;
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -245,9 +245,9 @@
extern const char sox_writerr[];
extern uint8_t const cswap[256];
-/*=============================================================================
+/*-----------------------------------------------------------------------------
* File Handlers
- *=============================================================================
+ *-----------------------------------------------------------------------------
*/
/* Psion record header check, defined in misc.c and used in prc.c and auto.c */
@@ -286,9 +286,9 @@
#define sox_rawstopread sox_format_nothing
#define sox_rawstopwrite sox_format_nothing
-/*=============================================================================
+/*-----------------------------------------------------------------------------
* Effects
- *=============================================================================
+ *-----------------------------------------------------------------------------
*/
typedef const sox_effect_handler_t *(*sox_effect_fn_t)(void);
@@ -315,6 +315,9 @@
extern const sox_effect_handler_t *sox_flanger_effect_fn(void);
extern const sox_effect_handler_t *sox_highpass_effect_fn(void);
extern const sox_effect_handler_t *sox_highp_effect_fn(void);
+#ifdef HAVE_LADSPA_H
+extern const sox_effect_handler_t *sox_ladspa_effect_fn(void);
+#endif
extern const sox_effect_handler_t *sox_lowpass_effect_fn(void);
extern const sox_effect_handler_t *sox_lowp_effect_fn(void);
extern const sox_effect_handler_t *sox_mask_effect_fn(void);
@@ -349,10 +352,10 @@
extern const sox_effect_handler_t *sox_vol_effect_fn(void);
/* Needed in rate.c */
-int sox_resample_start(sox_effect_t effp);
-int sox_resample_getopts(sox_effect_t effp, int n, char **argv);
-int sox_resample_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf, sox_size_t *isamp, sox_size_t *osamp);
-int sox_resample_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp);
-int sox_resample_stop(sox_effect_t effp);
+int sox_resample_start(sox_effect_t * effp);
+int sox_resample_getopts(sox_effect_t * effp, int n, char **argv);
+int sox_resample_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf, sox_size_t *isamp, sox_size_t *osamp);
+int sox_resample_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp);
+int sox_resample_stop(sox_effect_t * effp);
#endif
--- a/src/speed.c
+++ b/src/speed.c
@@ -27,7 +27,7 @@
#include <math.h>
#include <string.h>
-static int getopts(sox_effect_t effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int n, char * * argv)
{
sox_bool is_cents = sox_false;
double speed;
--- a/src/stat.c
+++ b/src/stat.c
@@ -42,7 +42,7 @@
/*
* Process options
*/
-static int sox_stat_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_stat_getopts(sox_effect_t * effp, int n, char **argv)
{
stat_t stat = (stat_t) effp->priv;
@@ -82,7 +82,7 @@
/*
* Prepare processing.
*/
-static int sox_stat_start(sox_effect_t effp)
+static int sox_stat_start(sox_effect_t * effp)
{
stat_t stat = (stat_t) effp->priv;
int i;
@@ -129,7 +129,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_stat_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_stat_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
@@ -201,7 +201,7 @@
/*
* Process tail of input samples.
*/
-static int sox_stat_drain(sox_effect_t effp, sox_ssample_t *obuf UNUSED, sox_size_t *osamp)
+static int sox_stat_drain(sox_effect_t * effp, sox_ssample_t *obuf UNUSED, sox_size_t *osamp)
{
stat_t stat = (stat_t) effp->priv;
@@ -226,7 +226,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-static int sox_stat_stop(sox_effect_t effp)
+static int sox_stat_stop(sox_effect_t * effp)
{
stat_t stat = (stat_t) effp->priv;
double amp, scale, rms = 0, freq;
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -70,7 +70,7 @@
/*
* Process options
*/
-static int sox_stretch_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_stretch_getopts(sox_effect_t * effp, int n, char **argv)
{
char usage[1024];
stretch_t stretch = (stretch_t) effp->priv;
@@ -148,7 +148,7 @@
/*
* Start processing
*/
-static int sox_stretch_start(sox_effect_t effp)
+static int sox_stretch_start(sox_effect_t * effp)
{
stretch_t stretch = (stretch_t)effp->priv;
sox_size_t i;
@@ -242,7 +242,7 @@
/*
* Processes flow.
*/
-static int sox_stretch_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_stretch_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
stretch_t stretch = (stretch_t) effp->priv;
@@ -309,7 +309,7 @@
* Drain buffer at the end
* maybe not correct ? end might be artificially faded?
*/
-static int sox_stretch_drain(sox_effect_t effp, sox_ssample_t *obuf, sox_size_t *osamp)
+static int sox_stretch_drain(sox_effect_t * effp, sox_ssample_t *obuf, sox_size_t *osamp)
{
stretch_t stretch = (stretch_t) effp->priv;
sox_size_t i;
@@ -343,7 +343,7 @@
* Do anything required when you stop reading samples.
* Don't close input file!
*/
-static int sox_stretch_stop(sox_effect_t effp)
+static int sox_stretch_stop(sox_effect_t * effp)
{
stretch_t stretch = (stretch_t) effp->priv;
--- 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.
*/
-static int sox_swap_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_swap_getopts(sox_effect_t * effp, int n, char **argv)
{
swap_t swap = (swap_t) effp->priv;
@@ -60,7 +60,7 @@
* Prepare processing.
* Do all initializations.
*/
-static int sox_swap_start(sox_effect_t effp)
+static int sox_swap_start(sox_effect_t * effp)
{
swap_t swap = (swap_t) effp->priv;
int i;
@@ -131,7 +131,7 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-static int sox_swap_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_swap_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
swap_t swap = (swap_t) effp->priv;
--- a/src/synth.c
+++ b/src/synth.c
@@ -278,7 +278,7 @@
-static int getopts(sox_effect_t effp, int argc, char **argv)
+static int getopts(sox_effect_t * effp, int argc, char **argv)
{
synth_t synth = (synth_t) effp->priv;
int argn = 0;
@@ -380,7 +380,7 @@
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
synth_t synth = (synth_t) effp->priv;
unsigned i;
@@ -564,7 +564,7 @@
-static int flow(sox_effect_t effp, const sox_ssample_t * ibuf, sox_ssample_t * obuf,
+static int flow(sox_effect_t * effp, const sox_ssample_t * ibuf, sox_ssample_t * obuf,
sox_size_t * isamp, sox_size_t * osamp)
{
synth_t synth = (synth_t) effp->priv;
@@ -583,7 +583,7 @@
-static int kill(sox_effect_t effp)
+static int kill(sox_effect_t * effp)
{
synth_t synth = (synth_t) effp->priv;
free(synth->channels);
--- a/src/tremolo.c
+++ b/src/tremolo.c
@@ -18,7 +18,7 @@
#include "sox_i.h"
-static int getopts(sox_effect_t effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int n, char * * argv)
{
double speed, depth = 40;
char dummy; /* To check for extraneous chars. */
--- a/src/trim.c
+++ b/src/trim.c
@@ -35,7 +35,7 @@
/*
* Process options
*/
-static int sox_trim_getopts(sox_effect_t effp, int n, char **argv)
+static int sox_trim_getopts(sox_effect_t * effp, int n, char **argv)
{
trim_t trim = (trim_t) effp->priv;
@@ -74,7 +74,7 @@
/*
* Start processing
*/
-static int sox_trim_start(sox_effect_t effp)
+static int sox_trim_start(sox_effect_t * effp)
{
trim_t trim = (trim_t) effp->priv;
@@ -114,7 +114,7 @@
* Place in buf[].
* Return number of samples read.
*/
-static int sox_trim_flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int sox_trim_flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
int result = SOX_SUCCESS;
@@ -169,7 +169,7 @@
return result;
}
-static int kill(sox_effect_t effp)
+static int kill(sox_effect_t * effp)
{
trim_t trim = (trim_t) effp->priv;
@@ -179,13 +179,13 @@
return (SOX_SUCCESS);
}
-sox_size_t sox_trim_get_start(sox_effect_t effp)
+sox_size_t sox_trim_get_start(sox_effect_t * effp)
{
trim_t trim = (trim_t)effp->priv;
return trim->start;
}
-void sox_trim_clear_start(sox_effect_t effp)
+void sox_trim_clear_start(sox_effect_t * effp)
{
trim_t trim = (trim_t)effp->priv;
trim->start = 0;
--- a/src/util.c
+++ b/src/util.c
@@ -11,6 +11,7 @@
*/
#include "sox_i.h"
+#include <assert.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
@@ -120,7 +121,7 @@
int sox_gettype(ft_t formp, sox_bool is_file_extension)
{
const char * const *list;
- int i;
+ unsigned i;
if (!formp->filetype) {
sox_fail_errno(formp, SOX_EFMT, "Filetype was not specified");
@@ -159,12 +160,12 @@
}
/* dummy effect routine for do-nothing functions */
-static int effect_nothing(sox_effect_t effp UNUSED)
+static int effect_nothing(sox_effect_t * effp UNUSED)
{
return SOX_SUCCESS;
}
-static int effect_nothing_flow(sox_effect_t effp UNUSED, const sox_ssample_t *ibuf UNUSED, sox_ssample_t *obuf UNUSED, sox_size_t *isamp, sox_size_t *osamp)
+static int effect_nothing_flow(sox_effect_t * effp UNUSED, const sox_ssample_t *ibuf UNUSED, sox_ssample_t *obuf UNUSED, sox_size_t *isamp, sox_size_t *osamp)
{
/* Pass through samples verbatim */
*isamp = *osamp = min(*isamp, *osamp);
@@ -172,7 +173,7 @@
return SOX_SUCCESS;
}
-static int effect_nothing_drain(sox_effect_t effp UNUSED, sox_ssample_t *obuf UNUSED, sox_size_t *osamp)
+static int effect_nothing_drain(sox_effect_t * effp UNUSED, sox_ssample_t *obuf UNUSED, sox_size_t *osamp)
{
/* Inform no more samples to drain */
*osamp = 0;
@@ -179,7 +180,7 @@
return SOX_EOF;
}
-static int effect_nothing_getopts(sox_effect_t effp, int n, char **argv UNUSED)
+static int effect_nothing_getopts(sox_effect_t * effp, int n, char **argv UNUSED)
{
#undef sox_fail
#define sox_fail sox_message_filename=effp->handler.name,sox_fail
@@ -190,8 +191,9 @@
return (SOX_SUCCESS);
}
-int sox_create_effect(sox_effect_t effp, sox_effect_handler_t const * e)
+int sox_create_effect(sox_effect_t * effp, sox_effect_handler_t const * e)
{
+ assert(e);
memset(effp, 0, sizeof(*effp));
effp->global_info = &effects_global_info;
effp->handler = *e;
@@ -204,20 +206,9 @@
return SOX_SUCCESS;
}
-int sox_get_effect(sox_effect_t effp, const char * name)
-{
- sox_effect_handler_t const * e = sox_find_effect(name);
-
- if (!e)
- return SOX_EOF;
-
- sox_create_effect(effp, e);
- return SOX_SUCCESS;
-}
-
/*
* Copy input and output signal info into effect structures.
- * Must pass in a bitmask containing info of wheither SOX_EFF_CHAN
+ * Must pass in a bitmask containing info on whether SOX_EFF_CHAN
* or SOX_EFF_RATE has been used previously on this effect stream.
* If not running multiple effects then just pass in a value of 0.
*
@@ -227,38 +218,32 @@
* calls.
*/
-int sox_update_effect(sox_effect_t effp, const sox_signalinfo_t *in, const sox_signalinfo_t *out,
+int sox_update_effect(sox_effect_t * effp, const sox_signalinfo_t *in, const sox_signalinfo_t *out,
int effect_mask)
{
effp->ininfo = *in;
-
effp->outinfo = *out;
- if (in->channels != out->channels)
- {
- /* Only effects with SOX_EFF_CHAN flag can actually handle
- * outputing a different number of channels then the input.
- */
- if (!(effp->handler.flags & SOX_EFF_CHAN))
- {
- /* If this effect is being ran before a SOX_EFF_CHAN effect
- * then effect's output is the same as the input file. Else its
- * input contains same number of channels as the output
- * file.
- */
- if (effect_mask & SOX_EFF_CHAN)
- effp->ininfo.channels = out->channels;
- else
- effp->outinfo.channels = in->channels;
-
- }
+ if (in->channels != out->channels) {
+ /* Only effects with SOX_EFF_CHAN flag can actually handle
+ * outputing a different number of channels then the input.
+ */
+ if (!(effp->handler.flags & SOX_EFF_CHAN)) {
+ /* If this effect is being run before a SOX_EFF_CHAN effect
+ * then its output is the same as the input file; otherwise,
+ * its input contains the same number of channels as the
+ * output file. */
+ if (effect_mask & SOX_EFF_CHAN)
+ effp->ininfo.channels = out->channels;
+ else
+ effp->outinfo.channels = in->channels;
+ }
}
if (in->rate != out->rate)
{
- /* Only the SOX_EFF_RATE effect can handle an input that
- * is a different sample rate then the output.
- */
+ /* Only SOX_EFF_RATE effects can handle an input that
+ * has a different sample rate from the output. */
if (!(effp->handler.flags & SOX_EFF_RATE))
{
if (effect_mask & SOX_EFF_RATE)
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -18,7 +18,7 @@
#include "sox_i.h"
-static int getopts(sox_effect_t effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int n, char * * argv)
{
double speed, depth = 0.5;
char dummy; /* To check for extraneous chars. */
--- a/src/vol.c
+++ b/src/vol.c
@@ -39,7 +39,7 @@
/*
* Process options: gain (float) type (amplitude, power, dB)
*/
-static int getopts(sox_effect_t effp, int argc, char **argv)
+static int getopts(sox_effect_t * effp, int argc, char **argv)
{
vol_t vol = (vol_t) effp->priv;
char type_string[11];
@@ -100,7 +100,7 @@
/*
* Start processing
*/
-static int start(sox_effect_t effp)
+static int start(sox_effect_t * effp)
{
vol_t vol = (vol_t) effp->priv;
@@ -116,7 +116,7 @@
/*
* Process data.
*/
-static int flow(sox_effect_t effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
+static int flow(sox_effect_t * effp, const sox_ssample_t *ibuf, sox_ssample_t *obuf,
sox_size_t *isamp, sox_size_t *osamp)
{
vol_t vol = (vol_t) effp->priv;
@@ -174,7 +174,7 @@
return SOX_SUCCESS;
}
-static int stop(sox_effect_t effp)
+static int stop(sox_effect_t * effp)
{
vol_t vol = (vol_t) effp->priv;
if (vol->limited) {