commit - 7d5813677378e693bd28b2cfbe6b3d95944aeed6
commit + e393e19a4ee86a1caaec027f3fb6679aea903da8
blob - 4e58a8f4ae2cdbd2955a88e9fb8117f3e8682a8d
blob + beaf01df613cafd5d3b69d82dac7e3072f276d6d
--- src/sam.c
+++ src/sam.c
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "debug.h"
-#include "sam.h"
-#include "render.h"
-#include "SamTabs.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "debug.h"
+#include "sam.h"
+#include "render.h"
+#include "SamTabs.h"
enum {
pR = 23,
};
-
-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<l; i++)
- input[i] = _input[i];
- input[l] = 0;
-}
-
-void SetSpeed(unsigned char _speed) {speed = _speed;};
-void SetPitch(unsigned char _pitch) {pitch = _pitch;};
-void SetMouth(unsigned char _mouth) {mouth = _mouth;};
-void SetThroat(unsigned char _throat) {throat = _throat;};
-void EnableSingmode() {singmode = 1;};
-char* GetBuffer(){return buffer;};
-int GetBufferLength(){return bufferpos;};
-
-void Init();
-int Parser1();
-void Parser2();
-int SAMMain();
-void CopyStress();
-void SetPhonemeLength();
-void AdjustLengths();
-void Code41240();
-void Insert(unsigned char position, unsigned char mem60, unsigned char mem59, unsigned char mem58);
+
+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<l; i++)
+ input[i] = _input[i];
+ input[l] = 0;
+}
+
+void SetSpeed(unsigned char _speed) {speed = _speed;};
+void SetPitch(unsigned char _pitch) {pitch = _pitch;};
+void SetMouth(unsigned char _mouth) {mouth = _mouth;};
+void SetThroat(unsigned char _throat) {throat = _throat;};
+void EnableSingmode() {singmode = 1;};
+char* GetBuffer(){return buffer;};
+int GetBufferLength(){return bufferpos;};
+
+void Init();
+int Parser1();
+void Parser2();
+int SAMMain();
+void CopyStress();
+void SetPhonemeLength();
+void AdjustLengths();
+void Code41240();
+void Insert(unsigned char position, unsigned char mem60, unsigned char mem59, unsigned char mem58);
void InsertBreath(unsigned char mem59);
-void PrepareOutput();
-void SetMouthThroat(unsigned char mouth, unsigned char throat);
+void PrepareOutput();
+void SetMouthThroat(unsigned char mouth, unsigned char throat);
void Init() {
int i;
}
-// Iterates through the phoneme buffer, copying the stress value from
-// the following phoneme under the following circumstance:
-
-// 1. The current phoneme is voiced, excluding plosives and fricatives
-// 2. The following phoneme is voiced, excluding plosives and fricatives, and
-// 3. The following phoneme is stressed
-//
-// In those cases, the stress value+1 from the following phoneme is copied.
-//
-// For example, the word LOITER is represented as LOY5TER, with as stress
-// of 5 on the dipthong OY. This routine will copy the stress value of 6 (5+1)
-// to the L that precedes it.
+// Iterates through the phoneme buffer, copying the stress value from
+// the following phoneme under the following circumstance:
+
+// 1. The current phoneme is voiced, excluding plosives and fricatives
+// 2. The following phoneme is voiced, excluding plosives and fricatives, and
+// 3. The following phoneme is stressed
+//
+// In those cases, the stress value+1 from the following phoneme is copied.
+//
+// For example, the word LOITER is represented as LOY5TER, with as stress
+// of 5 on the dipthong OY. This routine will copy the stress value of 6 (5+1)
+// to the L that precedes it.
+
+
-
-
void CopyStress() {
// loop thought all the phonemes to be output
unsigned char pos=0; //mem66
-// 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
+// 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
}
-// Rewrites the phonemes using the following rules:
-//
-// <DIPTHONG ENDING WITH WX> -> <DIPTHONG ENDING WITH WX> WX
-// <DIPTHONG NOT ENDING WITH WX> -> <DIPTHONG NOT ENDING WITH WX> YX
-// UL -> AX L
-// UM -> AX M
-// <STRESSED VOWEL> <SILENCE> <STRESSED VOWEL> -> <STRESSED VOWEL> <SILENCE> Q <VOWEL>
-// T R -> CH R
-// D R -> J R
-// <VOWEL> R -> <VOWEL> RX
-// <VOWEL> L -> <VOWEL> LX
-// G S -> G Z
-// K <VOWEL OR DIPTHONG NOT ENDING WITH IY> -> KX <VOWEL OR DIPTHONG NOT ENDING WITH IY>
-// G <VOWEL OR DIPTHONG NOT ENDING WITH IY> -> GX <VOWEL OR DIPTHONG NOT ENDING WITH IY>
-// S P -> S B
-// S T -> S D
-// S K -> S G
-// S KX -> S GX
-// <ALVEOLAR> UW -> <ALVEOLAR> UX
-// CH -> CH CH' (CH requires two phonemes to represent it)
-// J -> J J' (J requires two phonemes to represent it)
-// <UNSTRESSED VOWEL> T <PAUSE> -> <UNSTRESSED VOWEL> DX <PAUSE>
-// <UNSTRESSED VOWEL> D <PAUSE> -> <UNSTRESSED VOWEL> DX <PAUSE>
+// Rewrites the phonemes using the following rules:
+//
+// <DIPTHONG ENDING WITH WX> -> <DIPTHONG ENDING WITH WX> WX
+// <DIPTHONG NOT ENDING WITH WX> -> <DIPTHONG NOT ENDING WITH WX> YX
+// UL -> AX L
+// UM -> AX M
+// <STRESSED VOWEL> <SILENCE> <STRESSED VOWEL> -> <STRESSED VOWEL> <SILENCE> Q <VOWEL>
+// T R -> CH R
+// D R -> J R
+// <VOWEL> R -> <VOWEL> RX
+// <VOWEL> L -> <VOWEL> LX
+// G S -> G Z
+// K <VOWEL OR DIPTHONG NOT ENDING WITH IY> -> KX <VOWEL OR DIPTHONG NOT ENDING WITH IY>
+// G <VOWEL OR DIPTHONG NOT ENDING WITH IY> -> GX <VOWEL OR DIPTHONG NOT ENDING WITH IY>
+// S P -> S B
+// S T -> S D
+// S K -> S G
+// S KX -> S GX
+// <ALVEOLAR> UW -> <ALVEOLAR> UX
+// CH -> CH CH' (CH requires two phonemes to represent it)
+// J -> J J' (J requires two phonemes to represent it)
+// <UNSTRESSED VOWEL> T <PAUSE> -> <UNSTRESSED VOWEL> DX <PAUSE>
+// <UNSTRESSED VOWEL> D <PAUSE> -> <UNSTRESSED VOWEL> DX <PAUSE>
void rule_alveolar_uw(unsigned char X) {
// 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
if (index != END && (flags[index] & FLAG_STOPCONS)) {
// FIXME, this looks wrong?
- // RULE: <UNVOICED STOP CONSONANT> {optional silence} <STOP CONSONANT>
+ // RULE: <UNVOICED STOP CONSONANT> {optional silence} <STOP CONSONANT>
drule("<UNVOICED STOP CONSONANT> {optional silence} <STOP CONSONANT> - shorten both to 1/2 + 1");
phonemeLength[X] = (phonemeLength[X] >> 1) + 1;
phonemeLength[loopIndex] = (phonemeLength[loopIndex] >> 1) + 1;