C
C
cyber_genius2014-02-05 17:04:12
Microcontrollers
cyber_genius, 2014-02-05 17:04:12

What are the libraries for DSP (digital signal processing) in C/C++?

Considered many different options, but there either in a closed form (without source code), or for certain platforms. You need elementary, just a function and what to put where. I know that there are all sorts of matlabs, but for my practice this is of little use. For example, you need to do autocorrelation, median, fft, dwt, cwt, iir, fir, and so on. In general, everything that is on the topic, where there is more code with explanations and fewer formulas. Functions should be cross-platform and preferably in C, i.e. work under x86 and under ARM and under anything where there is a C compiler.
As examples of what you need:

FFT and DWT code:
/*******************************************************************************
* @brief One step 1D 5/3 discrete wavelet transform.
* @param in	The input data array.
* @param out The output data array.
* @param w The length
*******************************************************************************/
void dwt_53_1d( int16_t *in, int16_t *out, const uint32_t w )
{
  int wt = w - 2, i, j;
  int16_t *l, *h;
  l = out; h = &out[(w>>1) + (w&1)];
  h[0] = in[1] - ((in[0] + in[2])>>1);
  l[0] = in[0] + (h[0]>>1);

  for(i=2,j=1; i < wt; i+=2,j++)
  {
    h[j] = in[i+1] - ((in[i] + in[i+2])>>1);
    l[j] = in[i] + ((h[j-1] + h[j])>>2);
  }
  if(w&1)
  {
    l[j] = in[i] + (h[j-1]>>1);
  }
  else
  {
    h[j] = in[i+1] - in[i];
    l[j] = in[i] + ((h[j-1] + h[j])>>2);
  }
}

/*******************************************************************************
* @brief >Compute fast Fourier transform
* @param >signal buffer for transform
* @param >output data
* @param >buffer length
* @param >1 - forward transform, -1 backward transform
* @note  >buffer length must be equal 64,128,256 etc.
* @verbm >re im и к-во точек исходного массива. потом 1 - прямое, -1 обратное преобразование
* есть ограничение  - массив должен быть кратен 2 - лучше 64,128,256 и т.д
* re это массив который вводится (реальная часть), im можно обнулить просто (вещественная часть)
*******************************************************************************/
void fft( float *re, float *im, unsigned long n, int isign )
{
  unsigned long i, j, k, l, le, le1, ip, n2;
  float wpr, wpi, wr, wi, wtr, wti;

  n2 = n>>1;
  j = 1;
  for(i=0; i<n-1; i++)
  {
    if(i<j)
    {
      wtr     = re[j-1];
      wti     = im[j-1];
      re[j-1] = re[i];
      im[j-1] = im[i];
      re[i]   = wtr;
      im[i]   = wti;
    }
    k = n2;
    while(k<j){
      j -= k;
      k >>= 1;
    }
    j += k;
  }
  l=1;
  k=n;
  while(k>>=1)
  {
    le1 = (le=1<<l++) >> 1;
    wtr = PI / (float)le1;
    wpr = cos(wtr); wpi = -isign*sin(wtr);
    wr = 1.0;       wi = 0.0;
    for(j=0; j<le1; j++)
    {
      for(i=j; i<n; i+=le)
      {
        ip = i + le1;
        wtr    = wr*re[ip] - wi*im[ip];
        wti    = wi*re[ip] + wr*im[ip];
        re[ip] = re[i] - wtr;
        im[ip] = im[i] - wti;
        re[i]  = re[i] + wtr;
        im[i]  = im[i] + wti;
      }
      wr = (wtr=wr)*wpr - wi*wpi;
      wi = wi*wpr + wtr*wpi;
    }
  }
}


As you can see, everything is clear and nothing more.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rosperitus, 2014-02-05
@rosperitus

aquila-dsp.org/features
https://github.com/jgaeddert/liquid-dsp

C
cyber_genius, 2014-02-06
@cyber_genius

added the code in the question, someone may need it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question