/* HTS_Vocoder_get_excitation: get excitation of each sample */
static double HTS_Vocoder_get_excitation(HTS_Vocoder * v, const int fprd_index, const int iprd_index, const int nlpf, const double *lpf)
{
   double x;
   int i, j;

   if (nlpf > 0) {
      if (fprd_index == 0) {
         if (v->p1 == 0.0) {
            for (i = 0; i < v->fprd; i++)
               v->pulse_list[i] += HTS_white_noise(v);
            if (v->p != 0.0) {
               HTS_ping_pulse(v, v->fprd + nlpf, v->p, nlpf, lpf);
               v->pc = v->fprd + nlpf;
            }
         } else if (v->p == 0.0) {
            for (i = nlpf; i < v->fprd; i++)
               v->pulse_list[i] += HTS_white_noise(v);
         } else {
            for (i = 0, j = (v->iprd + 1) / 2; i < v->fprd; i++) {
               if ((v->pc + v->p1) <= i) {
                  HTS_ping_pulse(v, i, v->p1, nlpf, lpf);
                  v->pc += v->p1;
               }
               if (!--j) {
                  v->p1 += v->inc;
                  j = v->iprd;
               }
            }
            for (i = v->fprd; i < v->fprd + nlpf; i++) {
               if ((v->pc + v->p) <= i) {
                  HTS_ping_pulse(v, i, v->p, nlpf, lpf);
                  v->pc += v->p;
               }
            }
            for (i = nlpf; i < v->fprd + nlpf; i++)
               HTS_ping_noise(v, i, nlpf, lpf);
         }
      }
      x = v->pulse_list[fprd_index];
   } else {
      if (v->p1 == 0.0)
         x = HTS_white_noise(v);
      else {
         if ((v->pc += 1.0) >= v->p1) {
            x = sqrt(v->p1);
            v->pc -= v->p1;
         } else
            x = 0.0;
      }
      if (iprd_index <= 1)
         v->p1 += v->inc;
   }
   return x;
}
Beispiel #2
0
/* HTS_Vocoder_get_excitation: get excitation of each sample */
static double HTS_Vocoder_get_excitation(HTS_Vocoder * v, const double *lpf)
{
   double x;
   double noise, pulse = 0.0;

   if (v->excite_buff_size > 0) {
      noise = HTS_white_noise(v);
      pulse = 0.0;
      if (v->pitch_of_curr_point == 0.0) {
         HTS_Vocoder_excite_unvoiced_frame(v, noise);
      } else {
         v->pitch_counter += 1.0;
         if (v->pitch_counter >= v->pitch_of_curr_point) {
            pulse = sqrt(v->pitch_of_curr_point);
            v->pitch_counter -= v->pitch_of_curr_point;
         }
         HTS_Vocoder_excite_voiced_frame(v, noise, pulse, lpf);
         v->pitch_of_curr_point += v->pitch_inc_per_point;
      }
      x = v->excite_ring_buff[v->excite_buff_index];
      v->excite_ring_buff[v->excite_buff_index] = 0.0;
      v->excite_buff_index++;
      if (v->excite_buff_index >= v->excite_buff_size)
         v->excite_buff_index = 0;
   } else {
      if (v->pitch_of_curr_point == 0.0) {
         x = HTS_white_noise(v);
      } else {
         v->pitch_counter += 1.0;
         if (v->pitch_counter >= v->pitch_of_curr_point) {
            x = sqrt(v->pitch_of_curr_point);
            v->pitch_counter -= v->pitch_of_curr_point;
         } else {
            x = 0.0;
         }
         v->pitch_of_curr_point += v->pitch_inc_per_point;
      }
   }

   return x;
}
/* HTS_ping_noise: ping noise using low-pass filter */
static void HTS_ping_noise(HTS_Vocoder * v, const int ping_place, const int nlpf, const double *lpf)
{
   int i, j;
   const double power = HTS_white_noise(v);

   for (i = ping_place - nlpf, j = 0; i <= ping_place + nlpf; i++, j++)
      if (0 <= i && i < PULSELISTSIZE) {
         if (j == nlpf)
            v->pulse_list[i] += power * (1.0 - lpf[j]);
         else
            v->pulse_list[i] += power * (0.0 - lpf[j]);
      }
}
Beispiel #4
0
static double HTS_Vocoder_get_excitation(HTS_Vocoder *v, int fprd_index,
                                         int iprd_index)
{
   double x;

   if (v->p1 == 0.0)
      x = HTS_white_noise(v);
   else {
      if ((v->pc += 1.0) >= v->p1) {
         x = sqrt(v->p1);
         v->pc -= v->p1;
      } else
         x = 0.0;
   }
   if (!--iprd_index)
      v->p1 += v->inc;
   return x;
}