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

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 20 of file stretcher.cc.

References Nsound::Generator::drawFatGaussian(), Nsound::AudioStream::getDuration(), Nsound::AudioStream::getNChannels(), Nsound::AudioStream::getSampleRate(), Nsound::Stretcher::pitchShift(), Nsound::Stretcher::showProgress(), sr, and Nsound::Stretcher::timeShift().

21 {
22  AudioStream a("Temperature_in.wav");
23 
24  // Grab sample rate.
25  float64 sr = a.getSampleRate();
26 
27  // Create a audio playback object
28 
29  AudioPlaybackRt pb(sr, a.getNChannels());
30 
31  // Grab the duration in seconds.
32  float64 duration = a.getDuration();
33 
34  // Create a Gaussian curve for pitch/time shifting.
35  Sine sin(sr);
36 
37  Buffer bend = sin.drawFatGaussian(duration, 0.15) + 1.0;
38 
39  // Create a Stretcher instance
40  Stretcher stretch(sr, 0.08, 0.25);
41 
42  // Print progress to command line.
43  stretch.showProgress(true);
44 
45  cout << "Pitch Shifting Up" << endl;
46 
47  // Create new output AudioStream, pitch shift input AudioStream.
48  AudioStream out(sr, 2);
49 
50  out << stretch.pitchShift(a, bend);
51  out >> "Temperature_Pitch_Shifted_Up.wav";
52  out * 0.666 >> pb;
53 
54  cout << "Time Shifting Faster" << endl;
55 
56  // Time shift input AudioStream.
57  out = AudioStream(sr, 2);
58 
59  out << stretch.timeShift(a, 1.0 / bend);
60  out >> "Temperature_Time_Shifted_Faster.wav";
61  out * 0.666 >> pb;
62 
63  bend = 1.0 - 0.25 * sin.drawFatGaussian(duration, 0.15);
64 
65  cout << "Pitch Shifting Down" << endl;
66 
67  out = AudioStream(sr, 2);
68  out << stretch.pitchShift(a, bend);
69  out >> "Temperature_Pitch_Shifted_Down.wav";
70  out * 0.666 >> pb;
71 
72  cout << "Time Shifting Slower" << endl;
73 
74  bend = 1.0 + 0.75 * sin.drawFatGaussian(duration, 0.15);
75 
76  out = AudioStream(sr,2);
77  out << stretch.timeShift(a, bend);
78  out >> "Temperature_Time_Shifted_Slower.wav";
79  out * 0.666 >> pb;
80 
81  return 0;
82 }
double float64
Definition: Nsound.h:146
A Buffer for storing audio samples.
Definition: Buffer.h:60
DOXME.
Definition: Sine.h:43
float64 sr
Definition: example3.cc:24