commit 8e32e5c20dcbd0b890e26e65a6a33a2b45bed8db from: Vidar Hokstad date: Sat Feb 4 22:35:29 2017 UTC Refactoring commit - 89d29c95abf2b52024f0bbec9521696551c39917 commit + 8e32e5c20dcbd0b890e26e65a6a33a2b45bed8db blob - 5761f41c8f1af5cc1ea7c4555d3e69f75673bdd4 blob + 88a39fd332276adc526e833a0d2d1a650bbca01d --- src/SamTabs.h +++ src/SamTabs.h @@ -43,11 +43,13 @@ enum { FLAG_PLOSIVE = 0x0001, FLAG_STOPCONS = 0x0002, /* stop consonant */ FLAG_VOICED = 0x0004, + /* 0x08 */ FLAG_DIPTHONG = 0x0010, FLAG_DIP_YX = 0x0020, /* dipthong ending with YX */ FLAG_CONSONANT= 0x0040, FLAG_VOWEL = 0x0080, FLAG_PUNCT = 0x0100, + /* 0x200 */ FLAG_ALVEOLAR = 0x0400, FLAG_NASAL = 0x0800, FLAG_LIQUIC = 0x1000, /* liquic consonant */ blob - ddfe218e2d4018b0a3527975c4be7802a57843d2 blob + fa1a721ebd62eee4d5173de9a489f3c72e570029 --- src/sam.c +++ src/sam.c @@ -380,31 +380,25 @@ void SetPhonemeLength() { void Code41240() { unsigned char pos=0; - while(phonemeindex[pos] != 255) { - unsigned char index; //register AC - unsigned char X = pos; - index = phonemeindex[pos]; - if ((flags[index]&2) == 0) { - pos++; - continue; - } else if ((flags[index]&1) == 0) { - Insert(pos+1, index+1, phonemeLengthTable[index+1], stress[pos]); - Insert(pos+2, index+2, phonemeLengthTable[index+2], stress[pos]); - pos += 3; - continue; - } + while(phonemeindex[pos] != END) { + unsigned char index = phonemeindex[pos]; - unsigned char A; - while(!(A = phonemeindex[++X])); - - if (A != 255) { - if (flags[A] & 8) { ++pos; continue;} - if ((A == 36) || (A == 37)) {++pos; continue;} // '/H' '/X' - } - - Insert(pos+1, index+1, phonemeLengthTable[index+1], stress[pos]); - Insert(pos+2, index+2, phonemeLengthTable[index+2], stress[pos]); - pos += 3; + if ((flags[index]& FLAG_STOPCONS)) { + if ((flags[index]& FLAG_PLOSIVE)) { + unsigned char A; + unsigned char X = pos; + while(!(A = phonemeindex[++X])); /* Skip pause */ + + if (A != END) { + if ((flags[A] & 8) || (A == 36) || (A == 37)) {++pos; continue;} // '/H' '/X' + } + + } + Insert(pos+1, index+1, phonemeLengthTable[index+1], stress[pos]); + Insert(pos+2, index+2, phonemeLengthTable[index+2], stress[pos]); + pos += 2; + } + ++pos; } } @@ -484,7 +478,7 @@ void rule_g(unsigned char pos) { // If dipthong ending with YX, move continue processing next phoneme if ((index != 255) && ((flags[index] & FLAG_DIP_YX) == 0)) { // replace G with GX and continue processing next phoneme - if (debug) printf("RULE: G -> GX \n"); + drule("G -> GX "); phonemeindex[pos] = 63; // 'GX' } } @@ -554,40 +548,31 @@ void Parser2() { continue; } } - } else if (p == pR || p == 24 || p == 32 || p == 60) { - if (p == pR) { // 'R' - // RULES FOR PHONEMES BEFORE R - // Look at prior phoneme - X--; - //A = prior; - if (prior == pT || prior == pD) { - if (prior == pT) { - // Example: TRACK - drule("T R -> CH R"); - phonemeindex[pos-1] = 42; - } else if (prior == pD) { - // Example: DRY - drule("D R -> J R"); - phonemeindex[pos-1] = 44; - } - } else if (flags[prior] & FLAG_VOWEL) { - // Example: ART - drule(" R -> RX"); - phonemeindex[pos] = 18; // 'RX' - } - } else if (p == 24 && (flags[prior] & FLAG_VOWEL)) { // 'L' + prior has VOWEL flag set - // Example: ALL - drule(" L -> LX"); - phonemeindex[X] = 19; // 'LX' - } else if (prior == 60 && p == 32) { // 'G' 'S' - // Can't get to fire - - // 1. The G -> GX rule intervenes - // 2. Reciter already replaces GS -> GZ - drule("G S -> G Z"); - phonemeindex[pos] = 38; // 'Z' - } else if (p == 60) rule_g(pos); - } else { - if (A == 72) { // 'K' + } else if (p == pR) { // 'R' + // RULES FOR PHONEMES BEFORE R + if (prior == pT) { // Example: TRACK + drule("T R -> CH R"); + phonemeindex[pos-1] = 42; + } else if (prior == pD) { // Example: DRY + drule("D R -> J R"); + phonemeindex[pos-1] = 44; + } else if (flags[prior] & FLAG_VOWEL) { // Example: ART + drule(" R -> RX"); + phonemeindex[pos] = 18; // 'RX' + } + } else if (p == 24 && (flags[prior] & FLAG_VOWEL)) { // 'L' + prior has VOWEL flag set + // Example: ALL + drule(" L -> LX"); + phonemeindex[X] = 19; // 'LX' + } else if (prior == 60 && p == 32) { // 'G' 'S' + // Can't get to fire - + // 1. The G -> GX rule intervenes + // 2. Reciter already replaces GS -> GZ + drule("G S -> G Z"); + phonemeindex[pos] = 38; // 'Z' + } else if (p == 60) rule_g(pos); + else { + if (p == 72) { // 'K' // K -> KX // Example: COW unsigned char Y = phonemeindex[pos+1]; @@ -595,12 +580,13 @@ void Parser2() { if ((flags[Y] & FLAG_DIP_YX)==0 || Y==END) { // VOWELS AND DIPTHONGS ENDING WITH IY SOUND flag set? drule("K -> KX "); phonemeindex[pos] = 75; // 'KX' + p = 75; + pf = flags[p]; } } - unsigned char Y = phonemeindex[pos]; // Replace with softer version? - if ((flags[Y] & FLAG_PLOSIVE) && (prior == 32)) { // 'S' + if ((flags[p] & FLAG_PLOSIVE) && (prior == 32)) { // 'S' // RULE: // S P -> S B // S T -> S D @@ -608,20 +594,16 @@ void Parser2() { // S KX -> S GX // Examples: SPY, STY, SKY, SCOWL - if (debug) printf("RULE: S* %c%c -> S* %c%c\n", signInputTable1[Y], signInputTable2[Y],signInputTable1[Y-12], signInputTable2[Y-12]); - phonemeindex[pos] = Y-12; - } else if (!(flags[Y] & FLAG_PLOSIVE)) { - A = phonemeindex[X]; - if (A == 53 || A == 42 || A == 44) { - if (A == 53) rule_alveolar_uw(X); // Example: NEW, DEW, SUE, ZOO, THOO, TOO - else if (A == 42) rule_ch(X,mem59); // Example: CHEW - else if (A == 44) rule_j(X,mem59); // Example: JAY - } - } else { - A = Y; + if (debug) printf("RULE: S* %c%c -> S* %c%c\n", signInputTable1[p], signInputTable2[p],signInputTable1[p-12], signInputTable2[p-12]); + phonemeindex[pos] = p-12; + } else if (!(pf & FLAG_PLOSIVE)) { + p = phonemeindex[X]; + if (p == 53) rule_alveolar_uw(X); // Example: NEW, DEW, SUE, ZOO, THOO, TOO + else if (p == 42) rule_ch(X,mem59); // Example: CHEW + else if (p == 44) rule_j(X,mem59); // Example: JAY } - if (A == 69 || A == 57) { // 'T', 'D' + if (p == 69 || p == 57) { // 'T', 'D' // RULE: Soften T following vowel // NOTE: This rule fails for cases such as "ODD" // T -> DX