Nsound
0.9.4
Main Page
Namespaces
Classes
Files
File List
File Members
examples
example2.cc
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
//
3
// $Id: example2.cc 874 2014-09-08 02:21:29Z weegreenblobbie $
4
//
5
//-----------------------------------------------------------------------------
6
7
// Include the Nsound headers
8
#include <
Nsound/NsoundAll.h
>
9
10
using namespace
Nsound;
11
12
using
std::cerr;
13
using
std::endl;
14
15
int
16
main
(
void
)
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
}
NsoundAll.h
Nsound::AudioPlayback
Definition:
AudioPlayback.h:50
Nsound::float64
double float64
Definition:
Nsound.h:146
Nsound::Exception::what
const char * what() const
Definition:
Nsound.h:169
main
int main(void)
Definition:
example2.cc:16
Nsound::Generator::generate
virtual float64 generate(const float64 &frequency)
This is a real-time method for the wavetable oscillator.
Definition:
Generator.cc:972
Nsound::AudioStream
Definition:
AudioStream.h:52
Nsound::Buffer
A Buffer for storing audio samples.
Definition:
Buffer.h:60
Nsound::Exception
Definition:
Nsound.h:163
Nsound::AudioStream::pan
void pan(float64 pan)
Sets the amplitude level left vs right.
Definition:
AudioStream.cc:627
Nsound::Sine
DOXME.
Definition:
Sine.h:43
sr
float64 sr
Definition:
example3.cc:24
Generated on Sun Aug 23 2015 11:51:50 for Nsound by
1.8.6