31int win_bartlett (
double *w,
int n,
int win_type);
32int win_bartlett_hann (
double *w,
int n,
int win_type);
33int win_blackman (
double *w,
int n,
int win_type);
34int win_blackman_harris (
double *w,
int n,
int win_type);
35int win_blackman_nuttall(
double *w,
int n,
int win_type);
36int win_cheby (
double *w,
int n,
double param);
37int win_cos (
double *w,
int n,
int win_type);
38int win_flat_top (
double *w,
int n,
int win_type);
39int win_gaussian (
double *w,
int n,
int win_type,
double sigma);
40int win_hamming (
double *w,
int n,
int win_type);
41int win_hann (
double *w,
int n,
int win_type);
42int win_kaiser (
double* w,
int n,
int win_type,
double param);
43int win_lanczos (
double *w,
int n,
int win_type);
44int win_nuttall (
double *w,
int n,
int win_type);
45int win_rect (
double *w,
int n);
188#ifdef DOXYGEN_RUSSIAN
329int DSPL_API
window(
double* w,
int n,
int win_type,
double param)
331 switch(win_type & DSPL_WIN_MASK)
333 case DSPL_WIN_BARTLETT:
334 return win_bartlett(w, n, win_type);
335 case DSPL_WIN_BARTLETT_HANN:
336 return win_bartlett_hann(w, n, win_type);
337 case DSPL_WIN_BLACKMAN:
338 return win_blackman(w, n, win_type);
339 case DSPL_WIN_BLACKMAN_HARRIS:
340 return win_blackman_harris(w, n, win_type);
341 case DSPL_WIN_BLACKMAN_NUTTALL:
342 return win_blackman_nuttall(w, n, win_type);
344 return win_cheby(w, n, param);
345 case DSPL_WIN_FLAT_TOP:
346 return win_flat_top(w, n, win_type);
347 case DSPL_WIN_GAUSSIAN:
348 return win_gaussian(w, n, win_type, param);
349 case DSPL_WIN_HAMMING:
350 return win_hamming(w, n, win_type);
352 return win_hann(w, n, win_type);
353 case DSPL_WIN_KAISER:
354 return win_kaiser(w, n, win_type, param);
355 case DSPL_WIN_LANCZOS:
356 return win_lanczos(w, n, win_type);
357 case DSPL_WIN_NUTTALL:
358 return win_nuttall(w, n, win_type);
360 return win_rect(w, n);
362 return win_cos(w, n, win_type);
374int win_bartlett(
double *w,
int n,
int win_type)
384 switch(win_type & DSPL_WIN_SYM_MASK)
386 case DSPL_WIN_SYMMETRIC: x = (double)(n-1);
break;
387 case DSPL_WIN_PERIODIC : x = (double)n;
break;
391 for(i = 0; i < n; i++)
393 w[i] = 2.0 / x * (x * 0.5-fabs((
double)i - x * 0.5));
405int win_bartlett_hann(
double *w,
int n,
int win_type)
416 switch(win_type & DSPL_WIN_SYM_MASK)
418 case DSPL_WIN_SYMMETRIC: x = 1.0/(double)(n-1);
break;
419 case DSPL_WIN_PERIODIC : x = 1.0/(double)n;
break;
426 w[i] = 0.62 - 0.48 * fabs(y-0.5)-0.38*cos(M_2PI*y);
439int win_blackman(
double *w,
int n,
int win_type)
450 switch(win_type & DSPL_WIN_SYM_MASK)
452 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
453 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
460 w[i] = 0.42 - 0.5* cos(y)+0.08*cos(2.0*y);
472int win_blackman_harris(
double *w,
int n,
int win_type)
487 switch(win_type & DSPL_WIN_SYM_MASK)
489 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
490 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
497 w[i] = a0 - a1* cos(y)+a2*cos(2.0*y)-a3*cos(3.0*y);
509int win_blackman_nuttall(
double *w,
int n,
int win_type)
513 double a0 = 0.3635819;
514 double a1 = 0.4891775;
515 double a2 = 0.1365995;
516 double a3 = 0.0106411;
525 switch(win_type & DSPL_WIN_SYM_MASK)
527 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
528 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
535 w[i] = a0 - a1* cos(y)+a2*cos(2.0*y)-a3*cos(3.0*y);
551int win_cheby(
double *w,
int n,
double param)
554 double z, dz,
sum = 0, wmax=0, r1, x0, chx, chy, in;
565 r1 = pow(10, param/20);
566 x0 = cosh((1.0/(
double)(n-1)) * acosh(r1));
580 for(k = 0; k < m+2; k++)
582 z = (double)(k - m) - dz;
585 for(i = 1; i <= m; i++)
587 in = (double)i / (
double)n;
588 chx = x0 * cos(M_PI * in);
590 sum += chy * cos(2.0 * z * M_PI * in);
593 w[k] = r1 + 2.0 *
sum;
613int win_cos(
double *w,
int n,
int win_type)
624 switch(win_type & DSPL_WIN_SYM_MASK)
626 case DSPL_WIN_SYMMETRIC: x = M_PI/(double)(n-1);
break;
627 case DSPL_WIN_PERIODIC : x = M_PI/(double)n;
break;
648int win_flat_top(
double *w,
int n,
int win_type)
664 switch(win_type & DSPL_WIN_SYM_MASK)
666 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
667 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
674 w[i] = a0 - a1* cos(y)+a2*cos(2.0*y)-a3*cos(3.0*y)+a4*cos(4.0*y);
688int win_gaussian(
double *w,
int n,
int win_type,
double alpha)
700 switch(win_type & DSPL_WIN_SYM_MASK)
702 case DSPL_WIN_SYMMETRIC: a = (double)(n-1)*0.5;
break;
703 case DSPL_WIN_PERIODIC : a = (double)(n)*0.5;
break;
708 sigma = 1.0 / (alpha * a);
711 y = ((double)i - a)*sigma;
712 w[i] = exp(-0.5*y*y);
725int win_hamming(
double *w,
int n,
int win_type)
736 switch(win_type & DSPL_WIN_SYM_MASK)
738 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
739 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
744 for(i = 0; i < n; i++)
746 w[i] = 0.54-0.46*cos(y);
758int win_hann(
double *w,
int n,
int win_type)
769 switch(win_type & DSPL_WIN_SYM_MASK)
771 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
772 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
777 for(i = 0; i < n; i++)
779 w[i] = 0.5*(1-cos(y));
789int win_kaiser(
double* w,
int n,
int win_type,
double param)
791 double num, den, x, y, L;
798 switch(win_type & DSPL_WIN_SYM_MASK)
800 case DSPL_WIN_SYMMETRIC: L = (double)(n-1) / 2.0;
break;
801 case DSPL_WIN_PERIODIC : L = (double)n / 2.0;
break;
808 for(i = 0; i < n; i++)
810 x = 2.0*((double)i - L) / (double)n;
811 y = param * sqrt(1.0 - x*x);
825int win_lanczos(
double *w,
int n,
int win_type)
836 switch(win_type & DSPL_WIN_SYM_MASK)
838 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
839 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
844 for(i = 0; i < n; i++)
849 w[i] = sin(y - M_PI)/(y - M_PI);
861int win_nuttall(
double *w,
int n,
int win_type)
865 double a0 = 0.355768;
866 double a1 = 0.487396;
867 double a2 = 0.144232;
868 double a3 = 0.012604;
876 switch(win_type & DSPL_WIN_SYM_MASK)
878 case DSPL_WIN_SYMMETRIC: x = M_2PI/(double)(n-1);
break;
879 case DSPL_WIN_PERIODIC : x = M_2PI/(double)n;
break;
884 for(i = 0; i < n; i++)
886 w[i] = a0 - a1* cos(y)+a2*cos(2.0*y)-a3*cos(3.0*y);
899int win_rect(
double *w,
int n)
908 for(i = 0; i < n; i++)
int DSPL_API sum(double *x, int n, double *s)
#define ERROR_WIN_SYM
Symmetry or periodicity of a given window is not supported.
#define RES_OK
The function completed correctly. No errors.
#define ERROR_PTR
Pointer error. This error means that one of the required pointers (memory to be allocated for) is tra...
#define ERROR_SIZE
Error array size. This error occurs when in addition to the pointer the wrong input is passed to the ...
#define ERROR_WIN_PARAM
window function parameter error. Valid parameter values exist for each parametric window function.
#define ERROR_WIN_TYPE
Unknown window function type.
int DSPL_API cheby_poly1(double *x, int n, int ord, double *y)
Chebyshev polynomial of the first kind order ord
int DSPL_API bessel_i0(double *x, int n, double *y)
Modified Bessel Function of the First Kind – [1].
int DSPL_API window(double *w, int n, int win_type, double param)
Window function calculation.