new parameter addspacechars
[swftools.git] / src / wav2swf.c
index 70d51b1..72919e5 100644 (file)
@@ -24,7 +24,7 @@
 #include "../lib/rfxswf.h"
 #include "../lib/log.h"
 #include "../lib/args.h"
-#include "wav.h"
+#include "../lib/wav.h"
 
 char * filename = 0;
 char * outputname = "output.swf";
@@ -40,7 +40,6 @@ static struct options_t options[] = {
 {"o", "output"},
 {"r", "framerate"},
 {"s", "samplerate"},
-{"b", "bitrate"},
 {"d", "definesound"},
 {"l", "loop"},
 {"C", "cgi"},
@@ -114,7 +113,7 @@ int args_callback_option(char*name,char*val)
            samplerate = 44100;
        else {
            fprintf(stderr, "Invalid samplerate: %d\n", samplerate);
-           fprintf(stderr, "Allowed values: 11025, 22050, 44100\n", samplerate);
+           fprintf(stderr, "Allowed values: 11025, 22050, 44100\n");
            exit(1);
        }
        return 1;
@@ -163,7 +162,6 @@ void args_callback_usage(char *name)
     printf("-o , --output <filename>       Explicitly specify output file. (Otherwise, output will go to output.swf)\n");
     printf("-r , --framerate <fps>         Set file framerate to <fps> frames per second.\n");
     printf("-s , --samplerate <sps>        Set samplerate to <sps> frames per second (default: 11025).\n");
-    printf("-b , --bitrate bps             Set mp3 bitrate to <bps>.\n");
     printf("-d , --definesound             Generate a DefineSound tag instead of streaming sound.\n");
     printf("-l , --loop n                  (Only used with -d)\n");
     printf("-C , --cgi                     For use as CGI- prepend http header, write to stdout.\n");
@@ -229,17 +227,24 @@ int main (int argc,char ** argv)
        exit(1);
     }
 
-    if(!readWAV(filename, &wav))
+    if(!wav_read(&wav, filename))
     {
        msg("<fatal> Error reading %s", filename);
        exit(1);
     }
-    convertWAV2mono(&wav,&wav2, samplerate);
-    //printWAVInfo(&wav);
-    //printWAVInfo(&wav2);
+    wav_convert2mono(&wav,&wav2, samplerate);
+    //wav_print(&wav);
+    //wav_print(&wav2);
     samples = (U16*)wav2.data;
     numsamples = wav2.size/2;
 
+#ifdef WORDS_BIGENDIAN
+    /* swap bytes */
+    for(t=0;t<numsamples;t++) {
+        samples[t] = (samples[t]>>8)&0xff | (samples[t]<<8)&0xff00;
+    }
+#endif
+
     if(numsamples%blocksize != 0)
     {
        // apply padding, so that block is a multiple of blocksize