PDM编码的软件实现

PDM编码的软件实现

PDM(Pulse-density_modulation)

// Encode samples into pulse-density modulation
// using a first-order sigma-delta modulator
// C/C++ 描述 
// x[s]: signal array
// y[S]: output PDM array
//  qe : running error           
void PDM(double x[s], double y[s], double qe = 0,) // initial running error is zero
{
  for(int n = 0, n < s, ++n)
  {  
      if(x[n] >= qe)
          y[n] = 1;
      else
          y[n] = -1;
      qe = y[n] - x[n] + qe; // calculate the error to feedback 
  }                  
}

参考资料

Wikipedia-Pulse-density_modulation

你可能感兴趣的:(PDM)