SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SourceCollection.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef SOURCECOLLECTION_H_INCLUDED
21 #define SOURCECOLLECTION_H_INCLUDED
22 
23 
24 #include <mutex>
25 #include <memory>
26 #include <vector>
27 #include "Source.h"
28 
29 #define NUM_INITIAL_COLOURS 4
30 
31 namespace wonder {
32 
38 {
39 public:
40 
46  SourceCollection(int maxSources = MAX_WONDER_SOURCES);
47 
49  virtual ~SourceCollection();
50 
62  const Source& getSource(int sourceID) const;
63 
70  const int getMaxSources() const;
71 
81  bool setSource(const Source &source);
82 
87  void activate(int sourceID);
88 
93  void deactivate(int sourceID);
94 
101  void setPosition(int sourceID, float x, float y);
102 
108  void setAngle(int sourceID, float angle);
109 
117  void setType(int sourceID, int type);
118 
124  void setName(int sourceID, const std::string &name);
125 
131  void setColour(int sourceID, Colour colour);
132 
138  void setDopplerEffect(int sourceID, bool dopplerOn);
139 
147  void setParameterNormalized(int sourceID, int paramIndex,
148  float normalizedValue);
149 
157  void setParameterUnnormalized(int sourceID, int paramIndex,
158  float unnormalizedValue);
159 
160 private:
161  bool idInRange(int sourceID) const;
162 
163  const int maxSources_;
164  std::vector<Source> sources_;
165 
166  static Colour initialColours[NUM_INITIAL_COLOURS];
167 };
168 
169 }
170 
171 #endif // SOURCECOLLECTION_H_INCLUDED
A container class holding multiple sources (IDs 0 to maxSources-1), accessible via their sourceIDs...
Definition: SourceCollection.h:37
void setPosition(int sourceID, float x, float y)
Sets a source's position parameters.
Definition: SourceCollection.cpp:73
void activate(int sourceID)
Sets a source's state to active.
Definition: SourceCollection.cpp:59
const Source & getSource(int sourceID) const
Returns a reference to one of the internal Source objects of this SourceCollection.
Definition: SourceCollection.cpp:38
void deactivate(int sourceID)
Sets a source's state to not active.
Definition: SourceCollection.cpp:66
void setParameterUnnormalized(int sourceID, int paramIndex, float unnormalizedValue)
Sets a source's parameter from its unnormalized value.
Definition: SourceCollection.cpp:118
A struct representing a (RGB) colour.
Definition: Colours.h:28
SourceCollection(int maxSources=MAX_WONDER_SOURCES)
Constructor.
Definition: SourceCollection.cpp:24
void setType(int sourceID, int type)
Sets a source's type parameter.
Definition: SourceCollection.cpp:86
void setParameterNormalized(int sourceID, int paramIndex, float normalizedValue)
Sets a parameter from its normalized value.
Definition: SourceCollection.cpp:110
void setColour(int sourceID, Colour colour)
Sets a source's colour.
Definition: SourceCollection.cpp:98
void setDopplerEffect(int sourceID, bool dopplerOn)
Sets a source's doppler effect setting.
Definition: SourceCollection.cpp:105
void setAngle(int sourceID, float angle)
Sets a source's angle parameter.
Definition: SourceCollection.cpp:81
#define MAX_WONDER_SOURCES
The maximum number of sources.
Definition: WonderHeader.h:25
const int getMaxSources() const
Returns the number of Source objects that this SourceCollection contains.
Definition: SourceCollection.cpp:43
A class for objects representing a WONDER source with all its properties.
Definition: Source.h:60
void setName(int sourceID, const std::string &name)
Sets a source's name.
Definition: SourceCollection.cpp:91
virtual ~SourceCollection()
Destructor.
Definition: SourceCollection.cpp:34
bool setSource(const Source &source)
Copies the parameters of a given Source object to the internal Source object with the same ID (if the...
Definition: SourceCollection.cpp:48
#define NUM_INITIAL_COLOURS
Definition: SourceCollection.h:29