]> git.tdb.fi Git - libs/al.git/blobdiff - source/soundscape.cpp
Add more methods to Source
[libs/al.git] / source / soundscape.cpp
diff --git a/source/soundscape.cpp b/source/soundscape.cpp
new file mode 100644 (file)
index 0000000..694c884
--- /dev/null
@@ -0,0 +1,52 @@
+/* $Id$
+
+This file is part of libmspal
+Copyright © 2008 Mikko Rasa, Mikkosoft Productions
+Diestributed under the LGPL
+*/
+
+#include "source.h"
+#include "soundscape.h"
+
+using namespace std;
+
+namespace Msp {
+namespace AL {
+
+SoundScape::~SoundScape()
+{
+       for(list<Source *>::iterator i=sources.begin(); i!=sources.end(); ++i)
+               delete *i;
+}
+
+void SoundScape::add_source(Source *src)
+{
+       sources.push_back(src);
+}
+
+Source *SoundScape::play(const Buffer &buf, float x, float y, float z)
+{
+       Source *src=new Source;
+       add_source(src);
+       src->set_buffer(buf);
+       src->set_position(x, y, z);
+       src->play();
+       return src;
+}
+
+void SoundScape::tick()
+{
+       for(list<Source *>::iterator i=sources.begin(); i!=sources.end();)
+       {
+               if((*i)->get_state()==STOPPED)
+               {
+                       delete *i;
+                       i=sources.erase(i);
+               }
+               else
+                       ++i;
+       }
+}
+
+} // namespace AL
+} // namespace Msp