[xiph-commits] r17299 - branches/lowmem-branch/Tremolo

robin at svn.xiph.org robin at svn.xiph.org
Sun Jun 20 15:19:44 PDT 2010


Author: robin
Date: 2010-06-20 15:19:44 -0700 (Sun, 20 Jun 2010)
New Revision: 17299

Modified:
   branches/lowmem-branch/Tremolo/testtremor.c
Log:
Update testtremor app to have compile time option to output in (almost legal)
WAV format.



Modified: branches/lowmem-branch/Tremolo/testtremor.c
===================================================================
--- branches/lowmem-branch/Tremolo/testtremor.c	2010-06-20 22:18:49 UTC (rev 17298)
+++ branches/lowmem-branch/Tremolo/testtremor.c	2010-06-20 22:19:44 UTC (rev 17299)
@@ -28,6 +28,8 @@
 
 //#define PROFILE
 
+#define WAV_FORMAT
+
 #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
 #include <io.h>
 #include <fcntl.h>
@@ -298,6 +300,24 @@
       Output("Failed to open '%s' for output\n", argv[2]);
       exit(EXIT_FAILURE);
     }
+#ifdef WAV_FORMAT
+    { unsigned int rate = 44100, channels=2, bps=16, drate, dblock;
+      fprintf(out, "RIFF%c%c%c%c",0,0,0,0); /* RIFF, chunksize */
+      fprintf(out, "WAVEfmt %c%c%c%c",16,0,0,0); /* WAVEfmt, chunksize */;
+      fprintf(out, "%c%c%c%c", 1,0, channels,0); /* fmt(PCM), channels) */
+      fprintf(out, "%c%c%c%c", /* Sampling rate (blocks per second) */
+              rate,rate>>8,rate>>16,rate>>24);
+      drate = (bps>>3)*channels*rate;
+      fprintf(out, "%c%c%c%c", /* data rate */
+              drate,drate>>8,drate>>16,drate>>24);
+      dblock = (bps>>3)*channels;
+      fprintf(out, "%c%c", /* data block size(bytes) */
+              dblock,dblock>>8);
+      fprintf(out, "%c%c", /* bps */
+              bps,bps>>8);
+      fprintf(out, "data%c%c%c%c",0,0,0,0); /* sample header */
+    }
+#endif
   }
 
   if (argc >= 4)
@@ -312,7 +332,25 @@
         Output("Failed to open '%s' as output reference file\n", argv[3]);
         exit(EXIT_FAILURE);
       }
+#ifdef WAV_FORMAT
+    { unsigned int rate = 44100, channels=2, bps=16, drate, dblock;
+      fprintf(out, "RIFF%c%c%c%c",0,0,0,0); /* RIFF, chunksize */
+      fprintf(out, "WAVEfmt %c%c%c%c",16,0,0,0); /* WAVEfmt, chunksize */;
+      fprintf(out, "%c%c%c%c", 1,0, channels,0); /* fmt(PCM), channels) */
+      fprintf(out, "%c%c%c%c", /* Sampling rate (blocks per second) */
+              rate,rate>>8,rate>>16,rate>>24);
+      drate = (bps>>3)*channels*rate;
+      fprintf(out, "%c%c%c%c", /* data rate */
+              drate,drate>>8,drate>>16,drate>>24);
+      dblock = (bps>>3)*channels;
+      fprintf(out, "%c%c", /* data block size(bytes) */
+              dblock,dblock>>8);
+      fprintf(out, "%c%c", /* bps */
+              bps,bps>>8);
+      fprintf(out, "data%c%c%c%c",0,0,0,0); /* sample header */
     }
+#endif
+    }
   }
 
   Output("First test: Decode correctness\n");



More information about the commits mailing list