shithub: sox

Download patch

ref: 957fff9a40655b51d692220336af53c68607a7b0
parent: 908054f1665a91078bd05f9cc6414d584dc6d393
author: rrt <rrt>
date: Sat Sep 8 09:07:42 EDT 2007

Get LPC10 basically working. Playback seems odd (sounds like the pitch
has been shifted without the speed being affected), but it is
comprehensible; in any case, it produces identical output to the
sample code in the LPC10 code base.

--- a/src/lpc10.c
+++ b/src/lpc10.c
@@ -127,6 +127,8 @@
     return SOX_EOF;
   }
   lpc->samples = LPC10_SAMPLES_PER_FRAME;
+  ft->signal.size = SOX_SIZE_16BIT;
+  ft->signal.encoding = SOX_ENCODING_SIGN2;
 
   return SOX_SUCCESS;
 }
@@ -173,17 +175,19 @@
   lpcpriv_t lpc = (lpcpriv_t)ft->priv;
   sox_size_t nwritten = 0;
 
-  while (len + lpc->samples >= LPC10_SAMPLES_PER_FRAME) {
-    INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME];
-
-    while (lpc->samples < LPC10_SAMPLES_PER_FRAME) {
+  while (len > 0) {
+    while (len > 0 && lpc->samples < LPC10_SAMPLES_PER_FRAME) {
       lpc->speech[lpc->samples++] = SOX_SAMPLE_TO_FLOAT_32BIT(buf[nwritten++], ft->clips);
       len--;
     }
-    
-    lpc10_encode(lpc->speech, bits, lpc->encst);
-    write_bits(ft, bits, LPC10_BITS_IN_COMPRESSED_FRAME);
-    lpc->samples = 0;
+
+    if (lpc->samples == LPC10_SAMPLES_PER_FRAME) {
+      INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME];
+
+      lpc10_encode(lpc->speech, bits, lpc->encst);
+      write_bits(ft, bits, LPC10_BITS_IN_COMPRESSED_FRAME);
+      lpc->samples = 0;
+    }
   }
 
   return nwritten;