shithub: sox

Download patch

ref: 792012d799daefaa777397987a221fed54b63ecb
parent: c6cfb326193221d67eaaf8168eb18e2d75494df1
author: robs <robs>
date: Sun Nov 19 15:41:16 EST 2006

Fix wav file handler discarding the last PCM sample in certain circumstances.
Add support for 24-bit PCM raw, wav, & flac files.

--- a/src/wav.c
+++ b/src/wav.c
@@ -840,6 +840,17 @@
             ft->info.encoding = ST_ENCODING_SIGN2;
         break;
         
+    case ST_SIZE_24BIT:
+        if (ft->info.size == -1 || ft->info.size == ST_SIZE_24BIT)
+            ft->info.size = ST_SIZE_24BIT;
+        else
+            st_warn("User options overriding size read in .wav header");
+
+        /* Now we have enough information to set default encodings. */
+        if (ft->info.encoding == -1)
+            ft->info.encoding = ST_ENCODING_SIGN2;
+        break;
+        
     case ST_SIZE_DWORD:
         if (ft->info.size == -1 || ft->info.size == ST_SIZE_DWORD)
             ft->info.size = ST_SIZE_DWORD;
@@ -1154,7 +1165,7 @@
         /* Only return buffers that contain a totally playable
          * amount of audio.
          */
-        done -= (done % (ft->info.channels * ft->info.size));
+        done -= done % ft->info.channels;
         if (done/ft->info.channels > wav->numSamples)
             wav->numSamples = 0;
         else
@@ -1394,6 +1405,15 @@
                 ft->info.encoding = ST_ENCODING_SIGN2;
             }
             break;
+        case ST_SIZE_24BIT:
+            wBitsPerSample = 24;
+            if (ft->info.encoding != ST_ENCODING_SIGN2)
+            {
+                st_report("Do not support %s with 24-bit data.  Forcing to Signed.",st_encodings_str[(unsigned char)ft->info.encoding]);
+                ft->info.encoding = ST_ENCODING_SIGN2;
+            }
+            break;
+
         case ST_SIZE_DWORD:
             wBitsPerSample = 32;
             if (ft->info.encoding != ST_ENCODING_SIGN2 &&