From 2dc74a59cab851c594e9cb9a0c4f6ece340120a8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 18 Jan 2014 16:01:12 +0200 Subject: [PATCH] Add gain to SoundScape --- source/soundscape.cpp | 12 ++++++++++++ source/soundscape.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/source/soundscape.cpp b/source/soundscape.cpp index e12f39b..cc07285 100644 --- a/source/soundscape.cpp +++ b/source/soundscape.cpp @@ -6,12 +6,23 @@ using namespace std; namespace Msp { namespace AL { +SoundScape::SoundScape(): + gain(1) +{ } + SoundScape::~SoundScape() { for(list::iterator i=sources.begin(); i!=sources.end(); ++i) delete *i; } +void SoundScape::set_gain(float g) +{ + gain = g; + for(list::iterator i=sources.begin(); i!=sources.end(); ++i) + (*i)->set_gain(gain); +} + void SoundScape::add_source(Source &src) { sources.push_back(&src); @@ -23,6 +34,7 @@ Source &SoundScape::play(const Buffer &buf, float x, float y, float z) add_source(*src); src->set_buffer(buf); src->set_position(x, y, z); + src->set_gain(gain); src->play(); return *src; } diff --git a/source/soundscape.h b/source/soundscape.h index 9768532..a703c99 100644 --- a/source/soundscape.h +++ b/source/soundscape.h @@ -15,11 +15,14 @@ A SoundScape offers an easy way to play positional sound effects. class SoundScape { private: + float gain; std::list sources; public: + SoundScape(); ~SoundScape(); + void set_gain(float); void add_source(Source &); Source &play(const Buffer &, float, float, float); void tick(); -- 2.43.0