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

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 16 of file example2.cc.

References Nsound::Generator::generate(), Nsound::AudioStream::pan(), sr, and Nsound::Exception::what().

17 {
18  float64 sr = 44100.0;
19 
20  // Create a new instance of the Sine Generator
21  Sine sine(sr);
22 
23  Buffer pan;
24 
25  pan << sine.generate(1.0, 3.0);
26 
27  // Create a stereo AudioStream.
28  AudioStream as(sr, 2);
29 
30  // Fill it with a 220 Hz sine wave.
31  as << 0.5 * sine.generate(4.9, 220);
32 
33  // Execute the pan method.
34  as.pan(pan);
35 
36  // Write the AudioStream to a wave file
37  as >> "example2.wav";
38 
39  // Play it through the sound card
40 
41  try
42  {
43  AudioPlayback pb(sr, 2, 16);
44  as >> pb;
45  }
46  catch(Exception e)
47  {
48  cerr << "Could not play audio: " << e.what() << endl;
49  }
50 
51  return 0;
52 }
double float64
Definition: Nsound.h:146
const char * what() const
Definition: Nsound.h:169
A Buffer for storing audio samples.
Definition: Buffer.h:60
DOXME.
Definition: Sine.h:43
float64 sr
Definition: example3.cc:24