ref: 27dd7298086a2cf261bf22bc88245d2ee0d0ce9a
parent: 3ae7e2e44b739c26b560b79f8a66fa191ff8cf08
author: cbagwell <cbagwell>
date: Sat Sep 2 12:32:16 EDT 2006
Switching handlers back to func interface to make win32 happy.
--- a/src/avg.c
+++ b/src/avg.c
@@ -21,7 +21,8 @@
#include <string.h>
#include <stdlib.h>
-/* Private data for SKEL file */
+static st_effect_t st_avg_effect;
+
typedef struct avgstuff {
/* How to generate each output channel. sources[i][j] */
/* represents the fraction of channel i that should be passed */
@@ -546,7 +547,7 @@
return (ST_SUCCESS); /* nothing to do */
}
-st_effect_t st_avg_effect = {
+static st_effect_t st_avg_effect = {
"avg",
"Usage: avg [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
ST_EFF_MCHAN | ST_EFF_CHAN,
@@ -557,7 +558,7 @@
st_avg_stop
};
-st_effect_t st_pick_effect = {
+static st_effect_t st_pick_effect = {
"pick",
"Usage: pick [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
ST_EFF_MCHAN | ST_EFF_CHAN,
@@ -567,3 +568,13 @@
st_effect_nothing_drain,
st_avg_stop
};
+
+const st_effect_t *st_avg_effect_fn(void)
+{
+ return &st_avg_effect;
+}
+
+const st_effect_t *st_pick_effect_fn(void)
+{
+ return &st_pick_effect;
+}
--- a/src/band.c
+++ b/src/band.c
@@ -46,14 +46,16 @@
#include <string.h>
#include "st_i.h"
+static st_effect_t st_band_effect;
+
/* Private data for Bandpass effect */
typedef struct bandstuff {
- float center;
- float width;
- double A, B, C;
- double out1, out2;
- short noise;
- /* 50 bytes of data, 52 bytes long for allocation purposes. */
+ float center;
+ float width;
+ double A, B, C;
+ double out1, out2;
+ short noise;
+ /* 50 bytes of data, 52 bytes long for allocation purposes. */
} *band_t;
/*
@@ -61,26 +63,26 @@
*/
int st_band_getopts(eff_t effp, int n, char **argv)
{
- band_t band = (band_t) effp->priv;
+ band_t band = (band_t) effp->priv;
- band->noise = 0;
- if (n > 0 && !strcmp(argv[0], "-n")) {
- band->noise = 1;
- n--;
- argv++;
- }
- if ((n < 1) || !sscanf(argv[0], "%f", &band->center))
- {
- st_fail(st_band_effect.usage);
- return (ST_EOF);
- }
- band->width = band->center / 2;
- if ((n >= 2) && !sscanf(argv[1], "%f", &band->width))
- {
- st_fail(st_band_effect.usage);
- return (ST_EOF);
- }
- return (ST_SUCCESS);
+ band->noise = 0;
+ if (n > 0 && !strcmp(argv[0], "-n")) {
+ band->noise = 1;
+ n--;
+ argv++;
+ }
+ if ((n < 1) || !sscanf(argv[0], "%f", &band->center))
+ {
+ st_fail(st_band_effect.usage);
+ return (ST_EOF);
+ }
+ band->width = band->center / 2;
+ if ((n >= 2) && !sscanf(argv[1], "%f", &band->width))
+ {
+ st_fail(st_band_effect.usage);
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -88,23 +90,23 @@
*/
int st_band_start(eff_t effp)
{
- band_t band = (band_t) effp->priv;
- if (band->center > effp->ininfo.rate/2)
- {
- st_fail("Band: center must be < minimum data rate/2\n");
- return (ST_EOF);
- }
+ band_t band = (band_t) effp->priv;
+ if (band->center > effp->ininfo.rate/2)
+ {
+ st_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)*
- cos(2*M_PI*band->center/effp->ininfo.rate);
- if (band->noise)
- band->A = sqrt(((1+band->C)*(1+band->C)-band->B *
- band->B)*(1-band->C)/(1+band->C));
- else
- band->A = sqrt(1-band->B*band->B/(4*band->C))*(1-band->C);
- band->out1 = band->out2 = 0.0;
- return (ST_SUCCESS);
+ band->C = exp(-2*M_PI*band->width/effp->ininfo.rate);
+ band->B = -4*band->C/(1+band->C)*
+ cos(2*M_PI*band->center/effp->ininfo.rate);
+ if (band->noise)
+ band->A = sqrt(((1+band->C)*(1+band->C)-band->B *
+ band->B)*(1-band->C)/(1+band->C));
+ else
+ band->A = sqrt(1-band->B*band->B/(4*band->C))*(1-band->C);
+ band->out1 = band->out2 = 0.0;
+ return (ST_SUCCESS);
}
/*
@@ -113,26 +115,26 @@
*/
int st_band_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
- st_size_t *isamp, st_size_t *osamp)
+ st_size_t *isamp, st_size_t *osamp)
{
- band_t band = (band_t) effp->priv;
- int len, done;
- double d;
- st_sample_t l;
+ band_t band = (band_t) effp->priv;
+ int len, done;
+ double d;
+ st_sample_t l;
- len = ((*isamp > *osamp) ? *osamp : *isamp);
+ len = ((*isamp > *osamp) ? *osamp : *isamp);
- /* yeah yeah yeah registers & integer arithmetic yeah yeah yeah */
- for(done = 0; done < len; done++) {
- l = *ibuf++;
- d = (band->A * l - band->B * band->out1) - band->C * band->out2;
- band->out2 = band->out1;
- band->out1 = d;
- *obuf++ = d;
- }
- *isamp = len;
- *osamp = len;
- return(ST_SUCCESS);
+ /* yeah yeah yeah registers & integer arithmetic yeah yeah yeah */
+ for(done = 0; done < len; done++) {
+ l = *ibuf++;
+ d = (band->A * l - band->B * band->out1) - band->C * band->out2;
+ band->out2 = band->out1;
+ band->out1 = d;
+ *obuf++ = d;
+ }
+ *isamp = len;
+ *osamp = len;
+ return(ST_SUCCESS);
}
/*
@@ -141,10 +143,10 @@
*/
int st_band_stop(eff_t effp)
{
- return (ST_SUCCESS); /* nothing to do */
+ return (ST_SUCCESS); /* nothing to do */
}
-st_effect_t st_band_effect = {
+static st_effect_t st_band_effect = {
"band",
"Usage: band [ -n ] center [ width ]",
0,
@@ -154,3 +156,8 @@
st_effect_nothing_drain,
st_band_stop
};
+
+const st_effect_t *st_band_effect_fn(void)
+{
+ return &st_band_effect;
+}
--- a/src/bandpass.c
+++ b/src/bandpass.c
@@ -36,6 +36,8 @@
#include "st_i.h"
#include "btrworth.h"
+static st_effect_t st_bandpass_effect;
+
int st_bandpass_getopts (eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -77,7 +79,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_bandpass_effect = {
+static st_effect_t st_bandpass_effect = {
"bandpass",
"Usage: bandpass FREQUENCY BANDWIDTH",
0,
@@ -87,3 +89,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_bandpass_effect_fn(void)
+{
+ return &st_bandpass_effect;
+}
--- a/src/breject.c
+++ b/src/breject.c
@@ -36,6 +36,8 @@
#include "st_i.h"
#include "btrworth.h"
+static st_effect_t st_bandreject_effect;
+
int st_bandreject_getopts(eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -77,7 +79,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_bandreject_effect = {
+static st_effect_t st_bandreject_effect = {
"bandreject",
"Usage: bandreject FREQUENCY BANDWIDTH",
0,
@@ -87,3 +89,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_bandreject_effect_fn(void)
+{
+ return &st_bandreject_effect;
+}
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -71,7 +71,8 @@
#define MOD_TRIANGLE 1
#define MAX_CHORUS 7
-/* Private data for SKEL file */
+static st_effect_t st_chorus_effect;
+
typedef struct chorusstuff {
int num_chorus;
int modulation[MAX_CHORUS];
@@ -349,7 +350,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_chorus_effect = {
+static st_effect_t st_chorus_effect = {
"chorus",
"Usage: chorus gain-in gain-out delay decay speed depth [ -s | -t ]",
0,
@@ -359,3 +360,8 @@
st_chorus_drain,
st_chorus_stop
};
+
+const st_effect_t *st_chorus_effect_fn(void)
+{
+ return &st_chorus_effect;
+}
--- a/src/compand.c
+++ b/src/compand.c
@@ -43,7 +43,8 @@
* output level of the transfer function.
*/
-/* Private data for SKEL file */
+static st_effect_t st_compand_effect;
+
typedef struct {
int expectedChannels; /* Also flags that channels aren't to be treated
individually when = 1 and input not mono */
@@ -404,7 +405,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_compand_effect = {
+static st_effect_t st_compand_effect = {
"compand",
"Usage: {<attack_time>,<decay_time>}+ {<dB_in>,<db_out>}+ [<dB_postamp> [<initial-volume> [<delay_time]]]\n"
" where {}+ means e or more in a comma-separated, white-space-free list'\n"
@@ -417,3 +418,8 @@
st_compand_drain,
st_compand_stop
};
+
+const st_effect_t *st_compand_effect_fn(void)
+{
+ return &st_compand_effect;
+}
--- a/src/copy.c
+++ b/src/copy.c
@@ -14,17 +14,19 @@
#include "st_i.h"
#include "string.h" /* memcpy() */
+static st_effect_t st_copy_effect;
+
/*
* Process options
*/
int st_copy_getopts(eff_t effp, int n, char **argv)
{
- if (n)
- {
- st_fail(st_copy_effect.usage);
- return (ST_EOF);
- }
- return (ST_SUCCESS);
+ if (n)
+ {
+ st_fail(st_copy_effect.usage);
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -32,8 +34,8 @@
*/
int st_copy_start(eff_t effp)
{
- /* nothing to do */
- /* stuff data into delaying effects here */
+ /* nothing to do */
+ /* stuff data into delaying effects here */
return (ST_SUCCESS);
}
@@ -46,12 +48,12 @@
int st_copy_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
- int done;
-
- done = ((*isamp < *osamp) ? *isamp : *osamp);
- memcpy(obuf, ibuf, done * sizeof(st_sample_t));
- *isamp = *osamp = done;
- return (ST_SUCCESS);
+ int done;
+
+ done = ((*isamp < *osamp) ? *isamp : *osamp);
+ memcpy(obuf, ibuf, done * sizeof(st_sample_t));
+ *isamp = *osamp = done;
+ return (ST_SUCCESS);
}
/*
@@ -60,11 +62,11 @@
*/
int st_copy_stop(eff_t effp)
{
- /* nothing to do */
+ /* nothing to do */
return (ST_SUCCESS);
}
-st_effect_t st_copy_effect = {
+static st_effect_t st_copy_effect = {
"copy",
"Usage: Copy effect takes no options",
ST_EFF_MCHAN,
@@ -74,3 +76,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_copy_effect_fn(void)
+{
+ return &st_copy_effect;
+}
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -15,6 +15,8 @@
#include <math.h> /* exp(), sqrt() */
+static st_effect_t st_dcshift_effect;
+
/* type used for computations.
*/
#ifndef DCSHIFT_FLOAT
@@ -208,7 +210,7 @@
return ST_SUCCESS;
}
-st_effect_t st_dcshift_effect = {
+static st_effect_t st_dcshift_effect = {
"dcshift",
"Usage: dcshift shift [ limitergain ]\n"
" The peak limiter has a gain much less than 1.0 (ie 0.05 or 0.02) which is only\n"
@@ -220,3 +222,8 @@
st_effect_nothing_drain,
st_dcshift_stop
};
+
+const st_effect_t *st_dcshift_effect_fn(void)
+{
+ return &st_dcshift_effect;
+}
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -101,6 +101,8 @@
#include <math.h>
#include "st_i.h"
+static st_effect_t st_deemph_effect ;
+
/* Private data for deemph file */
typedef struct deemphstuff {
st_sample_t lastin;
@@ -203,7 +205,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_deemph_effect = {
+static st_effect_t st_deemph_effect = {
"deemph",
"Usage: Deemphasis filtering effect takes no options",
0,
@@ -213,3 +215,8 @@
st_effect_nothing_drain,
st_deemph_stop
};
+
+const st_effect_t *st_deemph_effect_fn(void)
+{
+ return &st_deemph_effect;
+}
--- a/src/earwax.c
+++ b/src/earwax.c
@@ -27,6 +27,8 @@
#include "st_i.h"
+static st_effect_t st_earwax_effect;
+
#define EARWAX_SCALE 64
/* A stereo fir filter. One side filters as if the signal was from
@@ -185,7 +187,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_earwax_effect = {
+static st_effect_t st_earwax_effect = {
"earwax",
"Usage: The earwax filtering effect takes no options",
ST_EFF_MCHAN,
@@ -195,3 +197,8 @@
st_earwax_drain,
st_earwax_stop
};
+
+const st_effect_t *st_earwax_effect_fn(void)
+{
+ return &st_earwax_effect;
+}
--- a/src/echo.c
+++ b/src/echo.c
@@ -59,6 +59,8 @@
#include <math.h>
#include "st_i.h"
+static st_effect_t st_echo_effect;
+
#define DELAY_BUFSIZ ( 50L * ST_MAXRATE )
#define MAX_ECHOS 7 /* 24 bit x ( 1 + MAX_ECHOS ) = */
/* 24 bit x 8 = 32 bit !!! */
@@ -269,7 +271,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_echo_effect = {
+static st_effect_t st_echo_effect = {
"echo",
"Usage: echo gain-in gain-out delay decay [ delay decay ... ]",
0,
@@ -279,3 +281,8 @@
st_echo_drain,
st_echo_stop
};
+
+const st_effect_t *st_echo_effect_fn(void)
+{
+ return &st_echo_effect;
+}
--- a/src/echos.c
+++ b/src/echos.c
@@ -50,6 +50,8 @@
#include <math.h>
#include "st_i.h"
+static st_effect_t st_echos_effect;
+
#define DELAY_BUFSIZ ( 50L * ST_MAXRATE )
#define MAX_ECHOS 7 /* 24 bit x ( 1 + MAX_ECHOS ) = */
/* 24 bit x 8 = 32 bit !!! */
@@ -273,7 +275,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_echos_effect = {
+static st_effect_t st_echos_effect = {
"echos",
"Usage: echos gain-in gain-out delay decay [ delay decay ... ]",
0,
@@ -283,3 +285,8 @@
st_echos_drain,
st_echos_stop
};
+
+const st_effect_t *st_echos_effect_fn(void)
+{
+ return &st_echos_effect;
+}
--- a/src/fade.c
+++ b/src/fade.c
@@ -24,6 +24,8 @@
#include <string.h>
#include "st_i.h"
+static st_effect_t st_fade_effect;
+
/* Private data for fade file */
typedef struct fadestuff
{ /* These are measured as samples */
@@ -398,7 +400,7 @@
return retval;
}
-st_effect_t st_fade_effect = {
+static st_effect_t st_fade_effect = {
"fade",
"Usage: fade [ type ] fade-in-length [ stop-time [ fade-out-length ] ]\n"
" Time is in hh:mm:ss.frac format.\n"
@@ -410,3 +412,8 @@
st_fade_drain,
st_fade_stop
};
+
+const st_effect_t *st_fade_effect_fn(void)
+{
+ return &st_fade_effect;
+}
--- a/src/filter.c
+++ b/src/filter.c
@@ -27,6 +27,8 @@
#include "st_i.h"
+static st_effect_t st_filter_effect;
+
#ifndef HAVE_MEMMOVE
#define memmove(dest,src,len) bcopy((src),(dest),(len))
#endif
@@ -315,7 +317,7 @@
}
}
-st_effect_t st_filter_effect = {
+static st_effect_t st_filter_effect = {
"filter",
"Usage: filter low-high [ windowlength [ beta ] ]",
0,
@@ -325,3 +327,8 @@
st_filter_drain,
st_filter_stop
};
+
+const st_effect_t *st_filter_effect_fn(void)
+{
+ return &st_filter_effect;
+}
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -57,6 +57,8 @@
#include <string.h>
#include "st_i.h"
+static st_effect_t st_flanger_effect;
+
#define MOD_SINE 0
#define MOD_TRIANGLE 1
@@ -287,7 +289,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_flanger_effect = {
+static st_effect_t st_flanger_effect = {
"flanger",
"Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]",
0,
@@ -297,3 +299,8 @@
st_flanger_drain,
st_flanger_stop
};
+
+const st_effect_t *st_flanger_effect_fn(void)
+{
+ return &st_flanger_effect;
+}
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -78,54 +78,48 @@
*
*/
-st_effect_t st_terminate_effect =
-{
- 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-st_effect_t *st_effects[] = {
- &st_avg_effect,
- &st_band_effect,
- &st_bandpass_effect,
- &st_bandreject_effect,
- &st_chorus_effect,
- &st_compand_effect,
- &st_copy_effect,
- &st_dcshift_effect,
- &st_deemph_effect,
- &st_earwax_effect,
- &st_echo_effect,
- &st_echos_effect,
- &st_fade_effect,
- &st_filter_effect,
- &st_flanger_effect,
- &st_highp_effect,
- &st_highpass_effect,
- &st_lowp_effect,
- &st_lowpass_effect,
- &st_mask_effect,
- &st_mcompand_effect,
- &st_noiseprof_effect,
- &st_noisered_effect,
- &st_pan_effect,
- &st_phaser_effect,
- &st_pick_effect,
- &st_pitch_effect,
- &st_polyphase_effect,
- &st_rate_effect,
- &st_repeat_effect,
- &st_resample_effect,
- &st_reverb_effect,
- &st_reverse_effect,
- &st_silence_effect,
- &st_speed_effect,
- &st_stat_effect,
- &st_stretch_effect,
- &st_swap_effect,
- &st_synth_effect,
- &st_trim_effect,
- &st_vibro_effect,
- &st_vol_effect,
- &st_terminate_effect,
+st_effect_fn_t st_effect_fns[] = {
+ st_avg_effect_fn,
+ st_band_effect_fn,
+ st_bandpass_effect_fn,
+ st_bandreject_effect_fn,
+ st_chorus_effect_fn,
+ st_compand_effect_fn,
+ st_copy_effect_fn,
+ st_dcshift_effect_fn,
+ st_deemph_effect_fn,
+ st_earwax_effect_fn,
+ st_echo_effect_fn,
+ st_echos_effect_fn,
+ st_fade_effect_fn,
+ st_filter_effect_fn,
+ st_flanger_effect_fn,
+ st_highp_effect_fn,
+ st_highpass_effect_fn,
+ st_lowp_effect_fn,
+ st_lowpass_effect_fn,
+ st_mask_effect_fn,
+ st_mcompand_effect_fn,
+ st_noiseprof_effect_fn,
+ st_noisered_effect_fn,
+ st_pan_effect_fn,
+ st_phaser_effect_fn,
+ st_pick_effect_fn,
+ st_pitch_effect_fn,
+ st_polyphase_effect_fn,
+ st_rate_effect_fn,
+ st_repeat_effect_fn,
+ st_resample_effect_fn,
+ st_reverb_effect_fn,
+ st_reverse_effect_fn,
+ st_silence_effect_fn,
+ st_speed_effect_fn,
+ st_stat_effect_fn,
+ st_stretch_effect_fn,
+ st_swap_effect_fn,
+ st_synth_effect_fn,
+ st_trim_effect_fn,
+ st_vibro_effect_fn,
+ st_vol_effect_fn,
NULL
};
--- a/src/highp.c
+++ b/src/highp.c
@@ -32,6 +32,8 @@
#include <math.h>
#include "st_i.h"
+static st_effect_t st_highp_effect;
+
/* Private data for Highpass effect */
typedef struct highpstuff {
float cutoff;
@@ -113,7 +115,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_highp_effect = {
+static st_effect_t st_highp_effect = {
"highp",
"Usage: highp cutoff",
0,
@@ -123,3 +125,8 @@
st_effect_nothing_drain,
st_highp_stop
};
+
+const st_effect_t *st_highp_effect_fn(void)
+{
+ return &st_highp_effect;
+}
--- a/src/highpass.c
+++ b/src/highpass.c
@@ -36,6 +36,7 @@
#include "st_i.h"
#include "btrworth.h"
+static st_effect_t st_highpass_effect;
int st_highpass_getopts(eff_t effp, int n, char **argv)
{
@@ -73,7 +74,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_highpass_effect = {
+static st_effect_t st_highpass_effect = {
"highpass",
"Usage: highpass FREQUENCY",
0,
@@ -83,3 +84,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_highpass_effect_fn(void)
+{
+ return &st_highpass_effect;
+}
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -30,6 +30,8 @@
#include <math.h>
#include "st_i.h"
+static st_effect_t st_lowp_effect;
+
/* Private data for Lowpass effect */
typedef struct lowpstuff {
float cutoff;
@@ -106,7 +108,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_lowp_effect = {
+static st_effect_t st_lowp_effect = {
"lowp",
"Usage: lowp cutoff",
0,
@@ -116,3 +118,8 @@
st_effect_nothing_drain,
st_lowp_stop
};
+
+const st_effect_t *st_lowp_effect_fn(void)
+{
+ return &st_lowp_effect;
+}
--- a/src/lowpass.c
+++ b/src/lowpass.c
@@ -24,6 +24,8 @@
#include "st_i.h"
#include "btrworth.h"
+static st_effect_t st_lowpass_effect;
+
int st_lowpass_getopts(eff_t effp, int n, char **argv)
{
butterworth_t butterworth = (butterworth_t)effp->priv;
@@ -58,7 +60,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_lowpass_effect = {
+static st_effect_t st_lowpass_effect = {
"lowpass",
"Usage: lowpass FREQUENCY",
0,
@@ -68,3 +70,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_lowpass_effect_fn(void)
+{
+ return &st_lowpass_effect;
+}
--- a/src/mask.c
+++ b/src/mask.c
@@ -15,13 +15,15 @@
#include <math.h>
#include "st_i.h"
-#define HALFABIT 1.44 /* square root of 2 */
+static st_effect_t st_mask_effect;
+#define HALFABIT 1.44 /* square root of 2 */
+
/*
* Problems:
- * 1) doesn't allow specification of noise depth
- * 2) does triangular noise, could do local shaping
- * 3) can run over 32 bits.
+ * 1) doesn't allow specification of noise depth
+ * 2) does triangular noise, could do local shaping
+ * 3) can run over 32 bits.
*/
/*
@@ -29,15 +31,15 @@
*/
int st_mask_getopts(eff_t effp, int n, char **argv)
{
- if (n)
- {
- st_fail(st_mask_effect.usage);
- return (ST_EOF);
- }
- /* should take # of bits */
+ if (n)
+ {
+ st_fail(st_mask_effect.usage);
+ return (ST_EOF);
+ }
+ /* should take # of bits */
- st_initrand();
- return (ST_SUCCESS);
+ st_initrand();
+ return (ST_SUCCESS);
}
/*
@@ -47,57 +49,57 @@
int st_mask_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
- int len, done;
-
- st_sample_t l;
- st_sample_t tri16; /* 16 signed bits of triangular noise */
+ int len, done;
+
+ st_sample_t l;
+ st_sample_t tri16; /* 16 signed bits of triangular noise */
- len = ((*isamp > *osamp) ? *osamp : *isamp);
- switch (effp->outinfo.encoding) {
- case ST_ENCODING_ULAW:
- case ST_ENCODING_ALAW:
- for(done = 0; done < len; done++) {
- tri16 =
- ((rand()%32768L) + (rand()%32768L)) - 32767;
+ len = ((*isamp > *osamp) ? *osamp : *isamp);
+ switch (effp->outinfo.encoding) {
+ case ST_ENCODING_ULAW:
+ case ST_ENCODING_ALAW:
+ for(done = 0; done < len; done++) {
+ tri16 =
+ ((rand()%32768L) + (rand()%32768L)) - 32767;
- l = *ibuf++ + tri16*16*HALFABIT; /* 2^4.5 */
- *obuf++ = l;
- }
- break;
- default:
- switch (effp->outinfo.size) {
- case ST_SIZE_BYTE:
- for(done = 0; done < len; done++) {
- tri16 =
- ((rand()%32768L) + (rand()%32768L)) - 32767;
+ l = *ibuf++ + tri16*16*HALFABIT; /* 2^4.5 */
+ *obuf++ = l;
+ }
+ break;
+ default:
+ switch (effp->outinfo.size) {
+ case ST_SIZE_BYTE:
+ for(done = 0; done < len; done++) {
+ tri16 =
+ ((rand()%32768L) + (rand()%32768L)) - 32767;
- l = *ibuf++ + tri16*256*HALFABIT; /* 2^8.5 */
- *obuf++ = l;
- }
- break;
- case ST_SIZE_WORD:
- for(done = 0; done < len; done++) {
- tri16 =
- ((rand()%32768L) + (rand()%32768L)) - 32767;
+ l = *ibuf++ + tri16*256*HALFABIT; /* 2^8.5 */
+ *obuf++ = l;
+ }
+ break;
+ case ST_SIZE_WORD:
+ for(done = 0; done < len; done++) {
+ tri16 =
+ ((rand()%32768L) + (rand()%32768L)) - 32767;
- l = *ibuf++ + tri16*HALFABIT; /* 2^.5 */
- *obuf++ = l;
- }
- break;
- default:
- for(done = 0; done < len; done++) {
- *obuf++ = *ibuf++;
- }
- break;
- }
- }
+ l = *ibuf++ + tri16*HALFABIT; /* 2^.5 */
+ *obuf++ = l;
+ }
+ break;
+ default:
+ for(done = 0; done < len; done++) {
+ *obuf++ = *ibuf++;
+ }
+ break;
+ }
+ }
- *isamp = done;
- *osamp = done;
- return (ST_SUCCESS);
+ *isamp = done;
+ *osamp = done;
+ return (ST_SUCCESS);
}
-st_effect_t st_mask_effect = {
+static st_effect_t st_mask_effect = {
"mask",
"Usage: Mask effect takes no options",
ST_EFF_MCHAN,
@@ -107,3 +109,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_mask_effect_fn(void)
+{
+ return &st_mask_effect;
+}
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -712,7 +712,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_mcompand_effect = {
+static st_effect_t st_mcompand_effect = {
"mcompand",
"Usage: mcompand quoted_compand_args [crossover_frequency quoted_compand_args [...]]\n"
"\n"
@@ -720,23 +720,7 @@
"\n"
" attack1,decay1[,attack2,decay2...]\n"
" in-dB1,out-dB1[,in-dB2,out-dB2...]\n"
- " [ gain [ initial-volume [ delay ] ] ]\n"
- "\n"
- " Beware a variety of headroom (clipping) bugaboos.\n"
- "\n"
- " Here is an example application, an FM radio sound simulator (or\n"
- " broadcast signal conditioner, if the lowp at the end is skipped -\n"
- " note that the pipeline is set up with US-style 75us preemphasis).\n"
- "\n"
- " sox -V -t raw -r 44100 -s -w -c 2 - -t raw -r 44100 -s -l -c 2 \\\n"
- " - vol -3 db filter 8000- 32 100 mcompand \".005,.1 \\\n"
- " -47,-40,-34,-34,-17,-33 0 0 0\" 100 \".003,.05 \\\n"
- " -47,-40,-34,-34,-17,-33 0 0 0\" 400 \".000625,.0125 \\\n"
- " -47,-40,-34,-34,-15,-33 0 0 0\" 1600 \".0001,.025 \\\n"
- " -47,-40,-34,-34,-31,-31,-0,-30 0 0 0\" 6400 \\\n"
- " \"0,.025 -38,-31,-28,-28,-0,-25 0 0 0\" vol 27 db vol -12 \\\n"
- " db highpass 22 highpass 22 filter -17500 256 vol +12 db \\\n"
- " vol -3 db lowp 1780",
+ " [ gain [ initial-volume [ delay ] ] ]\n",
ST_EFF_MCHAN,
st_mcompand_getopts,
st_mcompand_start,
@@ -744,3 +728,8 @@
st_mcompand_drain,
st_mcompand_stop
};
+
+const st_effect_t *st_mcompand_effect_fn(void)
+{
+ return &st_mcompand_effect;
+}
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -19,6 +19,8 @@
#include <string.h>
#include <errno.h>
+static st_effect_t st_noiseprof_effect;
+
typedef struct chandata {
float *sum;
int *profilecount;
@@ -209,7 +211,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_noiseprof_effect = {
+static st_effect_t st_noiseprof_effect = {
"noiseprof",
"Usage: noiseprof [filename]",
ST_EFF_MCHAN | ST_EFF_REPORT,
@@ -219,6 +221,11 @@
st_noiseprof_drain,
st_noiseprof_stop
};
+
+const st_effect_t *st_noiseprof_effect_fn(void)
+{
+ return &st_noiseprof_effect;
+}
/* For Emacs:
Local Variables:
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -16,6 +16,8 @@
#include <string.h>
#include <assert.h>
+static st_effect_t st_noisered_effect;
+
typedef struct chandata {
float *window;
float *lastwindow;
@@ -343,7 +345,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_noisered_effect = {
+static st_effect_t st_noisered_effect = {
"noisered",
"Usage: noiseprof profile-file [threshold]",
ST_EFF_MCHAN,
@@ -353,6 +355,11 @@
st_noisered_drain,
st_noisered_stop
};
+
+const st_effect_t *st_noisered_effect_fn(void)
+{
+ return &st_noisered_effect;
+}
/* For Emacs:
Local Variables:
--- a/src/pan.c
+++ b/src/pan.c
@@ -18,6 +18,8 @@
#include "st_i.h"
+static st_effect_t st_pan_effect;
+
/* type for computations.
float mantissa is okay for 8 or 16 bits signals.
maybe a little bit short for 24 bits.
@@ -445,7 +447,7 @@
return ST_SUCCESS;
}
-st_effect_t st_pan_effect = {
+static st_effect_t st_pan_effect = {
"pan",
"Usage: pan direction (in [-1.0 .. 1.0])",
ST_EFF_MCHAN | ST_EFF_CHAN,
@@ -455,3 +457,8 @@
st_effect_nothing_drain,
st_pan_stop
};
+
+const st_effect_t *st_pan_effect_fn(void)
+{
+ return &st_pan_effect;
+}
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -59,6 +59,8 @@
#include <string.h>
#include "st_i.h"
+static st_effect_t st_phaser_effect;
+
#define MOD_SINE 0
#define MOD_TRIANGLE 1
@@ -277,7 +279,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_phaser_effect = {
+static st_effect_t st_phaser_effect = {
"phaser",
"Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]",
0,
@@ -287,3 +289,8 @@
st_phaser_drain,
st_phaser_stop
};
+
+const st_effect_t *st_phaser_effect_fn(void)
+{
+ return &st_phaser_effect;
+}
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -42,6 +42,8 @@
#include <math.h> /* cos(), pow() */
+static st_effect_t st_pitch_effect;
+
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
@@ -613,7 +615,7 @@
return ST_SUCCESS;
}
-st_effect_t st_pitch_effect = {
+static st_effect_t st_pitch_effect = {
"pitch",
"Usage: pitch shift width interpole fade\n"
" (in cents, in ms, cub/lin, cos/ham/lin/trap)"
@@ -625,3 +627,8 @@
st_pitch_drain,
st_pitch_stop
};
+
+const st_effect_t *st_pitch_effect_fn(void)
+{
+ return &st_pitch_effect;
+}
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -665,7 +665,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_polyphase_effect = {
+static st_effect_t st_polyphase_effect = {
"polyphase",
"Usage: -w <nut / ham> : window type\n"
" -width <short / long> : window width\n"
@@ -682,3 +682,8 @@
st_poly_drain,
st_poly_stop
};
+
+const st_effect_t *st_polyphase_effect_fn(void)
+{
+ return &st_polyphase_effect;
+}
--- a/src/rate.c
+++ b/src/rate.c
@@ -56,12 +56,12 @@
*/
int st_rate_getopts(eff_t effp, int n, char **argv)
{
- if (n)
- {
- st_fail("Rate effect takes no options.");
- return (ST_EOF);
- }
- return (ST_SUCCESS);
+ if (n)
+ {
+ st_fail("Rate effect takes no options.");
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -69,25 +69,25 @@
*/
int st_rate_start(eff_t effp)
{
- rate_t rate = (rate_t) effp->priv;
+ rate_t rate = (rate_t) effp->priv;
unsigned long incr;
- if (effp->ininfo.rate == effp->outinfo.rate)
- {
- st_fail("Input and Output rates must be different to use rate effect");
- return(ST_EOF);
- }
+ if (effp->ininfo.rate == effp->outinfo.rate)
+ {
+ st_fail("Input and Output rates must be different to use rate effect");
+ return(ST_EOF);
+ }
- if (effp->ininfo.rate >= 65535 || effp->outinfo.rate >= 65535)
- {
- st_fail("rate effect can only handle rates <= 65535");
- return (ST_EOF);
- }
- if (effp->ininfo.size == ST_SIZE_DWORD ||
- effp->ininfo.size == ST_SIZE_DDWORD)
- {
- st_warn("rate effect reduces data to 16 bits");
- }
+ if (effp->ininfo.rate >= 65535 || effp->outinfo.rate >= 65535)
+ {
+ st_fail("rate effect can only handle rates <= 65535");
+ return (ST_EOF);
+ }
+ if (effp->ininfo.size == ST_SIZE_DWORD ||
+ effp->ininfo.size == ST_SIZE_DDWORD)
+ {
+ st_warn("rate effect reduces data to 16 bits");
+ }
rate->opos_frac=0;
rate->opos=0;
@@ -101,8 +101,8 @@
rate->ipos=0;
- rate->ilast = 0;
- return (ST_SUCCESS);
+ rate->ilast = 0;
+ return (ST_SUCCESS);
}
/*
@@ -112,10 +112,10 @@
int st_rate_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
- rate_t rate = (rate_t) effp->priv;
- st_sample_t *istart,*iend;
- st_sample_t *ostart,*oend;
- st_sample_t ilast,icur,out;
+ rate_t rate = (rate_t) effp->priv;
+ st_sample_t *istart,*iend;
+ st_sample_t *ostart,*oend;
+ st_sample_t ilast,icur,out;
unsigned long tmp;
double t;
@@ -129,7 +129,7 @@
while (obuf < oend) {
- /* Safety catch to make sure we have input samples. */
+ /* Safety catch to make sure we have input samples. */
if (ibuf >= iend) goto the_end;
/* read as many input samples so that ipos > opos */
@@ -137,7 +137,7 @@
while (rate->ipos <= rate->opos) {
ilast = *ibuf++;
rate->ipos++;
- /* See if we finished the input buffer yet */
+ /* See if we finished the input buffer yet */
if (ibuf >= iend) goto the_end;
}
@@ -156,10 +156,10 @@
rate->opos_frac = tmp & (((unsigned long) 1 << FRAC_BITS)-1);
}
the_end:
- *isamp = ibuf - istart;
- *osamp = obuf - ostart;
- rate->ilast = ilast;
- return (ST_SUCCESS);
+ *isamp = ibuf - istart;
+ *osamp = obuf - ostart;
+ rate->ilast = ilast;
+ return (ST_SUCCESS);
}
/*
@@ -168,7 +168,7 @@
*/
int st_rate_stop(eff_t effp)
{
- /* nothing to do */
+ /* nothing to do */
return (ST_SUCCESS);
}
@@ -226,11 +226,11 @@
/* Private data for Lerp via LCM file */
typedef struct ratestuff {
- st_rate_t lcmrate; /* least common multiple of rates */
- unsigned long inskip, outskip; /* LCM increments for I & O rates */
- unsigned long total;
- unsigned long intot, outtot; /* total samples in LCM basis */
- st_sample_t lastsamp; /* history */
+ st_rate_t lcmrate; /* least common multiple of rates */
+ unsigned long inskip, outskip; /* LCM increments for I & O rates */
+ unsigned long total;
+ unsigned long intot, outtot; /* total samples in LCM basis */
+ st_sample_t lastsamp; /* history */
} *rate_t;
/*
@@ -238,12 +238,12 @@
*/
int st_rate_getopts(eff_t effp, int n, char **argv)
{
- if (n)
- {
- st_fail(st_rate_effect.usage);
- return (ST_EOF);
- }
- return (ST_SUCCESS);
+ if (n)
+ {
+ st_fail(st_rate_effect.usage);
+ return (ST_EOF);
+ }
+ return (ST_SUCCESS);
}
/*
@@ -251,18 +251,18 @@
*/
int st_rate_start(eff_t effp)
{
- rate_t rate = (rate_t) effp->priv;
-
- rate->lcmrate = st_lcm((st_sample_t)effp->ininfo.rate, (st_sample_t)effp->outinfo.rate);
- /* Cursory check for LCM overflow.
- * If both rate are below 65k, there should be no problem.
- * 16 bits x 16 bits = 32 bits, which we can handle.
- */
- rate->inskip = rate->lcmrate / effp->ininfo.rate;
- rate->outskip = rate->lcmrate / effp->outinfo.rate;
- rate->total = rate->intot = rate->outtot = 0;
- rate->lastsamp = 0;
- return (ST_SUCCESS);
+ rate_t rate = (rate_t) effp->priv;
+
+ rate->lcmrate = st_lcm((st_sample_t)effp->ininfo.rate, (st_sample_t)effp->outinfo.rate);
+ /* Cursory check for LCM overflow.
+ * If both rate are below 65k, there should be no problem.
+ * 16 bits x 16 bits = 32 bits, which we can handle.
+ */
+ rate->inskip = rate->lcmrate / effp->ininfo.rate;
+ rate->outskip = rate->lcmrate / effp->outinfo.rate;
+ rate->total = rate->intot = rate->outtot = 0;
+ rate->lastsamp = 0;
+ return (ST_SUCCESS);
}
/*
@@ -272,58 +272,58 @@
int st_rate_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
- rate_t rate = (rate_t) effp->priv;
- int len, done;
- st_sample_t *istart = ibuf;
- st_sample_t last;
+ rate_t rate = (rate_t) effp->priv;
+ int len, done;
+ st_sample_t *istart = ibuf;
+ st_sample_t last;
- done = 0;
- if (rate->total == 0) {
- /* Emit first sample. We know the fence posts meet. */
- *obuf = *ibuf++;
- rate->lastsamp = *obuf++ / 65536L;
- done = 1;
- rate->total = 1;
- /* advance to second output */
- rate->outtot += rate->outskip;
- /* advance input range to span next output */
- while ((rate->intot + rate->inskip) <= rate->outtot){
- last = *ibuf++ / 65536L;
- rate->intot += rate->inskip;
- }
- }
+ done = 0;
+ if (rate->total == 0) {
+ /* Emit first sample. We know the fence posts meet. */
+ *obuf = *ibuf++;
+ rate->lastsamp = *obuf++ / 65536L;
+ done = 1;
+ rate->total = 1;
+ /* advance to second output */
+ rate->outtot += rate->outskip;
+ /* advance input range to span next output */
+ while ((rate->intot + rate->inskip) <= rate->outtot){
+ last = *ibuf++ / 65536L;
+ rate->intot += rate->inskip;
+ }
+ }
- /* start normal flow-through operation */
- last = rate->lastsamp;
-
- /* number of output samples the input can feed */
- len = (*isamp * rate->inskip) / rate->outskip;
- if (len > *osamp)
- len = *osamp;
- for(; done < len; done++) {
- *obuf = last;
- *obuf += ((float)((*ibuf / 65536L) - last)* ((float)rate->outtot -
- rate->intot))/rate->inskip;
- *obuf *= 65536L;
- obuf++;
- /* advance to next output */
- rate->outtot += rate->outskip;
- /* advance input range to span next output */
- while ((rate->intot + rate->inskip) <= rate->outtot){
- last = *ibuf++ / 65536L;
- rate->intot += rate->inskip;
- if (ibuf - istart == *isamp)
- goto out;
- }
- /* long samples with high LCM's overrun counters! */
- if (rate->outtot == rate->intot)
- rate->outtot = rate->intot = 0;
- }
+ /* start normal flow-through operation */
+ last = rate->lastsamp;
+
+ /* number of output samples the input can feed */
+ len = (*isamp * rate->inskip) / rate->outskip;
+ if (len > *osamp)
+ len = *osamp;
+ for(; done < len; done++) {
+ *obuf = last;
+ *obuf += ((float)((*ibuf / 65536L) - last)* ((float)rate->outtot -
+ rate->intot))/rate->inskip;
+ *obuf *= 65536L;
+ obuf++;
+ /* advance to next output */
+ rate->outtot += rate->outskip;
+ /* advance input range to span next output */
+ while ((rate->intot + rate->inskip) <= rate->outtot){
+ last = *ibuf++ / 65536L;
+ rate->intot += rate->inskip;
+ if (ibuf - istart == *isamp)
+ goto out;
+ }
+ /* long samples with high LCM's overrun counters! */
+ if (rate->outtot == rate->intot)
+ rate->outtot = rate->intot = 0;
+ }
out:
- *isamp = ibuf - istart;
- *osamp = len;
- rate->lastsamp = last;
- return (ST_SUCCESS);
+ *isamp = ibuf - istart;
+ *osamp = len;
+ rate->lastsamp = last;
+ return (ST_SUCCESS);
}
/*
@@ -332,12 +332,12 @@
*/
int st_rate_stop(eff_t effp)
{
- /* nothing to do */
+ /* nothing to do */
return (ST_SUCCESS);
}
#endif /* USE_OLD_RATE */
-st_effect_t st_rate_effect = {
+static st_effect_t st_rate_effect = {
"rate",
"Usage: Rate effect takes no options",
ST_EFF_RATE,
@@ -347,3 +347,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_rate_effect_fn(void)
+{
+ return &st_rate_effect;
+}
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -24,6 +24,8 @@
#include <string.h>
#include "st_i.h"
+static st_effect_t st_repeat_effect;
+
typedef struct repeatstuff {
FILE *fp;
int first_drain;
@@ -195,7 +197,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_repeat_effect = {
+static st_effect_t st_repeat_effect = {
"repeat",
"Usage: repeat count",
0,
@@ -205,3 +207,8 @@
st_repeat_drain,
st_repeat_stop
};
+
+const st_effect_t *st_repeat_effect_fn(void)
+{
+ return &st_repeat_effect;
+}
--- a/src/resample.c
+++ b/src/resample.c
@@ -58,6 +58,8 @@
/* resample includes */
#include "resampl.h"
+static st_effect_t st_resample_effect;
+
/* this Float MUST match that in filter.c */
#define Float double/*float*/
#define ISCALE 0x10000
@@ -710,7 +712,7 @@
}
}
-st_effect_t st_resample_effect = {
+static st_effect_t st_resample_effect = {
"resample",
"Usage: resample [ rolloff [ beta ] ]",
ST_EFF_RATE,
@@ -720,3 +722,8 @@
st_resample_drain,
st_resample_stop
};
+
+const st_effect_t *st_resample_effect_fn(void)
+{
+ return &st_resample_effect;
+}
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -95,6 +95,8 @@
#include <math.h>
#include "st_i.h"
+static st_effect_t st_reverb_effect;
+
#define REVERB_FADE_THRESH 10
#define DELAY_BUFSIZ ( 50L * ST_MAXRATE )
#define MAXREVERBS 8
@@ -287,7 +289,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_reverb_effect = {
+static st_effect_t st_reverb_effect = {
"reverb",
"Usage: reverb gain-out reverb-time delay [ delay ... ]",
0,
@@ -297,3 +299,8 @@
st_reverb_drain,
st_reverb_stop
};
+
+const st_effect_t *st_reverb_effect_fn(void)
+{
+ return &st_reverb_effect;
+}
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -20,6 +20,8 @@
#include "st_i.h"
+static st_effect_t st_reverse_effect;
+
/* Private data */
typedef struct reversestuff {
FILE *fp;
@@ -143,7 +145,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_reverse_effect = {
+static st_effect_t st_reverse_effect = {
"reverse",
"Usage: Reverse effect takes no options",
0,
@@ -153,3 +155,8 @@
st_reverse_drain,
st_reverse_stop
};
+
+const st_effect_t *st_reverse_effect_fn(void)
+{
+ return &st_reverse_effect;
+}
--- a/src/silence.c
+++ b/src/silence.c
@@ -18,6 +18,8 @@
#include <math.h>
#include "st_i.h"
+static st_effect_t st_silence_effect;
+
#ifndef TRUE
#define TRUE 1
#endif
@@ -694,7 +696,7 @@
return(ST_SUCCESS);
}
-st_effect_t st_silence_effect = {
+static st_effect_t st_silence_effect = {
"silence",
"Usage: silence above_periods [ duration thershold[d | %% ] ] [ below_periods duration threshold[ d | %% ]]",
ST_EFF_MCHAN,
@@ -704,3 +706,8 @@
st_silence_drain,
st_silence_stop
};
+
+const st_effect_t *st_silence_effect_fn(void)
+{
+ return &st_silence_effect;
+}
--- a/src/sox.c
+++ b/src/sox.c
@@ -849,11 +849,6 @@
if (argc_effect == ST_EOF)
{
- int i1;
- fprintf(stderr, "%s: Known effects: ",myname);
- for (i1 = 0; st_effects[i1]->name; i1++)
- fprintf(stderr, "%s ", st_effects[i1]->name);
- fprintf(stderr, "\n\n");
st_fail("Effect '%s' is not known!", argv[optind]);
cleanup();
exit(2);
@@ -1646,6 +1641,7 @@
{
int i;
const st_format_t *f;
+ const st_effect_t *e;
printf("%s: ", myname);
printf("Version %s\n\n", st_version());
@@ -1698,8 +1694,12 @@
}
printf("\n\nSupported effects: ");
- for (i = 0; st_effects[i]->name != NULL; i++) {
- printf("%s ", st_effects[i]->name);
+ for (i = 0; st_effect_fns[i]; i++) {
+ e = st_effect_fns[i]();
+ if (e && e->name)
+ {
+ printf("%s ", e->name);
+ }
}
printf( "\n\neffopts: depends on effect\n\n");
@@ -1709,6 +1709,7 @@
static void usage_effect(char *effect)
{
int i;
+ const st_effect_t *e;
printf("%s: ", myname);
printf("v%s\n\n", st_version());
@@ -1715,12 +1716,17 @@
printf("Effect usage:\n\n");
- for (i = 0; st_effects[i]->name != NULL; i++)
- if (!strcmp ("all", effect) || !strcmp (st_effects[i]->name, effect))
+
+ for (i = 0; st_effect_fns[i]; i++)
+ {
+ e = st_effect_fns[i]();
+ if (e && e->name &&
+ (!strcmp("all", effect) || !strcmp(e->name, effect)))
{
- char *p = strstr(st_effects[i]->usage, "Usage: ");
- printf("%s\n\n", p ? p + 7 : st_effects[i]->usage);
+ char *p = strstr(e->usage, "Usage: ");
+ printf("%s\n\n", p ? p + 7 : e->usage);
}
+ }
if (!effect)
printf("see --help-effect=effect for effopts ('all' for effopts of all effects)\n\n");
--- a/src/speed.c
+++ b/src/speed.c
@@ -16,6 +16,8 @@
#include <math.h> /* pow */
#include <string.h>
+static st_effect_t st_speed_effect;
+
/* type used for computations.
*/
#ifndef SPEED_FLOAT
@@ -300,7 +302,7 @@
return ST_SUCCESS;
}
-st_effect_t st_speed_effect = {
+static st_effect_t st_speed_effect = {
"speed",
"Usage: speed [-c] factor (default 1.0, <1 slows, -c: factor in cent)",
0,
@@ -310,3 +312,8 @@
st_speed_drain,
st_speed_stop
};
+
+const st_effect_t *st_speed_effect_fn(void)
+{
+ return &st_speed_effect;
+}
--- a/src/st.h
+++ b/src/st.h
@@ -273,7 +273,7 @@
char *name; /* effect name */
struct st_signalinfo ininfo; /* input signal specifications */
struct st_signalinfo outinfo; /* output signal specifications */
- st_effect_t *h; /* effects driver */
+ const st_effect_t *h; /* effects driver */
st_sample_t *obuf; /* output buffer */
st_size_t odone, olen; /* consumed, total length */
/* The following is a portable trick to align this variable on
@@ -285,8 +285,6 @@
double priv1;
char priv[ST_MAX_EFFECT_PRIVSIZE]; /* private area for effect */
};
-
-extern st_effect_t *st_effects[]; /* declared in handlers.c */
extern ft_t st_open_read(const char *path, const st_signalinfo_t *info,
const char *filetype);
--- a/src/st_i.h
+++ b/src/st_i.h
@@ -224,48 +224,52 @@
*=============================================================================
*/
-st_effect_t st_avg_effect;
-st_effect_t st_pick_effect;
-st_effect_t st_band_effect;
-st_effect_t st_bandpass_effect;
-st_effect_t st_bandreject_effect;
-st_effect_t st_chorus_effect;
-st_effect_t st_compand_effect;
-st_effect_t st_copy_effect;
-st_effect_t st_dcshift_effect;
-st_effect_t st_deemph_effect;
-st_effect_t st_earwax_effect;
-st_effect_t st_echo_effect;
-st_effect_t st_echos_effect;
-st_effect_t st_fade_effect;
-st_effect_t st_filter_effect;
-st_effect_t st_flanger_effect;
-st_effect_t st_highp_effect;
-st_effect_t st_highpass_effect;
-st_effect_t st_lowp_effect;
-st_effect_t st_lowpass_effect;
-st_effect_t st_mask_effect;
-st_effect_t st_mcompand_effect;
-st_effect_t st_noiseprof_effect;
-st_effect_t st_noisered_effect;
-st_effect_t st_pan_effect;
-st_effect_t st_phaser_effect;
-st_effect_t st_pitch_effect;
-st_effect_t st_polyphase_effect;
-st_effect_t st_rate_effect;
-st_effect_t st_repeat_effect;
-st_effect_t st_resample_effect;
-st_effect_t st_reverb_effect;
-st_effect_t st_reverse_effect;
-st_effect_t st_silence_effect;
-st_effect_t st_speed_effect;
-st_effect_t st_stat_effect;
-st_effect_t st_stretch_effect;
-st_effect_t st_swap_effect;
-st_effect_t st_synth_effect;
-st_effect_t st_trim_effect;
-st_effect_t st_vibro_effect;
-st_effect_t st_vol_effect;
+typedef const st_effect_t *(*st_effect_fn_t)(void);
+
+extern st_effect_fn_t st_effect_fns[];
+
+extern const st_effect_t *st_avg_effect_fn(void);
+extern const st_effect_t *st_pick_effect_fn(void);
+extern const st_effect_t *st_band_effect_fn(void);
+extern const st_effect_t *st_bandpass_effect_fn(void);
+extern const st_effect_t *st_bandreject_effect_fn(void);
+extern const st_effect_t *st_chorus_effect_fn(void);
+extern const st_effect_t *st_compand_effect_fn(void);
+extern const st_effect_t *st_copy_effect_fn(void);
+extern const st_effect_t *st_dcshift_effect_fn(void);
+extern const st_effect_t *st_deemph_effect_fn(void);
+extern const st_effect_t *st_earwax_effect_fn(void);
+extern const st_effect_t *st_echo_effect_fn(void);
+extern const st_effect_t *st_echos_effect_fn(void);
+extern const st_effect_t *st_fade_effect_fn(void);
+extern const st_effect_t *st_filter_effect_fn(void);
+extern const st_effect_t *st_flanger_effect_fn(void);
+extern const st_effect_t *st_highp_effect_fn(void);
+extern const st_effect_t *st_highpass_effect_fn(void);
+extern const st_effect_t *st_lowp_effect_fn(void);
+extern const st_effect_t *st_lowpass_effect_fn(void);
+extern const st_effect_t *st_mask_effect_fn(void);
+extern const st_effect_t *st_mcompand_effect_fn(void);
+extern const st_effect_t *st_noiseprof_effect_fn(void);
+extern const st_effect_t *st_noisered_effect_fn(void);
+extern const st_effect_t *st_pan_effect_fn(void);
+extern const st_effect_t *st_phaser_effect_fn(void);
+extern const st_effect_t *st_pitch_effect_fn(void);
+extern const st_effect_t *st_polyphase_effect_fn(void);
+extern const st_effect_t *st_rate_effect_fn(void);
+extern const st_effect_t *st_repeat_effect_fn(void);
+extern const st_effect_t *st_resample_effect_fn(void);
+extern const st_effect_t *st_reverb_effect_fn(void);
+extern const st_effect_t *st_reverse_effect_fn(void);
+extern const st_effect_t *st_silence_effect_fn(void);
+extern const st_effect_t *st_speed_effect_fn(void);
+extern const st_effect_t *st_stat_effect_fn(void);
+extern const st_effect_t *st_stretch_effect_fn(void);
+extern const st_effect_t *st_swap_effect_fn(void);
+extern const st_effect_t *st_synth_effect_fn(void);
+extern const st_effect_t *st_trim_effect_fn(void);
+extern const st_effect_t *st_vibro_effect_fn(void);
+extern const st_effect_t *st_vol_effect_fn(void);
/* Needed in sox.c
*/
--- a/src/stat.c
+++ b/src/stat.c
@@ -502,7 +502,7 @@
return ST_SUCCESS;
}
-st_effect_t st_stat_effect = {
+static st_effect_t st_stat_effect = {
"stat",
"Usage: [ -s n ] [ -rms ] [ -v ] [ -d ]",
ST_EFF_MCHAN | ST_EFF_REPORT,
@@ -512,3 +512,8 @@
st_stat_drain,
st_stat_stop
};
+
+const st_effect_t *st_stat_effect_fn(void)
+{
+ return &st_stat_effect;
+}
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -24,6 +24,8 @@
#include <stdlib.h> /* malloc and free */
#include <string.h> /* memcpy() */
+static st_effect_t st_stretch_effect;
+
#ifndef MIN
#define MIN(s1,s2) ((s1)<(s2)?(s1):(s2))
#endif
@@ -425,7 +427,7 @@
return ST_SUCCESS;
}
-st_effect_t st_stretch_effect = {
+static st_effect_t st_stretch_effect = {
"stretch",
"Usage: stretch factor [window fade shift fading]\n"
" (expansion, frame in ms, lin/..., unit<1.0, unit<0.5)\n"
@@ -437,3 +439,8 @@
st_stretch_drain,
st_stretch_stop
};
+
+const st_effect_t *st_stretch_effect_fn(void)
+{
+ return &st_stretch_effect;
+}
--- a/src/swap.c
+++ b/src/swap.c
@@ -13,7 +13,8 @@
#include "st_i.h"
-/* Private data for SKEL file */
+static st_effect_t st_swap_effect;
+
typedef struct swapstuff {
int order[4];
int def_opts;
@@ -197,7 +198,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_swap_effect = {
+static st_effect_t st_swap_effect = {
"swap",
"Usage: swap [1 2 | 1 2 3 4]",
ST_EFF_MCHAN,
@@ -207,3 +208,8 @@
st_swap_drain,
st_swap_stop
};
+
+const st_effect_t *st_swap_effect_fn(void)
+{
+ return &st_swap_effect;
+}
--- a/src/synth.c
+++ b/src/synth.c
@@ -16,6 +16,8 @@
#include <ctype.h>
#include "st_i.h"
+static st_effect_t st_synth_effect;
+
#define PCOUNT 5
#define SYNTH_SINE 0
@@ -734,7 +736,7 @@
return (ST_SUCCESS);
}
-st_effect_t st_synth_effect = {
+static st_effect_t st_synth_effect = {
"synth",
"Usage: synth [length] type mix [freq[-freq2]] [off] [ph] [p1] [p2] [p3]\n"
" <length> length in sec or hh:mm:ss.frac, 0=inputlength, default=0\n"
@@ -757,14 +759,10 @@
st_synth_drain,
st_synth_stop
};
-/*-------------------------------------------------------------- end of file */
-
-
-
-
-
-
-
-
+const st_effect_t *st_synth_effect_fn(void)
+{
+ return &st_synth_effect;
+}
+/*-------------------------------------------------------------- end of file */
--- a/src/trim.c
+++ b/src/trim.c
@@ -14,6 +14,8 @@
#include "st_i.h"
#include <string.h>
+static st_effect_t st_trim_effect;
+
/* Time resolutin one millisecond */
#define TIMERES 1000
@@ -217,7 +219,7 @@
trim->start = 0;
}
-st_effect_t st_trim_effect = {
+static st_effect_t st_trim_effect = {
"trim",
"Usage: trim start [length]",
ST_EFF_MCHAN,
@@ -227,3 +229,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_trim_effect_fn(void)
+{
+ return &st_trim_effect;
+}
--- a/src/util.c
+++ b/src/util.c
@@ -167,47 +167,54 @@
*/
int st_geteffect_opt(eff_t effp, int argc, char **argv)
{
- int i, optind;
+ int i, optind;
- for(i = 0; st_effects[i]->name; i++)
- {
- char *s1 = st_effects[i]->name, *s2 = argv[0];
+ for(i = 0; st_effect_fns[i]; i++)
+ {
+ char *s1, *s2;
+ const st_effect_t *e = st_effect_fns[i]();
- while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
- s1++, s2++;
- if (*s1 || *s2)
- continue; /* not a match */
+ if (!e || !e->name)
+ continue;
- /* Found it! */
- effp->name = st_effects[i]->name;
- effp->h = st_effects[i];
+ s1 = e->name;
+ s2 = argv[0];
- optind = 1;
+ while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
+ s1++, s2++;
+ if (*s1 || *s2)
+ continue; /* not a match */
- while (optind < argc)
+ /* Found it! */
+ effp->name = e->name;
+ effp->h = e;
+
+ optind = 1;
+
+ while (optind < argc)
+ {
+ for (i = 0; e->name; i++)
{
- for (i = 0; st_effects[i]->name; i++)
- {
- char *s1 = st_effects[i]->name, *s2 = argv[optind];
- while (*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
+ char *s1 = e->name, *s2 = argv[optind];
+ while (*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
s1++, s2++;
- if (*s1 || *s2)
- continue;
+ if (*s1 || *s2)
+ continue;
- /* Found it! */
- return (optind - 1);
- }
- /* Didn't find a match, try the next argument. */
- optind++;
+ /* Found it! */
+ return (optind - 1);
}
- /*
- * No matches found, all the following arguments are
- * for this effect passed in.
- */
- return (optind - 1);
+ /* Didn't find a match, try the next argument. */
+ optind++;
}
+ /*
+ * No matches found, all the following arguments are
+ * for this effect passed in.
+ */
+ return (optind - 1);
+ }
- return (ST_EOF);
+ return (ST_EOF);
}
/*
@@ -218,24 +225,31 @@
int st_geteffect(eff_t effp, char *effect_name)
{
- int i;
+ int i;
- for(i = 0; st_effects[i]->name; i++) {
- char *s1 = st_effects[i]->name, *s2 = effect_name;
+ for(i = 0; st_effect_fns[i]; i++) {
+ char *s1, *s2;
+ const st_effect_t *e = st_effect_fns[i]();
- while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
- s1++, s2++;
- if (*s1 || *s2)
- continue; /* not a match */
+ if (!e || !e->name)
+ continue;
- /* Found it! */
- effp->name = st_effects[i]->name;
- effp->h = st_effects[i];
+ s1 = e->name;
+ s2 = effect_name;
- return ST_SUCCESS;
- }
+ while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
+ s1++, s2++;
+ if (*s1 || *s2)
+ continue; /* not a match */
- return (ST_EOF);
+ /* Found it! */
+ effp->name = e->name;
+ effp->h = e;
+
+ return ST_SUCCESS;
+ }
+
+ return (ST_EOF);
}
/*
@@ -242,22 +256,28 @@
* Check that we have a known effect name. Return ST_SUCESS if found, else
* return ST_EOF.
*/
-
int st_checkeffect(char *effect_name)
{
- int i;
+ int i;
- for(i = 0; st_effects[i]->name; i++) {
- char *s1 = st_effects[i]->name, *s2 = effect_name;
- while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
- s1++, s2++;
- if (*s1 || *s2)
- continue; /* not a match */
+ for(i = 0; st_effect_fns[i]; i++) {
+ char *s1, *s2;
+ const st_effect_t *e = st_effect_fns[i]();
- return ST_SUCCESS;
- }
+ if (!e || !e->name)
+ continue;
- return (ST_EOF);
+ s1 = e->name;
+ s2 = effect_name;
+ while(*s1 && *s2 && (tolower(*s1) == tolower(*s2)))
+ s1++, s2++;
+ if (*s1 || *s2)
+ continue; /* not a match */
+
+ return ST_SUCCESS;
+ }
+
+ return (ST_EOF);
}
/*
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -28,14 +28,16 @@
#include <stdlib.h>
#include "st_i.h"
+static st_effect_t st_vibro_effect;
+
/* Private data for Vibro effect */
typedef struct vibrostuff {
- float speed;
- float depth;
- short *sinetab; /* sine wave to apply */
- int mult; /* multiplier */
- unsigned length; /* length of table */
- int counter; /* current counter */
+ float speed;
+ float depth;
+ short *sinetab; /* sine wave to apply */
+ int mult; /* multiplier */
+ unsigned length; /* length of table */
+ int counter; /* current counter */
} *vibro_t;
/*
@@ -43,22 +45,22 @@
*/
int st_vibro_getopts(eff_t effp, int n, char **argv)
{
- vibro_t vibro = (vibro_t) effp->priv;
+ vibro_t vibro = (vibro_t) effp->priv;
- vibro->depth = 0.5;
- if ((n == 0) || !sscanf(argv[0], "%f", &vibro->speed) ||
- ((n == 2) && !sscanf(argv[1], "%f", &vibro->depth)))
- {
- st_fail(st_vibro_effect.usage);
- return (ST_EOF);
- }
- if ((vibro->speed <= 0.001) || (vibro->speed > 30.0) ||
- (vibro->depth < 0.0) || (vibro->depth > 1.0))
- {
- st_fail("Vibro: speed must be < 30.0, 0.0 < depth < 1.0");
- return (ST_EOF);
- }
- return (ST_SUCCESS);
+ vibro->depth = 0.5;
+ if ((n == 0) || !sscanf(argv[0], "%f", &vibro->speed) ||
+ ((n == 2) && !sscanf(argv[1], "%f", &vibro->depth)))
+ {
+ st_fail(st_vibro_effect.usage);
+ return (ST_EOF);
+ }
+ if ((vibro->speed <= 0.001) || (vibro->speed > 30.0) ||
+ (vibro->depth < 0.0) || (vibro->depth > 1.0))
+ {
+ st_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. */
@@ -66,15 +68,15 @@
/* FIXME: move to misc.c */
static void sine(short *buf, int len, float depth)
{
- int i;
- int scale = depth * 128;
- int base = (1.0 - depth) * 128;
- double val;
+ int i;
+ int scale = depth * 128;
+ int base = (1.0 - depth) * 128;
+ double val;
- for (i = 0; i < len; i++) {
- val = sin((float)i/(float)len * 2.0 * M_PI);
- buf[i] = (val + 1.0) * scale + base * 2;
- }
+ for (i = 0; i < len; i++) {
+ val = sin((float)i/(float)len * 2.0 * M_PI);
+ buf[i] = (val + 1.0) * scale + base * 2;
+ }
}
/*
@@ -82,19 +84,19 @@
*/
int st_vibro_start(eff_t effp)
{
- vibro_t vibro = (vibro_t) effp->priv;
+ vibro_t vibro = (vibro_t) effp->priv;
- vibro->length = effp->ininfo.rate / vibro->speed;
- if (! (vibro->sinetab = (short*) malloc(vibro->length * sizeof(short))))
- {
- st_fail("Vibro: Cannot malloc %d bytes",
- vibro->length * sizeof(short));
- return (ST_EOF);
- }
+ vibro->length = effp->ininfo.rate / vibro->speed;
+ if (! (vibro->sinetab = (short*) malloc(vibro->length * sizeof(short))))
+ {
+ st_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);
+ sine(vibro->sinetab, vibro->length, vibro->depth);
+ vibro->counter = 0;
+ return (ST_SUCCESS);
}
/*
@@ -105,25 +107,25 @@
int st_vibro_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
- vibro_t vibro = (vibro_t) effp->priv;
- register int counter, tablen;
- int len, done;
- short *sinetab;
- st_sample_t l;
+ vibro_t vibro = (vibro_t) effp->priv;
+ register int counter, tablen;
+ int len, done;
+ short *sinetab;
+ st_sample_t l;
- len = ((*isamp > *osamp) ? *osamp : *isamp);
+ len = ((*isamp > *osamp) ? *osamp : *isamp);
- sinetab = vibro->sinetab;
- counter = vibro->counter;
- tablen = vibro->length;
- for(done = 0; done < len; done++) {
- l = *ibuf++;
- /* 24x8 gives 32-bit result */
- *obuf++ = ((l / 256) * sinetab[counter++ % tablen]);
- }
- vibro->counter = counter;
- /* processed all samples */
- return (ST_SUCCESS);
+ sinetab = vibro->sinetab;
+ counter = vibro->counter;
+ tablen = vibro->length;
+ for(done = 0; done < len; done++) {
+ l = *ibuf++;
+ /* 24x8 gives 32-bit result */
+ *obuf++ = ((l / 256) * sinetab[counter++ % tablen]);
+ }
+ vibro->counter = counter;
+ /* processed all samples */
+ return (ST_SUCCESS);
}
/*
@@ -132,11 +134,11 @@
*/
int st_vibro_stop(eff_t effp)
{
- /* nothing to do */
+ /* nothing to do */
return (ST_SUCCESS);
}
-st_effect_t st_vibro_effect = {
+static st_effect_t st_vibro_effect = {
"vibro",
"Usage: vibro speed [ depth ]",
0,
@@ -146,3 +148,8 @@
st_effect_nothing_drain,
st_effect_nothing
};
+
+const st_effect_t *st_vibro_effect_fn(void)
+{
+ return &st_vibro_effect;
+}
--- a/src/vol.c
+++ b/src/vol.c
@@ -12,6 +12,8 @@
#include <math.h> /* exp(), sqrt() */
+static st_effect_t st_vol_effect;
+
/* type used for computations.
*/
#ifndef VOL_FLOAT
@@ -213,7 +215,7 @@
return ST_SUCCESS;
}
-st_effect_t st_vol_effect = {
+static st_effect_t st_vol_effect = {
"vol",
"Usage: vol gain [ type [ limitergain ] ]"
" (default type=amplitude: 1.0 is constant, <0.0 change phase;\n"
@@ -227,3 +229,8 @@
st_effect_nothing_drain,
st_vol_stop
};
+
+const st_effect_t *st_vol_effect_fn(void)
+{
+ return &st_vol_effect;
+}