Nsound  0.9.4
Functions | Variables
test_filters.cc File Reference
#include <Nsound/NsoundAll.h>
#include "Test.h"
#include <iostream>
Include dependency graph for test_filters.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Variables

static const char * THIS_FILE = "test_filters.cc"
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 43 of file test_filters.cc.

References Nsound::Generator::drawLine(), Nsound::FilterHighPassIIR::filter(), Nsound::FilterHighPassFIR::filter(), Nsound::FilterLowPassFIR::filter(), Nsound::FilterLowPassIIR::filter(), Nsound::FilterBandRejectFIR::filter(), Nsound::FilterBandPassFIR::filter(), Nsound::FilterBandPassIIR::filter(), Nsound::FilterBandRejectIIR::filter(), Nsound::Generator::generate(), TEST_HEADER, Nsound::Tic(), and Nsound::Toc().

44 {
45  Sine sin(44100);
46 
47  Buffer frequency_sweep = sin.drawLine(5.0, 0.0, 1720.0);
48 
49  AudioStream output(44100, 1);
50  AudioStream input(44100, 1);
51 
52  input = sin.generate(5.0, frequency_sweep);
53 
54  input >> "filters_input.wav";
55 
56  Buffer low_freqs = 200.0 * sin.generate(5.0, 1.0) + frequency_sweep;
57 
58  Buffer high_freqs = 200.0 + low_freqs;
59 
60  cout << TEST_HEADER
61  << "testing FilterLowPassFIR ... " << flush;
62 
63  FilterLowPassFIR f1(44100, 256, 880.0);
64 
65  Tic();
66 
67  output = f1.filter(input);
68 
69  cout << Toc() << " seconds"
70  << endl;
71 
72  output >> "filters_fir_low_pass.wav";
73 
74  cout << TEST_HEADER
75  << "testing FilterLowPassIIR ... " << flush;
76 
77  Tic();
78 
79  FilterLowPassIIR f2(44100, 4, 880.0, 0.01);
80 
81  output = f2.filter(input);
82 
83  cout << Toc() << " seconds"
84  << endl;
85 
86  output >> "filters_iir_low_pass.wav";
87 
88  cout << TEST_HEADER
89  << "testing FilterLowPassFIR dynamic filtering... " << flush;
90 
91  Tic();
92 
93  output = f1.filter(input, low_freqs);
94 
95  cout << Toc() << " seconds"
96  << endl;
97 
98  output >> "filters_fir_low_pass_dynamic.wav";
99 
100  cout << TEST_HEADER
101  << "testing FilterLowPassIIR dynamic filtering... " << flush;
102 
103  Tic();
104 
105  output = f2.filter(input, low_freqs);
106 
107  cout << Toc() << " seconds"
108  << endl;
109 
110  output >> "filters_iir_low_pass_dynamic.wav";
111 
112  cout << TEST_HEADER
113  << "testing FilterHighPassFIR ... " << flush;
114 
115  FilterHighPassFIR f3(44100, 256, 880.0);
116 
117  Tic();
118  output = f3.filter(input);
119 
120  cout << Toc() << " seconds"
121  << endl;
122 
123  output >> "filters_fir_high_pass.wav";
124 
125  cout << TEST_HEADER
126  << "testing FilterHighPassIIR ... " << flush;
127 
128  FilterHighPassIIR f4(44100, 4, 880.0, 0.01);
129 
130  Tic();
131  output = f4.filter(input);
132 
133  cout << Toc() << " seconds"
134  << endl;
135 
136  output >> "filters_iir_high_pass.wav";
137 
138  cout << TEST_HEADER
139  << "testing FilterHighPassFIR dynamic filtering... " << flush;
140 
141  Tic();
142  output = f3.filter(input, high_freqs);
143 
144  cout << Toc() << " seconds"
145  << endl;
146 
147  output >> "filters_fir_high_pass_dynamic.wav";
148 
149  cout << TEST_HEADER
150  << "testing FilterHighPassIIR dynamic filtering... " << flush;
151 
152  Tic();
153  output = f4.filter(input, high_freqs);
154 
155  cout << Toc() << " seconds"
156  << endl;
157 
158  output >> "filters_iir_high_pass_dynamic.wav";
159 
160  cout << TEST_HEADER
161  << "testing FilterBandRejectFIR ... " << flush;
162 
163  FilterBandRejectFIR f5(44100, 512, 450.0, 870.0);
164 
165  Tic();
166  output = f5.filter(input);
167 
168  cout << Toc() << " seconds"
169  << endl;
170 
171  output >> "filters_fir_band_reject.wav";
172 
173  cout << TEST_HEADER
174  << "testing FilterBandRejectIIR ... " << flush;
175 
176  FilterBandRejectIIR f6(44100, 4, 440.0, 880.0, 0.01);
177 
178  Tic();
179  output = f6.filter(input);
180 
181  cout << Toc() << " seconds"
182  << endl;
183 
184  output >> "filters_iir_band_reject.wav";
185 
186  cout << TEST_HEADER
187  << "testing FilterBandRejectFIR dynamic filtering... " << flush;
188 
189  Tic();
190 
191  output = f5.filter(input, low_freqs, high_freqs);
192 
193  cout << Toc() << " seconds"
194  << endl;
195 
196  output >> "filters_fir_band_reject_dynamic.wav";
197 
198  cout << TEST_HEADER
199  << "testing FilterBandRejectIIR dynamic filtering... " << flush;
200 
201  Tic();
202 
203  output = f6.filter(input, low_freqs, high_freqs);
204 
205  cout << Toc() << " seconds"
206  << endl;
207 
208  output >> "filters_iir_band_reject_dynamic.wav";
209 
210  cout << TEST_HEADER
211  << "testing FilterBandPassFIR ... " << flush;
212 
213  FilterBandPassFIR f7(44100, 512, 440, 880);
214 
215  Tic();
216  output = f7.filter(input);
217 
218  cout << Toc() << " seconds"
219  << endl;
220 
221  output >> "filters_fir_band_pass.wav";
222 
223  cout << TEST_HEADER
224  << "testing FilterBandPassIIR ... " << flush;
225 
226  FilterBandPassIIR f8(44100, 4, 440.0, 880.0, 0.01);
227 
228  Tic();
229  output = f8.filter(input);
230 
231  cout << Toc() << " seconds"
232  << endl;
233 
234  output >> "filters_iir_band_pass.wav";
235 
236  cout << TEST_HEADER
237  << "testing FilterBandPassFIR dynamic filtering... " << flush;
238 
239  Tic();
240  output = f7.filter(input, low_freqs, high_freqs);
241 
242  cout << Toc() << " seconds"
243  << endl;
244 
245  output >> "filters_fir_band_pass_dynamic.wav";
246 
247  cout << TEST_HEADER
248  << "testing FilterBandPassIIR dynamic filtering... " << flush;
249 
250  Tic();
251  output = f8.filter(input, low_freqs, high_freqs);
252 
253  cout << Toc() << " seconds"
254  << endl;
255 
256  output >> "filters_iir_band_pass_dynamic.wav";
257 
258  return 0;
259 }
#define TEST_HEADER
Definition: Test.h:45
A class for filtering audio in the frequecy domain.
A class for filtering audio in the frequecy domain.
A Buffer for storing audio samples.
Definition: Buffer.h:60
Nsound::float64 Toc()
Definition: TicToc.cc:42
void Tic()
Definition: TicToc.cc:37
DOXME.
Definition: Sine.h:43

Variable Documentation

const char* THIS_FILE = "test_filters.cc"
static

Definition at line 41 of file test_filters.cc.