shithub: sox

Download patch

ref: ae4e7fe7d1f259058eea7e975ba1e5ac8569cf79
parent: aa6749ab96253c0ce21a529fd6d3eb1810b20f48
author: rrt <rrt>
date: Sat Apr 14 12:19:08 EDT 2007

Rename macros to cast to and from samples: BYTE -> 8BIT, WORD -> 16BIT &c.

--- a/src/8svx.c
+++ b/src/8svx.c
@@ -207,7 +207,7 @@
                         if (feof(p->ch[i]))
                                 return done;
                         /* scale signed up to long's range */
-                        *buf++ = SOX_SIGNED_BYTE_TO_SAMPLE(datum,);
+                        *buf++ = SOX_SIGNED_8BIT_TO_SAMPLE(datum,);
                 }
                 done += ft->signal.channels;
         }
@@ -272,7 +272,7 @@
 
         while(done < len) {
                 for (i = 0; i < ft->signal.channels; i++) {
-                        datum = SOX_SAMPLE_TO_SIGNED_BYTE(*buf++, ft->clips);
+                        datum = SOX_SAMPLE_TO_SIGNED_8BIT(*buf++, ft->clips);
                         /* FIXME: Needs to pass ft struct and not FILE */
                         putc(datum, p->ch[i]);
                 }
--- a/src/adpcms.c
+++ b/src/adpcms.c
@@ -162,10 +162,10 @@
 
   for (n = 0; n < (len&~1u) && sox_readb(ft, &byte) == SOX_SUCCESS; n += 2) {
     short word = adpcm_decode(byte >> 4, &state->encoder);
-    *buffer++ = SOX_SIGNED_WORD_TO_SAMPLE(word, ft->clips);
+    *buffer++ = SOX_SIGNED_16BIT_TO_SAMPLE(word, ft->clips);
 
     word = adpcm_decode(byte, &state->encoder);
-    *buffer++ = SOX_SIGNED_WORD_TO_SAMPLE(word, ft->clips);
+    *buffer++ = SOX_SIGNED_16BIT_TO_SAMPLE(word, ft->clips);
   }
   return n;
 }
@@ -210,7 +210,7 @@
   short word;
 
   while (count < length) {
-    word = SOX_SAMPLE_TO_SIGNED_WORD(*buffer++, ft->clips);
+    word = SOX_SAMPLE_TO_SIGNED_16BIT(*buffer++, ft->clips);
 
     byte <<= 4;
     byte |= adpcm_encode(word, &state->encoder) & 0x0F;
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -427,13 +427,13 @@
 static void ub_read_buf(sox_ssample_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++),);
+        *buf1++ = SOX_UNSIGNED_8BIT_TO_SAMPLE(*((unsigned char *)buf2++),);
 }
 
 static void sb_read_buf(sox_ssample_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++),);
+        *buf1++ = SOX_SIGNED_8BIT_TO_SAMPLE(*((int8_t *)buf2++),);
 }
 
 static void uw_read_buf(sox_ssample_t *buf1, char const * buf2, sox_size_t len, sox_bool swap, sox_size_t * clips UNUSED)
@@ -445,7 +445,7 @@
         if (swap)
             datum = sox_swapw(datum);
 
-        *buf1++ = SOX_UNSIGNED_WORD_TO_SAMPLE(datum,);
+        *buf1++ = SOX_UNSIGNED_16BIT_TO_SAMPLE(datum,);
     }
 }
 
@@ -458,7 +458,7 @@
         if (swap)
             datum = sox_swapw(datum);
 
-        *buf1++ = SOX_SIGNED_WORD_TO_SAMPLE(datum,);
+        *buf1++ = SOX_SIGNED_16BIT_TO_SAMPLE(datum,);
     }
 }
 
@@ -550,13 +550,13 @@
 static void sox_ub_write_buf(char* buf1, sox_ssample_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);
+        *(uint8_t *)buf1++ = SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf2++, *clips);
 }
 
 static void sox_sb_write_buf(char *buf1, sox_ssample_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);
+        *(int8_t *)buf1++ = SOX_SAMPLE_TO_SIGNED_8BIT(*buf2++, *clips);
 }
 
 static void sox_uw_write_buf(char *buf1, sox_ssample_t const * buf2, sox_size_t len, sox_bool swap, sox_size_t * clips)
@@ -563,7 +563,7 @@
 {
     while (len--)
     {
-        uint16_t datum = SOX_SAMPLE_TO_UNSIGNED_WORD(*buf2++, *clips);
+        uint16_t datum = SOX_SAMPLE_TO_UNSIGNED_16BIT(*buf2++, *clips);
         if (swap)
             datum = sox_swapw(datum);
         *(uint16_t *)buf1 = datum;
@@ -575,7 +575,7 @@
 {
     while (len--)
     {
-        int16_t datum = SOX_SAMPLE_TO_SIGNED_WORD(*buf2++, *clips);
+        int16_t datum = SOX_SAMPLE_TO_SIGNED_16BIT(*buf2++, *clips);
         if (swap)
             datum = sox_swapw(datum);
         *(int16_t *)buf1 = datum;
--- a/src/amr-wb.c
+++ b/src/amr-wb.c
@@ -133,7 +133,7 @@
       this->pcm_index = decode_1_frame(ft);
     if (this->pcm_index >= L_FRAME16k)
       break;
-    *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(0xfffc & this->pcm[this->pcm_index++], ft->clips);
+    *buf++ = SOX_SIGNED_16BIT_TO_SAMPLE(0xfffc & this->pcm[this->pcm_index++], ft->clips);
   }
   return done;
 }
@@ -174,7 +174,7 @@
   sox_size_t done;
 
   for (done = 0; done < len; ++done) {
-    this->pcm[this->pcm_index++] = (Word16) (SOX_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips));
+    this->pcm[this->pcm_index++] = (Word16) (SOX_SAMPLE_TO_SIGNED_16BIT(*buf++, ft->clips));
     if (this->pcm_index == L_FRAME16k) {
       this->pcm_index = 0;
       encode_1_frame(ft);
--- a/src/ao.c
+++ b/src/ao.c
@@ -19,7 +19,7 @@
 
 #include "sox_i.h"
 
-#ifdef HAVE_AO_AO_H
+#ifdef HAVE_LIBAO
 
 #include <stdlib.h>
 #include <stdio.h>
--- a/src/au.c
+++ b/src/au.c
@@ -338,7 +338,7 @@
                 return sox_rawread(ft, buf, samp);
         done = 0;
         while (samp > 0 && unpack_input(ft, &code) >= 0) {
-                *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(
+                *buf++ = SOX_SIGNED_16BIT_TO_SAMPLE(
                         (*p->dec_routine)(code, AUDIO_ENCODING_LINEAR,
                                           &p->state),);
                 samp--;
--- a/src/dat.c
+++ b/src/dat.c
@@ -139,7 +139,7 @@
       sprintf(s," %15.8g ",dat->timevalue);
       sox_writes(ft, s);
       for (i=0; i<ft->signal.channels; i++) {
-        sampval = SOX_SAMPLE_TO_FLOAT_DDWORD(*buf++, ft->clips);
+        sampval = SOX_SAMPLE_TO_FLOAT_64BIT(*buf++, ft->clips);
         sprintf(s," %15.8g", sampval);
         sox_writes(ft, s);
         done++;
--- a/src/flac.c
+++ b/src/flac.c
@@ -209,10 +209,10 @@
       for (channel = 0; channel < decoder->channels; channel++, actual++) {
         FLAC__int32 d = decoder->decoded_wide_samples[channel][decoder->wide_sample_number];
         switch (decoder->bits_per_sample) {
-        case  8: *sampleBuffer++ = SOX_SIGNED_BYTE_TO_SAMPLE(d,); break;
-        case 16: *sampleBuffer++ = SOX_SIGNED_WORD_TO_SAMPLE(d,); break;
+        case  8: *sampleBuffer++ = SOX_SIGNED_8BIT_TO_SAMPLE(d,); break;
+        case 16: *sampleBuffer++ = SOX_SIGNED_16BIT_TO_SAMPLE(d,); break;
         case 24: *sampleBuffer++ = SOX_SIGNED_24BIT_TO_SAMPLE(d,); break;
-        case 32: *sampleBuffer++ = SOX_SIGNED_DWORD_TO_SAMPLE(d,); break;
+        case 32: *sampleBuffer++ = SOX_SIGNED_32BIT_TO_SAMPLE(d,); break;
         }
       }
       ++decoder->wide_sample_number;
@@ -454,10 +454,10 @@
 
   for (i = 0; i < len; ++i) {
     switch (encoder->bits_per_sample) {
-      case  8: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_BYTE(sampleBuffer[i], format->clips); break;
-      case 16: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_WORD(sampleBuffer[i], format->clips); break;
+      case  8: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_8BIT(sampleBuffer[i], format->clips); break;
+      case 16: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_16BIT(sampleBuffer[i], format->clips); break;
       case 24: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_24BIT(sampleBuffer[i],format->clips); break;
-      case 32: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_DWORD(sampleBuffer[i],format->clips); break;
+      case 32: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_32BIT(sampleBuffer[i],format->clips); break;
     }
   }
   FLAC__stream_encoder_process_interleaved(encoder->flac, encoder->decoded_samples, len / format->signal.channels);
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -118,7 +118,7 @@
         {
                 while (p->samplePtr < p->sampleTop && done < samp)
                         buf[done++] = 
-                            SOX_SIGNED_WORD_TO_SAMPLE(*(p->samplePtr)++,);
+                            SOX_SIGNED_16BIT_TO_SAMPLE(*(p->samplePtr)++,);
 
                 if (done>=samp) break;
 
@@ -193,7 +193,7 @@
         {
                 while ((p->samplePtr < p->sampleTop) && (done < samp))
                         *(p->samplePtr)++ = 
-                            SOX_SAMPLE_TO_SIGNED_WORD(buf[done++], ft->clips);
+                            SOX_SAMPLE_TO_SIGNED_16BIT(buf[done++], ft->clips);
 
                 if (p->samplePtr == p->sampleTop)
                 {
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -165,7 +165,7 @@
                         return (0);
                 }
                 p->sample = sample_rate;
-                *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(p->sample,);
+                *buf++ = SOX_UNSIGNED_8BIT_TO_SAMPLE(p->sample,);
                 p->huffcount--;
                 p->nrbits = 0;
                 done++;
@@ -201,7 +201,7 @@
                                 p->sample = 0;
                         p->sample = (p->sample + datum) & 0xff;
                         p->huffcount--;
-                        *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(p->sample,);
+                        *buf++ = SOX_UNSIGNED_8BIT_TO_SAMPLE(p->sample,);
                         p->dictentry = 0;
                         done++;
                         len--;
@@ -280,7 +280,7 @@
 
   for (i = 0; i < len; i++) {
     datum = *buf++;
-    p->data[p->pos++] = SOX_SAMPLE_TO_UNSIGNED_BYTE(datum, ft->clips);
+    p->data[p->pos++] = SOX_SAMPLE_TO_UNSIGNED_8BIT(datum, ft->clips);
   }
 
   return len;
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -461,8 +461,8 @@
         j=0;
         for (i=0; i<nsamples; i++)
         {
-            buffer_l[i]=SOX_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips);
-            buffer_r[i]=SOX_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips);
+            buffer_l[i]=SOX_SAMPLE_TO_SIGNED_16BIT(buf[j++], ft->clips);
+            buffer_r[i]=SOX_SAMPLE_TO_SIGNED_16BIT(buf[j++], ft->clips);
         }
     }
     else
@@ -470,7 +470,7 @@
         j=0;
         for (i=0; i<nsamples; i++)
         {
-            buffer_l[i]=SOX_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips); 
+            buffer_l[i]=SOX_SAMPLE_TO_SIGNED_16BIT(buf[j++], ft->clips); 
         }
     }
 
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -130,7 +130,7 @@
         int j;
         for (j = 0; j < ncopy; j ++) {
             chan->window[j+data->bufdata] =
-                SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[i+j*tracks], effp->clips);
+                SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[i+j*tracks], effp->clips);
         }
         if (ncopy + data->bufdata == WINDOWSIZE)
             collect_data(chan);
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -224,7 +224,7 @@
         for (j = 0; j < use; j ++) {
             float s = chan->window[j] + chan->lastwindow[WINDOWSIZE/2 + j];
             obuf[chan_num + num_chans * j] =
-                SOX_FLOAT_DWORD_TO_SAMPLE(s, effp->clips);
+                SOX_FLOAT_32BIT_TO_SAMPLE(s, effp->clips);
         }
         free(chan->lastwindow);
     } else {
@@ -231,7 +231,7 @@
         for (j = 0; j < use; j ++) {
             assert(chan->window[j] >= -1 && chan->window[j] <= 1);
             obuf[chan_num + num_chans * j] =
-                SOX_FLOAT_DWORD_TO_SAMPLE(chan->window[j], effp->clips);
+                SOX_FLOAT_32BIT_TO_SAMPLE(chan->window[j], effp->clips);
         }
     }
     chan->lastwindow = chan->window;
@@ -272,7 +272,7 @@
         
         for (j = 0; j < ncopy; j ++)
             chan->window[oldbuf + j] =
-                SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[i + tracks * j], effp->clips);
+                SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[i + tracks * j], effp->clips);
 
         if (!whole_window)
             continue;
--- a/src/rabbit.c
+++ b/src/rabbit.c
@@ -127,7 +127,7 @@
   r->data->data_in = (float *)xrealloc(r->data->data_in, newsamples * sizeof(float));
 
   for (i = 0 ; i < *isamp; i++)
-    r->data->data_in[r->samples + i] = SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[i], effp->clips);
+    r->data->data_in[r->samples + i] = SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[i], effp->clips);
 
   r->samples = newsamples;
   r->data->input_frames = r->samples / channels;
@@ -175,7 +175,7 @@
 
   outsamps = min(r->data->output_frames_gen * channels - r->outsamp, *osamp);
   for (i = 0; i < outsamps; i++)
-    obuf[i] = SOX_FLOAT_DWORD_TO_SAMPLE(r->data->data_out[r->outsamp + i], effp->clips);
+    obuf[i] = SOX_FLOAT_32BIT_TO_SAMPLE(r->data->data_out[r->outsamp + i], effp->clips);
   *osamp = (sox_size_t)outsamps;
   r->outsamp += outsamps;
 
--- a/src/raw.c
+++ b/src/raw.c
@@ -16,10 +16,10 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#define SOX_ULAW_BYTE_TO_SAMPLE(d,clips)   SOX_SIGNED_WORD_TO_SAMPLE(sox_ulaw2linear16(d),clips)
-#define SOX_ALAW_BYTE_TO_SAMPLE(d,clips)   SOX_SIGNED_WORD_TO_SAMPLE(sox_alaw2linear16(d),clips)
-#define SOX_SAMPLE_TO_ULAW_BYTE(d,c) sox_14linear2ulaw(SOX_SAMPLE_TO_SIGNED_WORD(d,c) >> 2)
-#define SOX_SAMPLE_TO_ALAW_BYTE(d,c) sox_13linear2alaw(SOX_SAMPLE_TO_SIGNED_WORD(d,c) >> 3)
+#define SOX_ULAW_BYTE_TO_SAMPLE(d,clips)   SOX_SIGNED_16BIT_TO_SAMPLE(sox_ulaw2linear16(d),clips)
+#define SOX_ALAW_BYTE_TO_SAMPLE(d,clips)   SOX_SIGNED_16BIT_TO_SAMPLE(sox_alaw2linear16(d),clips)
+#define SOX_SAMPLE_TO_ULAW_BYTE(d,c) sox_14linear2ulaw(SOX_SAMPLE_TO_SIGNED_16BIT(d,c) >> 2)
+#define SOX_SAMPLE_TO_ALAW_BYTE(d,c) sox_13linear2alaw(SOX_SAMPLE_TO_SIGNED_16BIT(d,c) >> 3)
 
 int sox_rawseek(ft_t ft, sox_size_t offset)
 {
@@ -107,18 +107,18 @@
     return nread; \
   }
 
-static READ_SAMPLES_FUNC(b, 1, u, uint8_t, uint8_t, SOX_UNSIGNED_BYTE_TO_SAMPLE)
-static READ_SAMPLES_FUNC(b, 1, s, int8_t, uint8_t, SOX_SIGNED_BYTE_TO_SAMPLE)
+static READ_SAMPLES_FUNC(b, 1, u, uint8_t, uint8_t, SOX_UNSIGNED_8BIT_TO_SAMPLE)
+static READ_SAMPLES_FUNC(b, 1, s, int8_t, uint8_t, SOX_SIGNED_8BIT_TO_SAMPLE)
 static READ_SAMPLES_FUNC(b, 1, ulaw, uint8_t, uint8_t, SOX_ULAW_BYTE_TO_SAMPLE)
 static READ_SAMPLES_FUNC(b, 1, alaw, uint8_t, uint8_t, SOX_ALAW_BYTE_TO_SAMPLE)
-static READ_SAMPLES_FUNC(w, 2, u, uint16_t, uint16_t, SOX_UNSIGNED_WORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(w, 2, s, int16_t, uint16_t, SOX_SIGNED_WORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(w, 2, u, uint16_t, uint16_t, SOX_UNSIGNED_16BIT_TO_SAMPLE)
+static READ_SAMPLES_FUNC(w, 2, s, int16_t, uint16_t, SOX_SIGNED_16BIT_TO_SAMPLE)
 static READ_SAMPLES_FUNC(3, 3, u, uint24_t, uint24_t, SOX_UNSIGNED_24BIT_TO_SAMPLE)
 static READ_SAMPLES_FUNC(3, 3, s, int24_t, uint24_t, SOX_SIGNED_24BIT_TO_SAMPLE)
-static READ_SAMPLES_FUNC(dw, 4, u, uint32_t, uint32_t, SOX_UNSIGNED_DWORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(dw, 4, s, int32_t, uint32_t, SOX_SIGNED_DWORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(f, sizeof(float), su, float, float, SOX_FLOAT_DWORD_TO_SAMPLE)
-static READ_SAMPLES_FUNC(df, sizeof(double), su, double, double, SOX_FLOAT_DDWORD_TO_SAMPLE)
+static READ_SAMPLES_FUNC(dw, 4, u, uint32_t, uint32_t, SOX_UNSIGNED_32BIT_TO_SAMPLE)
+static READ_SAMPLES_FUNC(dw, 4, s, int32_t, uint32_t, SOX_SIGNED_32BIT_TO_SAMPLE)
+static READ_SAMPLES_FUNC(f, sizeof(float), su, float, float, SOX_FLOAT_32BIT_TO_SAMPLE)
+static READ_SAMPLES_FUNC(df, sizeof(double), su, double, double, SOX_FLOAT_64BIT_TO_SAMPLE)
 
 #define WRITE_SAMPLES_FUNC(type, size, sign, ctype, uctype, cast) \
   sox_size_t sox_write_ ## sign ## type ## _samples( \
@@ -134,18 +134,18 @@
     return nwritten; \
   }
 
-static WRITE_SAMPLES_FUNC(b, 1, u, uint8_t, uint8_t, SOX_SAMPLE_TO_UNSIGNED_BYTE)
-static WRITE_SAMPLES_FUNC(b, 1, s, int8_t, uint8_t, SOX_SAMPLE_TO_SIGNED_BYTE)
+static WRITE_SAMPLES_FUNC(b, 1, u, uint8_t, uint8_t, SOX_SAMPLE_TO_UNSIGNED_8BIT)
+static WRITE_SAMPLES_FUNC(b, 1, s, int8_t, uint8_t, SOX_SAMPLE_TO_SIGNED_8BIT)
 static WRITE_SAMPLES_FUNC(b, 1, ulaw, uint8_t, uint8_t, SOX_SAMPLE_TO_ULAW_BYTE)
 static WRITE_SAMPLES_FUNC(b, 1, alaw, uint8_t, uint8_t, SOX_SAMPLE_TO_ALAW_BYTE)
-static WRITE_SAMPLES_FUNC(w, 2, u, uint16_t, uint16_t, SOX_SAMPLE_TO_UNSIGNED_WORD)
-static WRITE_SAMPLES_FUNC(w, 2, s, int16_t, uint16_t, SOX_SAMPLE_TO_SIGNED_WORD)
+static WRITE_SAMPLES_FUNC(w, 2, u, uint16_t, uint16_t, SOX_SAMPLE_TO_UNSIGNED_16BIT)
+static WRITE_SAMPLES_FUNC(w, 2, s, int16_t, uint16_t, SOX_SAMPLE_TO_SIGNED_16BIT)
 static WRITE_SAMPLES_FUNC(3, 3, u, uint24_t, uint24_t, SOX_SAMPLE_TO_UNSIGNED_24BIT)
 static WRITE_SAMPLES_FUNC(3, 3, s, int24_t, uint24_t, SOX_SAMPLE_TO_SIGNED_24BIT)
-static WRITE_SAMPLES_FUNC(dw, 4, u, uint32_t, uint32_t, SOX_SAMPLE_TO_UNSIGNED_DWORD)
-static WRITE_SAMPLES_FUNC(dw, 4, s, int32_t, uint32_t, SOX_SAMPLE_TO_SIGNED_DWORD)
-static WRITE_SAMPLES_FUNC(f, sizeof(float), su, float, float, SOX_SAMPLE_TO_FLOAT_DWORD)
-static WRITE_SAMPLES_FUNC(df, sizeof(double), su, double, double, SOX_SAMPLE_TO_FLOAT_DDWORD)
+static WRITE_SAMPLES_FUNC(dw, 4, u, uint32_t, uint32_t, SOX_SAMPLE_TO_UNSIGNED_32BIT)
+static WRITE_SAMPLES_FUNC(dw, 4, s, int32_t, uint32_t, SOX_SAMPLE_TO_SIGNED_32BIT)
+static WRITE_SAMPLES_FUNC(f, sizeof(float), su, float, float, SOX_SAMPLE_TO_FLOAT_32BIT)
+static WRITE_SAMPLES_FUNC(df, sizeof(double), su, double, double, SOX_SAMPLE_TO_FLOAT_64BIT)
 
 typedef sox_size_t (ft_io_fun)(ft_t ft, sox_ssample_t *buf, sox_size_t len);
 
--- a/src/silence.c
+++ b/src/silence.c
@@ -314,11 +314,11 @@
     switch(effp->ininfo.size)
     {
         case SOX_SIZE_BYTE:
-            value = SOX_SAMPLE_TO_SIGNED_BYTE(value, dummy_clipped_count);
+            value = SOX_SAMPLE_TO_SIGNED_8BIT(value, dummy_clipped_count);
             ratio = (double)abs(value) / (double)SOX_INT8_MAX;
             break;
         case SOX_SIZE_16BIT:
-            value = SOX_SAMPLE_TO_SIGNED_WORD(value, dummy_clipped_count);
+            value = SOX_SAMPLE_TO_SIGNED_16BIT(value, dummy_clipped_count);
             ratio = (double)abs(value) / (double)SOX_INT16_MAX;
             break;
         case SOX_SIZE_24BIT:
@@ -326,7 +326,7 @@
             ratio = (double)abs(value) / (double)SOX_INT24_MAX;
             break;
         case SOX_SIZE_32BIT:
-            value = SOX_SAMPLE_TO_SIGNED_DWORD(value,);
+            value = SOX_SAMPLE_TO_SIGNED_32BIT(value,);
             ratio = (double)labs(value) / (double)SOX_INT32_MAX;
             break;
         default:
--- a/src/skelform.c
+++ b/src/skelform.c
@@ -98,7 +98,7 @@
     case SOX_SIZE_BYTE:
       switch (ft->signal.encoding) {
       case SOX_ENCODING_UNSIGNED:
-        *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(sample,);
+        *buf++ = SOX_UNSIGNED_8BIT_TO_SAMPLE(sample,);
         break;
       default:
         sox_fail("Undetected sample encoding in read!");
@@ -168,7 +168,7 @@
     switch (ft->signal.encoding) {
     case SOX_ENCODING_UNSIGNED:
       while (len--) {
-        len = sox_writeb(ft, SOX_SAMPLE_TO_UNSIGNED_BYTE(*buf++, ft->clips));
+        len = sox_writeb(ft, SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf++, ft->clips));
         if (len == 0)
           break;
       }
--- a/src/smp.c
+++ b/src/smp.c
@@ -327,7 +327,7 @@
         for(; done < len && smp->NoOfSamps; done++, smp->NoOfSamps--) {
                 sox_readw(ft, &datum);
                 /* scale signed up to long's range */
-                *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(datum,);
+                *buf++ = SOX_SIGNED_16BIT_TO_SAMPLE(datum,);
         }
         return done;
 }
@@ -373,7 +373,7 @@
         sox_size_t done = 0;
 
         while(done < len) {
-                datum = (int) SOX_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips);
+                datum = (int) SOX_SAMPLE_TO_SIGNED_16BIT(*buf++, ft->clips);
                 sox_writew(ft, (uint16_t)datum);
                 smp->NoOfSamps++;
                 done++;
--- a/src/sox.h
+++ b/src/sox.h
@@ -95,26 +95,26 @@
 #define SOX_SIGNED_TO_SAMPLE(bits,d)((sox_ssample_t)(d)<<(32-bits))
 #define SOX_UNSIGNED_TO_SAMPLE(bits,d)(SOX_SIGNED_TO_SAMPLE(bits,d)^SOX_SAMPLE_NEG)
 
-#define SOX_UNSIGNED_BYTE_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(8,d)
-#define SOX_SIGNED_BYTE_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(8,d)
-#define SOX_UNSIGNED_WORD_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(16,d)
-#define SOX_SIGNED_WORD_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(16,d)
+#define SOX_UNSIGNED_8BIT_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(8,d)
+#define SOX_SIGNED_8BIT_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(8,d)
+#define SOX_UNSIGNED_16BIT_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(16,d)
+#define SOX_SIGNED_16BIT_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(16,d)
 #define SOX_UNSIGNED_24BIT_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(24,d)
 #define SOX_SIGNED_24BIT_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(24,d)
-#define SOX_UNSIGNED_DWORD_TO_SAMPLE(d,clips) ((sox_ssample_t)(d)^SOX_SAMPLE_NEG)
-#define SOX_SIGNED_DWORD_TO_SAMPLE(d,clips) (sox_ssample_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_ssample_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)
-#define SOX_SAMPLE_TO_SIGNED_WORD(d,clips) SOX_SAMPLE_TO_SIGNED(16,d,clips)
+#define SOX_UNSIGNED_32BIT_TO_SAMPLE(d,clips) ((sox_ssample_t)(d)^SOX_SAMPLE_NEG)
+#define SOX_SIGNED_32BIT_TO_SAMPLE(d,clips) (sox_ssample_t)(d)
+#define SOX_FLOAT_32BIT_TO_SAMPLE SOX_FLOAT_64BIT_TO_SAMPLE
+#define SOX_FLOAT_64BIT_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_ssample_t)((uint32_t)((double)(sox_macro_temp_double)*SOX_SAMPLE_MAX+(SOX_SAMPLE_MAX+.5))-SOX_SAMPLE_MAX))
+#define SOX_SAMPLE_TO_UNSIGNED_8BIT(d,clips) SOX_SAMPLE_TO_UNSIGNED(8,d,clips)
+#define SOX_SAMPLE_TO_SIGNED_8BIT(d,clips) SOX_SAMPLE_TO_SIGNED(8,d,clips)
+#define SOX_SAMPLE_TO_UNSIGNED_16BIT(d,clips) SOX_SAMPLE_TO_UNSIGNED(16,d,clips)
+#define SOX_SAMPLE_TO_SIGNED_16BIT(d,clips) SOX_SAMPLE_TO_SIGNED(16,d,clips)
 #define SOX_SAMPLE_TO_UNSIGNED_24BIT(d,clips) SOX_SAMPLE_TO_UNSIGNED(24,d,clips)
 #define SOX_SAMPLE_TO_SIGNED_24BIT(d,clips) SOX_SAMPLE_TO_SIGNED(24,d,clips)
-#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_UNSIGNED_32BIT(d,clips) (uint32_t)((d)^SOX_SAMPLE_NEG)
+#define SOX_SAMPLE_TO_SIGNED_32BIT(d,clips) (int32_t)(d)
+#define SOX_SAMPLE_TO_FLOAT_32BIT SOX_SAMPLE_TO_FLOAT_64BIT
+#define SOX_SAMPLE_TO_FLOAT_64BIT(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)))
 
 
 
--- a/src/sox_sample_test.c
+++ b/src/sox_sample_test.c
@@ -146,27 +146,27 @@
   TEST_SINT(24)
 
   d = -1.0000000001;
-  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  sample = SOX_FLOAT_64BIT_TO_SAMPLE(d, clips);
   assert(sample == -SOX_SAMPLE_MAX && --clips == 0);
 
   d = -1;
-  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  sample = SOX_FLOAT_64BIT_TO_SAMPLE(d, clips);
   assert(sample == -SOX_SAMPLE_MAX && clips == 0);
-  d = SOX_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
+  d = SOX_SAMPLE_TO_FLOAT_64BIT(sample,clips);
   assert(d == -1 && clips == 0);
 
   --sample;
-  d = SOX_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
+  d = SOX_SAMPLE_TO_FLOAT_64BIT(sample,clips);
   assert(d == -1 && --clips == 0);
 
   d = 1;
-  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  sample = SOX_FLOAT_64BIT_TO_SAMPLE(d, clips);
   assert(sample == SOX_SAMPLE_MAX && clips == 0);
-  d = SOX_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
+  d = SOX_SAMPLE_TO_FLOAT_64BIT(sample,clips);
   assert(d == 1 && clips == 0);
 
   d = 1.0000000001;
-  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  sample = SOX_FLOAT_64BIT_TO_SAMPLE(d, clips);
   assert(sample == SOX_SAMPLE_MAX && --clips == 0);
 
   {
--- a/src/stat.c
+++ b/src/stat.c
@@ -144,7 +144,7 @@
 
   if (stat->fft) {
     for (x = 0; x < len; x++) {
-      stat->re_in[stat->fft_offset++] = SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[x], effp->clips);
+      stat->re_in[stat->fft_offset++] = SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[x], effp->clips);
 
       if (stat->fft_offset >= stat->fft_size) {
         stat->fft_offset = 0;
--- a/src/voc.c
+++ b/src/voc.c
@@ -373,7 +373,7 @@
                     } else if (v->format == VOC_FMT_ALAW) {
                         *buf++ =  SOX_ALAW_BYTE_TO_SAMPLE(uc);
                     } else {
-                        *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(uc,);
+                        *buf++ = SOX_UNSIGNED_8BIT_TO_SAMPLE(uc,);
                     }
                     break;
                 case SOX_SIZE_16BIT:
@@ -384,7 +384,7 @@
                             v->rest = 0;
                             return done;
                         }
-                    *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(sw,);
+                    *buf++ = SOX_SIGNED_16BIT_TO_SAMPLE(sw,);
                     v->rest--; /* Processed 2 bytes so update */
                     break;
                 }
@@ -456,10 +456,10 @@
         v->samples += len;
         while(done < len) {
           if (ft->signal.size == SOX_SIZE_BYTE) {
-            uc = SOX_SAMPLE_TO_UNSIGNED_BYTE(*buf++, ft->clips);
+            uc = SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf++, ft->clips);
             sox_writeb(ft, uc);
           } else {
-            sw = (int) SOX_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips);
+            sw = (int) SOX_SAMPLE_TO_SIGNED_16BIT(*buf++, ft->clips);
             sox_writew(ft,sw);
           }
           done++;
--- a/src/wav.c
+++ b/src/wav.c
@@ -232,7 +232,7 @@
 
   /* copy out any samples left from the last call */
     while(wav->gsmindex && (wav->gsmindex<160*2) && (done < len))
-        buf[done++]=SOX_SIGNED_WORD_TO_SAMPLE(wav->gsmsample[wav->gsmindex++],);
+        buf[done++]=SOX_SIGNED_16BIT_TO_SAMPLE(wav->gsmsample[wav->gsmindex++],);
 
   /* read and decode loop, possibly leaving some samples in wav->gsmsample */
     while (done < len) {
@@ -258,7 +258,7 @@
         }
 
         while ((wav->gsmindex <160*2) && (done < len)){
-            buf[done++]=SOX_SIGNED_WORD_TO_SAMPLE(wav->gsmsample[(wav->gsmindex)++],);
+            buf[done++]=SOX_SIGNED_16BIT_TO_SAMPLE(wav->gsmsample[(wav->gsmindex)++],);
         }
     }
 
@@ -300,7 +300,7 @@
     while (done < len) {
         while ((wav->gsmindex < 160*2) && (done < len))
             wav->gsmsample[(wav->gsmindex)++] = 
-                SOX_SAMPLE_TO_SIGNED_WORD(buf[done++], ft->clips);
+                SOX_SAMPLE_TO_SIGNED_16BIT(buf[done++], ft->clips);
 
         if (wav->gsmindex < 160*2)
             break;
@@ -1045,7 +1045,7 @@
                     top = p+ct;
                     /* Output is already signed */
                     while (p<top)
-                        *buf++ = SOX_SIGNED_WORD_TO_SAMPLE((*p++),);
+                        *buf++ = SOX_SIGNED_16BIT_TO_SAMPLE((*p++),);
 
                     wav->samplePtr = p;
                 }
--- a/src/xa.c
+++ b/src/xa.c
@@ -242,7 +242,7 @@
                 xa->state[i].prevSample = xa->state[i].curSample;
                 xa->state[i].curSample = sample;
                 
-                buf[done++] = SOX_SIGNED_WORD_TO_SAMPLE(sample,);
+                buf[done++] = SOX_SIGNED_16BIT_TO_SAMPLE(sample,);
                 xa->bytesDecoded += ft->signal.size;
             }
             for (i = 0; i < ft->signal.channels && done < len; i++) {
@@ -256,7 +256,7 @@
                 xa->state[i].prevSample = xa->state[i].curSample;
                 xa->state[i].curSample = sample;
                 
-                buf[done++] = SOX_SIGNED_WORD_TO_SAMPLE(sample,);
+                buf[done++] = SOX_SIGNED_16BIT_TO_SAMPLE(sample,);
                 xa->bytesDecoded += ft->signal.size;
             }