42 using namespace Nsound;
50 #define THIS_FILE "FilterLeastSquaresFIR_UnitTest.cc"
68 freqs << 0.0 << 100.0 << 100.0 << 500.0;
69 amplitude << 1.0 << 1.0 << 0.0 << 0.0;
73 Buffer noise(
"gold/Filter_noise.wav");
75 cout <<
TEST_HEADER <<
"Testing FilterLeastSquaresFIR::filter(input) ...";
84 Buffer gold(
"gold/FilterLeastSquaresFIR_out1.wav");
93 <<
"Output did not match gold file!"
97 diff.
plot(
"data - gold");
109 cout << TEST_HEADER <<
"Testing FilterLeastSquaresFIR::filter(input) ..."
120 <<
"Output did not match gold file!"
123 diff.
plot(
"data - gold");
139 freqs << 0.0 << 100.0 << 100.0 << 500.0;
140 amplitude << 0.0 << 0.0 << 1.0 << 1.0;
144 cout << TEST_HEADER <<
"Testing FilterLeastSquaresFIR::filter(input) ...";
146 data = f.
filter(0.9 * noise);
151 gold =
Buffer(
"gold/FilterLeastSquaresFIR_out2.wav");
159 <<
"Output did not match gold file!"
162 diff.
plot(
"data - gold");
174 cout << TEST_HEADER <<
"Testing FilterLeastSquaresFIR::filter(input) ...";
176 data = f.
filter(0.9 * noise);
184 <<
"Output did not match gold file!"
187 diff.
plot(
"data - gold");
199 cout << TEST_HEADER <<
"Testing FilterLeastSquaresFIR::setWindow() ...";
204 freqs << 0.0 << 30.0 << 30.0 << 500.0;
205 amplitude << 1.0 << 1.0 << 0.0 << 0.0;
217 gold =
Buffer(
"gold/FilterLeastSquaresFIR_out3.wav");
226 <<
"Output did not match gold file!"
229 diff.
plot(
"data - gold");
238 cout << SUCCESS << endl;
void makeKernel(const Buffer &freq_axis, const Buffer &litude_axis)
void FilterLeastSquaresFIR_UnitTest()
static void show()
Acutally draw the plots to the screen.
AudioStream filter(const AudioStream &x)
void setWindow(WindowType type)
void plot(const std::string &title="Buffer") const
Requires matplotlib. Creates a plot of this Buffer.
Buffer getAbs() const
Modifies a copy of the Buffer by making any negative value positive.
#define TEST_ERROR_HEADER
static void setIEEEFloat(boolean flag)
void abs()
Modifies the Buffer by making any negative value positive.
A Buffer for storing audio samples.
Buffer getFrequencyResponse(const uint32 n_fft=8192)
A FIR filter that is defined as the least square error to the desired requency response.
static void setDefaultSampleSize(uint32 size)
float64 getMax() const
Returns the maximum sample value in the Buffer.
Buffer getdB() const
Returns the Buffer in dB.