Nsound  0.9.4
test_moving_average.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: test_moving_average.cc 874 2014-09-08 02:21:29Z weegreenblobbie $
4 //
5 //-----------------------------------------------------------------------------
6 
7 // Nsound headers
8 #include <Nsound/NsoundAll.h>
9 
10 using namespace Nsound;
11 
12 //-----------------------------------------------------------------------------
13 int
14 main(void)
15 {
16  float64 sr = 48000.0;
17 
18  Sine sine(sr);
19 
20  // Draw a pulse.
21  Buffer input = sine.silence(0.25)
22  << sine.drawLine(0.25, 1.0, 1.0)
23  << sine.silence(0.25);
24 
25  input += sine.whiteNoise(0.75) * 0.25;
26 
27  input.plot("noisy input");
28 
29  FilterMovingAverage fma(101);
30 
31  Buffer output = fma.filter(input);
32 
33  output.plot("filtered output");
34 
35  Plotter::show();
36 
37  return 0;
38 }
39 
static void show()
Acutally draw the plots to the screen.
Definition: Plotter.cc:252
void plot(const std::string &title="Buffer") const
Requires matplotlib. Creates a plot of this Buffer.
Definition: Buffer.cc:1551
double float64
Definition: Nsound.h:146
Buffer silence(const float64 &duration) const
This method generates silence.
Definition: Generator.cc:1310
AudioStream filter(const AudioStream &x)
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer whiteNoise(const float64 &duration) const
This method generates noise from a uniform distribution.
Definition: Generator.cc:1325
int main(void)
Buffer drawLine(const float64 &duration, const float64 &amplitude_start, const float64 &amplitude_finish) const
This method draws a linear line beteween 2 points.
Definition: Generator.cc:464
DOXME.
Definition: Sine.h:43
float64 sr
Definition: example3.cc:24