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

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 13 of file mynameis.cc.

References Nsound::Generator::drawLine(), Nsound::FilterHighPassIIR::filter(), Nsound::FilterBandPassIIR::filter(), Nsound::Generator::generate(), Nsound::AudioStream::getDuration(), Nsound::AudioStream::getPan(), Nsound::AudioStream::getSampleRate(), Nsound::AudioStream::normalize(), Nsound::Buffer::normalize(), Nsound::Stretcher::pitchShift(), Nsound::Stretcher::showProgress(), Nsound::Generator::silence(), sr, Nsound::AudioStream::substream(), and Nsound::Stretcher::timeShift().

14 {
15  AudioStream as0("mynameis.wav");
16 
17  float64 sr = as0.getSampleRate();
18 
19  // Get rid of some low frequency noise from the recording.
20  FilterHighPassIIR hp(sr, 6, 200.0, 0.01);
21 
22  as0 = hp.filter(as0);
23 
24  Buffer raw = as0[0];
25 
26  raw.normalize();
27  raw *= 0.5;
28 
29  AudioStream as1(sr, 2);
30 
31  as1 << raw;
32 
33  float64 raw_duration = as1.getDuration();
34 
35  // dynamic pan
36  Sine sine(sr);
37 
38  AudioStream temp = as1.getPan(sine.generate(1.0,8.0));
39 
40  temp >> "mynameis-pan.wav";
41 
42  // Create a Stretcher instance
43  Stretcher stretch(sr, 0.08, 0.25);
44 
45  stretch.showProgress(true);
46 
47  // Pitch UP
48  temp = stretch.pitchShift(as1, 1.3);
49 
50  temp >> "mynameis-high-pitch.wav";
51 
52  // Pitch DOWN
53  temp = stretch.pitchShift(as1, 0.7);
54 
55  temp >> "mynameis-low-pitch.wav";
56 
57  // Speed UP
58  temp = stretch.timeShift(as1, 0.7);
59 
60  temp >> "mynameis-faster.wav";
61 
62  // Speed DOWN
63  temp = stretch.timeShift(as1, 1.3);
64 
65  temp >> "mynameis-slower.wav";
66 
67  // wobble
68  Buffer wobble = 1.0 + 0.25 * sine.generate(1.0,5.0);
69 
70  temp = stretch.pitchShift(as1, wobble);
71 
72  temp >> "mynameis-wobble.wav";
73 
74  // ramp
75  Buffer ramp = sine.drawLine(as1.getDuration(), 0.7, 1.3);
76 
77  temp = stretch.pitchShift(as1, ramp);
78 
79  temp >> "mynameis-ramp.wav";
80 
81  // dynamic filter
82  Buffer low_freqs = sine.drawLine(1.0, 1000, 1000)
83  << sine.drawLine(raw_duration - 1.0, 1000, 20);
84 
85  Buffer high_freqs = sine.drawLine(1.0, 2000, 2000)
86  << sine.drawLine(raw_duration - 1.0, 2000, 16000);
87 
88  FilterBandPassIIR bpf(sr, 4, 1000, 2000, 0.01);
89 
90  AudioStream filtered(sr, 1);
91 
92  filtered << raw << sine.silence(0.25);
93 
94  filtered = bpf.filter(filtered, low_freqs, high_freqs);
95 
96  // There is a large click at the end of this result from the IIR high pass
97  // portion, IIR filter are not stable at every frequency.
98 
99  // Cut off the click.
100  filtered = filtered.substream(0.0f, 3.7f);
101 
102  filtered.normalize();
103  filtered *= 0.5;
104 
105  filtered >> "mynameis-filtered.wav";
106 
107  return 0;
108 }
double float64
Definition: Nsound.h:146
A class for filtering audio in the frequecy domain.
AudioStream getPan(float64 pan) const
Sets the amplitude level left vs right.
Definition: AudioStream.h:353
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
DOXME.
Definition: Sine.h:43
float64 sr
Definition: example3.cc:24