int OpenWavFile(char *path, int rate) //=================================== { static unsigned char wave_hdr[44] = { 'R','I','F','F',0x24,0xf0,0xff,0x7f,'W','A','V','E','f','m','t',' ', 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0, 2,0,0x10,0,'d','a','t','a', 0x00,0xf0,0xff,0x7f}; if(path == NULL) return(2); while(isspace(*path)) path++; f_wavfile = NULL; if(path[0] != 0) { if(strcmp(path,"stdout")==0) f_wavfile = stdout; else f_wavfile = fopen(path,"wb"); } if(f_wavfile == NULL) { fprintf(stderr,"Can't write to: '%s'\n",path); return(1); } fwrite(wave_hdr,1,24,f_wavfile); Write4Bytes(f_wavfile,rate); Write4Bytes(f_wavfile,rate * 2); fwrite(&wave_hdr[32],1,12,f_wavfile); return(0); } // end of OpenWavFile
int OpenWavFile(char *path, int rate) //=================================== { static unsigned char wave_hdr[44] = { 'R','I','F','F',0x24,0xf0,0xff,0x7f,'W','A','V','E','f','m','t',' ', 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0, 2,0,0x10,0,'d','a','t','a', 0x00,0xf0,0xff,0x7f}; if(path == NULL) return(2); if(path[0] == 0) return(0); if(strcmp(path,"stdout")==0) f_wavfile = stdout; else f_wavfile = fopen(path,"wb"); if(f_wavfile != NULL) { fwrite(wave_hdr,1,24,f_wavfile); Write4Bytes(f_wavfile,rate); Write4Bytes(f_wavfile,rate * 2); fwrite(&wave_hdr[32],1,12,f_wavfile); return(0); } return(1); } // end of OpenWavFile
static int OpenWaveFile(const char *path, int rate) //================================================= { // Set the length of 0x7ffff000 for --stdout // This will be changed to the correct length for -w (write to file) static unsigned char wave_hdr[44] = { 'R','I','F','F',0x24,0xf0,0xff,0x7f,'W','A','V','E','f','m','t',' ', 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0, 2,0,0x10,0,'d','a','t','a', 0x00,0xf0,0xff,0x7f}; if(path == NULL) return(2); if(strcmp(path,"stdout")==0) f_wave = stdout; else f_wave = fopen(path,"wb"); if(f_wave != NULL) { fwrite(wave_hdr,1,24,f_wave); Write4Bytes(f_wave,rate); Write4Bytes(f_wave,rate * 2); fwrite(&wave_hdr[32],1,12,f_wave); return(0); } return(1); } // end of OpenWaveFile
int OpenWaveFile2(const char *path) /*********************************/ { // Set the length of 0x7fffffff for --stdout // This will be changed to the correct length for -w (write to file) static unsigned char wave_hdr[44] = { 'R','I','F','F',0,0,0,0,'W','A','V','E','f','m','t',' ', 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0, 2,0,0x10,0,'d','a','t','a', 0xff,0xff,0xff,0x7f}; if(path == NULL) return(2); if(strcmp(path,"stdout")==0) f_wave = stdout; else f_wave = fopen(path,"wb"); if(f_wave != NULL) { fwrite(wave_hdr,1,24,f_wave); Write4Bytes(f_wave,samplerate); Write4Bytes(f_wave,samplerate * 2); fwrite(&wave_hdr[32],1,12,f_wave); return(0); } wxLogStatus(_T("Can't write to WAV file: '"+wxString(path,wxConvLocal))+_T("'")); return(1); } // end of OpenWaveFile
static void CloseWavFile() { unsigned int pos; if ((f_wavfile == NULL) || (f_wavfile == stdout)) return; fflush(f_wavfile); pos = ftell(f_wavfile); if (fseek(f_wavfile, 4, SEEK_SET) != -1) Write4Bytes(f_wavfile, pos - 8); if (fseek(f_wavfile, 40, SEEK_SET) != -1) Write4Bytes(f_wavfile, pos - 44); fclose(f_wavfile); f_wavfile = NULL; }
static int OpenWaveFile(const char *path, int rate) //================================================= { // Set the length of 0x7ffff000 for --stdout // This will be changed to the correct length for -w (write to file) static unsigned char wave_hdr[44] = { 'R','I','F','F',0x24,0xf0,0xff,0x7f,'W','A','V','E','f','m','t',' ', 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0, 2,0,0x10,0,'d','a','t','a', 0x00,0xf0,0xff,0x7f}; if(path == NULL) return(2); while(isspace(*path)) path++; f_wave = NULL; if(path[0] != 0) { if(strcmp(path,"stdout")==0) { #ifdef PLATFORM_WINDOWS // prevent Windows adding 0x0d before 0x0a bytes _setmode(_fileno(stdout), _O_BINARY); #endif f_wave = stdout; } else f_wave = fopen(path,"wb"); } if(f_wave != NULL) { fwrite(wave_hdr,1,24,f_wave); Write4Bytes(f_wave,rate); Write4Bytes(f_wave,rate * 2); fwrite(&wave_hdr[32],1,12,f_wave); return(0); } return(1); } // end of OpenWaveFile
static void CloseWaveFile() //========================= { unsigned int pos; if((f_wave == NULL) || (f_wave == stdout)) return; fflush(f_wave); pos = ftell(f_wave); fseek(f_wave,4,SEEK_SET); Write4Bytes(f_wave,pos - 8); fseek(f_wave,40,SEEK_SET); Write4Bytes(f_wave,pos - 44); fclose(f_wave); f_wave = NULL; } // end of CloseWaveFile
static int OpenWavFile(char *path, int rate) { static unsigned char wave_hdr[44] = { 'R', 'I', 'F', 'F', 0x24, 0xf0, 0xff, 0x7f, 'W', 'A', 'V', 'E', 'f', 'm', 't', ' ', 0x10, 0, 0, 0, 1, 0, 1, 0, 9, 0x3d, 0, 0, 0x12, 0x7a, 0, 0, 2, 0, 0x10, 0, 'd', 'a', 't', 'a', 0x00, 0xf0, 0xff, 0x7f }; if (path == NULL) return 2; while (isspace(*path)) path++; f_wavfile = NULL; if (path[0] != 0) { if (strcmp(path, "stdout") == 0) { #ifdef PLATFORM_WINDOWS // prevent Windows adding 0x0d before 0x0a bytes _setmode(_fileno(stdout), _O_BINARY); #endif f_wavfile = stdout; } else f_wavfile = fopen(path, "wb"); } if (f_wavfile == NULL) { fprintf(stderr, "Can't write to: '%s'\n", path); return 1; } fwrite(wave_hdr, 1, 24, f_wavfile); Write4Bytes(f_wavfile, rate); Write4Bytes(f_wavfile, rate * 2); fwrite(&wave_hdr[32], 1, 12, f_wavfile); return 0; }