From 3175ff964c7d85d070df823189997f6b753cfef7 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Sun, 20 Jun 2010 22:19:44 +0000 Subject: Update testtremor app to have compile time option to output in (almost legal) WAV format. git-svn-id: https://svn.xiph.org/branches/lowmem-branch/Tremolo@17299 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- testtremor.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/testtremor.c b/testtremor.c index 734b084..3f19f6a 100644 --- a/testtremor.c +++ b/testtremor.c @@ -28,6 +28,8 @@ //#define PROFILE +#define WAV_FORMAT + #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ #include #include @@ -298,6 +300,24 @@ int main(int argc, char *argv[]){ 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,6 +332,24 @@ int main(int argc, char *argv[]){ 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 } } -- cgit v1.2.1