Skip to content

Commit

Permalink
New commented render routine
Browse files Browse the repository at this point in the history
  • Loading branch information
s-macke committed Mar 3, 2014
1 parent e739518 commit 4d9e878
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions src/sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ unsigned char phonemeIndexOutput[60]; //tab47296
unsigned char stressOutput[60]; //tab47365
unsigned char phonemeLengthOutput[60]; //tab47416

unsigned char tab44800[256];
unsigned char sampledConsonantFlag[256]; // tab44800

unsigned char pitches[256]; // tab43008

Expand Down Expand Up @@ -163,7 +163,7 @@ void Init()
frequency3[i] = 0;
stress[i] = 0;
phonemeLength[i] = 0;
tab44800[i] = 0;
sampledConsonantFlag[i] = 0;
}

for(i=0; i<60; i++)
Expand Down Expand Up @@ -252,7 +252,7 @@ int SAMMain()
if (debug)
{
PrintPhonemes(phonemeindex, phonemeLength, stress);
PrintOutput(tab44800, frequency1, frequency2, frequency3, amplitude1, amplitude2, amplitude3, pitches);
PrintOutput(sampledConsonantFlag, frequency1, frequency2, frequency3, amplitude1, amplitude2, amplitude3, pitches);
}
return 1;
}
Expand Down Expand Up @@ -1802,6 +1802,8 @@ void AddInflection(unsigned char mem48, unsigned char phase1)
// 4. Render the each frame.



//void Code47574()
void Render()
{
unsigned char phase1 = 0; //mem43
Expand All @@ -1820,6 +1822,7 @@ void Render()
X = 0;
mem44 = 0;


// CREATE FRAMES
//
// The length parameter in the list corresponds to the number of frames
Expand Down Expand Up @@ -1879,7 +1882,7 @@ do
amplitude1[X] = ampl1data[Y]; // F1 amplitude
amplitude2[X] = ampl2data[Y]; // F2 amplitude
amplitude3[X] = ampl3data[Y]; // F3 amplitude
tab44800[X] = sampledConsonantFlags[Y]; // flags
sampledConsonantFlag[X] = sampledConsonantFlags[Y]; // phoneme data for sampled consonants
pitches[X] = pitch + phase1; // pitch
X++;
phase2--;
Expand Down Expand Up @@ -1924,7 +1927,6 @@ do
// pitch from the center of the current phoneme to the center of the next
// phoneme.


A = 0;
mem44 = 0;
mem49 = 0; // mem49 starts at as 0
Expand Down Expand Up @@ -2143,16 +2145,23 @@ do
//pos48078:
while(1)
{
A = tab44800[Y];
// get the sampled information on the phoneme
A = sampledConsonantFlag[Y];
mem39 = A;

// unvoiced sampled phoneme?
A = A & 248;
if(A != 0)
{
// render the sample for the phoneme
RenderSample(&mem66);

// skip ahead two in the phoneme buffer
Y += 2;
mem48 -= 2;
} else
{
// simulate the glottal pulse and formants
mem56 = multtable[sinus[phase1] | amplitude1[Y]];

carry = 0;
Expand Down Expand Up @@ -2197,20 +2206,32 @@ do
phase3 = 0;
continue;
}

// decrement the count
mem38--;

// is the count non-zero and the sampled flag is zero?
if((mem38 != 0) || (mem39 == 0))
{
// reset the phase of the formants to match the pulse
phase1 += frequency1[Y];
phase2 += frequency2[Y];
phase3 += frequency3[Y];
continue;
}

// voiced sampled phonemes interleave the sample with the
// glottal pulse. The sample flag is non-zero, so render
// the sample for the phoneme.
RenderSample(&mem66);
goto pos48159;
} //while

//--------------------------
// I am sure, but I think the following code is never executed

// The following code is never reached. It's left over from when
// the voiced sample code was part of this loop, instead of part
// of RenderSample();

//pos48315:
int tempA;
phase1 = A ^ 255;
Expand Down Expand Up @@ -2260,7 +2281,6 @@ do
}



//return = (mem39212*mem39213) >> 1
unsigned char trans(unsigned char mem39212, unsigned char mem39213)
{
Expand Down

0 comments on commit 4d9e878

Please sign in to comment.