Nsound  0.9.4
demo-delayline.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: bebot.cc 887 2015-04-26 02:49:19Z weegreenblobbie $
4 //
5 //-----------------------------------------------------------------------------
6 
7 #include <Nsound/NsoundAll.h>
8 
9 #include <iostream>
10 
11 using std::cout;
12 using std::cerr;
13 using std::endl;
14 
15 using namespace Nsound;
16 
17 int
18 main(void)
19 {
20  AudioStream as1("california.wav");
21 
22  float64 sr = as1.getSampleRate();
23  float64 dur = as1.getDuration();
24 
26 
27  Generator gen(sr);
28 
29  DelayLine dl(sr, dur);
30 
31  Buffer dt_line = gen.drawLine(dur, 0.01, 0.25);
32 
33  Buffer out = dl.delay(as1[0], dt_line);
34 
35  out += as1[0];
36 
37  out.normalize();
38  out *= 0.666;
39 
40  out << gen.silence(0.5);
41 
42  out >> "dt-cali.wav";
43 
44  return 0;
45 }
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
double float64
Definition: Nsound.h:146
Buffer silence(const float64 &duration) const
This method generates silence.
Definition: Generator.cc:1310
void normalize()
Multiplies the Buffer by a constant gain so the peak sample has magnitude 1.0.
Definition: Buffer.cc:1064
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer delay(const Buffer &x, const Buffer &delay_time)
Definition: DelayLine.cc:58
static void setDefaultSampleRate(const int32 rate)
Definition: Wavefile.cc:70
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
int main(void)
A class the provides draw utilities and a wavetable oscillator.
Definition: Generator.h:50
float64 sr
Definition: example3.cc:24