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

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 19 of file example4.cc.

References Nsound::ReverberationRoom::filter(), Nsound::Clarinet::play(), Nsound::GuitarBass::play(), Nsound::FluteSlide::play(), Nsound::Wavefile::setDefaults(), Nsound::Generator::silence(), sr, and Nsound::Exception::what().

20 {
21  float64 sr = 44100.0;
22 
23  Sine sine(sr);
24 
25  GuitarBass bass(sr);
26  FluteSlide slide(sr);
27  Clarinet clarinet(sr);
28 
29  AudioStream out(sr, 1);
30 
31  out << bass.play() << sine.silence(1.0)
32  << slide.play() << sine.silence(1.0)
33  << clarinet.play() << sine.silence(1.0);
34 
35  out *= 0.5;
36 
37  // Set the default Wavefile sample size and rate.
38  Wavefile::setDefaults(sr, 16);
39 
40  out >> "example4.wav";
41 
42  ReverberationRoom room(sr, 0.9); // 0.9 = room feed back (0.0 to 1.0)
43 
44  AudioStream out2 = room.filter(0.5 * (bass.play() << sine.silence(1.5)));
45 
46  out2 >> "example4_reverb.wav";
47 
48  // Try to play the audio
49 
50  try
51  {
52  AudioPlayback pb(sr, 2, 16);
53  out >> pb;
54  out2 >> pb;
55  }
56  catch(Exception e)
57  {
58  cerr << "Could not play audio: " << e.what() << endl;
59  }
60 
61  return 0;
62 }
Class Drum.
Definition: Clarinet.h:48
double float64
Definition: Nsound.h:146
const char * what() const
Definition: Nsound.h:169
Class Drum.
Definition: FluteSlide.h:50
DOXME.
Definition: Sine.h:43
float64 sr
Definition: example3.cc:24
Class Drum.
Definition: GuitarBass.h:50