Fixed bug with PCM conversion.
authorFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Thu, 13 Jul 2017 00:30:32 +0000 (20:30 -0400)
committerFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Thu, 13 Jul 2017 00:30:32 +0000 (20:30 -0400)
src/utils/pcm.c

index 89afe1eef237491a5e64c25c2c8924f1fa69d823..7d66f164903fcb7b08b539ea9023a8ae32e33880 100644 (file)
@@ -10,7 +10,7 @@
             case 1:
 
                 sample32 = 0;
-                sample32 += ((((signed int) bytes[3]) << 0) & 0xFFFFFFFF);
+                sample32 += ((((signed char) bytes[3]) << 0) & 0xFFFFFFFF);
 
                 sampleFloat = (float) sample32;
 
@@ -21,8 +21,8 @@
             case 2:
 
                 sample32 = 0;
-                sample32 += ((((signed int) bytes[2]) << 0) & 0x000000FF);
-                sample32 += ((((signed int) bytes[3]) << 8) & 0xFFFFFF00);
+                sample32 += ((((signed char) bytes[2]) << 0) & 0x000000FF);
+                sample32 += ((((signed char) bytes[3]) << 8) & 0xFFFFFF00);
 
                 sampleFloat = (float) sample32;
 
@@ -33,9 +33,9 @@
             case 3:
 
                 sample32 = 0;
-                sample32 += ((((signed int) bytes[1]) << 0) & 0x000000FF);
-                sample32 += ((((signed int) bytes[2]) << 8) & 0x0000FF00);
-                sample32 += ((((signed int) bytes[3]) << 16) & 0xFFFF0000);
+                sample32 += ((((signed char) bytes[1]) << 0) & 0x000000FF);
+                sample32 += ((((signed char) bytes[2]) << 8) & 0x0000FF00);
+                sample32 += ((((signed char) bytes[3]) << 16) & 0xFFFF0000);
 
                 sampleFloat = (float) sample32;
 
             case 4:
 
                 sample32 = 0;
-                sample32 += ((((signed int) bytes[0]) << 0) & 0x000000FF);
-                sample32 += ((((signed int) bytes[1]) << 8) & 0x0000FF00);
-                sample32 += ((((signed int) bytes[2]) << 16) & 0x00FF0000);
-                sample32 += ((((signed int) bytes[3]) << 24) & 0xFF000000);
+                sample32 += ((((signed char) bytes[0]) << 0) & 0x000000FF);
+                sample32 += ((((signed char) bytes[1]) << 8) & 0x0000FF00);
+                sample32 += ((((signed char) bytes[2]) << 16) & 0x00FF0000);
+                sample32 += ((((signed char) bytes[3]) << 24) & 0xFF000000);
 
                 sampleFloat = (float) sample32;