static float glottalSource(void) { float x0; if (t0 == 0) { return 0; } if (nper < nopen) { x0 = (a1 * x1) + (a2 * x2); x2 = x1; x1 = x0; } else { x0 = (b1 * x1) - c1; x1 = x0; } if (nper >= t0) { nper = 0; /* begin pitchSynchronousReset */ if ((frame[F0]) > 0) { /* begin voicedPitchSynchronousReset */ pitch = frame[F0]; addFlutter(); /* begin addJitter */ pitch += ((((nextRandom()) - 32767) * (frame[Jitter])) / 32768.0) * (frame[F0]); /* begin addFrequencyDiplophonia */ if ((periodCount % 2) == 0) { pitch += ((frame[Diplophonia]) * (frame[F0])) * (1.0 - (frame[Ro])); } else { pitch -= ((frame[Diplophonia]) * (frame[F0])) * (1.0 - (frame[Ro])); } if (pitch < 0) { pitch = 0; } t0 = ((sqInt) (samplingRate / pitch) ); nmod = t0; if ((frame[Voicing]) > 0) { nmod = ((sqInt) nmod >> 1); }
static void synthesizeFrameintostartingAt(float *aKlattFrame, short *buffer, sqInt startIndex) { float ampGain; float aspiration; float aspirationNoise; float bypass; float friction; float frictionNoise; float gain; float glotout; sqInt index; float noise; float out; float parGlotout; float parVoicing; float source; sqInt temp; sqInt top; float turbulence; float voice; float voicing; float x0; float out1; float answer; float p1; float answer1; float p11; float answer2; float p12; float answer3; float p13; float answer4; float p14; float answer5; float p15; float answer6; float p16; float answer7; float p17; double answer8; double p18; float answer9; float p19; double answer10; double p110; float answer11; float p111; float answer12; float p112; setCurrentFrame(aKlattFrame); if (pitch > 0) { voicing = (pow(2.0,((((frame[Voicing]) - 7) - 87.0) / 6.0))) * 32.767; parVoicing = (pow(2.0,(((frame[Voicing]) - 87.0) / 6.0))) * 32.767; turbulence = ((pow(2.0,(((frame[Turbulence]) - 87.0) / 6.0))) * 32.767) * 0.1; } else { voicing = (parVoicing = (turbulence = 0.0)); } friction = ((pow(2.0,(((frame[Friction]) - 87.0) / 6.0))) * 32.767) * 0.25; aspiration = ((pow(2.0,(((frame[Aspiration]) - 87.0) / 6.0))) * 32.767) * 0.05; /* -26.0 dB */ /* Flod overall gain into output resonator (low-pass filter) */ bypass = ((pow(2.0,(((frame[Bypass]) - 87.0) / 6.0))) * 32.767) * 0.05; gain = (frame[Gain]) - 3; if (gain <= 0) { gain = 57; } ampGain = (pow(2.0,((gain - 87.0) / 6.0))) * 32.767; resonatorfrequencybandwidthgain(Rout, 0, samplingRate, ampGain); noise = nlast; index = startIndex; top = (samplesPerFrame + startIndex) - 1; while (index <= top) { /* Get low-passed random number for aspiration and friction noise */ /* radom number between -8196.0 and 8196.0 */ /* Tilt down noise spectrum by soft low-pass filter having a pole near the origin in the z-plane. */ noise = (((double) ((nextRandom()) - 32768) )) / 4.0; noise += 0.75 * nlast; /* Amplitude modulate noise (reduce noise amplitude during second half of glottal period) if voicing simultaneously present. */ nlast = noise; if (nper > nmod) { noise = noise * 0.5; } /* Compute voicing waveform. */ frictionNoise = friction * noise; /* begin glottalSource */ if (t0 == 0) { voice = 0; goto l1; } if (nper < nopen) { x0 = (a1 * x1) + (a2 * x2); x2 = x1; x1 = x0; } else { x0 = (b1 * x1) - c1; x1 = x0; } if (nper >= t0) { nper = 0; /* begin pitchSynchronousReset */ if ((frame[F0]) > 0) { /* begin voicedPitchSynchronousReset */ pitch = frame[F0]; addFlutter(); /* begin addJitter */ pitch += ((((nextRandom()) - 0x7FFF) * (frame[Jitter])) / 32768.0) * (frame[F0]); /* begin addFrequencyDiplophonia */ if ((periodCount % 2) == 0) { pitch += ((frame[Diplophonia]) * (frame[F0])) * (1.0 - (frame[Ro])); } else { pitch -= ((frame[Diplophonia]) * (frame[F0])) * (1.0 - (frame[Ro])); } if (pitch < 0) { pitch = 0; } t0 = ((sqInt)(samplingRate / pitch)); nmod = t0; if ((frame[Voicing]) > 0) { nmod = ((sqInt) nmod >> 1); } nopen = ((sqInt)(t0 * (frame[Ro]))); rorark(frame[Ro], frame[Ra], frame[Rk]); /* begin addShimmer */ x1 += ((((nextRandom()) - 0x7FFF) * (frame[Shimmer])) / 32768.0) * x1; if (x1 > 0) { x1 = 0; } /* begin addAmplitudeDiplophonia */ if (!((periodCount % 2) == 0)) { x1 = x1 * (1.0 - (frame[Diplophonia])); if (x1 > 0) { x1 = 0; } } periodCount = (periodCount + 1) % 0xFFFF; } else {