Nsound  0.9.4
Functions
test_granulator.cc File Reference
#include <Nsound/AudioStream.h>
#include <Nsound/Buffer.h>
#include <Nsound/Granulator.h>
#include <Nsound/Sine.h>
#include <Nsound/TicToc.h>
#include <Nsound/Wavefile.h>
#include <cmath>
#include <iostream>
Include dependency graph for test_granulator.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 47 of file test_granulator.cc.

References Nsound::Generator::drawDecay(), Nsound::Granulator::GAUSSIAN_30, Nsound::Granulator::generate(), Nsound::Wavefile::setDefaultSampleRate(), Nsound::Wavefile::setDefaultSampleSize(), Nsound::Tic(), and Nsound::Toc().

48 {
49  Wavefile::setDefaultSampleRate(44100);
50  Wavefile::setDefaultSampleSize(16);
51 
52  Granulator grains(44100, Granulator::GAUSSIAN_30);
53  Sine sin(44100);
54 
55  Buffer grain_freqs;
56  grain_freqs << 180;
57 
58  Buffer waves_per_grain;
59  waves_per_grain << 2.0;
60 
61  Buffer grains_per_second = 1200 * sin.drawDecay(5.0);
62 
63  Tic();
64  cout << "gran.generate() ... " << flush;
65 
66  Buffer output(4096);
67 
68  output << 0.6 * grains.generate(5, grain_freqs, waves_per_grain, grains_per_second);
69 
70  cout << Toc() << " seconds" << endl << flush;
71 
72  output >> "grains.wav";
73 
74  return 0;
75 }
A Buffer for storing audio samples.
Definition: Buffer.h:60
Nsound::float64 Toc()
Definition: TicToc.cc:42
void Tic()
Definition: TicToc.cc:37
DOXME.
Definition: Sine.h:43