diff CollidoscopeApp/include/Wave.h @ 5:75b744078d66

added license
author Fiore Martin <f.martin@qmul.ac.uk>
date Wed, 13 Jul 2016 16:06:46 +0200
parents 7fb593d53361
children a4a336624f5a
line wrap: on
line diff
--- a/CollidoscopeApp/include/Wave.h	Wed Jul 13 12:31:37 2016 +0200
+++ b/CollidoscopeApp/include/Wave.h	Wed Jul 13 16:06:46 2016 +0200
@@ -1,3 +1,25 @@
+/*
+
+ Copyright (C) 2015  Fiore Martin
+ Copyright (C) 2016  Queen Mary University of London 
+ Author: Fiore Martin
+
+ This file is part of Collidoscope.
+ 
+ Collidoscope is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
 #pragma once
 
 
@@ -45,7 +67,7 @@
  */ 
 class Wave
 {
-	friend class ParticleController;
+    friend class ParticleController;
 
 public:
 
@@ -53,9 +75,9 @@
      * The selection of the wave that is controlled by the big horizontal knob
      *
      */ 
-	class Selection {
-		
-	public:
+    class Selection {
+        
+    public:
 
         Selection( Wave * w, Color color );
         
@@ -63,39 +85,39 @@
         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 );
-		
+        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;
-		}
+        }
 
-		size_t getStart(void) const { return mSelectionStart; }
-		
+        size_t getStart(void) const { return mSelectionStart; }
+        
         size_t getEnd(void) const { return mSelectionEnd; }
 
-		size_t inline getSize(void) const { 
-			if (mNull)
-				return 0;
-			else
-				return 1 + mSelectionEnd - mSelectionStart; 
-		}
+        size_t inline getSize(void) const { 
+            if (mNull)
+                return 0;
+            else
+                return 1 + mSelectionEnd - mSelectionStart; 
+        }
 
-		float inline  getParticleSpread() const { return mParticleSpread; }
+        float inline  getParticleSpread() const { return mParticleSpread; }
 
         /** When selection is null no selection is showed on the wave */
-		inline void setToNull(){
+        inline void setToNull(){
             mParticleSpread = 1.0f;
-			mNull = true;
-		}
+            mNull = true;
+        }
 
-		inline bool isNull() const{
-			return mNull;
-		}
+        inline bool isNull() const{
+            return mNull;
+        }
 
-		inline const Color & getColor() const{
-			return mColor;
-		}
+        inline const Color & getColor() const{
+            return mColor;
+        }
 
     private:
 
@@ -111,58 +133,58 @@
 
         Wave * mWave;
 
-	}; // class Selection
+    }; // class Selection
 
-	
+    
 
 #ifdef USE_PARTICLES
-	ParticleController mParticleController;
+    ParticleController mParticleController;
 #endif 
 
-	
+    
 
-	/* Maps id of the synth to cursor. There is one cursor for each Synth being played */
-	std::map < SynthID, Cursor > mCursors;
+    /* 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;
+    std::vector<int> mCursorsPos;
 
 public:
-	
+    
     // 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 */
-	static const int MAX_DURATION = 8;
+    static const cinder::Color CURSOR_CLR;
+    /* must be in sync with supercollider durationFactor ControlSpec max */
+    static const int MAX_DURATION = 8;
 #ifdef USE_PARTICLES
-	static const int PARTICLESIZE_COEFF = 40;
+    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);
+    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);
+    void setChunk(size_t index, float bottom, float top);
 
-	const Chunk & getChunk(size_t index);
+    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];
-	    cursor.pos = pos;
-	    cursor.lastUpdate = ci::app::getElapsedSeconds();
+        Cursor & cursor = mCursors[id];
+        cursor.pos = pos;
+        cursor.lastUpdate = ci::app::getElapsedSeconds();
 
 #ifdef USE_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 */
+        // 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);
                 
             /* get radom point within seleciton as center of the particle */
@@ -173,33 +195,33 @@
             centrePoint.y = di.flipY( di.audioToHeigt(0.0) );
 
             const float wavePixelLen = mNumChunks * ( 2 + Chunk::kWidth);
-		    centrePoint.x *= float(di.getWindowWidth()) / wavePixelLen;
+            centrePoint.x *= float(di.getWindowWidth()) / wavePixelLen;
 
-		    mParticleController.addParticles(
+            mParticleController.addParticles(
                 std::max( 1, (int)(amountCoeff * ParticleController::kMaxParticleAdd * mFilterCoeff) ), // amount of particles to add 
-			    centrePoint,
+                centrePoint,
                 mSelection.getParticleSpread() * PARTICLESIZE_COEFF   // size of the cloud 
-			    );
-	    }
+                );
+        }
 #endif
 
-		
-	}
+        
+    }
 
     void update( double secondsPerChunk, const DrawInfo& di );
 
     void removeCursor( SynthID id ) { mCursors.erase( id ); }
 
     /** Sets the transparency of this wave. \a alpha ranges from 0 to 1 */
-	inline void setselectionAlpha(float alpha){ mFilterCoeff = alpha;}
+    inline void setselectionAlpha(float alpha){ mFilterCoeff = alpha;}
 
     void draw( const DrawInfo& di );
 
-	Selection& getSelection() { return mSelection; };
+    Selection& getSelection() { return mSelection; };
 
-	size_t getSize() const{ return mChunks.size();  }
+    size_t getSize() const{ return mChunks.size();  }
 
-	void setScopePoint(int index, float audioVal);
+    void setScopePoint(int index, float audioVal);
 
     Wave( size_t numChunks, Color selectionColor );