shithub: sox

Download patch

ref: dcb06f2c5b8279ece7f3dda0cce4aed3286cd79f
parent: 94c7cb322517928839dde6a263783b773e2629c3
author: robs <robs>
date: Sun Feb 25 12:08:07 EST 2007

Some warnings clean-ups

--- a/amr-wb/basic_op.h
+++ b/amr-wb/basic_op.h
@@ -1,3 +1,4 @@
+#define round AMR_WB_round
 /*___________________________________________________________________________
  |                                                                           |
  |   Constants and Globals                                                   |
--- a/src/FFT.c
+++ b/src/FFT.c
@@ -55,10 +55,10 @@
 
 #include "FFT.h"
 
-int **gFFTBitTable = NULL;
-const int MaxFastBits = 16;
+unsigned **gFFTBitTable = NULL;
+const unsigned MaxFastBits = 16;
 
-static int IsPowerOfTwo(int x)
+static int IsPowerOfTwo(unsigned x)
 {
    if (x < 2)
       return 0;
@@ -66,12 +66,12 @@
    return !(x & (x-1));         /* Thanks to 'byang' for this cute trick! */
 }
 
-static int NumberOfBitsNeeded(int PowerOfTwo)
+static int NumberOfBitsNeeded(unsigned PowerOfTwo)
 {
    int i;
 
    if (PowerOfTwo < 2) {
-      sox_debug("Error: FFT called with size %d", PowerOfTwo);
+      sox_fail("Error: FFT called with size %d", PowerOfTwo);
       exit(2);
    }
 
@@ -80,9 +80,9 @@
          return i;
 }
 
-static int ReverseBits(int index, int NumBits)
+static unsigned ReverseBits(unsigned index, unsigned NumBits)
 {
-   int i, rev;
+   unsigned i, rev;
 
    for (i = rev = 0; i < NumBits; i++) {
       rev = (rev << 1) | (index & 1);
@@ -96,14 +96,14 @@
 /* This function permanently allocates about 250Kb (actually (2**16)-2 ints). */
 static void InitFFT(void)
 {
-   int len, b;
+   unsigned len, b;
    
-   gFFTBitTable = (int**)xcalloc(MaxFastBits, sizeof(*gFFTBitTable));
+   gFFTBitTable = xcalloc(MaxFastBits, sizeof(*gFFTBitTable));
    
    for (b = 1, len = 2; b <= MaxFastBits; b++) {
-      int i;
+      unsigned i;
 
-      gFFTBitTable[b - 1] = (int*)xcalloc(len, sizeof(**gFFTBitTable));
+      gFFTBitTable[b - 1] = xcalloc(len, sizeof(**gFFTBitTable));
       for (i = 0; i < len; i++)
         gFFTBitTable[b - 1][i] = ReverseBits(i, b);
 
@@ -117,19 +117,19 @@
 /*
  * Complex Fast Fourier Transform
  */
-void FFT(int NumSamples,
+void FFT(unsigned NumSamples,
          int InverseTransform,
          const float *RealIn, float *ImagIn, float *RealOut, float *ImagOut)
 {
-   int NumBits;                 /* Number of bits needed to store indices */
-   int i, j, k, n;
-   int BlockSize, BlockEnd;
+   unsigned i, BlockSize, NumBits;                 /* Number of bits needed to store indices */
+   int j, k, n;
+   int BlockEnd;
 
    double angle_numerator = 2.0 * M_PI;
    float tr, ti;                /* temp real, temp imaginary */
 
    if (!IsPowerOfTwo(NumSamples)) {
-      sox_debug("%d is not a power of two", NumSamples);
+      sox_fail("%d is not a power of two", NumSamples);
       exit(2);
    }
 
@@ -227,10 +227,9 @@
  * i4  <->  imag[n/2-i]
  */
 
-void RealFFT(int NumSamples, const float *RealIn, float *RealOut, float *ImagOut)
+void RealFFT(unsigned NumSamples, const float *RealIn, float *RealOut, float *ImagOut)
 {
-   int Half = NumSamples / 2;
-   int i, i3;
+   unsigned i, i3, Half = NumSamples / 2;
    float theta = M_PI / Half;
    float wtemp = (float) sin(0.5 * theta);
    float wpr = -2.0 * wtemp * wtemp;
@@ -287,9 +286,9 @@
  * of its code.
  */
 
-void PowerSpectrum(int NumSamples, const float *In, float *Out)
+void PowerSpectrum(sox_size_t NumSamples, const float *In, float *Out)
 {
-  int Half, i, i3;
+  unsigned Half, i, i3;
   float theta, wtemp, wpr, wpi, wr, wi;
   float h1r, h1i, h2r, h2i, rt, it;
   float *tmpReal;
--- a/src/FFT.h
+++ b/src/FFT.h
@@ -54,7 +54,7 @@
  * input array, and that NumSamples must be a power of two.
  */
 
-void PowerSpectrum(int NumSamples, const float *In, float *Out);
+void PowerSpectrum(unsigned NumSamples, const float *In, float *Out);
 
 /*
  * Computes an FFT when the input data is real but you still
@@ -63,7 +63,7 @@
  * two.
  */
 
-void RealFFT(int NumSamples,
+void RealFFT(unsigned NumSamples,
              const float *RealIn, float *RealOut, float *ImagOut);
 
 /*
@@ -72,7 +72,7 @@
  * inverse transform as well.
  */
 
-void FFT(int NumSamples,
+void FFT(unsigned NumSamples,
          int InverseTransform,
          const float *RealIn, float *ImagIn, float *RealOut, float *ImagOut);
 
--- a/src/adpcm.c
+++ b/src/adpcm.c
@@ -103,7 +103,7 @@
 
 /* AdpcmBlockExpandI() outputs interleaved samples into one output buffer */
 const char *AdpcmBlockExpandI(
-        int chans,          /* total channels             */
+        unsigned chans,          /* total channels             */
         int nCoef,
         const short *iCoef,
         const unsigned char *ibuff,/* input buffer[blockAlign]   */
@@ -112,7 +112,7 @@
 )
 {
         const unsigned char *ip;
-        int ch;
+        unsigned ch;
         const char *errmsg = NULL;
         MsState_t state[4];                                             /* One decompressor state for each channel */
 
@@ -141,7 +141,7 @@
                 lsbshortldi(obuff[ch], ip);
 
         {
-                int ch;
+                unsigned ch;
                 unsigned char b;
                 short *op, *top, *tmp;
 
@@ -153,11 +153,11 @@
                 while (op < top) {
                         b = *ip++;
                         tmp = op;
-                        *op++ = AdpcmDecode(b >> 4, state+ch, tmp[-chans], tmp[-2*chans]);
+                        *op++ = AdpcmDecode(b >> 4, state+ch, tmp[-chans], tmp[-(2*chans)]);
                         if (++ch == chans) ch = 0;
                         /* ch = ++ch % chans; */
                         tmp = op;
-                        *op++ = AdpcmDecode(b&0x0f, state+ch, tmp[-chans], tmp[-2*chans]);
+                        *op++ = AdpcmDecode(b&0x0f, state+ch, tmp[-chans], tmp[-(2*chans)]);
                         if (++ch == chans) ch = 0;
                         /* ch = ++ch % chans; */
                 }
@@ -166,8 +166,8 @@
 }
 
 static int AdpcmMashS(
-        int ch,              /* channel number to encode, REQUIRE 0 <= ch < chans  */
-        int chans,           /* total channels */
+        unsigned ch,              /* channel number to encode, REQUIRE 0 <= ch < chans  */
+        unsigned chans,           /* total channels */
         SAMPL v[2],          /* values to use as starting 2 */
         const short iCoef[2],/* lin predictor coeffs */
         const SAMPL *ibuff,  /* ibuff[] is interleaved input samples */
@@ -249,8 +249,8 @@
 }
 
 static inline void AdpcmMashChannel(
-        int ch,             /* channel number to encode, REQUIRE 0 <= ch < chans  */
-        int chans,          /* total channels */
+        unsigned ch,             /* channel number to encode, REQUIRE 0 <= ch < chans  */
+        unsigned chans,          /* total channels */
         const SAMPL *ip,    /* ip[] is interleaved input samples */
         int n,              /* samples to encode PER channel, REQUIRE */
         int *st,            /* input/output steps, 16<=st[i] */
@@ -299,7 +299,7 @@
 }
 
 void AdpcmBlockMashI(
-        int chans,          /* total channels */
+        unsigned chans,          /* total channels */
         const SAMPL *ip,    /* ip[n*chans] is interleaved input samples */
         int n,              /* samples to encode PER channel */
         int *st,            /* input/output steps, 16<=st[i] */
@@ -307,7 +307,7 @@
         int blockAlign      /* >= 7*chans + chans*(n-2)/2.0    */
 )
 {
-        int ch;
+        unsigned ch;
         unsigned char *p;
 
         sox_debug("AdpcmMashI(chans %d, ip %p, n %d, st %p, obuff %p, bA %d)\n",
@@ -329,9 +329,9 @@
  */
 sox_size_t AdpcmSamplesIn(
         sox_size_t dataLen,
-        unsigned short chans,
-        unsigned short blockAlign,
-        unsigned short samplesPerBlock
+        sox_size_t chans,
+        sox_size_t blockAlign,
+        sox_size_t samplesPerBlock
 ){
         sox_size_t m, n;
 
@@ -352,8 +352,8 @@
 }
 
 sox_size_t AdpcmBytesPerBlock(
-        unsigned short chans,
-        unsigned short samplesPerBlock
+        sox_size_t chans,
+        sox_size_t samplesPerBlock
 )
 {
         sox_size_t n;
--- a/src/adpcm.h
+++ b/src/adpcm.h
@@ -12,7 +12,7 @@
 
 /* AdpcmBlockExpandI() outputs interleaved samples into one output buffer */
 extern const char *AdpcmBlockExpandI(
-	int chans,          /* total channels             */
+	unsigned chans,          /* total channels             */
 	int nCoef,
 	const short *iCoef,
 	const unsigned char *ibuff,/* input buffer[blockAlign]   */
@@ -21,7 +21,7 @@
 );
 
 extern void AdpcmBlockMashI(
-	int chans,          /* total channels */
+	unsigned chans,          /* total channels */
 	const SAMPL *ip,    /* ip[n*chans] is interleaved input samples */
 	int n,              /* samples to encode PER channel, REQUIRE */
 	int *st,            /* input/output steps, 16<=st[i] */
@@ -41,9 +41,9 @@
  */
 extern sox_size_t AdpcmSamplesIn(
 	sox_size_t dataLen,
-	unsigned short chans,
-	unsigned short blockAlign,
-	unsigned short samplesPerBlock
+	sox_size_t chans,
+	sox_size_t blockAlign,
+	sox_size_t samplesPerBlock
 );
 
 /*
@@ -52,6 +52,6 @@
  *   to encode number of chans with given samplesPerBlock
  */
 extern sox_size_t AdpcmBytesPerBlock(
-	unsigned short chans,
-	unsigned short samplesPerBlock
+	sox_size_t chans,
+	sox_size_t samplesPerBlock
 );
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -424,19 +424,19 @@
     return sox_alsasetup(ft, SND_PCM_STREAM_CAPTURE);
 }
 
-static void sox_ub_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips UNUSED)
+static void sox_ub_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, sox_bool swap UNUSED, sox_size_t * clips UNUSED)
 {
     while (len--)
         *buf1++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(*((unsigned char *)buf2++),);
 }
 
-static void sox_sb_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips UNUSED)
+static void sox_sb_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, sox_bool swap UNUSED, sox_size_t * clips UNUSED)
 {
     while (len--)
         *buf1++ = SOX_SIGNED_BYTE_TO_SAMPLE(*((int8_t *)buf2++),);
 }
 
-static void sox_uw_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap, sox_size_t * clips UNUSED)
+static void sox_uw_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, sox_bool swap, sox_size_t * clips UNUSED)
 {
     while (len--)
     {
@@ -449,7 +449,7 @@
     }
 }
 
-static void sox_sw_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap, sox_size_t * clips UNUSED)
+static void sox_sw_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, sox_bool swap, sox_size_t * clips UNUSED)
 {
     while (len--)
     {
@@ -467,7 +467,7 @@
     sox_size_t len;
     int err;
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
-    void (*read_buf)(sox_sample_t *, char const *, sox_size_t, char, sox_size_t *) = 0;
+    void (*read_buf)(sox_sample_t *, char const *, sox_size_t, sox_bool, sox_size_t *) = 0;
 
     switch(ft->signal.size) {
         case SOX_SIZE_BYTE:
@@ -523,7 +523,7 @@
         }
         else
         {
-            read_buf(buf+(len*sizeof(sox_sample_t)), alsa->buf, err, ft->signal.reverse_bytes, &ft->clips);
+            read_buf(buf+(len*sizeof(sox_sample_t)), alsa->buf, (unsigned)err, ft->signal.reverse_bytes, &ft->clips);
             len += err * ft->signal.channels;
         }
     }
@@ -547,19 +547,19 @@
     return sox_alsasetup(ft, SND_PCM_STREAM_PLAYBACK);
 }
 
-static void sox_ub_write_buf(char* buf1, sox_sample_t const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips)
+static void sox_ub_write_buf(char* buf1, sox_sample_t const * buf2, sox_size_t len, sox_bool swap UNUSED, sox_size_t * clips)
 {
     while (len--)
         *(uint8_t *)buf1++ = SOX_SAMPLE_TO_UNSIGNED_BYTE(*buf2++, *clips);
 }
 
-static void sox_sb_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips)
+static void sox_sb_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, sox_bool swap UNUSED, sox_size_t * clips)
 {
     while (len--)
         *(int8_t *)buf1++ = SOX_SAMPLE_TO_SIGNED_BYTE(*buf2++, *clips);
 }
 
-static void sox_uw_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, char swap, sox_size_t * clips)
+static void sox_uw_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, sox_bool swap, sox_size_t * clips)
 {
     while (len--)
     {
@@ -571,7 +571,7 @@
     }
 }
 
-static void sox_sw_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, char swap, sox_size_t * clips)
+static void sox_sw_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, sox_bool swap, sox_size_t * clips)
 {
     while (len--)
     {
@@ -587,7 +587,7 @@
 {
     sox_size_t osamp, done;
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
-    void (*write_buf)(char *, const sox_sample_t *, sox_size_t, char, sox_size_t *) = 0;
+    void (*write_buf)(char *, const sox_sample_t *, sox_size_t, sox_bool, sox_size_t *) = 0;
 
     switch(ft->signal.size) {
         case SOX_SIZE_BYTE:
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -210,12 +210,12 @@
 
                 if (chorus->modulation[i] == MOD_SINE)
                   sox_generate_wave_table(SOX_WAVE_SINE, SOX_INT, chorus->lookup_tab[i],
-                                         chorus->length[i], 0, chorus->depth_samples[i], 0);
+                                         (unsigned)chorus->length[i], 0., (double)chorus->depth_samples[i], 0.);
                 else
                   sox_generate_wave_table(SOX_WAVE_TRIANGLE, SOX_INT, chorus->lookup_tab[i], 
-                                         chorus->length[i],
-                                         chorus->samples[i] - 1 - 2 * chorus->depth_samples[i],
-                                         chorus->samples[i] - 1, 3 * M_PI_2);
+                                         (unsigned)chorus->length[i],
+                                         (double)(chorus->samples[i] - 1 - 2 * chorus->depth_samples[i]),
+                                         (double)(chorus->samples[i] - 1), 3 * M_PI_2);
                 chorus->phase[i] = 0;
                 
                 if ( chorus->samples[i] > chorus->maxsamples )
--- a/src/dither.c
+++ b/src/dither.c
@@ -32,7 +32,7 @@
     return SOX_EOF;
   }
   
-  dither->amount = sqrt(2); /* M_SQRT2 missing in some places */   /* Default to half a bit. */
+  dither->amount = sqrt(2.); /* M_SQRT2 missing in some places */   /* Default to half a bit. */
   if (n == 1) {
     double amount;
     char dummy;
--- a/src/fade.c
+++ b/src/fade.c
@@ -36,7 +36,7 @@
 } *fade_t;
 
 /* prototypes */
-static double fade_gain(sox_size_t index, sox_size_t range, char fadetype);
+static double fade_gain(sox_size_t index, sox_size_t range, int fadetype);
 
 /*
  * Process options
@@ -332,7 +332,7 @@
 /* Function returns gain value 0.0 - 1.0 according index / range ratio
 * and -1.0 if  type is invalid
 * todo: to optimize performance calculate gain every now and then and interpolate */
-static double fade_gain(sox_size_t index, sox_size_t range, char type)
+static double fade_gain(sox_size_t index, sox_size_t range, int type)
 {
     double retval = 0.0, findex = 0.0;
 
--- a/src/filter.c
+++ b/src/filter.c
@@ -186,7 +186,8 @@
                    sox_size_t *isamp, sox_size_t *osamp)
 {
         filter_t f = (filter_t) effp->priv;
-        sox_size_t i, Nx, Nproc;
+        sox_size_t Nx;
+        long i, Nproc;
 
         /* constrain amount we actually process */
         /* sox_debug("Xh %d, Xt %d, isamp %d, ",f->Xh, f->Xt, *isamp); */
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -222,8 +222,8 @@
       SOX_FLOAT,
       f->lfo,
       f->lfo_length,
-      (sox_size_t)(f->delay_min / 1000 * effp->ininfo.rate + .5),
-      f->delay_buf_length - 2,
+      (double)(sox_size_t)(f->delay_min / 1000 * effp->ininfo.rate + .5),
+      (double)(f->delay_buf_length - 2),
       3 * M_PI_2);  /* Start the sweep at minimum delay (for mono at least) */
 
   sox_debug("delay_buf_length=%u lfo_length=%u\n",
--- a/src/ima_rw.c
+++ b/src/ima_rw.c
@@ -65,12 +65,12 @@
 }
 
 static void ImaExpandS(
-        int ch,             /* channel number to decode, REQUIRE 0 <= ch < chans  */
-        int chans,          /* total channels             */
+        unsigned ch,             /* channel number to decode, REQUIRE 0 <= ch < chans  */
+        unsigned chans,          /* total channels             */
         const unsigned char *ibuff,/* input buffer[blockAlign]   */
         SAMPL *obuff,       /* obuff[n] will be output samples */
         int n,              /* samples to decode PER channel, REQUIRE n % 8 == 1  */
-        int o_inc           /* index difference between successive output samples */
+        unsigned o_inc           /* index difference between successive output samples */
 )
 {
         const unsigned char *ip;
@@ -133,13 +133,13 @@
 
 /* ImaBlockExpandI() outputs interleaved samples into one output buffer */
 void ImaBlockExpandI(
-        int chans,          /* total channels             */
+        unsigned chans,          /* total channels             */
         const unsigned char *ibuff,/* input buffer[blockAlign]   */
         SAMPL *obuff,       /* output samples, n*chans    */
         int n               /* samples to decode PER channel, REQUIRE n % 8 == 1  */
 )
 {
-        int ch;
+        unsigned ch;
         for (ch=0; ch<chans; ch++)
                 ImaExpandS(ch, chans, ibuff, obuff+ch, n, chans);
 }
@@ -146,21 +146,21 @@
 
 /* ImaBlockExpandM() outputs non-interleaved samples into chan separate output buffers */
 void ImaBlockExpandM(
-        int chans,          /* total channels             */
+        unsigned chans,          /* total channels             */
         const unsigned char *ibuff,/* input buffer[blockAlign]   */
         SAMPL **obuffs,     /* chan output sample buffers, each takes n samples */
         int n               /* samples to decode PER channel, REQUIRE n % 8 == 1  */
 )
 {
-        int ch;
+        unsigned ch;
         for (ch=0; ch<chans; ch++)
                 ImaExpandS(ch, chans, ibuff, obuffs[ch], n, 1);
 }
 
 static int ImaMashS(
-        int ch,             /* channel number to encode, REQUIRE 0 <= ch < chans  */
-        int chans,          /* total channels */
-        SAMPL v0,           /* value to use as starting prediction0 */
+        unsigned ch,             /* channel number to encode, REQUIRE 0 <= ch < chans  */
+        unsigned chans,          /* total channels */
+        int v0,           /* value to use as starting prediction0 */
         const SAMPL *ibuff, /* ibuff[] is interleaved input samples */
         int n,              /* samples to encode PER channel, REQUIRE n % 8 == 1 */
         int *st,            /* input/output state, REQUIRE 0 <= *st <= ISSTMAX */
@@ -245,8 +245,8 @@
 
 /* mash one channel... if you want to use opt>0, 9 is a reasonable value */
 inline static void ImaMashChannel(
-        int ch,             /* channel number to encode, REQUIRE 0 <= ch < chans  */
-        int chans,          /* total channels */
+        unsigned ch,             /* channel number to encode, REQUIRE 0 <= ch < chans  */
+        unsigned chans,          /* total channels */
         const SAMPL *ip,    /* ip[] is interleaved input samples */
         int n,              /* samples to encode PER channel, REQUIRE n % 8 == 1 */
         int *st,            /* input/output state, REQUIRE 0 <= *st <= ISSTMAX */
@@ -299,7 +299,7 @@
 
 /* mash one block.  if you want to use opt>0, 9 is a reasonable value */
 void ImaBlockMashI(
-        int chans,          /* total channels */
+        unsigned chans,          /* total channels */
         const SAMPL *ip,    /* ip[] is interleaved input samples */
         int n,              /* samples to encode PER channel, REQUIRE n % 8 == 1 */
         int *st,            /* input/output state, REQUIRE 0 <= *st <= ISSTMAX */
@@ -307,7 +307,7 @@
         int opt             /* non-zero allows some cpu-intensive code to improve output */
 )
 {
-        int ch;
+        unsigned ch;
         for (ch=0; ch<chans; ch++)
                 ImaMashChannel(ch, chans, ip, n, st+ch, obuff, opt);
 }
@@ -322,9 +322,9 @@
  */
 sox_size_t ImaSamplesIn(
   sox_size_t dataLen,
-  unsigned short chans,
-  unsigned short blockAlign,
-  unsigned short samplesPerBlock
+  sox_size_t chans,
+  sox_size_t blockAlign,
+  sox_size_t samplesPerBlock
 )
 {
   sox_size_t m, n;
@@ -353,8 +353,8 @@
  *   to encode number of chans with given samplesPerBlock
  */
 sox_size_t ImaBytesPerBlock(
-  unsigned short chans,
-  unsigned short samplesPerBlock
+  sox_size_t chans,
+  sox_size_t samplesPerBlock
 )
 {
   sox_size_t n;
--- a/src/ima_rw.h
+++ b/src/ima_rw.h
@@ -33,7 +33,7 @@
 
 /* ImaBlockExpandI() outputs interleaved samples into one output buffer */
 extern void ImaBlockExpandI(
-	int chans,          /* total channels             */
+	unsigned chans,          /* total channels             */
 	const unsigned char *ibuff,/* input buffer[blockAlign]   */
 	SAMPL *obuff,       /* output samples, n*chans    */
 	int n               /* samples to decode PER channel, REQUIRE n % 8 == 1  */
@@ -41,7 +41,7 @@
 
 /* ImaBlockExpandM() outputs non-interleaved samples into chan separate output buffers */
 extern void ImaBlockExpandM(
-	int chans,          /* total channels             */
+	unsigned chans,          /* total channels             */
 	const unsigned char *ibuff,/* input buffer[blockAlign]   */
 	SAMPL **obuffs,     /* chan output sample buffers, each takes n samples */
 	int n               /* samples to decode PER channel, REQUIRE n % 8 == 1  */
@@ -49,7 +49,7 @@
 
 /* mash one block.  if you want to use opt>0, 9 is a reasonable value */
 extern void ImaBlockMashI(
-	int chans,          /* total channels */
+	unsigned chans,          /* total channels */
 	const SAMPL *ip,    /* ip[] is interleaved input samples */
 	int n,              /* samples to encode PER channel, REQUIRE n % 8 == 1 */
 	int *st,            /* input/output state[chans], REQUIRE 0 <= st[ch] <= ISSTMAX */
@@ -69,9 +69,9 @@
  */
 extern sox_size_t ImaSamplesIn(
 	sox_size_t dataLen,
-	unsigned short chans,
-	unsigned short blockAlign,
-	unsigned short samplesPerBlock
+	sox_size_t chans,
+	sox_size_t blockAlign,
+	sox_size_t samplesPerBlock
 );
 
 /*
@@ -80,7 +80,7 @@
  *   to encode number of chans with given samplesPerBlock
  */
 extern sox_size_t ImaBytesPerBlock(
-	unsigned short chans,
-	unsigned short samplesPerBlock
+	sox_size_t chans,
+	sox_size_t samplesPerBlock
 );
 
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -455,10 +455,11 @@
            vol to, is a constant equal to the difference between this
            band's delay and the longest delay of all the bands. */
 
-        if (l->delay_buf_cnt >= l->delay_size)
+        if (l->delay_buf_cnt >= l->delay_size) {
           checkbuf = l->delay_buf[(l->delay_buf_ptr + c->delay_buf_size - l->delay_size)%c->delay_buf_size] * level_out_lin;
           SOX_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
           l->delay_buf[(l->delay_buf_ptr + c->delay_buf_size - l->delay_size)%c->delay_buf_size] = checkbuf;
+        }
         if (l->delay_buf_cnt >= c->delay_buf_size)
           obuf[done++] = l->delay_buf[l->delay_buf_ptr];
         else
--- a/src/misc.c
+++ b/src/misc.c
@@ -218,7 +218,7 @@
 }
 
 /* Write null-terminated string (without \0). */
-int sox_writes(ft_t ft, char *c)
+int sox_writes(ft_t ft, char const * c)
 {
         if (sox_writebuf(ft, c, 1, strlen(c)) != strlen(c))
         {
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -51,7 +51,7 @@
 
 #define ID3_TAG_FLAG_FOOTERPRESENT 0x10
 
-static int tagtype(const unsigned char *data, int length)
+static int tagtype(const unsigned char *data, size_t length)
 {
     /* TODO: It would be nice to look for Xing VBR headers
      * or TLE fields in ID3 to detect length of file
@@ -385,7 +385,7 @@
   }
 
   if (ft->signal.channels != SOX_ENCODING_UNKNOWN) {
-    if ( (lame_set_num_channels(p->gfp,ft->signal.channels)) < 0) {
+    if ( (lame_set_num_channels(p->gfp,(int)ft->signal.channels)) < 0) {
         sox_fail_errno(ft,SOX_EOF,"Unsupported number of channels");
         return(SOX_EOF);
     }
@@ -393,7 +393,7 @@
   else
     ft->signal.channels = lame_get_num_channels(p->gfp); /* LAME default */
 
-  lame_set_in_samplerate(p->gfp,ft->signal.rate);
+  lame_set_in_samplerate(p->gfp,(int)ft->signal.rate);
 
   lame_set_bWriteVbrTag(p->gfp, 0); /* disable writing VBR tag */
 
@@ -483,7 +483,7 @@
 
     if ((written = lame_encode_buffer(p->gfp,buffer_l, buffer_r,
                                       nsamples, (unsigned char *)mp3buffer,
-                                      mp3buffer_size)) > mp3buffer_size){
+                                      (int)mp3buffer_size)) > mp3buffer_size){
         sox_fail_errno(ft,SOX_EOF,"Encoding failed");
         goto end;
     }
@@ -512,11 +512,12 @@
   struct mp3priv *p = (struct mp3priv *) ft->priv;
   char mp3buffer[7200];
   int written;
+  size_t written2;
   
   if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){
     sox_fail_errno(ft,SOX_EOF,"Encoding failed");
   }
-  else if ((int)sox_writebuf(ft, mp3buffer, 1, written) < written){
+  else if (sox_writebuf(ft, mp3buffer, 1, written2 = written) < written2){
     sox_fail_errno(ft,SOX_EOF,"File write failed");
   }
 
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -60,8 +60,8 @@
 static int sox_noiseprof_start(eff_t effp)
 {
     profdata_t data = (profdata_t) effp->priv;
-    int channels = effp->ininfo.channels;
-    int i;
+    unsigned channels = effp->ininfo.channels;
+    unsigned i;
    
     if (data->output_filename != NULL) {
         if (strcmp(data->output_filename, "-") != 0)
@@ -113,11 +113,11 @@
                     sox_size_t *isamp, sox_size_t *osamp)
 {
     profdata_t data = (profdata_t) effp->priv;
-    int samp = min(*isamp, *osamp);
-    int tracks = effp->ininfo.channels;
+    sox_size_t samp = min(*isamp, *osamp);
+    sox_size_t tracks = effp->ininfo.channels;
     sox_size_t track_samples = samp / tracks;
     int ncopy = 0;
-    int i;
+    sox_size_t i;
 
     assert(effp->ininfo.channels == effp->outinfo.channels);
 
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -70,9 +70,9 @@
 static int sox_noisered_start(eff_t effp)
 {
     reddata_t data = (reddata_t) effp->priv;
-    int fchannels = 0;
-    int channels = effp->ininfo.channels;
-    int i;
+    sox_size_t fchannels = 0;
+    sox_size_t channels = effp->ininfo.channels;
+    sox_size_t i;
     FILE* ifp;
 
     data->chandata = (chandata_t*)xcalloc(channels, sizeof(*(data->chandata)));
@@ -95,9 +95,9 @@
     }
 
     while (1) {
-        int i1;
+        sox_size_t i1;
         float f1;
-        if (2 != fscanf(ifp, " Channel %d: %f", &i1, &f1))
+        if (2 != fscanf(ifp, " Channel %u: %f", &i1, &f1))
             break;
         if (i1 != fchannels) {
             sox_fail("noisered: Got channel %d, expected channel %d.",
@@ -130,7 +130,7 @@
 /* Mangle a single window. Each output sample (except the first and last
  * half-window) is the result of two distinct calls to this function, 
  * due to overlapping windows. */
-static void reduce_noise(chandata_t* chan, float* window, float level)
+static void reduce_noise(chandata_t* chan, float* window, double level)
 {
     float *inr, *ini, *outr, *outi, *power;
     float *smoothing = chan->smoothing;
@@ -205,8 +205,8 @@
 
 /* Do window management once we have a complete window, including mangling
  * the current window. */
-static int process_window(eff_t effp, reddata_t data, int chan_num, int num_chans,
-                          sox_sample_t *obuf, int len) {
+static int process_window(eff_t effp, reddata_t data, unsigned chan_num, unsigned num_chans,
+                          sox_sample_t *obuf, unsigned len) {
     int j;
     float* nextwindow;
     int use = min(len, WINDOWSIZE)-min(len,(WINDOWSIZE/2));
@@ -296,8 +296,8 @@
 static int sox_noisered_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
     reddata_t data = (reddata_t)effp->priv;
-    int i;
-    int tracks = effp->ininfo.channels;
+    unsigned i;
+    unsigned tracks = effp->ininfo.channels;
     for (i = 0; i < tracks; i ++)
         *osamp = process_window(effp, data, i, tracks, obuf, data->bufdata);
 
--- a/src/pad.c
+++ b/src/pad.c
@@ -20,15 +20,15 @@
 
 typedef struct pad
 {
-  int npads;         /* Number of pads requested */
+  unsigned npads;     /* Number of pads requested */
   struct {
-    char *str;       /* Command-line argument to parse for this pad */
+    char * str;       /* Command-line argument to parse for this pad */
     sox_size_t start; /* Start padding when in_pos equals this */
     sox_size_t pad;   /* Number of samples to pad */
   } * pads;
 
   sox_size_t in_pos;  /* Number of samples read from the input stream */
-  int pads_pos;      /* Number of pads completed so far */
+  unsigned pads_pos;  /* Number of pads completed so far */
   sox_size_t pad_pos; /* Number of samples through the current pad */
 } * pad_t;
 
@@ -39,7 +39,7 @@
 {
   pad_t p = (pad_t) effp->priv;
   char const * next;
-  int i;
+  unsigned i;
 
   for (i = 0; i < p->npads; ++i) {
     if (argv) /* 1st parse only */
@@ -72,7 +72,7 @@
 static int start(eff_t effp)
 {
   pad_t p = (pad_t) effp->priv;
-  int i;
+  unsigned i;
 
   parse(effp, 0, effp->ininfo.rate); /* Re-parse now rate is known */
   p->in_pos = p->pad_pos = p->pads_pos = 0;
@@ -124,7 +124,7 @@
 {
   pad_t p = (pad_t) effp->priv;
   if (p->pads_pos != p->npads)
-    sox_warn("Input audio too short; pads not applied: %i",p->npads-p->pads_pos);
+    sox_warn("Input audio too short; pads not applied: %u",p->npads-p->pads_pos);
   return SOX_SUCCESS;
 }
 
@@ -131,7 +131,7 @@
 static int delete(eff_t effp)
 {
   pad_t p = (pad_t) effp->priv;
-  int i;
+  unsigned i;
   for (i = 0; i < p->npads; ++i)
     free(p->pads[i].str);
   free(p->pads);
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -165,10 +165,10 @@
 
         if (phaser->modulation == MOD_SINE)
           sox_generate_wave_table(SOX_WAVE_SINE, SOX_INT, phaser->lookup_tab,
-              phaser->length, 0, phaser->maxsamples - 1, 0);
+              phaser->length, 0., (double)(phaser->maxsamples - 1), 0.);
         else
           sox_generate_wave_table(SOX_WAVE_TRIANGLE, SOX_INT, phaser->lookup_tab,
-              phaser->length, 0, 2 * (phaser->maxsamples - 1), 3 * M_PI_2);
+              phaser->length, 0., (double)(2 * (phaser->maxsamples - 1)), 3 * M_PI_2);
         phaser->counter = 0;
         phaser->phase = 0;
         phaser->fade_out = phaser->maxsamples;
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -169,8 +169,8 @@
  */
 static void interpolation(
   pitch_t pitch,
-  const sox_sample_t *ibuf, int ilen, 
-  double * out, int olen,
+  const sox_sample_t *ibuf, sox_size_t ilen, 
+  double * out, sox_size_t olen,
   double rate) /* signed */
 {
     register int i, size;
@@ -180,7 +180,7 @@
 
     if (rate>0) /* sweep forwards */
     {
-        for (index=0.0, i=0; i<olen; i++, index+=rate)
+        for (index=0.0, i=0; i<(int)olen; i++, index+=rate)
         {
             register int ifl = (int) index; /* FLOOR */
             register double frac = index - ifl;
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -127,7 +127,7 @@
   0
 };
 
-static int prime(int n, int *q0)
+static int prime(unsigned n, int *q0)
 {
   const unsigned short *p;
   int pr, *q;
@@ -189,9 +189,10 @@
   return (p-m);
 }
 
-static int optimize_factors(poly_t rate, int numer, int denom, int *l1, int *l2)
+static int optimize_factors(poly_t rate, unsigned numer, unsigned denom, int *l1, int *l2)
 {
-  int f_min,c_min,u_min,ct1,ct2;
+  unsigned f_min;
+  int c_min,u_min,ct1,ct2;
   size_t amalg;
   int k;
 
@@ -210,7 +211,8 @@
 
   for (amalg = max(9,l2[0]); amalg <= (size_t)(9+l2[ct2-1]); amalg++) {
     for (k = 0; k<100000; k++) {
-      int u,u1,u2,j,f,cost;
+      unsigned f;
+      int u,u1,u2,j,cost;
       cost = 0;
       f = denom;
       u = min(ct1,ct2) + 1;
@@ -295,7 +297,7 @@
 
 /* Calculate the sinc function properly */
 
-static Float sinc(Float value)
+static Float sinc(double value)
 {
     return(fabs(value) < 1E-50 ? 1.0 : sin(value) / value);
 }
@@ -306,7 +308,7 @@
 
    buffer must already be allocated.
 */
-static void fir_design(poly_t rate, Float *buffer, int length, Float cutoff)
+static void fir_design(poly_t rate, Float *buffer, int length, double cutoff)
 {
     int j;
     double sum;
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -100,7 +100,7 @@
         if (repeat->first_drain == 1) {
                 repeat->first_drain = 0;
 
-                fseeko(repeat->fp, 0, SEEK_END);
+                fseeko(repeat->fp, (off_t)0, SEEK_END);
                 repeat->total = ftello(repeat->fp);
 
                 if ((repeat->total % sizeof(sox_sample_t)) != 0) {
@@ -111,7 +111,7 @@
                 repeat->total /= sizeof(sox_sample_t);
                 repeat->remaining = repeat->total;
 
-                fseeko(repeat->fp, 0, SEEK_SET);
+                fseeko(repeat->fp, (off_t)0, SEEK_SET);
         }
 
         if (repeat->remaining == 0) {
@@ -120,7 +120,7 @@
                         return (SOX_EOF);
                 } else {
                         repeat->repeats--;
-                        fseeko(repeat->fp, 0, SEEK_SET);
+                        fseeko(repeat->fp, (off_t)0, SEEK_SET);
                         repeat->remaining = repeat->total;
                 }
         }
@@ -142,7 +142,7 @@
 
                 while (repeat->repeats > 0) {
                         repeat->repeats--;
-                        fseeko(repeat->fp, 0, SEEK_SET);
+                        fseeko(repeat->fp, (off_t)0, SEEK_SET);
 
                         if (repeat->total >= *osamp - done) {
                                 samp = *osamp - done;
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -25,7 +25,7 @@
 /* Private data */
 typedef struct reversestuff {
         FILE *fp;
-        sox_size_t pos;
+        off_t pos;
         int phase;
 } *reverse_t;
 
@@ -86,7 +86,7 @@
 
         if (reverse->phase == WRITING) {
                 fflush(reverse->fp);
-                fseeko(reverse->fp, 0, SEEK_END);
+                fseeko(reverse->fp, (off_t)0, SEEK_END);
                 reverse->pos = ftello(reverse->fp);
                 if (reverse->pos % sizeof(sox_sample_t) != 0)
                 {
--- a/src/silence.c
+++ b/src/silence.c
@@ -291,7 +291,7 @@
         return(SOX_SUCCESS);
 }
 
-static int aboveThreshold(eff_t effp, sox_sample_t value, double threshold, char unit)
+static int aboveThreshold(eff_t effp, sox_sample_t value, double threshold, int unit)
 {
     double ratio;
     int rc;
--- a/src/smp.c
+++ b/src/smp.c
@@ -171,7 +171,7 @@
 
 static int sox_smpseek(ft_t ft, sox_size_t offset) 
 {
-    int new_offset, channel_block, alignment;
+    sox_size_t new_offset, channel_block, alignment;
     smp_t smp = (smp_t) ft->priv;
 
     new_offset = offset * ft->signal.size;
@@ -205,7 +205,7 @@
         smp_t smp = (smp_t) ft->priv;
         int i;
         int namelen, commentlen;
-        long samplestart;
+        sox_size_t samplestart;
         struct smpheader header;
         struct smptrailer trailer;
 
--- a/src/sndfile.c
+++ b/src/sndfile.c
@@ -155,7 +155,7 @@
 
 static struct {
   const char *ext;
-  int len;
+  unsigned len;
   int format;
 } format_map[] =
 {
@@ -216,7 +216,7 @@
 }
 
 /* Make libsndfile subtype from sample encoding and size */
-static int sndfile_format(int encoding, int size)
+static int sndfile_format(sox_encoding_t encoding, int size)
 {
   if (encoding < SOX_ENCODING_SIZE_IS_WORD) {
     switch (encoding) {
--- a/src/sox.h
+++ b/src/sox.h
@@ -86,7 +86,7 @@
 #define SOX_SAMPLE_NEG SOX_INT_MIN(32)
 #define SOX_SAMPLE_TO_UNSIGNED(bits,d,clips) \
   (uint##bits##_t)( \
-    sox_macro_temp_sample=d, \
+    sox_macro_temp_sample=(d), \
     sox_macro_temp_sample>(sox_sample_t)(SOX_SAMPLE_MAX-(1U<<(31-bits)))? \
       ++(clips),SOX_UINT_MAX(bits): \
       ((uint32_t)(sox_macro_temp_sample^SOX_SAMPLE_NEG)+(1U<<(31-bits)))>>(32-bits))
@@ -104,7 +104,7 @@
 #define SOX_UNSIGNED_DWORD_TO_SAMPLE(d,clips) (sox_sample_t)((d)^SOX_SAMPLE_NEG)
 #define SOX_SIGNED_DWORD_TO_SAMPLE(d,clips) (sox_sample_t)(d)
 #define SOX_FLOAT_DWORD_TO_SAMPLE SOX_FLOAT_DDWORD_TO_SAMPLE
-#define SOX_FLOAT_DDWORD_TO_SAMPLE(d,clips) (sox_macro_temp_double=d,sox_macro_temp_double<-1?++(clips),(-SOX_SAMPLE_MAX):sox_macro_temp_double>1?++(clips),SOX_SAMPLE_MAX:(sox_sample_t)((uint32_t)((double)(sox_macro_temp_double)*SOX_SAMPLE_MAX+(SOX_SAMPLE_MAX+.5))-SOX_SAMPLE_MAX))
+#define SOX_FLOAT_DDWORD_TO_SAMPLE(d,clips) (sox_macro_temp_double=(d),sox_macro_temp_double<-1?++(clips),(-SOX_SAMPLE_MAX):sox_macro_temp_double>1?++(clips),SOX_SAMPLE_MAX:(sox_sample_t)((uint32_t)((double)(sox_macro_temp_double)*SOX_SAMPLE_MAX+(SOX_SAMPLE_MAX+.5))-SOX_SAMPLE_MAX))
 #define SOX_SAMPLE_TO_UNSIGNED_BYTE(d,clips) SOX_SAMPLE_TO_UNSIGNED(8,d,clips)
 #define SOX_SAMPLE_TO_SIGNED_BYTE(d,clips) SOX_SAMPLE_TO_SIGNED(8,d,clips)
 #define SOX_SAMPLE_TO_UNSIGNED_WORD(d,clips) SOX_SAMPLE_TO_UNSIGNED(16,d,clips)
@@ -114,7 +114,7 @@
 #define SOX_SAMPLE_TO_UNSIGNED_DWORD(d,clips) (uint32_t)((d)^SOX_SAMPLE_NEG)
 #define SOX_SAMPLE_TO_SIGNED_DWORD(d,clips) (int32_t)(d)
 #define SOX_SAMPLE_TO_FLOAT_DWORD SOX_SAMPLE_TO_FLOAT_DDWORD
-#define SOX_SAMPLE_TO_FLOAT_DDWORD(d,clips) (sox_macro_temp_sample=d,sox_macro_temp_sample==SOX_SAMPLE_MIN?++(clips),-1.0:((double)(sox_macro_temp_sample)*(1.0/SOX_SAMPLE_MAX)))
+#define SOX_SAMPLE_TO_FLOAT_DDWORD(d,clips) (sox_macro_temp_sample=(d),sox_macro_temp_sample==SOX_SAMPLE_MIN?++(clips),-1.0:((double)(sox_macro_temp_sample)*(1.0/SOX_SAMPLE_MAX)))
 
 
 
@@ -416,7 +416,7 @@
 int sox_updateeffect(eff_t, const sox_signalinfo_t *in, const sox_signalinfo_t *out, int);
 int sox_gettype(ft_t, sox_bool);
 ft_t sox_initformat(void);
-char const * sox_parsesamples(sox_rate_t rate, const char *str, sox_size_t *samples, char def);
+char const * sox_parsesamples(sox_rate_t rate, const char *str, sox_size_t *samples, int def);
 
 /* The following routines are unique to the trim effect.
  * sox_trim_get_start can be used to find what is the start
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -102,7 +102,7 @@
 int sox_padbytes(ft_t ft, sox_size_t n);
 size_t sox_writebuf(ft_t ft, void const *buf, size_t size, sox_size_t len);
 int sox_reads(ft_t ft, char *c, sox_size_t len);
-int sox_writes(ft_t ft, char *c);
+int sox_writes(ft_t ft, char const * c);
 int sox_readb(ft_t ft, uint8_t *ub);
 int sox_writeb(ft_t ft, int ub);
 int sox_readw(ft_t ft, uint16_t *uw);
--- a/src/speed.c
+++ b/src/speed.c
@@ -42,7 +42,7 @@
     if (scanned == 1 || (scanned == 2 && c == 'c')) {
       is_cents |= scanned == 2;
       if (is_cents || speed > 0) {
-        effp->globalinfo->speed *= is_cents? pow(2, speed/1200) : speed;
+        effp->globalinfo->speed *= is_cents? pow(2., speed/1200) : speed;
         return SOX_SUCCESS;
       }
     }
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -33,7 +33,7 @@
         char *buf;
         char fldname[64], fldtype[16], fldsval[128];
         int i;
-        int header_size, bytes_read;
+        sox_size_t header_size, bytes_read;
         long rate;
 
         /* Needed for rawread() */
@@ -55,8 +55,8 @@
         }
 
         /* Determine header size, and allocate a buffer large enough to hold it. */
-        sscanf(fldsval, "%d", &header_size);
-        buf = (char *)xmalloc(header_size);
+        sscanf(fldsval, "%u", &header_size);
+        buf = xmalloc(header_size);
 
         /* Skip what we have read so far */
         header_size -= 16;
--- a/src/stat.c
+++ b/src/stat.c
@@ -115,7 +115,7 @@
 /*
  * Print power spectrum to given stream
  */
-static void print_power_spectrum(unsigned samples, float rate, float *re_in, float *re_out)
+static void print_power_spectrum(unsigned samples, double rate, float *re_in, float *re_out)
 {
   float ffa = rate / samples;
   unsigned i;
@@ -148,7 +148,7 @@
 
       if (stat->fft_offset >= stat->fft_size) {
         stat->fft_offset = 0;
-        print_power_spectrum(stat->fft_size, effp->ininfo.rate, stat->re_in, stat->re_out);
+        print_power_spectrum(stat->fft_size, (double)effp->ininfo.rate, stat->re_in, stat->re_out);
       }
 
     }
@@ -215,7 +215,7 @@
     for (x = stat->fft_offset; x < stat->fft_size; x++)
       stat->re_in[x] = 0;
       
-    print_power_spectrum(stat->fft_size, effp->ininfo.rate, stat->re_in, stat->re_out);
+    print_power_spectrum(stat->fft_size, (double)effp->ininfo.rate, stat->re_in, stat->re_out);
   }
 
   *osamp = 0;
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -270,7 +270,7 @@
 static sox_size_t sox_txwwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
     sox_size_t i;
-    unsigned int w1,w2;
+    sox_sample_t w1,w2;
 
     tx16w_len += len;
     if (tx16w_len > TXMAXLEN) return 0;
--- a/src/util.c
+++ b/src/util.c
@@ -296,7 +296,7 @@
  * # of samples.
  * Returns NULL on error, pointer to next char to parse otherwise.
  */
-char const * sox_parsesamples(sox_rate_t rate, const char *str, sox_size_t *samples, char def)
+char const * sox_parsesamples(sox_rate_t rate, const char *str, sox_size_t *samples, int def)
 {
     int found_samples = 0, found_time = 0;
     int time = 0;
--- a/src/voc.c
+++ b/src/voc.c
@@ -167,7 +167,7 @@
     long           rate;        /* rate code (byte) of this chunk */
     int            silent;      /* sound or silence? */
     long           srate;       /* rate code (byte) of silence */
-    long           blockseek;   /* start of current output block */
+    sox_size_t     blockseek;   /* start of current output block */
     long           samples;     /* number of samples output */
     uint16_t       format;      /* VOC audio format */
     int            size;        /* word length of data */
@@ -788,9 +788,9 @@
             sox_writeb(ft, 0);           /* block length (for now) */
             sox_writeb(ft, 0);           /* block length (for now) */
             v->rate = ft->signal.rate;
-            sox_writedw(ft, v->rate);    /* Rate code */
+            sox_writedw(ft, (unsigned)v->rate);    /* Rate code */
             sox_writeb(ft, 16);          /* Sample Size */
-            sox_writeb(ft, ft->signal.channels);   /* Sample Size */
+            sox_writeb(ft, (signed)ft->signal.channels);   /* Sample Size */
             sox_writew(ft, 0x0004);      /* Encoding */
             sox_writeb(ft, 0);           /* Unused */
             sox_writeb(ft, 0);           /* Unused */
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -56,9 +56,9 @@
 /* Decoding data */
         OggVorbis_File *vf;
         char *buf;
-        int buf_len;
-        int start;
-        int end;  /* Unsent data samples in buf[start] through buf[end-1] */
+        sox_size_t buf_len;
+        sox_size_t start;
+        sox_size_t end;  /* Unsent data samples in buf[start] through buf[end-1] */
         int current_section;
         int eof;
 
@@ -73,7 +73,7 @@
 }
 
 static int _fseeko64_wrap(FILE *f, ogg_int64_t off, int whence) {
-  int ret = fseeko(f, (long)off, whence);
+  int ret = fseeko(f, off, whence);
   if (ret == EBADF)
     ret = -1;
   return ret;
@@ -94,7 +94,7 @@
         vorbis_t vb = (vorbis_t) ft->priv;
         vorbis_info *vi;
         vorbis_comment *vc;
-        int comment_size;
+        sox_size_t comment_size;
         int i, offset;
 
         ov_callbacks callbacks = {
@@ -148,7 +148,7 @@
                 for (i = 0; i < vc->comments; i++)
                 {
                         strncpy(ft->comment + offset, vc->user_comments[i],
-                                vc->comment_lengths[i]);
+                                (size_t)vc->comment_lengths[i]);
                         offset += vc->comment_lengths[i];
                         ft->comment[offset] = '\n';
                         offset++;
@@ -161,7 +161,7 @@
 
         /* Setup buffer */
         vb->buf_len = DEF_BUF_LEN;
-        vb->buf = (char *)xcalloc(vb->buf_len, sizeof(char));
+        vb->buf = xcalloc(vb->buf_len, sizeof(char));
         vb->start = vb->end = 0;
 
         /* Fill in other info */
@@ -185,7 +185,7 @@
         while (vb->end < vb->buf_len)
         {
                 num_read = ov_read(vb->vf, vb->buf + vb->end,
-                                   vb->buf_len - vb->end, 0, 2, 1,
+                                   (int)(vb->buf_len - vb->end), 0, 2, 1,
                                    &vb->current_section);
 
                 if (num_read == 0)
@@ -260,8 +260,8 @@
 static int oe_write_page(ogg_page *page, ft_t ft)
 {
         int written;
-        written = sox_writebuf(ft, page->header,1,page->header_len);
-        written += sox_writebuf(ft, page->body,1,page->body_len);
+        written = sox_writebuf(ft, page->header,1,(sox_size_t)page->header_len);
+        written += sox_writebuf(ft, page->body,1,(sox_size_t)page->body_len);
 
         return written;
 }
@@ -360,7 +360,7 @@
             }
             quality = ft->signal.compression;
         }
-        vorbis_encode_init_vbr(&ve->vi, ft->signal.channels, ft->signal.rate, quality / 10);
+        vorbis_encode_init_vbr(&ve->vi, (int)ft->signal.channels, (int)ft->signal.rate, quality / 10);
 
         vorbis_analysis_init(&ve->vd, &ve->vi);
         vorbis_block_init(&ve->vd, &ve->vb);
@@ -382,7 +382,7 @@
         vorbis_t vb = (vorbis_t) ft->priv;
         vorbis_enc_t *ve = vb->vorbis_enc_data;
         sox_size_t samples = len / ft->signal.channels;
-        float **buffer = vorbis_analysis_buffer(&ve->vd, samples);
+        float **buffer = vorbis_analysis_buffer(&ve->vd, (int)samples);
         sox_size_t i, j;
         int ret;
         int eos = 0;
@@ -393,7 +393,7 @@
                         buffer[j][i] = buf[i*ft->signal.channels + j]
                                 / ((float)SOX_SAMPLE_MAX);
 
-        vorbis_analysis_wrote(&ve->vd, samples);
+        vorbis_analysis_wrote(&ve->vd, (int)samples);
 
         while(vorbis_analysis_blockout(&ve->vd,&ve->vb)==1)
         {
--- a/src/wav.c
+++ b/src/wav.c
@@ -77,7 +77,7 @@
 static unsigned short  ImaAdpcmReadBlock(ft_t ft)
 {
     wav_t       wav = (wav_t) ft->priv;
-    int bytesRead;
+    size_t bytesRead;
     int samplesThisBlock;
 
     /* Pull in the packet and check the header */
@@ -117,7 +117,7 @@
 static unsigned short  AdpcmReadBlock(ft_t ft)
 {
     wav_t       wav = (wav_t) ft->priv;
-    int bytesRead;
+    size_t bytesRead;
     int samplesThisBlock;
     const char *errmsg;
 
@@ -152,7 +152,7 @@
 static int xxxAdpcmWriteBlock(ft_t ft)
 {
     wav_t wav = (wav_t) ft->priv;
-    int chans, ct;
+    sox_size_t chans, ct;
     short *p;
 
     chans = ft->signal.channels;
@@ -1730,7 +1730,7 @@
                 new_offset += (channel_block - alignment);
             new_offset += wav->dataStart;
 
-            ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
+            ft->sox_errno = sox_seeki(ft, (sox_size_t)new_offset, SEEK_SET);
 
             if( ft->sox_errno == SOX_SUCCESS )
                 wav->numSamples = (ft->length / ft->signal.channels) -