commit e393e19a4ee86a1caaec027f3fb6679aea903da8 from: Vidar Hokstad date: Sun Sep 23 08:27:17 2018 UTC Revert "Strip whitespace" This reverts commit 9190106e427f10f90bd47c38968605160135fcef. commit - 7d5813677378e693bd28b2cfbe6b3d95944aeed6 commit + e393e19a4ee86a1caaec027f3fb6679aea903da8 blob - 4e58a8f4ae2cdbd2955a88e9fb8117f3e8682a8d blob + beaf01df613cafd5d3b69d82dac7e3072f276d6d --- src/sam.c +++ src/sam.c @@ -1,10 +1,10 @@ -#include -#include -#include -#include "debug.h" -#include "sam.h" -#include "render.h" -#include "SamTabs.h" +#include +#include +#include +#include "debug.h" +#include "sam.h" +#include "render.h" +#include "SamTabs.h" enum { pR = 23, @@ -15,74 +15,74 @@ enum { }; - -char input[256]; //tab39445 -//standard sam sound -unsigned char speed = 72; -unsigned char pitch = 64; -unsigned char mouth = 128; -unsigned char throat = 128; -int singmode = 0; - -extern int debug; - -unsigned char mem39; -unsigned char mem44; -unsigned char mem47; -unsigned char mem49; -unsigned char mem50; -unsigned char mem51; -unsigned char mem53; -unsigned char mem59=0; - + +char input[256]; //tab39445 +//standard sam sound +unsigned char speed = 72; +unsigned char pitch = 64; +unsigned char mouth = 128; +unsigned char throat = 128; +int singmode = 0; + +extern int debug; + +unsigned char mem39; +unsigned char mem44; +unsigned char mem47; +unsigned char mem49; +unsigned char mem50; +unsigned char mem51; +unsigned char mem53; +unsigned char mem59=0; + unsigned char X; - -unsigned char stress[256]; //numbers from 0 to 8 -unsigned char phonemeLength[256]; //tab40160 -unsigned char phonemeindex[256]; - -unsigned char phonemeIndexOutput[60]; //tab47296 -unsigned char stressOutput[60]; //tab47365 -unsigned char phonemeLengthOutput[60]; //tab47416 - - - - -// contains the final soundbuffer -int bufferpos=0; -char *buffer = NULL; - - -void SetInput(char *_input) -{ - int i, l; - l = strlen(_input); - if (l > 254) l = 254; - for(i=0; i 254) l = 254; + for(i=0; i -// -// The byte 0x9B marks the end of the buffer. Some phonemes are 2 bytes -// long, such as "DH" and "AX". Others are 1 byte long, such as "T" and "Z". -// There are also stress markers, such as "5" and ".". -// -// The first character of the phonemes are stored in the table signInputTable1[]. -// The second character of the phonemes are stored in the table signInputTable2[]. -// The stress characters are arranged in low to high stress order in stressInputTable[]. -// -// The following process is used to parse the input[] buffer: -// -// Repeat until the <0x9B> character is reached: -// -// First, a search is made for a 2 character match for phonemes that do not -// end with the '*' (wildcard) character. On a match, the index of the phoneme -// is added to phonemeIndex[] and the buffer position is advanced 2 bytes. -// -// If this fails, a search is made for a 1 character match against all -// phoneme names ending with a '*' (wildcard). If this succeeds, the -// phoneme is added to phonemeIndex[] and the buffer position is advanced -// 1 byte. -// -// If this fails, search for a 1 character match in the stressInputTable[]. -// If this succeeds, the stress value is placed in the last stress[] table -// at the same index of the last added phoneme, and the buffer position is -// advanced by 1 byte. -// -// If this fails, return a 0. -// -// On success: -// -// 1. phonemeIndex[] will contain the index of all the phonemes. -// 2. The last index in phonemeIndex[] will be 255. -// 3. stress[] will contain the stress value for each phoneme +// The input[] buffer contains a string of phonemes and stress markers along +// the lines of: +// +// DHAX KAET IHZ AH5GLIY. <0x9B> +// +// The byte 0x9B marks the end of the buffer. Some phonemes are 2 bytes +// long, such as "DH" and "AX". Others are 1 byte long, such as "T" and "Z". +// There are also stress markers, such as "5" and ".". +// +// The first character of the phonemes are stored in the table signInputTable1[]. +// The second character of the phonemes are stored in the table signInputTable2[]. +// The stress characters are arranged in low to high stress order in stressInputTable[]. +// +// The following process is used to parse the input[] buffer: +// +// Repeat until the <0x9B> character is reached: +// +// First, a search is made for a 2 character match for phonemes that do not +// end with the '*' (wildcard) character. On a match, the index of the phoneme +// is added to phonemeIndex[] and the buffer position is advanced 2 bytes. +// +// If this fails, a search is made for a 1 character match against all +// phoneme names ending with a '*' (wildcard). If this succeeds, the +// phoneme is added to phonemeIndex[] and the buffer position is advanced +// 1 byte. +// +// If this fails, search for a 1 character match in the stressInputTable[]. +// If this succeeds, the stress value is placed in the last stress[] table +// at the same index of the last added phoneme, and the buffer position is +// advanced by 1 byte. +// +// If this fails, return a 0. +// +// On success: +// +// 1. phonemeIndex[] will contain the index of all the phonemes. +// 2. The last index in phonemeIndex[] will be 255. +// 3. stress[] will contain the stress value for each phoneme // input[] holds the string of phonemes, each two bytes wide // signInputTable1[] holds the first character of each phoneme @@ -426,29 +426,29 @@ void drule_post(unsigned char X) { } -// Rewrites the phonemes using the following rules: -// -// -> WX -// -> YX -// UL -> AX L -// UM -> AX M -// -> Q -// T R -> CH R -// D R -> J R -// R -> RX -// L -> LX -// G S -> G Z -// K -> KX -// G -> GX -// S P -> S B -// S T -> S D -// S K -> S G -// S KX -> S GX -// UW -> UX -// CH -> CH CH' (CH requires two phonemes to represent it) -// J -> J J' (J requires two phonemes to represent it) -// T -> DX -// D -> DX +// Rewrites the phonemes using the following rules: +// +// -> WX +// -> YX +// UL -> AX L +// UM -> AX M +// -> Q +// T R -> CH R +// D R -> J R +// R -> RX +// L -> LX +// G S -> G Z +// K -> KX +// G -> GX +// S P -> S B +// S T -> S D +// S K -> S G +// S KX -> S GX +// UW -> UX +// CH -> CH CH' (CH requires two phonemes to represent it) +// J -> J J' (J requires two phonemes to represent it) +// T -> DX +// D -> DX void rule_alveolar_uw(unsigned char X) { @@ -639,7 +639,7 @@ void AdjustLengths() { // test for vowel index = phonemeindex[X]; - // test for fricative/unvoiced or not voiced + // test for fricative/unvoiced or not voiced if(!(flags[index] & FLAG_FRICATIVE) || (flags[index] & FLAG_VOICED)) { //nochmal überprüfen unsigned char A = phonemeLength[X]; // change phoneme length to (length * 1.5) + 1 @@ -709,7 +709,7 @@ void AdjustLengths() { if (index != END && (flags[index] & FLAG_STOPCONS)) { // FIXME, this looks wrong? - // RULE: {optional silence} + // RULE: {optional silence} drule(" {optional silence} - shorten both to 1/2 + 1"); phonemeLength[X] = (phonemeLength[X] >> 1) + 1; phonemeLength[loopIndex] = (phonemeLength[loopIndex] >> 1) + 1;