@@ -317,9 +317,7 @@ void Render(sam_memory* sam)
317
317
unsigned char phase1 = 0 ; //mem43
318
318
unsigned char phase2 ;
319
319
unsigned char phase3 ;
320
- unsigned char mem66 ;
321
320
unsigned char mem38 ;
322
- unsigned char sample ;
323
321
unsigned char mem40 ;
324
322
unsigned char speedcounter ; //mem45
325
323
unsigned char mem47 ;
@@ -331,7 +329,6 @@ void Render(sam_memory* sam)
331
329
unsigned char mem56 ;
332
330
unsigned char mem44 = 0 ;
333
331
int i ;
334
- int carry ;
335
332
if (sam -> common .phoneme_output [0 ].index == PHONEME_END ) return ; //exit if no data
336
333
337
334
A = 0 ;
@@ -346,63 +343,62 @@ void Render(sam_memory* sam)
346
343
// The parameters are copied from the phoneme to the frame verbatim.
347
344
348
345
349
- // pos47587:
350
- do
351
- {
352
- // get the index
353
- Y = mem44 ;
354
- // get the phoneme at the index
355
- A = sam -> common .phoneme_output [mem44 ].index ;
356
- mem56 = A ;
357
-
358
- // if terminal phoneme, exit the loop
359
- if (A == PHONEME_END ) break ;
360
-
361
- // period phoneme *.
362
- if (A == 1 )
363
- {
364
- // add rising inflection
365
- A = 1 ;
366
- mem48 = 1 ;
367
- //goto pos48376;
368
- AddInflection (sam , mem48 , phase1 );
369
- }
370
- /*
371
- if (A == 2) goto pos48372;
372
- */
373
-
374
- // question mark phoneme?
375
- if (A == 2 )
376
- {
377
- // create falling inflection
378
- mem48 = 255 ;
379
- AddInflection (sam , mem48 , phase1 );
380
- }
381
- // pos47615:
382
-
383
- // get the stress amount (more stress = higher pitch)
384
- phase1 = tab47492 [sam -> common .phoneme_output [Y ].stress + 1 ];
385
-
386
- // get number of frames to write
387
- phase2 = sam -> common .phoneme_output [Y ].length ;
388
- Y = mem56 ;
389
-
390
- // copy from the source to the frames list
391
- do
392
- {
393
- sam -> render .freq_amp [X ].freq1 = get_freq1 (Y , sam -> common .mouth ); // F1 frequency
394
- sam -> render .freq_amp [X ].freq2 = get_freq2 (Y , sam -> common .throat ); // F2 frequency
395
- sam -> render .freq_amp [X ].freq3 = freq3data [Y ]; // F3 frequency
396
- sam -> render .freq_amp [X ].amp1 = ampl1data [Y ]; // F1 amplitude
397
- sam -> render .freq_amp [X ].amp2 = ampl2data [Y ]; // F2 amplitude
398
- sam -> render .freq_amp [X ].amp3 = ampl3data [Y ]; // F3 amplitude
399
- sam -> render .flags [X ] = sampledConsonantFlags [Y ]; // phoneme data for sampled consonants
400
- sam -> render .pitch [X ] = sam -> common .pitch + phase1 ; // pitch
401
- X ++ ;
402
- phase2 -- ;
403
- } while (phase2 != 0 );
404
- mem44 ++ ;
405
- } while (mem44 != RENDER_FRAMES );
346
+ do
347
+ {
348
+ // get the index
349
+ Y = mem44 ;
350
+ // get the phoneme at the index
351
+ A = sam -> common .phoneme_output [mem44 ].index ;
352
+ mem56 = A ;
353
+
354
+ // if terminal phoneme, exit the loop
355
+ if (A == PHONEME_END ) break ;
356
+
357
+ // period phoneme *.
358
+ if (A == 1 )
359
+ {
360
+ // add rising inflection
361
+ A = 1 ;
362
+ mem48 = 1 ;
363
+ //goto pos48376;
364
+ AddInflection (sam , mem48 , phase1 );
365
+ }
366
+ /*
367
+ if (A == 2) goto pos48372;
368
+ */
369
+
370
+ // question mark phoneme?
371
+ if (A == 2 )
372
+ {
373
+ // create falling inflection
374
+ mem48 = 255 ;
375
+ AddInflection (sam , mem48 , phase1 );
376
+ }
377
+ // pos47615:
378
+
379
+ // get the stress amount (more stress = higher pitch)
380
+ phase1 = tab47492 [sam -> common .phoneme_output [Y ].stress + 1 ];
381
+
382
+ // get number of frames to write
383
+ phase2 = sam -> common .phoneme_output [Y ].length ;
384
+ Y = mem56 ;
385
+
386
+ // copy from the source to the frames list
387
+ do
388
+ {
389
+ sam -> render .freq_amp [X ].freq1 = get_freq1 (Y , sam -> common .mouth ); // F1 frequency
390
+ sam -> render .freq_amp [X ].freq2 = get_freq2 (Y , sam -> common .throat ); // F2 frequency
391
+ sam -> render .freq_amp [X ].freq3 = freq3data [Y ]; // F3 frequency
392
+ sam -> render .freq_amp [X ].amp1 = ampl1data [Y ]; // F1 amplitude
393
+ sam -> render .freq_amp [X ].amp2 = ampl2data [Y ]; // F2 amplitude
394
+ sam -> render .freq_amp [X ].amp3 = ampl3data [Y ]; // F3 amplitude
395
+ sam -> render .flags [X ] = sampledConsonantFlags [Y ]; // phoneme data for sampled consonants
396
+ sam -> render .pitch [X ] = sam -> common .pitch + phase1 ; // pitch
397
+ X ++ ;
398
+ phase2 -- ;
399
+ } while (phase2 != 0 );
400
+ mem44 ++ ;
401
+ } while (mem44 != OUTPUT_PHONEMES );
406
402
407
403
408
404
// -------------------
712
708
sam -> render .pitch [i ] -= (sam -> render .freq_amp [i ].freq1 >> 1 );
713
709
}
714
710
}
711
+ OutputFrames (sam , mem48 );
712
+ }
715
713
716
- phase1 = 0 ;
717
- phase2 = 0 ;
718
- phase3 = 0 ;
719
- mem49 = 0 ;
720
- speedcounter = 72 ; //sam standard speed
714
+ void OutputFrames (sam_memory * sam , unsigned char frame_count ) {
721
715
722
- // RESCALE AMPLITUDE
723
- //
724
- // Rescale volume from a linear scale to decibels.
725
- //
716
+ unsigned char phase1 = 0 ;
717
+ unsigned char phase2 = 0 ;
718
+ unsigned char phase3 = 0 ;
719
+ unsigned char speedcounter = 72 ; //sam standard speed
720
+ unsigned char count ;
721
+ unsigned char glottal_pulse ;
722
+ unsigned char sample ;
723
+ unsigned char mem66 = 0 ;
726
724
727
- //amplitude rescaling
728
- for (i = RENDER_FRAMES - 1 ; i >=0 ; i -- )
725
+ // RESCALE AMPLITUDE
726
+ // Rescale volume from a linear scale to decibels.
727
+ for (int i = RENDER_FRAMES - 1 ; i >=0 ; i -- )
729
728
{
730
729
sam -> render .freq_amp [i ].amp1 = amplitudeRescale [sam -> render .freq_amp [i ].amp1 ];
731
730
sam -> render .freq_amp [i ].amp2 = amplitudeRescale [sam -> render .freq_amp [i ].amp2 ];
734
733
735
734
Y = 0 ;
736
735
A = sam -> render .pitch [0 ];
737
- mem44 = A ;
736
+ glottal_pulse = A ;
738
737
X = A ;
739
- mem38 = A - (A >>2 ); // 3/4*A ???
738
+ count = A - (A >>2 ); // 3/4*A ???
740
739
741
- if (debug )
742
- {
743
- PrintOutput (sam -> render .flags , sam -> render .freq_amp , sam -> render .pitch , mem48 );
744
- }
740
+ if (debug )
741
+ {
742
+ PrintOutput (sam -> render .flags , sam -> render .freq_amp , sam -> render .pitch , frame_count );
743
+ }
745
744
746
745
// PROCESS THE FRAMES
747
746
//
@@ -767,18 +766,18 @@ if (debug)
767
766
// render the sample for the phoneme
768
767
RenderSample (sam , & mem66 , sample );
769
768
770
- // skip ahead two in the phoneme buffer
769
+ // skip ahead two in the fram ebuffer
771
770
Y += 2 ;
772
- mem48 -= 2 ;
771
+ frame_count -= 2 ;
773
772
} else
774
773
{
775
774
// simulate the glottal pulse and formants
776
- mem56 = multtable [sinus [phase1 ] | sam -> render .freq_amp [Y ].amp1 ];
775
+ unsigned char accum = multtable [sinus [phase1 ] | sam -> render .freq_amp [Y ].amp1 ];
777
776
778
- carry = 0 ;
779
- if ((mem56 + multtable [sinus [phase2 ] | sam -> render .freq_amp [Y ].amp2 ] ) > 255 ) carry = 1 ;
780
- mem56 += multtable [sinus [phase2 ] | sam -> render .freq_amp [Y ].amp2 ];
781
- A = mem56 + multtable [rectangle [phase3 ] | sam -> render .freq_amp [Y ].amp3 ] + (carry ?1 :0 );
777
+ int carry = 0 ;
778
+ if ((accum + multtable [sinus [phase2 ] | sam -> render .freq_amp [Y ].amp2 ] ) > 255 ) carry = 1 ;
779
+ accum += multtable [sinus [phase2 ] | sam -> render .freq_amp [Y ].amp2 ];
780
+ A = accum + multtable [rectangle [phase3 ] | sam -> render .freq_amp [Y ].amp3 ] + (carry ?1 :0 );
782
781
A = ((A + 136 ) & 255 ) >> 4 ; //there must be also a carry
783
782
//mem[54296] = A;
784
783
@@ -789,26 +788,26 @@ if (debug)
789
788
Y ++ ; //go to next amplitude
790
789
791
790
// decrement the frame count
792
- mem48 -- ;
791
+ frame_count -- ;
793
792
}
794
793
795
794
// if the frame count is zero, exit the loop
796
- if (mem48 == 0 ) return ;
795
+ if (frame_count == 0 ) return ;
797
796
speedcounter = sam -> common .speed ;
798
797
pos48155 :
799
798
800
799
// decrement the remaining length of the glottal pulse
801
- mem44 -- ;
800
+ glottal_pulse -- ;
802
801
803
802
// finished with a glottal pulse?
804
- if (mem44 == 0 )
803
+ if (glottal_pulse == 0 )
805
804
{
806
805
pos48159 :
807
806
// fetch the next glottal pulse length
808
807
A = sam -> render .pitch [Y ];
809
- mem44 = A ;
808
+ glottal_pulse = A ;
810
809
A = A - (A >>2 );
811
- mem38 = A ;
810
+ count = A ;
812
811
813
812
// reset the formant wave generators to keep them in
814
813
// sync with the glottal pulse
@@ -819,11 +818,10 @@ if (debug)
819
818
}
820
819
821
820
// decrement the count
822
- mem38 -- ;
821
+ count -- ;
823
822
824
823
// is the count non-zero and the sampled flag is zero?
825
- if ((mem38 != 0 ) || (sample == 0 ))
826
- {
824
+ if ((count != 0 ) || (sample == 0 )) {
827
825
// reset the phase of the formants to match the pulse
828
826
phase1 += sam -> render .freq_amp [Y ].freq1 ;
829
827
phase2 += sam -> render .freq_amp [Y ].freq2 ;
@@ -846,12 +844,9 @@ if (debug)
846
844
847
845
void AddInflection (sam_memory * sam , unsigned char mem48 , unsigned char phase1 )
848
846
{
849
- //pos48372:
850
- // mem48 = 255;
851
- //pos48376:
852
847
853
848
// store the location of the punctuation
854
- unsigned char mem49 = X ;
849
+ unsigned char punctuation = X ;
855
850
A = X ;
856
851
int Atemp = A ;
857
852
@@ -866,26 +861,24 @@ void AddInflection(sam_memory* sam, unsigned char mem48, unsigned char phase1)
866
861
while ( (A = sam -> render .pitch [X ]) == 127 ) X ++ ;
867
862
868
863
869
- pos48398 :
870
- //48398: CLC
871
- //48399: ADC 48
872
-
873
- // add the inflection direction
874
- A += mem48 ;
875
- phase1 = A ;
876
-
877
- // set the inflection
878
- sam -> render .pitch [X ] = A ;
879
- pos48406 :
880
-
881
- // increment the position
882
- X ++ ;
883
-
884
- // exit if the punctuation has been reached
885
- if (X == mem49 ) return ; //goto pos47615;
886
- if (sam -> render .pitch [X ] == 255 ) goto pos48406 ;
887
- A = phase1 ;
888
- goto pos48398 ;
864
+ while (1 ) {
865
+
866
+ // add the inflection direction
867
+ A += mem48 ;
868
+ phase1 = A ;
869
+
870
+ // set the inflection
871
+ sam -> render .pitch [X ] = A ;
872
+ do {
873
+
874
+ // increment the position
875
+ X ++ ;
876
+
877
+ // exit if the punctuation has been reached
878
+ if (X == punctuation ) return ; //goto pos47615;
879
+ } while (sam -> render .pitch [X ] == 255 );
880
+ A = phase1 ;
881
+ }
889
882
}
890
883
891
884
static inline unsigned char trans (unsigned char mem39212 , unsigned char mem39213 ) {
0 commit comments