even more stuff
This commit is contained in:
9
core/src/dsp/window/blackman.h
Normal file
9
core/src/dsp/window/blackman.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "cosine.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double blackman(double n, double N) {
|
||||
const double coefs[] = { 0.42, 0.5, 0.08 };
|
||||
return cosine(n, N, coefs, sizeof(coefs) / sizeof(double));
|
||||
}
|
||||
}
|
||||
10
core/src/dsp/window/blackman_harris.h
Normal file
10
core/src/dsp/window/blackman_harris.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#include "cosine.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double blackmanHarris(double n, double N) {
|
||||
const double coefs[] = { 0.35875, 0.48829, 0.14128, 0.01168 };
|
||||
return cosine(n, N, coefs, sizeof(coefs) / sizeof(double));
|
||||
}
|
||||
}
|
||||
10
core/src/dsp/window/blackman_nuttall.h
Normal file
10
core/src/dsp/window/blackman_nuttall.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#include "cosine.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double blackmanNuttall(double n, double N) {
|
||||
const double coefs[] = { 0.3635819, 0.4891775, 0.1365995, 0.0106411 };
|
||||
return cosine(n, N, coefs, sizeof(coefs) / sizeof(double));
|
||||
}
|
||||
}
|
||||
17
core/src/dsp/window/cosine.h
Normal file
17
core/src/dsp/window/cosine.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include "../math/constants.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double cosine(double n, double N, const double* coefs, int coefCount) {
|
||||
assert(coefCount > 0);
|
||||
double win = 0.0;
|
||||
double sign = 1.0;
|
||||
for (int i = 0; i < coefCount; i++) {
|
||||
win += sign * coefs[i] * cos((double)i * 2.0 * DB_M_PI * n / N);
|
||||
sign = -sign;
|
||||
}
|
||||
return win;
|
||||
}
|
||||
}
|
||||
9
core/src/dsp/window/hamming.h
Normal file
9
core/src/dsp/window/hamming.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "cosine.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double hamming(double n, double N) {
|
||||
const double coefs[] = { 0.54, 0.46 };
|
||||
return cosine(n, N, coefs, sizeof(coefs) / sizeof(double));
|
||||
}
|
||||
}
|
||||
9
core/src/dsp/window/hann.h
Normal file
9
core/src/dsp/window/hann.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "cosine.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double hann(double n, double N) {
|
||||
const double coefs[] = { 0.5, 0.5 };
|
||||
return cosine(n, N, coefs, sizeof(coefs) / sizeof(double));
|
||||
}
|
||||
}
|
||||
9
core/src/dsp/window/nuttall.h
Normal file
9
core/src/dsp/window/nuttall.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "cosine.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double nuttall(double n, double N) {
|
||||
const double coefs[] = { 0.355768, 0.487396, 0.144232, 0.012604 };
|
||||
return cosine(n, N, coefs, sizeof(coefs) / sizeof(double));
|
||||
}
|
||||
}
|
||||
8
core/src/dsp/window/rectangular.h
Normal file
8
core/src/dsp/window/rectangular.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include "cosine.h"
|
||||
|
||||
namespace dsp::window {
|
||||
inline double rectangular(double n, double N) {
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user