Nsound  0.9.4
Functions
bebot.cc File Reference
#include <Nsound/NsoundAll.h>
#include <iostream>
Include dependency graph for bebot.cc:

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 18 of file bebot.cc.

References Nsound::Generator::addSlaveSync(), Nsound::Generator::drawLine(), Nsound::FilterLowPassIIR::filter(), Nsound::Generator::generate(), Nsound::GeneratorDecay::generate2(), Nsound::Buffer::getMin(), Nsound::Buffer::normalize(), Nsound::Generator::silence(), and sr.

19 {
20  float64 sr = 44100.0;
21 //~ float64 freq = 110.0;
22 
23 //~ float64 T = 10.0 / freq;
24 
25  FilterLowPassIIR lpf(sr, 6, 80, 0.05);
26 
27  Sine gen(sr);
28  Triangle gent(sr, 0.02, 0.02);
29 
30  GeneratorDecay gend(sr);
31 
32  gend.addSlaveSync(gen);
33 //~ gend.addSlaveSync(gent);
34 
35  AudioStream aout(sr, 1);
36 
37  //-------------------------------------------------------------------------
38  // Const frequency, n harmonics ramp up
39 
40  Buffer freqs = gen.drawLine(2, 49.0, 49.0);
41  Buffer Ks = gen.drawLine(2, 275, 8000.0);
42  Buffer alpha = gen.drawLine(2, 6, 36);
43  Buffer f_cut = gen.drawLine(2, 1000, 8000);
44 
45  aout << gen.silence(0.5);
46 
47  Buffer temp = gend.generate2(2, freqs, alpha);
48  temp *= gen.generate(2, Ks);
49 
50  temp -= temp.getMin();
51 
52  temp.normalize();
53 
54  temp *= gent.generate(2, freqs);
55 
56  aout << lpf.filter(temp, f_cut);
57 
58  //-------------------------------------------------------------------------
59  // Frequency ramp, n harmonics constant
60 
61  aout << gen.silence(0.5);
62 
63  freqs = gen.drawLine(2.0, 49, 600.0);
64  Ks = gen.drawLine(2.0, 8000, 8000);
65 
66  temp = gend.generate2(2, freqs, 36);
67  temp *= gen.generate(2, Ks);
68 
69  temp -= temp.getMin();
70  temp.normalize();
71 
72  temp *= gent.generate(2, freqs);
73 
74  aout << lpf.filter(temp, 8000);
75 
76  //-------------------------------------------------------------------------
77  // Frequency const, n harmonics ramp down
78 
79  aout << gen.silence(0.5);
80 
81  freqs = gen.drawLine(2.0, 600, 600.0);
82  Ks = gen.drawLine(2.0, 8000, 275);
83  alpha = gen.drawLine(2, 36, 6);
84  f_cut = gen.drawLine(2, 8000, 1000);
85 
86  temp = gend.generate2(2, freqs, alpha);
87  temp *= gen.generate(2, Ks);
88 
89  temp -= temp.getMin();
90  temp.normalize();
91 
92  temp *= gent.generate(2, freqs);
93 
94  aout << lpf.filter(temp, f_cut);
95 
96  //-------------------------------------------------------------------------
97  // Frequency ramp down, n harmonics constant
98 
99  aout << gen.silence(0.5);
100 
101  freqs = gen.drawLine(2.0, 600, 49.0);
102  Ks = gen.drawLine(2.0, 275, 275);
103  alpha = gen.drawLine(2, 6, 6);
104  f_cut = gen.drawLine(2, 1000, 1000);
105 
106  temp = gend.generate2(2, freqs, alpha);
107  temp *= gen.generate(2, Ks);
108 
109  temp -= temp.getMin();
110  temp.normalize();
111 
112  temp *= gent.generate(2, freqs);
113 
114  aout << lpf.filter(temp, f_cut);
115 
116  //-------------------------------------------------------------------------
117  // output
118 
119  aout << gen.silence(0.5);
120 
121  aout *= 0.666;
122 
123  aout >> "bebot.wav";
124 
125  AudioPlaybackRt pb(sr, 1, 3, 0.05);
126 
127  aout >> pb;
128 
129  return 0;
130 }
Triangle generator.
Definition: Triangle.h:48
A class tha generates decay curves.
double float64
Definition: Nsound.h:146
A class for filtering audio in the frequecy domain.
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
float64 getMin() const
Returns the minimum sample value in the Buffer.
Definition: Buffer.cc:1004
DOXME.
Definition: Sine.h:43
float64 sr
Definition: example3.cc:24