Nsound  0.9.4
dynamic_filter.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: dynamic_filter.cc 913 2015-08-08 16:41:22Z weegreenblobbie $
4 //
5 //-----------------------------------------------------------------------------
6 
7 // Nsound headers
8 #include <Nsound/NsoundAll.h>
9 
10 using namespace Nsound;
11 
12 int
13 main(void)
14 {
15  // Read in the wavefile.
16  AudioStream input("Temperature_in.wav");
17 
18  // Grab the duration in seconds.
19  float32 duration = input.getDuration();
20 
21  // Create a low pass filter with a kernel of 256 terms.
22  FilterLowPassFIR lpf(input.getSampleRate(), 256, 100);
23 
24  // Create a buffer that will hold cut off frequencies.
25  Buffer frequencies;
26 
27  // Fill it with two lines
28  Sine sin(input.getSampleRate());
29 
30  frequencies << sin.drawLine(0.5 * duration, 8000, 50)
31  << sin.drawLine(0.5 * duration, 50, 8000);
32 
33  // Filter it.
34  AudioStream output = lpf.filter(input, frequencies);
35 
36  // Write to disk.
37  output >> "Temperature_out.wav";
38 
39  AudioPlaybackRt pb(input.getSampleRate(), 2);
40 
41  output * 0.666 >> pb;
42 
43  return 0;
44 }
float64 getDuration() const
Returns the number of seconds of audio data in the stream.
Definition: AudioStream.cc:183
float64 getSampleRate() const
Returns the sample rate of the stream.
Definition: AudioStream.h:217
int main(void)
A Buffer for storing audio samples.
Definition: Buffer.h:60
float float32
Definition: Nsound.h:145
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