ref: 29647996bc9726866a073a2125247df99244290b
parent: 60523b85292c443a86d9422ce62c16b9c962b23e
author: cbagwell <cbagwell>
date: Thu Oct 9 00:21:45 EDT 2008
Move some utils used by sox.c into public sox.h interface.
--- a/src/effects_i.c
+++ b/src/effects_i.c
@@ -118,7 +118,7 @@
((a * a * a - a) * y_2d[i[0]] + (b * b * b - b) * y_2d[i[1]]) * d * d / 6;
}
-enum_item const lsx_wave_enum[] = {
+sox_enum_item const lsx_wave_enum[] = {
ENUM_ITEM(SOX_WAVE_,SINE)
ENUM_ITEM(SOX_WAVE_,TRIANGLE)
{0, 0}};
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -91,7 +91,7 @@
-static enum_item const interp_enum[] = {
+static sox_enum_item const interp_enum[] = {
ENUM_ITEM(INTERP_,LINEAR)
ENUM_ITEM(INTERP_,QUADRATIC)
{0, 0}};
--- a/src/rate.c
+++ b/src/rate.c
@@ -427,7 +427,7 @@
prepare_coefs(coefs, f->num_coefs, phases, interp_order, mult);
sox_debug("fir_len=%i phases=%i coef_interp=%i mult=%i size=%s",
f->num_coefs, phases, interp_order, mult,
- sigfigs3((num_taps + 1) * (interp_order + 1) * sizeof(sample_t)));
+ sox_sigfigs3((num_taps + 1) * (interp_order + 1) * sizeof(sample_t)));
free(coefs);
}
last_stage.fn = f1->fn;
--- a/src/sox.c
+++ b/src/sox.c
@@ -82,7 +82,7 @@
static sox_bool interactive = sox_false;
static sox_bool uservolume = sox_false;
typedef enum {RG_off, RG_track, RG_album} rg_mode;
-static enum_item const rg_modes[] = {
+static sox_enum_item const rg_modes[] = {
ENUM_ITEM(RG_,off)
ENUM_ITEM(RG_,track)
ENUM_ITEM(RG_,album)
@@ -240,7 +240,7 @@
fprintf(output, "\n");
if (f && f->replay_gain != HUGE_VAL){
- sprintf(buffer, "%s gain: %+.1fdB", find_enum_value(f->replay_gain_mode, rg_modes)->text, f->replay_gain);
+ sprintf(buffer, "%s gain: %+.1fdB", sox_find_enum_value(f->replay_gain_mode, rg_modes)->text, f->replay_gain);
buffer[0] += 'A' - 'a';
fprintf(output, "%-24s", buffer);
} else
@@ -318,7 +318,7 @@
if (f && f->replay_gain != HUGE_VAL)
fprintf(output, "Replay gain : %+g dB (%s)\n" , f->replay_gain,
- find_enum_value(f->replay_gain_mode, rg_modes)->text);
+ sox_find_enum_value(f->replay_gain_mode, rg_modes)->text);
if (f && f->volume != HUGE_VAL)
fprintf(output, "Level adjust : %g (linear gain)\n" , f->volume);
@@ -994,9 +994,9 @@
percentage = max(100. * read_wide_samples / input_wide_samples, 0);
}
fprintf(stderr, "\r%-5s %s [%s] of %s Out:%-5s [%6s|%-6s]%s Clip:%-5s",
- sigfigs3p(percentage), str_time(read_time), str_time(left_time),
- str_time(in_time), sigfigs3(output_samples),
- vu(0), vu(1), headroom(), sigfigs3(total_clips()));
+ sox_sigfigs3p(percentage), str_time(read_time), str_time(left_time),
+ str_time(in_time), sox_sigfigs3(output_samples),
+ vu(0), vu(1), headroom(), sox_sigfigs3(total_clips()));
}
if (all_done)
fputc('\n', stderr);
@@ -1722,7 +1722,7 @@
return -1;
}
-static enum_item const combine_methods[] = {
+static sox_enum_item const combine_methods[] = {
ENUM_ITEM(sox_,sequence)
ENUM_ITEM(sox_,concatenate)
ENUM_ITEM(sox_,mix)
@@ -1732,13 +1732,13 @@
{0, 0}};
enum {ENDIAN_little, ENDIAN_big, ENDIAN_swap};
-static enum_item const endian_options[] = {
+static sox_enum_item const endian_options[] = {
ENUM_ITEM(ENDIAN_,little)
ENUM_ITEM(ENDIAN_,big)
ENUM_ITEM(ENDIAN_,swap)
{0, 0}};
-static enum_item const plot_methods[] = {
+static sox_enum_item const plot_methods[] = {
ENUM_ITEM(sox_plot_,off)
ENUM_ITEM(sox_plot_,octave)
ENUM_ITEM(sox_plot_,gnuplot)
@@ -1749,7 +1749,7 @@
encoding_ms_adpcm, encoding_ima_adpcm, encoding_oki_adpcm,
encoding_gsm_full_rate, encoding_u_law, encoding_a_law};
-static enum_item const encodings[] = {
+static sox_enum_item const encodings[] = {
{"signed-integer", encoding_signed_integer},
{"unsigned-integer", encoding_unsigned_integer},
{"floating-point", encoding_floating_point},
@@ -1762,9 +1762,9 @@
{"a-law", encoding_a_law},
{0, 0}};
-static int enum_option(int option_index, enum_item const * items)
+static int enum_option(int option_index, sox_enum_item const * items)
{
- enum_item const * p = find_enum_text(optarg, items);
+ sox_enum_item const * p = sox_find_enum_text(optarg, items);
if (p == NULL) {
size_t len = 1;
char * set = lsx_malloc(len);
--- a/src/sox.h
+++ b/src/sox.h
@@ -32,7 +32,7 @@
* Please do not count on these numbers being in sync.
*/
#define SOX_LIB_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#define SOX_LIB_VERSION_CODE SOX_LIB_VERSION(14, 1, 0)
+#define SOX_LIB_VERSION_CODE SOX_LIB_VERSION(14, 1, 1)
const char *sox_version(void); /* Returns version number */
@@ -547,5 +547,13 @@
} sox_format_tab_t;
extern sox_format_tab_t sox_format_fns[];
+
+typedef struct {char const *text; unsigned value;} sox_enum_item;
+#define ENUM_ITEM(prefix, item) {#item, prefix##item},
+
+sox_enum_item const * sox_find_enum_text(char const * text, sox_enum_item const * sox_enum_items);
+sox_enum_item const * sox_find_enum_value(unsigned value, sox_enum_item const * sox_enum_items);
+char const * sox_sigfigs3(size_t number);
+char const * sox_sigfigs3p(double percentage);
#endif
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -20,7 +20,7 @@
#include <errno.h>
typedef enum {SOX_SHORT, SOX_INT, SOX_FLOAT, SOX_DOUBLE} sox_data_t;
typedef enum {SOX_WAVE_SINE, SOX_WAVE_TRIANGLE} lsx_wave_t;
-extern enum_item const lsx_wave_enum[];
+extern sox_enum_item const lsx_wave_enum[];
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> /* For off_t not found in stdio.h */
@@ -228,9 +228,9 @@
}
#define TEXTUAL_PARAMETER(name, enum_table) { \
- enum_item const * e; \
+ sox_enum_item const * e; \
if (argc == 0) break; \
- e = find_enum_text(*argv, enum_table); \
+ e = sox_find_enum_text(*argv, enum_table); \
if (e != NULL) { \
p->name = e->value; \
--argc, ++argv; \
--- a/src/spectrogram.c
+++ b/src/spectrogram.c
@@ -41,7 +41,7 @@
#define MAX_COLS 999 /* Also max seconds */
typedef enum {Window_Hann, Window_Hamming, Window_Bartlett, Window_Rectangular, Window_Kaiser} win_type_t;
-static enum_item const window_options[] = {
+static sox_enum_item const window_options[] = {
ENUM_ITEM(Window_,Hann)
ENUM_ITEM(Window_,Hamming)
ENUM_ITEM(Window_,Bartlett)
@@ -72,9 +72,9 @@
#define secs(cols) \
((double)(cols) * p->step_size * p->block_steps / effp->in_signal.rate)
-static int enum_option(int c, enum_item const * items)
+static int enum_option(int c, sox_enum_item const * items)
{
- enum_item const * p = find_enum_text(optarg, items);
+ sox_enum_item const * p = sox_find_enum_text(optarg, items);
if (p == NULL) {
size_t len = 1;
char * set = lsx_malloc(len);
--- a/src/synth.c
+++ b/src/synth.c
@@ -28,7 +28,7 @@
synth_brownnoise
} type_t;
-static enum_item const synth_type[] = {
+static sox_enum_item const synth_type[] = {
ENUM_ITEM(synth_, sine)
ENUM_ITEM(synth_, square)
ENUM_ITEM(synth_, sawtooth)
@@ -45,7 +45,7 @@
typedef enum {synth_create, synth_mix, synth_amod, synth_fmod} combine_t;
-static enum_item const combine_type[] = {
+static sox_enum_item const combine_type[] = {
ENUM_ITEM(synth_, create)
ENUM_ITEM(synth_, mix)
ENUM_ITEM(synth_, amod)
@@ -258,7 +258,7 @@
while (argn < argc) { /* type [combine] [f1[-f2] [p1 [p2 [p3 [p3 [p4]]]]]] */
channel_t chan;
char * end_ptr;
- enum_item const *p = find_enum_text(argv[argn], synth_type);
+ sox_enum_item const *p = sox_find_enum_text(argv[argn], synth_type);
if (p == NULL) {
sox_fail("no type given");
@@ -272,7 +272,7 @@
break;
/* maybe there is a combine-type in next arg */
- p = find_enum_text(argv[argn], combine_type);
+ p = sox_find_enum_text(argv[argn], combine_type);
if (p != NULL) {
chan->combine = p->value;
if (++argn == argc)
@@ -389,8 +389,8 @@
}
sox_debug("type=%s, combine=%s, samples_to_do=%lu, f1=%g, f2=%g, "
"offset=%g, phase=%g, p1=%g, p2=%g, p3=%g mult=%g",
- find_enum_value(chan->type, synth_type)->text,
- find_enum_value(chan->combine, combine_type)->text,
+ sox_find_enum_value(chan->type, synth_type)->text,
+ sox_find_enum_value(chan->combine, combine_type)->text,
(unsigned long)synth->samples_to_do, chan->freq, chan->freq2,
chan->offset, chan->phase, chan->p1, chan->p2, chan->p3, chan->mult);
}
--- a/src/util.c
+++ b/src/util.c
@@ -51,9 +51,9 @@
return result;
}
-enum_item const * find_enum_text(char const * text, enum_item const * enum_items)
+sox_enum_item const * sox_find_enum_text(char const * text, sox_enum_item const * enum_items)
{
- enum_item const * result = NULL; /* Assume not found */
+ sox_enum_item const * result = NULL; /* Assume not found */
while (enum_items->text) {
if (strcasecmp(text, enum_items->text) == 0)
@@ -68,7 +68,7 @@
return result;
}
-enum_item const * find_enum_value(unsigned value, enum_item const * enum_items)
+sox_enum_item const * sox_find_enum_value(unsigned value, sox_enum_item const * enum_items)
{
for (;enum_items->text; ++enum_items)
if (value == enum_items->value)
@@ -76,7 +76,7 @@
return NULL;
}
-char const * sigfigs3(size_t number)
+char const * sox_sigfigs3(size_t number)
{
static char string[16][10];
static unsigned n;
@@ -92,7 +92,7 @@
return string[n];
}
-char const * sigfigs3p(double percentage)
+char const * sox_sigfigs3p(double percentage)
{
static char string[16][10];
static unsigned n;
--- a/src/util.h
+++ b/src/util.h
@@ -100,11 +100,3 @@
#endif
char const * find_file_extension(char const * pathname);
-
-typedef struct {char const *text; unsigned value;} enum_item;
-#define ENUM_ITEM(prefix, item) {#item, prefix##item},
-
-enum_item const * find_enum_text(char const * text, enum_item const * enum_items);
-enum_item const * find_enum_value(unsigned value, enum_item const * enum_items);
-char const * sigfigs3(size_t number);
-char const * sigfigs3p(double percentage);
--- a/src/vol.c
+++ b/src/vol.c
@@ -26,7 +26,7 @@
enum {vol_amplitude, vol_dB, vol_power};
-static enum_item const vol_types[] = {
+static sox_enum_item const vol_types[] = {
ENUM_ITEM(vol_,amplitude)
ENUM_ITEM(vol_,dB)
ENUM_ITEM(vol_,power)
@@ -59,7 +59,7 @@
}
if (have_type) {
- enum_item const * p = find_enum_text(type_ptr, vol_types);
+ sox_enum_item const * p = sox_find_enum_text(type_ptr, vol_types);
if (!p)
return lsx_usage(effp);
switch (p->value) {