Granulator.h

Go to the documentation of this file.
00001 //
00002 //  Granulator.h -- CSL class for doing granular synthesis
00003 //
00004 //  See the copyright notice and acknowledgment of authors in the file COPYRIGHT
00005 //
00006 
00007 #ifndef CSL_GRAN_H
00008 #define CSL_GRAN_H
00009 
00010 #include "CSL_Core.h"       // my superclass
00011 #include "ThreadUtilities.h"
00012 
00013 namespace csl {             // my namespace
00014 
00015 #define MAXGRAINS 200
00016 
00020 
00021 typedef struct Grain {
00022     float amplitude;        
00023     float rate;             
00024     float duration;         
00025     float time;             
00026     float pan;              
00027     float env;              
00028     float position;         
00029     unsigned delay;         
00030     float * samples;        
00031     unsigned numSamples;    
00032     Grain * nextGrain;      
00033 } Grain;
00034 
00036 
00037 typedef enum {          
00038     kFree,              
00039     kDSP,               
00040     kSched,             
00041 } GrainulatorState;
00042 
00046 
00047 class GrainCloud {
00048 public:
00049     GrainCloud();               
00050     ~GrainCloud();
00051             
00052     void startThreads();        
00053     void reset();               
00054                             // public data members (set from GUI)
00055     float mRateBase;            
00056     float mRateRange;           
00057     float mOffsetBase;          
00058     float mOffsetRange;         
00059     float mDensityBase;         
00060     float mDensityRange;        
00061     float mDurationBase;        
00062     float mDurationRange;       
00063     float mWidthBase;           
00064     float mWidthRange;          
00065     float mVolumeBase;          
00066     float mVolumeRange;         
00067     float mEnvelopeBase;        
00068     float mEnvelopeRange;       
00069 
00070     float * mSamples;           
00071     unsigned numSamples;        
00072     bool isPlaying;             
00073 
00074     Grain * mSilentGrains;      
00075     Grain * mPlayingGrains;     
00076     GrainulatorState gState;    
00077     int64 gNow;                 
00078     float sampsPerTick;         
00079 
00080 protected:
00081     CThread * spawnerThread;    
00082     CThread * reaperThread;     
00083     bool threadOn;              
00084 };
00085 
00087 
00088 class GrainPlayer : public UnitGenerator {
00089 public:
00090     GrainPlayer(GrainCloud * cloud);
00091     ~GrainPlayer();
00093     void nextBuffer(Buffer & outputBuffer) throw (CException);
00094     
00095     GrainCloud * mCloud;        
00096 };
00097 
00098 }       // end of namespace
00099 
00100 #endif

Generated on Sat Oct 17 14:12:31 2009 for CSL by  doxygen 1.4.5-20051010