diff CollidoscopeApp/include/Wave.h @ 3:7fb593d53361

added comments
author Fiore Martin <f.martin@qmul.ac.uk>
date Tue, 12 Jul 2016 18:29:38 +0200
parents 02467299402e
children 75b744078d66
line wrap: on
line diff
--- a/CollidoscopeApp/include/Wave.h	Mon Jul 11 17:03:40 2016 +0200
+++ b/CollidoscopeApp/include/Wave.h	Tue Jul 12 18:29:38 2016 +0200
@@ -30,29 +30,42 @@
 using ci::Color;
 using ci::ColorA;
 
+/**
+ * A Cursor is the white thingy that loops through the selection when Collidoscope is played.
+ */ 
 struct Cursor {
     static const int kNoPosition = -100;
     int pos;
     double lastUpdate;
 };
 
-
+/**
+ * Collidoscope's graphical wave 
+ *
+ */ 
 class Wave
 {
 	friend class ParticleController;
 
 public:
 
+    /**
+     * The selection of the wave that is controlled by the big horizontal knob
+     *
+     */ 
 	class Selection {
 		
 	public:
 
         Selection( Wave * w, Color color );
         
+        /** Sets the start of selection. start is the index of the first chunk of the selection  */
         void setStart( size_t start );
 
+        /** Sets the size of selection. size is the number of chunks the selection is made of */
 		void setSize( size_t size );
 		
+        /** Particle spread is used to calculate the size of the cloud of particles */
         void inline setParticleSpread( float spread ){
             mParticleSpread = spread;
 		}
@@ -70,6 +83,7 @@
 
 		float inline  getParticleSpread() const { return mParticleSpread; }
 
+        /** When selection is null no selection is showed on the wave */
 		inline void setToNull(){
             mParticleSpread = 1.0f;
 			mNull = true;
@@ -107,13 +121,14 @@
 
 	
 
-	/* there is one cursor for each Synth being played */
+	/* Maps id of the synth to cursor. There is one cursor for each Synth being played */
 	std::map < SynthID, Cursor > mCursors;
+    /** Holds the positions of the cursor, namely on which chunk the cursor is currently */
 	std::vector<int> mCursorsPos;
 
 public:
 	
-    // note used to identify the loop for cursor position 
+    // value used to identify the loop for cursor position 
     static const int kLoopNote = -1;
 	static const cinder::Color CURSOR_CLR;
 	/* must be in sync with supercollider durationFactor ControlSpec max */
@@ -122,12 +137,21 @@
 	static const int PARTICLESIZE_COEFF = 40;
 #endif
 
+    /** Resetting a wave makes it shrink until it disappears. Each time a new sample is recorder the wave is reset
+     *  \param onlyChunks if false the selection is also set to null, if true only the chunks are reset
+     */
 	void reset(bool onlyChunks);
 
+    /** sets top and bottom values for the chunk. 
+     * \a bottom and \a top are in audio coordinates [-1.0, 1.0]
+     */
 	void setChunk(size_t index, float bottom, float top);
 
 	const Chunk & getChunk(size_t index);
 
+    /** places the cursor on the wave. Every cursor is associated to a synth voice of the audio engine. 
+     *  The synth id identifies uniquely the cursor in the internal map of the wave.
+     *  If the cursor doesn't exist it is created */
     inline void setCursorPos( SynthID id, int pos, const DrawInfo& di ){
 
 	    Cursor & cursor = mCursors[id];
@@ -135,9 +159,8 @@
 	    cursor.lastUpdate = ci::app::getElapsedSeconds();
 
 #ifdef USE_PARTICLES
-	    /* if the duration is greater than 1.0 carry on the cursor as a particle
-	    the smaller the selection the more particles
-	    the bigger the duration the more particles */
+	    // The idea is that, if the duration is greater than 1.0, the cursor continues in form of particles
+	    // The smaller the selection the more particles; the bigger the duration the more particles 
 	    if (mSelection.getParticleSpread() > 1.0f){
 		    /* amountCoeff ranges from 1/8 to 1 */
             const float amountCoeff = (mSelection.getParticleSpread() / MAX_DURATION);
@@ -167,7 +190,7 @@
 
     void removeCursor( SynthID id ) { mCursors.erase( id ); }
 
-    // parameter ranges from 0 to 1 
+    /** Sets the transparency of this wave. \a alpha ranges from 0 to 1 */
 	inline void setselectionAlpha(float alpha){ mFilterCoeff = alpha;}
 
     void draw( const DrawInfo& di );
@@ -180,7 +203,7 @@
 
     Wave( size_t numChunks, Color selectionColor );
 
-    // no copies 
+    /** no copies */
     Wave( const Wave &copy ) = delete;
     Wave & operator=(const Wave &copy) = delete;
 
@@ -197,6 +220,7 @@
 
     float mFilterCoeff;
 
+    // cinder gl batch for batch drawing 
     ci::gl::BatchRef mChunkBatch;
 
 };