]> git.tdb.fi Git - libs/al.git/blob - source/soundscape.cpp
Drop copyright notices and Id tags from source files
[libs/al.git] / source / soundscape.cpp
1 #include "source.h"
2 #include "soundscape.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace AL {
8
9 SoundScape::~SoundScape()
10 {
11         for(list<Source *>::iterator i=sources.begin(); i!=sources.end(); ++i)
12                 delete *i;
13 }
14
15 void SoundScape::add_source(Source &src)
16 {
17         sources.push_back(&src);
18 }
19
20 Source &SoundScape::play(const Buffer &buf, float x, float y, float z)
21 {
22         Source *src = new Source;
23         add_source(*src);
24         src->set_buffer(buf);
25         src->set_position(x, y, z);
26         src->play();
27         return *src;
28 }
29
30 void SoundScape::tick()
31 {
32         for(list<Source *>::iterator i=sources.begin(); i!=sources.end();)
33         {
34                 if((*i)->get_state()==STOPPED)
35                 {
36                         delete *i;
37                         i = sources.erase(i);
38                 }
39                 else
40                         ++i;
41         }
42 }
43
44 } // namespace AL
45 } // namespace Msp