ref: 08aa4092a380b7cee8b651f51d7fc6a928bcfaa6
parent: fd2d41a5b2289b46956c68074272f5e1b3f0ddd0
author: cbagwell <cbagwell>
date: Wed Jun 28 21:46:06 EDT 2006
Make effect usage available to applications.
--- a/Changelog
+++ b/Changelog
@@ -12,7 +12,9 @@
all failures from return codes and cleanup as they
want.
o Changed how list of formats and effects are stored internally.
- Effects libst users only.
+ Effects libst users only. Dirk
+ o Store effects usage so that its accessable by applications.
+ Dirk
o Modify the synth effect to not use SIGINT to stop processing
and instead return ST_EOF. This allows exact acount of
samples to be written out instead of an approximate amount.
--- a/src/avg.c
+++ b/src/avg.c
@@ -45,7 +45,6 @@
#define MIX_LEFT_BACK 8
#define MIX_RIGHT_BACK 9
-#define ST_AVG_USAGE "usage: avg [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]"
/*
* Process options
@@ -83,7 +82,7 @@
avg->mix = MIX_RIGHT_BACK;
else if (argv[0][0] == '-' && !isdigit((int)argv[0][1])
&& argv[0][1] != '.') {
- st_fail(ST_AVG_USAGE);
+ st_fail(st_avg_effect.usage);
return (ST_EOF);
}
else {
@@ -108,7 +107,7 @@
avg->mix = MIX_CENTER;
}
else {
- st_fail(ST_AVG_USAGE);
+ st_fail(st_avg_effect.usage);
return ST_EOF;
}
@@ -549,7 +548,7 @@
st_effect_t st_avg_effect = {
"avg",
- NULL,
+ "Usage: avg [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
ST_EFF_MCHAN | ST_EFF_CHAN,
st_avg_getopts,
st_avg_start,
@@ -560,7 +559,7 @@
st_effect_t st_pick_effect = {
"pick",
- NULL,
+ "Usage: pick [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
ST_EFF_MCHAN | ST_EFF_CHAN,
st_avg_getopts,
st_avg_start,
--- a/src/band.c
+++ b/src/band.c
@@ -71,13 +71,13 @@
}
if ((n < 1) || !sscanf(argv[0], "%f", &band->center))
{
- st_fail("Usage: band [ -n ] center [ width ]");
+ 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("Usage: band [ -n ] center [ width ]");
+ st_fail(st_band_effect.usage);
return (ST_EOF);
}
return (ST_SUCCESS);
@@ -146,7 +146,7 @@
st_effect_t st_band_effect = {
"band",
- NULL,
+ "Usage: band [ -n ] center [ width ]",
0,
st_band_getopts,
st_band_start,
--- a/src/bandpass.c
+++ b/src/bandpass.c
@@ -41,7 +41,7 @@
butterworth_t butterworth = (butterworth_t)effp->priv;
if (n != 2) {
- st_fail("Usage: bandpass FREQUENCY BANDWIDTH");
+ st_fail(st_bandpass_effect.usage);
return (ST_EOF);
}
@@ -79,7 +79,7 @@
st_effect_t st_bandpass_effect = {
"bandpass",
- NULL,
+ "Usage: bandpass FREQUENCY BANDWIDTH",
0,
st_bandpass_getopts,
st_bandpass_start,
--- a/src/breject.c
+++ b/src/breject.c
@@ -41,7 +41,7 @@
butterworth_t butterworth = (butterworth_t)effp->priv;
if (n != 2) {
- st_fail("Usage: bandreject FREQUENCY BANDWIDTH");
+ st_fail(st_bandreject_effect.usage);
return (ST_EOF);
}
@@ -79,7 +79,7 @@
st_effect_t st_bandreject_effect = {
"bandreject",
- NULL,
+ "Usage: bandreject FREQUENCY BANDWIDTH",
0,
st_bandreject_getopts,
st_bandreject_start,
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -101,7 +101,7 @@
if ( ( n < 7 ) || (( n - 2 ) % 5 ) )
{
- st_fail("Usage: chorus gain-in gain-out delay decay speed depth [ -s | -t ]");
+ st_fail(st_chorus_effect.usage);
return (ST_EOF);
}
@@ -123,7 +123,7 @@
chorus->modulation[chorus->num_chorus] = MOD_TRIANGLE;
else
{
- st_fail("Usage: chorus gain-in gain-out delay decay speed [ -s | -t ]");
+ st_fail(st_chorus_effect.usage);
return (ST_EOF);
}
i++;
@@ -351,7 +351,7 @@
st_effect_t st_chorus_effect = {
"chorus",
- NULL,
+ "Usage: chorus gain-in gain-out delay decay speed depth [ -s | -t ]",
0,
st_chorus_getopts,
st_chorus_start,
--- a/src/compand.c
+++ b/src/compand.c
@@ -75,13 +75,7 @@
if (n < 2 || n > 5)
{
- st_fail("Wrong number of arguments for the compander effect\n"
- "Use: {<attack_time>,<decay_time>}+ {<dB_in>,<db_out>}+ "
- "[<dB_postamp> [<initial-volume> [<delay_time]]]\n"
- "where {}+ means `one or more in a comma-separated, "
- "white-space-free list'\n"
- "and [] indications possible omission. dB values are floating\n"
- "point or `-inf'; times are in seconds.");
+ st_fail (st_compand_effect.usage);
return (ST_EOF);
}
else { /* Right no. of args, but are they well formed? */
@@ -412,7 +406,10 @@
st_effect_t st_compand_effect = {
"compand",
- NULL,
+ "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"
+ " and [] indications possible omission. dB values are floating\n"
+ " point or -inf'; times are in seconds.",
ST_EFF_MCHAN,
st_compand_getopts,
st_compand_start,
--- a/src/copy.c
+++ b/src/copy.c
@@ -21,7 +21,7 @@
{
if (n)
{
- st_fail("Copy effect takes no options.");
+ st_fail(st_copy_effect.usage);
return (ST_EOF);
}
return (ST_SUCCESS);
@@ -66,7 +66,7 @@
st_effect_t st_copy_effect = {
"copy",
- NULL,
+ "Usage: Copy effect takes no options",
ST_EFF_MCHAN,
st_copy_getopts,
st_copy_start,
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -29,12 +29,7 @@
#define ONE ((DCSHIFT_FLOAT)(1.0e0))
#define TWENTY ((DCSHIFT_FLOAT)(20.0e0))
-char *dcshift_usage = "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"
-"used on peaks to prevent clipping. (default is no limiter)";
-#define DCSHIFT_USAGE dcshift_usage
-
typedef struct {
DCSHIFT_FLOAT dcshift; /* DC shift. */
int uselimiter; /* boolean: are we using the limiter? */
@@ -56,13 +51,13 @@
if (n < 1)
{
- st_fail(DCSHIFT_USAGE);
+ st_fail(st_dcshift_effect.usage);
return ST_EOF;
}
if (n && (!sscanf(argv[0], DCSHIFT_FLOAT_SCAN, &dcs->dcshift)))
{
- st_fail(DCSHIFT_USAGE);
+ st_fail(st_dcshift_effect.usage);
return ST_EOF;
}
@@ -70,7 +65,7 @@
{
if (!sscanf(argv[1], DCSHIFT_FLOAT_SCAN, &dcs->limitergain))
{
- st_fail(DCSHIFT_USAGE);
+ st_fail(st_dcshift_effect.usage);
return ST_EOF;
}
@@ -215,7 +210,9 @@
st_effect_t st_dcshift_effect = {
"dcshift",
- NULL,
+ "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"
+ " used on peaks to prevent clipping. (default is no limiter)",
ST_EFF_MCHAN,
st_dcshift_getopts,
st_dcshift_start,
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -117,7 +117,7 @@
{
if (n)
{
- st_fail("Deemphasis filtering effect takes no options.\n");
+ st_fail(st_deemph_effect.usage);
return (ST_EOF);
}
if (sizeof(double)*ST_MAX_EFFECT_PRIVSIZE < sizeof(struct deemphstuff))
@@ -205,7 +205,7 @@
st_effect_t st_deemph_effect = {
"deemph",
- NULL,
+ "Usage: Deemphasis filtering effect takes no options",
ST_EFF_MCHAN,
st_deemph_getopts,
st_deemph_start,
--- a/src/earwax.c
+++ b/src/earwax.c
@@ -80,7 +80,7 @@
{
/* no options */
if (n){
- st_fail("The earwax filtering effect takes no options.\n");
+ st_fail(st_earwax_effect.usage);
return (ST_EOF);
}
return (ST_SUCCESS);
@@ -187,7 +187,7 @@
st_effect_t st_earwax_effect = {
"earwax",
- NULL,
+ "Usage: The earwax filtering effect takes no options",
ST_EFF_MCHAN,
st_earwax_getopts,
st_earwax_start,
--- a/src/echo.c
+++ b/src/echo.c
@@ -89,7 +89,7 @@
if ((n < 4) || (n % 2))
{
- st_fail("Usage: echo gain-in gain-out delay decay [ delay decay ... ]");
+ st_fail(st_echo_effect.usage);
return (ST_EOF);
}
@@ -271,7 +271,7 @@
st_effect_t st_echo_effect = {
"echo",
- NULL,
+ "Usage: echo gain-in gain-out delay decay [ delay decay ... ]",
0,
st_echo_getopts,
st_echo_start,
--- a/src/echos.c
+++ b/src/echos.c
@@ -79,7 +79,7 @@
if ((n < 4) || (n % 2))
{
- st_fail("Usage: echos gain-in gain-out delay decay [ delay decay ... ]");
+ st_fail(st_echos_effect.usage);
return (ST_EOF);
}
@@ -275,7 +275,7 @@
st_effect_t st_echos_effect = {
"echos",
- NULL,
+ "Usage: echos gain-in gain-out delay decay [ delay decay ... ]",
0,
st_echos_getopts,
st_echos_start,
--- a/src/fade.c
+++ b/src/fade.c
@@ -34,8 +34,6 @@
int endpadwarned;
} *fade_t;
-#define FADE_USAGE "Usage: fade [ type ] fade-in-length [ stop-time [ fade-out-length ] ]\nTime is in hh:mm:ss.frac format.\nFade type one of q, h, t, l or p.\n"
-
/* prototypes */
static double fade_gain(st_size_t index, st_size_t range, char fadetype);
@@ -55,7 +53,7 @@
if (n < 1 || n > 4)
{ /* Wrong number of arguments. */
- st_fail(FADE_USAGE);
+ st_fail(st_fade_effect.usage);
return(ST_EOF);
}
@@ -89,7 +87,7 @@
if (st_parsesamples(0, fade->in_stop_str, &fade->in_stop, 't') !=
ST_SUCCESS)
{
- st_fail(FADE_USAGE);
+ st_fail(st_fade_effect.usage);
return(ST_EOF);
}
@@ -112,7 +110,7 @@
if (st_parsesamples(0, fade->out_stop_str,
&fade->out_stop, 't') != ST_SUCCESS)
{
- st_fail(FADE_USAGE);
+ st_fail(st_fade_effect.usage);
return(ST_EOF);
}
}
@@ -130,7 +128,7 @@
if (st_parsesamples(0, fade->out_start_str,
&fade->out_start, 't') != ST_SUCCESS)
{
- st_fail(FADE_USAGE);
+ st_fail(st_fade_effect.usage);
return(ST_EOF);
}
}
@@ -152,7 +150,7 @@
if (st_parsesamples(effp->ininfo.rate, fade->in_stop_str,
&fade->in_stop, 't') != ST_SUCCESS)
{
- st_fail(FADE_USAGE);
+ st_fail(st_fade_effect.usage);
return(ST_EOF);
}
@@ -164,7 +162,7 @@
if (st_parsesamples(effp->ininfo.rate, fade->out_stop_str,
&fade->out_stop, 't') != ST_SUCCESS)
{
- st_fail(FADE_USAGE);
+ st_fail(st_fade_effect.usage);
return(ST_EOF);
}
@@ -174,7 +172,7 @@
if (st_parsesamples(effp->ininfo.rate, fade->out_start_str,
&fade->out_start, 't') != ST_SUCCESS)
{
- st_fail(FADE_USAGE);
+ st_fail(st_fade_effect.usage);
return(ST_EOF);
}
/* Fade time is relative to stop time. */
@@ -402,7 +400,9 @@
st_effect_t st_fade_effect = {
"fade",
- NULL,
+ "Usage: fade [ type ] fade-in-length [ stop-time [ fade-out-length ] ]\n"
+ " Time is in hh:mm:ss.frac format.\n"
+ " Fade type one of q, h, t, l or p.",
ST_EFF_MCHAN,
st_fade_getopts,
st_fade_start,
--- a/src/filter.c
+++ b/src/filter.c
@@ -82,13 +82,13 @@
/* fprintf(stderr,"freq: %d-%d\n", f->freq0, f->freq1);fflush(stderr); */
if (f->freq0 == 0 && f->freq1 == 0)
{
- st_fail("Usage: filter low-high [ windowlength [ beta ] ]");
+ st_fail(st_filter_effect.usage);
return (ST_EOF);
}
if ((n >= 2) && !sscanf(argv[1], "%ld", &f->Nwin))
{
- st_fail("Usage: filter low-high [ windowlength ]");
+ st_fail(st_filter_effect.usage);
return (ST_EOF);
}
else if (f->Nwin < 4) {
@@ -98,7 +98,7 @@
if ((n >= 3) && !sscanf(argv[2], "%lf", &f->beta))
{
- st_fail("Usage: filter low-high [ windowlength [ beta ] ]");
+ st_fail(st_filter_effect.usage);
return (ST_EOF);
}
@@ -317,7 +317,7 @@
st_effect_t st_filter_effect = {
"filter",
- NULL,
+ "Usage: filter low-high [ windowlength [ beta ] ]",
0,
st_filter_getopts,
st_filter_start,
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -85,7 +85,7 @@
if (!((n == 5) || (n == 6)))
{
- st_fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
+ st_fail(st_flanger_effect.usage);
return (ST_EOF);
}
@@ -102,7 +102,7 @@
flanger->modulation = MOD_TRIANGLE;
else
{
- st_fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
+ st_fail(st_flanger_effect.usage);
return (ST_EOF);
}
}
@@ -289,7 +289,7 @@
st_effect_t st_flanger_effect = {
"flanger",
- NULL,
+ "Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]",
0,
st_flanger_getopts,
st_flanger_start,
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -14,7 +14,7 @@
* Sound Tools file format and effect tables.
*/
-st_format_t st_terminator_format =
+st_format_t st_terminate_format =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
@@ -71,7 +71,7 @@
&st_vox_format,
&st_wav_format,
&st_wve_format,
- &st_terminator_format,
+ &st_terminate_format,
NULL
};
@@ -84,7 +84,7 @@
*
*/
-st_effect_t st_terminator_effect =
+st_effect_t st_terminate_effect =
{
0, 0, 0, 0, 0, 0, 0, 0
};
@@ -132,6 +132,6 @@
&st_trim_effect,
&st_vibro_effect,
&st_vol_effect,
- &st_terminator_effect,
+ &st_terminate_effect,
NULL
};
--- a/src/highp.c
+++ b/src/highp.c
@@ -48,7 +48,7 @@
if ((n < 1) || !sscanf(argv[0], "%f", &highp->cutoff))
{
- st_fail("Usage: highp cutoff");
+ st_fail(st_highp_effect.usage);
return (ST_EOF);
}
return (ST_SUCCESS);
@@ -115,7 +115,7 @@
st_effect_t st_highp_effect = {
"highp",
- NULL,
+ "Usage: highp cutoff",
0,
st_highp_getopts,
st_highp_start,
--- a/src/highpass.c
+++ b/src/highpass.c
@@ -42,7 +42,7 @@
butterworth_t butterworth = (butterworth_t)effp->priv;
if (n != 1) {
- st_fail("Usage: highpass FREQUENCY");
+ st_fail(st_highpass_effect.usage);
return (ST_EOF);
}
@@ -75,7 +75,7 @@
st_effect_t st_highpass_effect = {
"highpass",
- NULL,
+ "Usage: highpass FREQUENCY",
0,
st_highpass_getopts,
st_highpass_start,
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -46,7 +46,7 @@
if ((n < 1) || !sscanf(argv[0], "%f", &lowp->cutoff))
{
- st_fail("Usage: lowp cutoff");
+ st_fail(st_lowp_effect.usage);
return (ST_EOF);
}
return (ST_SUCCESS);
@@ -108,7 +108,7 @@
st_effect_t st_lowp_effect = {
"lowp",
- NULL,
+ "Usage: lowp cutoff",
0,
st_lowp_getopts,
st_lowp_start,
--- a/src/lowpass.c
+++ b/src/lowpass.c
@@ -29,7 +29,7 @@
butterworth_t butterworth = (butterworth_t)effp->priv;
if (n != 1) {
- st_fail("Usage: lowpass FREQUENCY");
+ st_fail(st_lowpass_effect.usage);
return (ST_EOF);
}
@@ -60,7 +60,7 @@
st_effect_t st_lowpass_effect = {
"lowpass",
- NULL,
+ "Usage: lowpass FREQUENCY",
0,
st_lowpass_getopts,
st_lowpass_start,
--- a/src/mask.c
+++ b/src/mask.c
@@ -31,7 +31,7 @@
{
if (n)
{
- st_fail("Mask effect takes no options.");
+ st_fail(st_mask_effect.usage);
return (ST_EOF);
}
/* should take # of bits */
@@ -99,7 +99,7 @@
st_effect_t st_mask_effect = {
"mask",
- NULL,
+ "Usage: Mask effect takes no options",
ST_EFF_MCHAN,
st_mask_getopts,
st_effect_nothing,
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -714,7 +714,29 @@
st_effect_t st_mcompand_effect = {
"mcompand",
- NULL,
+ "Usage: mcompand quoted_compand_args [crossover_frequency quoted_compand_args [...]]\n"
+ "\n"
+ "quoted_compand_args are as for the compand effect:\n"
+ "\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",
ST_EFF_MCHAN,
st_mcompand_getopts,
st_mcompand_start,
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -44,7 +44,7 @@
if (n == 1) {
data->output_filename = argv[0];
} else if (n > 1) {
- st_fail("Usage: noiseprof [filename]");
+ st_fail(st_noiseprof_effect.usage);
return (ST_EOF);
}
@@ -211,7 +211,7 @@
st_effect_t st_noiseprof_effect = {
"noiseprof",
- NULL,
+ "Usage: noiseprof [filename]",
ST_EFF_MCHAN | ST_EFF_REPORT,
st_noiseprof_getopts,
st_noiseprof_start,
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -41,7 +41,7 @@
reddata_t data = (reddata_t) effp->priv;
if (n > 2 || n < 1) {
- st_fail("Usage: noiseprof profile-file [threshold]");
+ st_fail(st_noisered_effect.usage);
return (ST_EOF);
}
data->threshold = 0.5;
@@ -345,7 +345,7 @@
st_effect_t st_noisered_effect = {
"noisered",
- NULL,
+ "Usage: noiseprof profile-file [threshold]",
ST_EFF_MCHAN,
st_noisered_getopts,
st_noisered_start,
--- a/src/pan.c
+++ b/src/pan.c
@@ -38,10 +38,6 @@
#define QUARTER ((PAN_FLOAT)(0.25e0))
#define ZERO ((PAN_FLOAT)(0.0e0))
-/* error message */
-
-#define PAN_USAGE "Usage: pan direction (in [-1.0 .. 1.0])"
-
/* structure to hold pan parameter */
typedef struct {
@@ -67,7 +63,7 @@
if (n && (!sscanf(argv[0], PAN_FLOAT_SCAN, &pan->dir) ||
pan->dir < MONE || pan->dir > ONE))
{
- st_fail(PAN_USAGE);
+ st_fail(st_pan_effect.usage);
return ST_EOF;
}
@@ -451,7 +447,7 @@
st_effect_t st_pan_effect = {
"pan",
- NULL,
+ "Usage: pan direction (in [-1.0 .. 1.0])",
ST_EFF_MCHAN | ST_EFF_CHAN,
st_pan_getopts,
st_pan_start,
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -85,7 +85,7 @@
if (!((n == 5) || (n == 6)))
{
- st_fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
+ st_fail(st_phaser_effect.usage);
return (ST_EOF);
}
@@ -102,7 +102,7 @@
phaser->modulation = MOD_TRIANGLE;
else
{
- st_fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
+ st_fail(st_phaser_effect.usage);
return (ST_EOF);
}
}
@@ -279,7 +279,7 @@
st_effect_t st_phaser_effect = {
"phaser",
- NULL,
+ "Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]",
0,
st_phaser_getopts,
st_phaser_start,
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -55,11 +55,6 @@
#define PITCH_FLOAT_SCAN "%lf"
#endif
-#define PITCH_USAGE \
- "Usage: pitch shift width interpole fade" \
- " (in cents, in ms, cub/lin, cos/ham/lin/trap)" \
- " (defaults: 0 20 c c)"
-
/* cross fading options for transitions
*/
#define PITCH_FADE_COS 0 /* cosine */
@@ -287,7 +282,7 @@
if (n && !sscanf(argv[0], PITCH_FLOAT_SCAN, &pitch->shift))
{
- st_fail(PITCH_USAGE);
+ st_fail(st_pitch_effect.usage);
return ST_EOF;
}
@@ -295,7 +290,7 @@
pitch->width = PITCH_DEFAULT_WIDTH;
if (n>1 && !sscanf(argv[1], PITCH_FLOAT_SCAN, &pitch->width))
{
- st_fail(PITCH_USAGE);
+ st_fail(st_pitch_effect.usage);
return ST_EOF;
}
@@ -314,7 +309,7 @@
pitch->interopt = PITCH_INTERPOLE_CUB;
break;
default:
- st_fail(PITCH_USAGE);
+ st_fail(st_pitch_effect.usage);
return ST_EOF;
}
}
@@ -342,7 +337,7 @@
pitch->fadeopt = PITCH_FADE_COS;
break;
default:
- st_fail(PITCH_USAGE);
+ st_fail(st_pitch_effect.usage);
return ST_EOF;
}
}
@@ -351,7 +346,7 @@
if (n>4 && (!sscanf(argv[4], PITCH_FLOAT_SCAN, &pitch->coef) ||
pitch->coef<ZERO || pitch->coef>HALF))
{
- st_fail(PITCH_USAGE);
+ st_fail(st_pitch_effect.usage);
return ST_EOF;
}
@@ -620,7 +615,9 @@
st_effect_t st_pitch_effect = {
"pitch",
- NULL,
+ "Usage: pitch shift width interpole fade\n"
+ " (in cents, in ms, cub/lin, cos/ham/lin/trap)"
+ " (defaults: 0 20 c c)",
0,
st_pitch_getopts,
st_pitch_start,
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -667,7 +667,14 @@
st_effect_t st_polyphase_effect = {
"polyphase",
- NULL,
+ "Usage: -w <nut / ham> : window type\n"
+ " -width <short / long> : window width\n"
+ " short = 128 samples\n"
+ " long = 1024 samples\n"
+ " <num> num: explicit number\n"
+ "\n"
+ " -cutoff <float> : frequency cutoff for base bandwidth.\n"
+ " Default = 0.95 = 95%",
ST_EFF_RATE,
st_poly_getopts,
st_poly_start,
--- a/src/rate.c
+++ b/src/rate.c
@@ -240,7 +240,7 @@
{
if (n)
{
- st_fail("Rate effect takes no options.");
+ st_fail(st_rate_effect.usage);
return (ST_EOF);
}
return (ST_SUCCESS);
@@ -339,7 +339,7 @@
st_effect_t st_rate_effect = {
"rate",
- NULL,
+ "Usage: Rate effect takes no options",
ST_EFF_RATE,
st_rate_getopts,
st_rate_start,
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -37,7 +37,7 @@
repeat_t repeat = (repeat_t)effp->priv;
if (n != 1) {
- st_fail("Usage: repeat count]");
+ st_fail(st_repeat_effect.usage);
return (ST_EOF);
}
@@ -197,7 +197,7 @@
st_effect_t st_repeat_effect = {
"repeat",
- NULL,
+ "Usage: repeat count",
0,
st_repeat_getopts,
st_repeat_start,
--- a/src/resample.c
+++ b/src/resample.c
@@ -145,7 +145,7 @@
if ((n >= 1) && (sscanf(argv[0], "%lf", &r->rolloff) != 1))
{
- st_fail("Usage: resample [ rolloff [ beta ] ]");
+ st_fail(st_resample_effect.usage);
return (ST_EOF);
}
else if ((r->rolloff <= 0.01) || (r->rolloff >= 1.0))
@@ -156,7 +156,7 @@
if ((n >= 2) && !sscanf(argv[1], "%lf", &r->beta))
{
- st_fail("Usage: resample [ rolloff [ beta ] ]");
+ st_fail(st_resample_effect.usage);
return (ST_EOF);
}
else if (r->beta <= 2.0) {
@@ -712,7 +712,7 @@
st_effect_t st_resample_effect = {
"resample",
- NULL,
+ "Usage: resample [ rolloff [ beta ] ]",
ST_EFF_RATE,
st_resample_getopts,
st_resample_start,
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -123,7 +123,7 @@
if ( n < 3 )
{
- st_fail("Usage: reverb gain-out reverb-time delay [ delay ... ]");
+ st_fail(st_reverb_effect.usage);
return (ST_EOF);
}
@@ -289,7 +289,7 @@
st_effect_t st_reverb_effect = {
"reverb",
- NULL,
+ "Usage: reverb gain-out reverb-time delay [ delay ... ]",
0,
st_reverb_getopts,
st_reverb_start,
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -38,7 +38,7 @@
{
if (n)
{
- st_fail("Reverse effect takes no options.");
+ st_fail(st_reverse_effect.usage);
return (ST_EOF);
}
return(ST_SUCCESS);
@@ -145,7 +145,7 @@
st_effect_t st_reverse_effect = {
"reverse",
- NULL,
+ "Usage: Reverse effect takes no options",
0,
st_reverse_getopts,
st_reverse_start,
--- a/src/silence.c
+++ b/src/silence.c
@@ -88,8 +88,6 @@
silence->rms_sum = 0;
}
-#define SILENCE_USAGE "Usage: silence above_periods [ duration thershold[d | %% ] ] [ below_periods duration threshold[ d | %% ]]"
-
int st_silence_getopts(eff_t effp, int n, char **argv)
{
silence_t silence = (silence_t) effp->priv;
@@ -97,7 +95,7 @@
if (n < 1)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return (ST_EOF);
}
@@ -105,7 +103,7 @@
silence->start = FALSE;
if (sscanf(argv[0], "%d", &silence->start_periods) != 1)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return(ST_EOF);
}
if (silence->start_periods < 0)
@@ -121,7 +119,7 @@
silence->start = TRUE;
if (n < 2)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return ST_EOF;
}
@@ -141,7 +139,7 @@
&silence->start_duration,'s') !=
ST_SUCCESS)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return(ST_EOF);
}
@@ -149,7 +147,7 @@
&silence->start_unit);
if (parse_count < 1)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return ST_EOF;
}
else if (parse_count < 2)
@@ -165,12 +163,12 @@
{
if (n < 3)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return ST_EOF;
}
if (sscanf(argv[0], "%d", &silence->stop_periods) != 1)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return ST_EOF;
}
if (silence->stop_periods < 0)
@@ -200,7 +198,7 @@
&silence->stop_duration,'s') !=
ST_SUCCESS)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return(ST_EOF);
}
@@ -208,7 +206,7 @@
&silence->stop_unit);
if (parse_count < 1)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return ST_EOF;
}
else if (parse_count < 2)
@@ -224,7 +222,7 @@
if ((silence->start_unit != '%') && (silence->start_unit != 'd'))
{
st_fail("Invalid unit specified");
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return(ST_EOF);
}
if ((silence->start_unit == '%') && ((silence->start_threshold < 0.0)
@@ -290,7 +288,7 @@
&silence->start_duration, 's') !=
ST_SUCCESS)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return(ST_EOF);
}
}
@@ -300,7 +298,7 @@
&silence->stop_duration,'s') !=
ST_SUCCESS)
{
- st_fail(SILENCE_USAGE);
+ st_fail(st_silence_effect.usage);
return(ST_EOF);
}
}
@@ -698,7 +696,7 @@
st_effect_t st_silence_effect = {
"silence",
- NULL,
+ "Usage: silence above_periods [ duration thershold[d | %% ] ] [ below_periods duration threshold[ d | %% ]]",
ST_EFF_MCHAN,
st_silence_getopts,
st_silence_start,
--- a/src/speed.c
+++ b/src/speed.c
@@ -31,8 +31,6 @@
#define ONESIXTH ((SPEED_FLOAT)(1.0e0/6.0e0))
#define ZERO ((SPEED_FLOAT)(0.0e0))
-#define SPEED_USAGE "speed [-c] factor (default 1.0, <1 slows, -c: factor in cent)"
-
/* automaton status
*/
typedef enum { sp_input, sp_transfer, sp_compute } buffer_state_t;
@@ -110,7 +108,7 @@
(cent==0 && speed->factor<=ZERO)))
{
printf("n = %d cent = %d speed = %f\n",n,cent,speed->factor);
- st_fail(SPEED_USAGE);
+ st_fail(st_speed_effect.usage);
return ST_EOF;
}
else if (cent != 0) /* CONST==2**(1/1200) */
@@ -304,7 +302,7 @@
st_effect_t st_speed_effect = {
"speed",
- NULL,
+ "Usage: speed [-c] factor (default 1.0, <1 slows, -c: factor in cent)",
0,
st_speed_getopts,
st_speed_start,
--- a/src/stat.c
+++ b/src/stat.c
@@ -504,7 +504,7 @@
st_effect_t st_stat_effect = {
"stat",
- NULL,
+ "Usage: ?",
ST_EFF_MCHAN | ST_EFF_REPORT,
st_stat_getopts,
st_stat_start,
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -33,11 +33,6 @@
#define STRETCH_FLOAT_SCAN "%f"
#endif
-#define STRETCH_USAGE \
- "Usage: stretch factor [window fade shift fading]\n" \
- "\t(expansion, frame in ms, lin/..., unit<1.0, unit<0.5)\n" \
- "\t(defaults: 1.0 20 lin ...)"
-
/* ok, it looks stupid to have such constant.
this is because of the cast, if floats are switched to doubles.
*/
@@ -108,6 +103,7 @@
*/
int st_stretch_getopts(eff_t effp, int n, char **argv)
{
+ char usage[1024];
stretch_t stretch = (stretch_t) effp->priv;
/* default options */
@@ -117,13 +113,15 @@
if (n>0 && !sscanf(argv[0], STRETCH_FLOAT_SCAN, &stretch->factor))
{
- st_fail(STRETCH_USAGE "\n\terror while parsing factor");
+ sprintf (usage, "%s\n\terror while parsing factor", st_stretch_effect.usage);
+ st_fail(usage);
return ST_EOF;
}
if (n>1 && !sscanf(argv[1], STRETCH_FLOAT_SCAN, &stretch->window))
{
- st_fail(STRETCH_USAGE "\n\terror while parsing window size");
+ sprintf (usage, "%s\n\terror while parsing window size", st_stretch_effect.usage);
+ st_fail(usage);
return ST_EOF;
}
@@ -136,7 +134,8 @@
stretch->fade = st_linear_fading;
break;
default:
- st_fail(STRETCH_USAGE "\n\terror while parsing fade type");
+ sprintf (usage, "%s\n\terror while parsing fade type", st_stretch_effect.usage);
+ st_fail(usage);
return ST_EOF;
}
}
@@ -147,13 +146,15 @@
if (n>3 && !sscanf(argv[3], STRETCH_FLOAT_SCAN, &stretch->shift))
{
- st_fail(STRETCH_USAGE "\n\terror while parsing shift ratio");
+ sprintf (usage, "%s\n\terror while parsing shift ratio", st_stretch_effect.usage);
+ st_fail(usage);
return ST_EOF;
}
if (stretch->shift > ONE || stretch->shift <= ZERO)
{
- st_fail(STRETCH_USAGE "\n\terror with shift ratio value");
+ sprintf (usage, "%s\n\terror with shift ratio value", st_stretch_effect.usage);
+ st_fail(usage);
return ST_EOF;
}
@@ -168,13 +169,15 @@
if (n>4 && !sscanf(argv[4], STRETCH_FLOAT_SCAN, &stretch->fading))
{
- st_fail(STRETCH_USAGE "\n\terror while parsing fading ratio");
+ sprintf (usage, "%s\n\terror while parsing fading ratio", st_stretch_effect.usage);
+ st_fail(usage);
return ST_EOF;
}
if (stretch->fading > HALF || stretch->fading < ZERO)
{
- st_fail(STRETCH_USAGE "\n\terror with fading ratio value");
+ sprintf (usage, "%s\n\terror with fading ratio value", st_stretch_effect.usage);
+ st_fail(usage);
return ST_EOF;
}
@@ -424,7 +427,9 @@
st_effect_t st_stretch_effect = {
"stretch",
- NULL,
+ "Usage: stretch factor [window fade shift fading]\n"
+ " (expansion, frame in ms, lin/..., unit<1.0, unit<0.5)\n"
+ " (defaults: 1.0 20 lin ...)",
0,
st_stretch_getopts,
st_stretch_start,
--- a/src/swap.c
+++ b/src/swap.c
@@ -35,7 +35,7 @@
swap->def_opts = 0;
if (n != 2 && n != 4)
{
- st_fail("Usage: swap [1 2 | 1 2 3 4]");
+ st_fail(st_swap_effect.usage);
return (ST_EOF);
}
else if (n == 2)
@@ -199,7 +199,7 @@
st_effect_t st_swap_effect = {
"swap",
- NULL,
+ "Usage: swap [1 2 | 1 2 3 4]",
ST_EFF_MCHAN,
st_swap_getopts,
st_swap_start,
--- a/src/synth.c
+++ b/src/synth.c
@@ -16,22 +16,6 @@
#include <ctype.h>
#include "st_i.h"
-#define USSTR ""\
-"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"\
-" <type> is sine, square, triangle, sawtooth, trapetz, exp,\n"\
-" whitenoise, pinknoise, brownnoise, default=sine\n"\
-" <mix> is create, mix, amod, default=create\n"\
-" <freq> frequency at beginning in Hz, not used for noise..\n"\
-" <freq2> frequency at end in Hz, not used for noise..\n"\
-" <freq/2> can be given as %%n, where 'n' is the number of\n"\
-" half notes in respect to A (440Hz)\n"\
-" <off> Bias (DC-offset) of signal in percent, default=0\n"\
-" <ph> phase shift 0..100 shift phase 0..2*Pi, not used for noise..\n"\
-" <p1> square: Ton/Toff, triangle+trapetz: rising slope time (0..100)\n"\
-" <p2> trapetz: ON time (0..100)\n"\
-" <p3> trapetz: falling slope position (0..100)"
-
#define PCOUNT 5
#define SYNTH_SINE 0
@@ -232,7 +216,6 @@
int st_synth_getopts(eff_t effp, int n, char **argv)
{
int argn;
- char *usstr=USSTR;
char *hlp;
int i;
int c;
@@ -258,7 +241,7 @@
argn=0;
if ( n<0){
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return(ST_EOF);
}
if(n==0){
@@ -280,7 +263,7 @@
if (st_parsesamples(0, synth->length_str, &synth->length, 't') !=
ST_SUCCESS)
{
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return (ST_EOF);
}
argn++;
@@ -326,7 +309,7 @@
}else{
/* type not given, error */
st_warn("synth: no type given");
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return(ST_EOF);
}
if(n > argn){
@@ -350,7 +333,7 @@
synth->freq2[c] = synth->freq[c];
if(synth->freq[c] < 0.0){
st_warn("synth: illegal freq");
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return(ST_EOF);
}
if(*hlp=='-') {
@@ -359,7 +342,7 @@
synth->freq2[c]=StringToFreq(hlp+1,&hlp2);
if(synth->freq2[c] < 0.0){
st_warn("synth: illegal freq2");
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return(ST_EOF);
}
}
@@ -373,7 +356,7 @@
}
if( i >= PCOUNT) {
st_warn("synth: too many parameters");
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return(ST_EOF);
}
@@ -381,7 +364,7 @@
if(hlp==argv[argn]){
/* error in number */
st_warn("synth: parameter error");
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return(ST_EOF);
}
i++;
@@ -427,7 +410,6 @@
int i;
int c;
synth_t synth = (synth_t) effp->priv;
- char *usstr=USSTR;
st_initrand();
@@ -436,7 +418,7 @@
if (st_parsesamples(effp->ininfo.rate, synth->length_str,
&synth->length, 't') != ST_SUCCESS)
{
- st_fail(usstr);
+ st_fail(st_synth_effect.usage);
return(ST_EOF);
}
}
@@ -754,7 +736,20 @@
st_effect_t st_synth_effect = {
"synth",
- NULL,
+ "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"
+ " <type> is sine, square, triangle, sawtooth, trapetz, exp,\n"
+ " whitenoise, pinknoise, brownnoise, default=sine\n"
+ " <mix> is create, mix, amod, default=create\n"
+ " <freq> frequency at beginning in Hz, not used for noise..\n"
+ " <freq2> frequency at end in Hz, not used for noise..\n"
+ " <freq/2> can be given as %%n, where 'n' is the number of\n"
+ " half notes in respect to A (440Hz)\n"
+ " <off> Bias (DC-offset) of signal in percent, default=0\n"
+ " <ph> phase shift 0..100 shift phase 0..2*Pi, not used for noise..\n"
+ " <p1> square: Ton/Toff, triangle+trapetz: rising slope time (0..100)\n"
+ " <p2> trapetz: ON time (0..100)\n"
+ " <p3> trapetz: falling slope position (0..100)",
ST_EFF_MCHAN,
st_synth_getopts,
st_synth_start,
--- a/src/trim.c
+++ b/src/trim.c
@@ -17,8 +17,6 @@
/* Time resolutin one millisecond */
#define TIMERES 1000
-#define TRIM_USAGE "Trim usage: trim start [length]"
-
typedef struct
{
/* options here */
@@ -57,7 +55,7 @@
if (st_parsesamples(0, trim->length_str,
&trim->length, 't') != ST_SUCCESS)
{
- st_fail(TRIM_USAGE);
+ st_fail(st_trim_effect.usage);
return(ST_EOF);
}
case 1:
@@ -72,12 +70,12 @@
if (st_parsesamples(0, trim->start_str,
&trim->start, 't') != ST_SUCCESS)
{
- st_fail(TRIM_USAGE);
+ st_fail(st_trim_effect.usage);
return(ST_EOF);
}
break;
default:
- st_fail(TRIM_USAGE);
+ st_fail(st_trim_effect.usage);
return ST_EOF;
break;
@@ -95,7 +93,7 @@
if (st_parsesamples(effp->ininfo.rate, trim->start_str,
&trim->start, 't') != ST_SUCCESS)
{
- st_fail(TRIM_USAGE);
+ st_fail(st_trim_effect.usage);
return(ST_EOF);
}
/* Account for # of channels */
@@ -106,7 +104,7 @@
if (st_parsesamples(effp->ininfo.rate, trim->length_str,
&trim->length, 't') != ST_SUCCESS)
{
- st_fail(TRIM_USAGE);
+ st_fail(st_trim_effect.usage);
return(ST_EOF);
}
}
@@ -221,7 +219,7 @@
st_effect_t st_trim_effect = {
"trim",
- NULL,
+ "Usage: trim start [length]",
ST_EFF_MCHAN,
st_trim_getopts,
st_trim_start,
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -49,7 +49,7 @@
if ((n == 0) || !sscanf(argv[0], "%f", &vibro->speed) ||
((n == 2) && !sscanf(argv[1], "%f", &vibro->depth)))
{
- st_fail("Usage: vibro speed [ depth ]");
+ st_fail(st_vibro_effect.usage);
return (ST_EOF);
}
if ((vibro->speed <= 0.001) || (vibro->speed > 30.0) ||
@@ -138,7 +138,7 @@
st_effect_t st_vibro_effect = {
"vibro",
- NULL,
+ "Usage: vibro speed [ depth ]",
0,
st_vibro_getopts,
st_vibro_start,
--- a/src/vol.c
+++ b/src/vol.c
@@ -26,13 +26,6 @@
#define ONE ((VOL_FLOAT)(1.0e0))
#define TWENTY ((VOL_FLOAT)(20.0e0))
-#define VOL_USAGE \
- "Usage: vol gain [ type [ limitergain ] ]" \
- " (default type=amplitude: 1.0 is constant, <0.0 change phase;" \
- " type=power 1.0 is constant; type=dB: 0.0 is constant, +6 doubles ampl.)" \
- " The peak limiter has a gain much less than 1.0 (ie 0.05 or 0.02) which is only" \
- " used on peaks to prevent clipping. (default is no limiter)"
-
typedef struct {
VOL_FLOAT gain; /* amplitude gain. */
@@ -56,7 +49,7 @@
if (n && (!sscanf(argv[0], VOL_FLOAT_SCAN, &vol->gain)))
{
- st_fail(VOL_USAGE);
+ st_fail(st_vol_effect.usage);
return ST_EOF;
}
@@ -88,7 +81,7 @@
{
if ((fabs(vol->gain) < ONE) || !sscanf(argv[2], VOL_FLOAT_SCAN, &vol->limitergain) || !((vol->limitergain > ZERO) && (vol->limitergain < ONE)))
{
- st_fail(VOL_USAGE);
+ st_fail(st_vol_effect.usage);
return ST_EOF;
}
@@ -222,7 +215,11 @@
st_effect_t st_vol_effect = {
"vol",
- NULL,
+ "Usage: vol gain [ type [ limitergain ] ]"
+ " (default type=amplitude: 1.0 is constant, <0.0 change phase;\n"
+ " type=power 1.0 is constant; type=dB: 0.0 is constant, +6 doubles ampl.)\n"
+ " The peak limiter has a gain much less than 1.0 (ie 0.05 or 0.02) which is only\n"
+ " used on peaks to prevent clipping. (default is no limiter)",
ST_EFF_MCHAN,
st_vol_getopts,
st_vol_start,