comparison CollidoscopeApp/include/Wave.h @ 16:4dad0b810f18

Comment tidy up + attributions
author Fiore Martin <f.martin@qmul.ac.uk>
date Tue, 16 Aug 2016 14:27:53 +0100
parents a4a336624f5a
children
comparison
equal deleted inserted replaced
15:5241f96479d6 16:4dad0b810f18
86 86
87 /** Sets the size of selection. size is the number of chunks the selection is made of */ 87 /** Sets the size of selection. size is the number of chunks the selection is made of */
88 void setSize( size_t size ); 88 void setSize( size_t size );
89 89
90 /** The particle spread parameter affects the size of the cloud of particles 90 /** The particle spread parameter affects the size of the cloud of particles
91 * The cloud is the visual conterpart of the grain duration coefficien in sound. 91 * The cloud is the visual counterpart of the grain duration coefficient in sound.
92 * Indeed spread accepts values from 1 to 8, exactly as the duration coefficient 92 * Indeed spread accepts values from 1 to 8, exactly as the duration coefficient
93 */ 93 */
94 void inline setParticleSpread( float spread ){ 94 void inline setParticleSpread( float spread ){
95 mParticleSpread = spread; 95 mParticleSpread = spread;
96 } 96 }
146 146
147 147
148 148
149 /* Maps id of the synth to cursor. There is one cursor for each Synth being played */ 149 /* Maps id of the synth to cursor. There is one cursor for each Synth being played */
150 std::map < SynthID, Cursor > mCursors; 150 std::map < SynthID, Cursor > mCursors;
151 /** Holds the positions of the cursor, namely on which chunk the cursor is currently */ 151 /** Holds the positions of the cursor, namely on which chunk the cursor is currently on */
152 std::vector<int> mCursorsPos; 152 std::vector<int> mCursorsPos;
153 153
154 public: 154 public:
155 155
156 // value used to identify the loop for cursor position 156 // value used to identify the loop for cursor position
157 static const int kLoopNote = -1; 157 static const int kLoopNote = -1;
158 static const cinder::Color CURSOR_CLR; 158 static const cinder::Color CURSOR_CLR;
159 /* must be in sync with supercollider durationFactor ControlSpec max */
160 static const int MAX_DURATION = 8; 159 static const int MAX_DURATION = 8;
161 #ifdef USE_PARTICLES 160 #ifdef USE_PARTICLES
162 static const int PARTICLESIZE_COEFF = 40; 161 static const int PARTICLESIZE_COEFF = 40;
163 #endif 162 #endif
164 163
165 /** Resetting a wave makes it shrink until it disappears. Each time a new sample is recorder the wave is reset 164 /** Resetting a wave makes it shrink until it disappears. Each time a new sample is recorded, the wave is reset.
166 * \param onlyChunks if false the selection is also set to null, if true only the chunks are reset 165 * \param onlyChunks if false the selection is also set to null, if true only the chunks are reset
167 */ 166 */
168 void reset(bool onlyChunks); 167 void reset(bool onlyChunks);
169 168
170 /** sets top and bottom values for the chunk. 169 /** sets top and bottom values for the chunk.
172 */ 171 */
173 void setChunk(size_t index, float bottom, float top); 172 void setChunk(size_t index, float bottom, float top);
174 173
175 const Chunk & getChunk(size_t index); 174 const Chunk & getChunk(size_t index);
176 175
177 /** places the cursor on the wave. Every cursor is associated to a synth voice of the audio engine. 176 /** Places the cursor on the wave. Every cursor is associated to a synth voice of the audio engine.
178 * The synth id identifies uniquely the cursor in the internal map of the wave. 177 * The synth id identifies uniquely the cursor in the internal map of the wave.
179 * If the cursor doesn't exist it is created */ 178 * If the cursor doesn't exist it is created */
180 inline void setCursorPos( SynthID id, int pos, const DrawInfo& di ){ 179 inline void setCursorPos( SynthID id, int pos, const DrawInfo& di ){
181 180
182 Cursor & cursor = mCursors[id]; 181 Cursor & cursor = mCursors[id];
183 cursor.pos = pos; 182 cursor.pos = pos;
184 cursor.lastUpdate = ci::app::getElapsedSeconds(); 183 cursor.lastUpdate = ci::app::getElapsedSeconds();
185 184
186 #ifdef USE_PARTICLES 185 #ifdef USE_PARTICLES
187 // The idea is that, if the duration is greater than 1.0, the cursor continues in form of particles 186 // The idea is that, if the duration is greater than 1.0, the cursor continues in form of particles.
188 // The smaller the selection the more particles; the bigger the duration the more particles 187 // The smaller the selection the more particles; the bigger the duration the more particles.
189 if (mSelection.getParticleSpread() > 1.0f){ 188 if (mSelection.getParticleSpread() > 1.0f){
190 /* amountCoeff ranges from 1/8 to 1 */ 189 /* amountCoeff ranges from 1/8 to 1 */
191 const float amountCoeff = (mSelection.getParticleSpread() / MAX_DURATION); 190 const float amountCoeff = (mSelection.getParticleSpread() / MAX_DURATION);
192 191
193 /* get radom point within seleciton as center of the particle */ 192 /* get radom point within seleciton as center of the particle */
194 vec2 centrePoint; // was former getRandomPoint 193 vec2 centrePoint;
195 const int randomChunkIndex = ci::Rand::randInt(mSelection.getStart(), mSelection.getEnd() ); 194 const int randomChunkIndex = ci::Rand::randInt(mSelection.getStart(), mSelection.getEnd() );
196 195
197 centrePoint.x = di.flipX( 1 + (randomChunkIndex * (2 + Chunk::kWidth)) + Chunk::kWidth / 2 ); 196 centrePoint.x = di.flipX( 1 + (randomChunkIndex * (2 + Chunk::kWidth)) + Chunk::kWidth / 2 );
198 centrePoint.y = di.flipY( di.audioToHeigt(0.0) ); 197 centrePoint.y = di.flipY( di.audioToHeigt(0.0) );
199 198
241 240
242 Selection mSelection; 241 Selection mSelection;
243 242
244 cinder::Color mColor; 243 cinder::Color mColor;
245 244
245 // How much filter is applied in audio. It affects the alpha value of the selection color.
246 float mFilterCoeff; 246 float mFilterCoeff;
247 247
248 // cinder gl batch for batch drawing 248 // cinder gl batch for batch drawing
249 ci::gl::BatchRef mChunkBatch; 249 ci::gl::BatchRef mChunkBatch;
250 250