commit 7d5813677378e693bd28b2cfbe6b3d95944aeed6 from: Vidar Hokstad date: Sun Sep 23 08:27:04 2018 UTC Revert "CR/LF" This reverts commit 55bc9805f51d4bf50e463d8cb437229d7f2e4e20. commit - 55bc9805f51d4bf50e463d8cb437229d7f2e4e20 commit + 7d5813677378e693bd28b2cfbe6b3d95944aeed6 blob - 682d254d8e8a78419830044d20e4335b50ba4d95 blob + 8ab17f3e45a1d6f057107081e5fef14a1ef51dc7 --- src/main.c +++ src/main.c @@ -1,269 +1,269 @@ -#include -#include -#include -#include - -#include "reciter.h" -#include "sam.h" -#include "debug.h" - -#ifdef USESDL -#include -#include -#endif - -void WriteWav(char* filename, char* buffer, int bufferlength) -{ - FILE *file = fopen(filename, "wb"); - if (file == NULL) return; - //RIFF header - fwrite("RIFF", 4, 1,file); - unsigned int filesize=bufferlength + 12 + 16 + 8 - 8; - fwrite(&filesize, 4, 1, file); - fwrite("WAVE", 4, 1, file); - - //format chunk - fwrite("fmt ", 4, 1, file); - unsigned int fmtlength = 16; - fwrite(&fmtlength, 4, 1, file); - unsigned short int format=1; //PCM - fwrite(&format, 2, 1, file); - unsigned short int channels=1; - fwrite(&channels, 2, 1, file); - unsigned int samplerate = 22050; - fwrite(&samplerate, 4, 1, file); - fwrite(&samplerate, 4, 1, file); // bytes/second - unsigned short int blockalign = 1; - fwrite(&blockalign, 2, 1, file); - unsigned short int bitspersample=8; - fwrite(&bitspersample, 2, 1, file); - - //data chunk - fwrite("data", 4, 1, file); - fwrite(&bufferlength, 4, 1, file); - fwrite(buffer, bufferlength, 1, file); - - fclose(file); -} - -void PrintUsage() -{ - printf("usage: sam [options] Word1 Word2 ....\n"); - printf("options\n"); - printf(" -phonetic enters phonetic mode. (see below)\n"); - printf(" -pitch number set pitch value (default=64)\n"); - printf(" -speed number set speed value (default=72)\n"); - printf(" -throat number set throat value (default=128)\n"); - printf(" -mouth number set mouth value (default=128)\n"); - printf(" -wav filename output to wav instead of libsdl\n"); - printf(" -sing special treatment of pitch\n"); - printf(" -debug print additional debug messages\n"); - printf("\n"); - - - printf(" VOWELS VOICED CONSONANTS \n"); - printf("IY f(ee)t R red \n"); - printf("IH p(i)n L allow \n"); - printf("EH beg W away \n"); - printf("AE Sam W whale \n"); - printf("AA pot Y you \n"); - printf("AH b(u)dget M Sam \n"); - printf("AO t(al)k N man \n"); - printf("OH cone NX so(ng) \n"); - printf("UH book B bad \n"); - printf("UX l(oo)t D dog \n"); - printf("ER bird G again \n"); - printf("AX gall(o)n J judge \n"); - printf("IX dig(i)t Z zoo \n"); - printf(" ZH plea(s)ure \n"); - printf(" DIPHTHONGS V seven \n"); - printf("EY m(a)de DH (th)en \n"); - printf("AY h(igh) \n"); - printf("OY boy \n"); - printf("AW h(ow) UNVOICED CONSONANTS \n"); - printf("OW slow S Sam \n"); - printf("UW crew Sh fish \n"); - printf(" F fish \n"); - printf(" TH thin \n"); - printf(" SPECIAL PHONEMES P poke \n"); - printf("UL sett(le) (=AXL) T talk \n"); - printf("UM astron(omy) (=AXM) K cake \n"); - printf("UN functi(on) (=AXN) CH speech \n"); - printf("Q kitt-en (glottal stop) /H a(h)ead \n"); -} - -#ifdef USESDL - -int pos = 0; -void MixAudio(void *unused, Uint8 *stream, int len) -{ - int bufferpos = GetBufferLength(); - char *buffer = GetBuffer(); - int i; - if (pos >= bufferpos) return; - if ((bufferpos-pos) < len) len = (bufferpos-pos); - for(i=0; i +#include +#include +#include + +#include "reciter.h" +#include "sam.h" +#include "debug.h" + +#ifdef USESDL +#include +#include +#endif + +void WriteWav(char* filename, char* buffer, int bufferlength) +{ + FILE *file = fopen(filename, "wb"); + if (file == NULL) return; + //RIFF header + fwrite("RIFF", 4, 1,file); + unsigned int filesize=bufferlength + 12 + 16 + 8 - 8; + fwrite(&filesize, 4, 1, file); + fwrite("WAVE", 4, 1, file); + + //format chunk + fwrite("fmt ", 4, 1, file); + unsigned int fmtlength = 16; + fwrite(&fmtlength, 4, 1, file); + unsigned short int format=1; //PCM + fwrite(&format, 2, 1, file); + unsigned short int channels=1; + fwrite(&channels, 2, 1, file); + unsigned int samplerate = 22050; + fwrite(&samplerate, 4, 1, file); + fwrite(&samplerate, 4, 1, file); // bytes/second + unsigned short int blockalign = 1; + fwrite(&blockalign, 2, 1, file); + unsigned short int bitspersample=8; + fwrite(&bitspersample, 2, 1, file); + + //data chunk + fwrite("data", 4, 1, file); + fwrite(&bufferlength, 4, 1, file); + fwrite(buffer, bufferlength, 1, file); + + fclose(file); +} + +void PrintUsage() +{ + printf("usage: sam [options] Word1 Word2 ....\n"); + printf("options\n"); + printf(" -phonetic enters phonetic mode. (see below)\n"); + printf(" -pitch number set pitch value (default=64)\n"); + printf(" -speed number set speed value (default=72)\n"); + printf(" -throat number set throat value (default=128)\n"); + printf(" -mouth number set mouth value (default=128)\n"); + printf(" -wav filename output to wav instead of libsdl\n"); + printf(" -sing special treatment of pitch\n"); + printf(" -debug print additional debug messages\n"); + printf("\n"); + + + printf(" VOWELS VOICED CONSONANTS \n"); + printf("IY f(ee)t R red \n"); + printf("IH p(i)n L allow \n"); + printf("EH beg W away \n"); + printf("AE Sam W whale \n"); + printf("AA pot Y you \n"); + printf("AH b(u)dget M Sam \n"); + printf("AO t(al)k N man \n"); + printf("OH cone NX so(ng) \n"); + printf("UH book B bad \n"); + printf("UX l(oo)t D dog \n"); + printf("ER bird G again \n"); + printf("AX gall(o)n J judge \n"); + printf("IX dig(i)t Z zoo \n"); + printf(" ZH plea(s)ure \n"); + printf(" DIPHTHONGS V seven \n"); + printf("EY m(a)de DH (th)en \n"); + printf("AY h(igh) \n"); + printf("OY boy \n"); + printf("AW h(ow) UNVOICED CONSONANTS \n"); + printf("OW slow S Sam \n"); + printf("UW crew Sh fish \n"); + printf(" F fish \n"); + printf(" TH thin \n"); + printf(" SPECIAL PHONEMES P poke \n"); + printf("UL sett(le) (=AXL) T talk \n"); + printf("UM astron(omy) (=AXM) K cake \n"); + printf("UN functi(on) (=AXN) CH speech \n"); + printf("Q kitt-en (glottal stop) /H a(h)ead \n"); +} + +#ifdef USESDL + +int pos = 0; +void MixAudio(void *unused, Uint8 *stream, int len) +{ + int bufferpos = GetBufferLength(); + char *buffer = GetBuffer(); + int i; + if (pos >= bufferpos) return; + if ((bufferpos-pos) < len) len = (bufferpos-pos); + for(i=0; i