shithub: sox

Download patch

ref: f261dd3a92387f085c0651d60084a2ea81d80cba
parent: f07dfa6b839c70648a0c9eedd2429199d08e27a7
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Aug 16 23:28:29 EDT 2023

build libsox on Plan 9

--- a/src/bend.c
+++ b/src/bend.c
@@ -113,7 +113,7 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int argc, char **argv)
+static int soxcreate(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t *p = (priv_t *) effp->priv;
   char const * opts = "f:o:";
@@ -319,7 +319,7 @@
 {
   static sox_effect_handler_t handler = {
     "bend", "[-f frame-rate(25)] [-o over-sample(16)] {start,cents,end}",
-    0, create, start, flow, 0, stop, lsx_kill, sizeof(priv_t)
+    0, soxcreate, start, flow, 0, stop, lsx_kill, sizeof(priv_t)
   };
   return &handler;
 }
--- a/src/biquad.c
+++ b/src/biquad.c
@@ -156,7 +156,7 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t             * p = (priv_t *)effp->priv;
   double             * d = &p->b0;
@@ -172,7 +172,7 @@
 {
   static sox_effect_handler_t handler = {
     "biquad", "b0 b1 b2 a0 a1 a2", 0,
-    create, lsx_biquad_start, lsx_biquad_flow, NULL, NULL, NULL, sizeof(priv_t)
+    soxcreate, lsx_biquad_start, lsx_biquad_flow, NULL, NULL, NULL, sizeof(priv_t)
   };
   return &handler;
 }
--- a/src/contrast.c
+++ b/src/contrast.c
@@ -19,7 +19,7 @@
 
 typedef struct {double contrast;} priv_t;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   p->contrast = 75;
@@ -44,6 +44,6 @@
 sox_effect_handler_t const * lsx_contrast_effect_fn(void)
 {
   static sox_effect_handler_t handler = {"contrast", "[enhancement (75)]",
-    0, create, NULL, flow, NULL, NULL, NULL, sizeof(priv_t)};
+    0, soxcreate, NULL, flow, NULL, NULL, NULL, sizeof(priv_t)};
   return &handler;
 }
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -608,7 +608,13 @@
         lsx_debug("  filename  \"%.14s\"", hdr.Filename);
         lsx_debug("  id        0x%x", hdr.Id);
         lsx_debug("  state     0x%x", hdr.State);
-        lsx_debug("  time      %s", ctime(&hdr.Unixtime)); /* ctime generates lf */
+        lsx_debug("  time      %s",
+#ifdef __plan9__
+            ctime(hdr.Unixtime)
+#else
+            ctime(&hdr.Unixtime)
+#endif
+        ); /* ctime generates lf */
         lsx_debug("  usender   %u", hdr.Usender);
         lsx_debug("  ureceiver %u", hdr.Ureceiver);
         lsx_debug("  length    %" PRIuPTR, hdr.Length);
--- a/src/delay.c
+++ b/src/delay.c
@@ -40,7 +40,7 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   unsigned i;
@@ -157,7 +157,7 @@
 {
   static sox_effect_handler_t handler = {
     "delay", "{position}", SOX_EFF_LENGTH | SOX_EFF_MODIFY,
-    create, start, flow, drain, stop, lsx_kill, sizeof(priv_t)
+    soxcreate, start, flow, drain, stop, lsx_kill, sizeof(priv_t)
   };
   return &handler;
 }
--- a/src/downsample.c
+++ b/src/downsample.c
@@ -27,7 +27,7 @@
                          carried over from last block */
 } priv_t;
 
-static int create(sox_effect_t *effp, int argc, char **argv)
+static int soxcreate(sox_effect_t *effp, int argc, char **argv)
 {
   priv_t *p = (priv_t*)effp->priv;
   p->factor = 2;
@@ -80,6 +80,6 @@
 {
   static sox_effect_handler_t handler = {"downsample", "[factor (2)]",
     SOX_EFF_RATE | SOX_EFF_MODIFY,
-    create, start, flow, NULL, NULL, NULL, sizeof(priv_t)};
+    soxcreate, start, flow, NULL, NULL, NULL, sizeof(priv_t)};
   return &handler;
 }
--- a/src/fir.c
+++ b/src/fir.c
@@ -25,7 +25,7 @@
   int                n;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t             * p = (priv_t *)effp->priv;
   dft_filter_priv_t  * b = &p->base;
@@ -98,7 +98,7 @@
   handler = *lsx_dft_filter_effect_fn();
   handler.name = "fir";
   handler.usage = "[coef-file|coefs]";
-  handler.getopts = create;
+  handler.getopts = soxcreate;
   handler.start = start;
   handler.priv_size = sizeof(priv_t);
   return &handler;
--- a/src/firfit.c
+++ b/src/firfit.c
@@ -30,7 +30,7 @@
   int        num_knots, n;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char **argv)
+static int soxcreate(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   dft_filter_priv_t * b = &p->base;
@@ -138,7 +138,7 @@
   handler.name = "firfit";
   handler.usage = "[knots-file]";
   handler.flags |= SOX_EFF_ALPHA;
-  handler.getopts = create;
+  handler.getopts = soxcreate;
   handler.start = start;
   handler.priv_size = sizeof(priv_t);
   return &handler;
--- a/src/formats.c
+++ b/src/formats.c
@@ -473,6 +473,8 @@
 #elif defined _MSC_VER || defined _WIN32 || defined _WIN64 || \
       defined _ISO_STDIO_ISO_H || defined __sgi
   fp->_ptr = fp->_base;
+#elif defined NO_REWIND_PIPE
+  (void)fp;
 #else
   /* To fix this #error, either simply remove the #error line and live without
    * file-type detection with pipes, or add support for your compiler in the
--- a/src/gain.c
+++ b/src/gain.c
@@ -31,7 +31,7 @@
   FILE          * tmp_file;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   char const * q;
@@ -231,7 +231,7 @@
 {
   static sox_effect_handler_t handler = {
     "gain", NULL, SOX_EFF_GAIN,
-    create, start, flow, drain, stop, NULL, sizeof(priv_t)};
+    soxcreate, start, flow, drain, stop, NULL, sizeof(priv_t)};
   static char const * lines[] = {
     "[-e|-b|-B|-r] [-n] [-l|-h] [gain-dB]",
     "-e\t Equalise channels: peak to that with max peak;",
--- a/src/loudness.c
+++ b/src/loudness.c
@@ -25,7 +25,7 @@
   int        n;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char **argv)
+static int soxcreate(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   dft_filter_priv_t * b = &p->base;
@@ -122,7 +122,7 @@
   handler = *lsx_dft_filter_effect_fn();
   handler.name = "loudness";
   handler.usage = "[gain [ref]]";
-  handler.getopts = create;
+  handler.getopts = soxcreate;
   handler.start = start;
   handler.priv_size = sizeof(priv_t);
   return &handler;
--- /dev/null
+++ b/src/mkfile
@@ -1,0 +1,34 @@
+</$objtype/mkfile
+
+LIB=libsox.a$O
+CFLAGS=$CFLAGS -p -I/sys/include/npe -D__plan9__ -D__${objtype}__
+
+HFILES=\
+	adpcms.h aiff.h cvsd.h cvsdfilt.h g711.h g72x.h vox.h raw.h formats.h \
+	sox_i.h xmalloc.h util.h soxomp.h band.h biquad.h compandt.h \
+	dft_filter.h dither.h effects.h fft4g.h fifo.h mcompand_xover.h \
+	noisered.h rate_filters.h rate_half_fir.h rate_poly_fir0.h rate_poly_fir.h \
+
+OFILES=\
+	adpcms.$O aiff.$O cvsd.$O \
+	g711.$O g721.$O g723_24.$O g723_40.$O g72x.$O vox.$O \
+	raw.$O formats.$O formats_i.$O skelform.$O xmalloc.$O getopt.$O \
+	util.$O libsox.$O libsox_i.$O sox-fmt.$O  \
+	bend.$O biquad.$O biquads.$O chorus.$O compand.$O \
+	compandt.$O contrast.$O dcshift.$O delay.$O dft_filter.$O \
+	dither.$O divide.$O downsample.$O earwax.$O \
+	echo.$O echos.$O effects.$O effects_i.$O effects_i_dsp.$O \
+	fade.$O fft4g.$O fir.$O firfit.$O flanger.$O gain.$O \
+	hilbert.$O input.$O loudness.$O mcompand.$O \
+	noiseprof.$O noisered.$O output.$O overdrive.$O pad.$O phaser.$O rate.$O \
+	remix.$O repeat.$O reverb.$O reverse.$O silence.$O sinc.$O skeleff.$O \
+	speed.$O splice.$O stat.$O stats.$O stretch.$O swap.$O \
+	synth.$O tempo.$O tremolo.$O trim.$O upsample.$O vad.$O vol.$O \
+
+UPDATE=\
+	mkfile\
+	$HFILES\
+	${OFILES:%.$O=%.c}\
+	${LIB:/$objtype/%=/386/%}\
+
+</sys/src/cmd/mklib
--- a/src/overdrive.c
+++ b/src/overdrive.c
@@ -21,7 +21,7 @@
   double gain, colour, last_in, last_out, b0, b1, a1;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   --argc, ++argv;
@@ -66,6 +66,6 @@
 sox_effect_handler_t const * lsx_overdrive_effect_fn(void)
 {
   static sox_effect_handler_t handler = {"overdrive", "[gain [colour]]",
-    SOX_EFF_GAIN, create, start, flow, NULL, NULL, NULL, sizeof(priv_t)};
+    SOX_EFF_GAIN, soxcreate, start, flow, NULL, NULL, NULL, sizeof(priv_t)};
   return &handler;
 }
--- a/src/pad.c
+++ b/src/pad.c
@@ -70,7 +70,7 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   --argc, ++argv;
@@ -174,7 +174,7 @@
 {
   static sox_effect_handler_t handler = {
     "pad", "{length[@position]}", SOX_EFF_MCHAN|SOX_EFF_LENGTH|SOX_EFF_MODIFY,
-    create, start, flow, drain, stop, lsx_kill, sizeof(priv_t)
+    soxcreate, start, flow, drain, stop, lsx_kill, sizeof(priv_t)
   };
   return &handler;
 }
--- a/src/rate.c
+++ b/src/rate.c
@@ -528,7 +528,7 @@
   rate_shared_t   shared, * shared_ptr;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char **argv)
+static int soxcreate(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t * p = (priv_t *) effp->priv;
   int c, quality;
@@ -687,7 +687,7 @@
 sox_effect_handler_t const * lsx_rate_effect_fn(void)
 {
   static sox_effect_handler_t handler = {
-    "rate", 0, SOX_EFF_RATE, create, start, flow, drain, stop, 0, sizeof(priv_t)
+    "rate", 0, SOX_EFF_RATE, soxcreate, start, flow, drain, stop, 0, sizeof(priv_t)
   };
   static char const * lines[] = {
     "[-q|-l|-m|-h|-v] [override-options] RATE[k]",
--- a/src/remix.c
+++ b/src/remix.c
@@ -110,7 +110,7 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   --argc, ++argv;
@@ -193,7 +193,7 @@
   static sox_effect_handler_t handler = {
     "remix", "[-m|-a] [-p] <0|in-chan[v|p|i volume]{,in-chan[v|p|i volume]}>",
     SOX_EFF_MCHAN | SOX_EFF_CHAN | SOX_EFF_GAIN | SOX_EFF_PREC,
-    create, start, flow, NULL, NULL, closedown, sizeof(priv_t)
+    soxcreate, start, flow, NULL, NULL, closedown, sizeof(priv_t)
   };
   return &handler;
 }
@@ -270,7 +270,7 @@
 {
   char *args[] = {0, "1,2i", "1,2i"};
   args[0] = argv[0];
-  return --argc? lsx_usage(effp) : create(effp, 3, args);
+  return --argc? lsx_usage(effp) : soxcreate(effp, 3, args);
 }
 
 sox_effect_handler_t const * lsx_oops_effect_fn(void)
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -24,7 +24,7 @@
   FILE          * tmp_file;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   p->num_repeats = 1;
@@ -109,6 +109,6 @@
 {
   static sox_effect_handler_t effect = {"repeat", "[count (1)]",
     SOX_EFF_MCHAN | SOX_EFF_LENGTH | SOX_EFF_MODIFY,
-    create, start, flow, drain, stop, NULL, sizeof(priv_t)};
+    soxcreate, start, flow, drain, stop, NULL, sizeof(priv_t)};
   return &effect;
 }
--- a/src/sinc.c
+++ b/src/sinc.c
@@ -26,7 +26,7 @@
   sox_bool           round;
 } priv_t;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   dft_filter_priv_t * b = &p->base;
@@ -150,7 +150,7 @@
   handler = *lsx_dft_filter_effect_fn();
   handler.name = "sinc";
   handler.usage = "[-a att|-b beta] [-p phase|-M|-I|-L] [-t tbw|-n taps] [freqHP][-freqLP [-t tbw|-n taps]]";
-  handler.getopts = create;
+  handler.getopts = soxcreate;
   handler.start = start;
   handler.priv_size = sizeof(priv_t);
   return &handler;
--- a/src/skelform.c
+++ b/src/skelform.c
@@ -183,7 +183,7 @@
   return SOX_SUCCESS;
 }
 
-static int seek(sox_format_t UNUSED * ft, uint64_t UNUSED offset)
+static int soxseek(sox_format_t UNUSED * ft, uint64_t UNUSED offset)
 {
   /* Seek relative to current position. */
   return SOX_SUCCESS;
@@ -211,7 +211,7 @@
     names, 0,
     startread, read_samples, stopread,
     startwrite, write_samples, stopwrite,
-    seek, encodings, NULL, sizeof(priv_t)
+    soxseek, encodings, NULL, sizeof(priv_t)
   };
 
   return &handler;
--- a/src/splice.c
+++ b/src/splice.c
@@ -164,7 +164,7 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   --argc, ++argv;
@@ -296,7 +296,7 @@
     "\n  excess    At the end of part 1 & the start of part2 (default 0.005)"
     "\n  leeway    Before part2 (default 0.005; set to 0 for cross-fade)",
     SOX_EFF_MCHAN | SOX_EFF_LENGTH,
-    create, start, flow, drain, stop, lsx_kill, sizeof(priv_t)
+    soxcreate, start, flow, drain, stop, lsx_kill, sizeof(priv_t)
   };
   return &handler;
 }
--- a/src/upsample.c
+++ b/src/upsample.c
@@ -22,7 +22,7 @@
 
 typedef struct {unsigned factor, pos;} priv_t;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   p->factor = 2;
@@ -59,6 +59,6 @@
 sox_effect_handler_t const * lsx_upsample_effect_fn(void)
 {
   static sox_effect_handler_t handler = {"upsample", "[factor (2)]",
-    SOX_EFF_RATE | SOX_EFF_MODIFY, create, start, flow, NULL, NULL, NULL, sizeof(priv_t)};
+    SOX_EFF_RATE | SOX_EFF_MODIFY, soxcreate, start, flow, NULL, NULL, NULL, sizeof(priv_t)};
   return &handler;
 }
--- a/src/vad.c
+++ b/src/vad.c
@@ -45,7 +45,7 @@
       if (p->name < min || *parseIndex) return lsx_usage(effp); \
       break;
 
-static int create(sox_effect_t * effp, int argc, char * * argv)
+static int soxcreate(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
   #define opt_str "+b:N:n:r:f:m:M:h:l:H:L:T:t:s:g:p:"
@@ -301,7 +301,7 @@
 {
   static sox_effect_handler_t handler = {"vad", NULL,
     SOX_EFF_MCHAN | SOX_EFF_LENGTH | SOX_EFF_MODIFY,
-    create, start, flowTrigger, drain, stop, NULL, sizeof(priv_t)
+    soxcreate, start, flowTrigger, drain, stop, NULL, sizeof(priv_t)
   };
   static char const * lines[] = {
     "[options]",