]> git.tdb.fi Git - libs/al.git/blobdiff - source/soundscape.cpp
Make sound format support optional
[libs/al.git] / source / soundscape.cpp
index 6ec00f06b9113909ff6e20d4bb976836b758095f..cc07285bfdded63e99909852f259764847a103ef 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspal
-Copyright © 2008 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "source.h"
 #include "soundscape.h"
 
@@ -13,25 +6,37 @@ using namespace std;
 namespace Msp {
 namespace AL {
 
+SoundScape::SoundScape():
+       gain(1)
+{ }
+
 SoundScape::~SoundScape()
 {
        for(list<Source *>::iterator i=sources.begin(); i!=sources.end(); ++i)
                delete *i;
 }
 
-void SoundScape::add_source(Source *src)
+void SoundScape::set_gain(float g)
+{
+       gain = g;
+       for(list<Source *>::iterator i=sources.begin(); i!=sources.end(); ++i)
+               (*i)->set_gain(gain);
+}
+
+void SoundScape::add_source(Source &src)
 {
-       sources.push_back(src);
+       sources.push_back(&src);
 }
 
-Source *SoundScape::play(const Buffer &buf, float x, float y, float z)
+Source &SoundScape::play(const Buffer &buf, float x, float y, float z)
 {
-       Source *src=new Source;
-       add_source(src);
+       Source *src = new Source;
+       add_source(*src);
        src->set_buffer(buf);
        src->set_position(x, y, z);
+       src->set_gain(gain);
        src->play();
-       return src;
+       return *src;
 }
 
 void SoundScape::tick()
@@ -41,7 +46,7 @@ void SoundScape::tick()
                if((*i)->get_state()==STOPPED)
                {
                        delete *i;
-                       i=sources.erase(i);
+                       i = sources.erase(i);
                }
                else
                        ++i;