Mixer.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 #ifndef CSL_Mixer_H
00007 #define CSL_Mixer_H
00008 
00009 #include "CSL_Core.h"
00010 
00011 namespace csl {
00012 
00019 
00020 class Mixer : public UnitGenerator, public Scalable {
00021 public:
00022     Mixer();                    
00023     Mixer(unsigned chans);
00024     Mixer(UnitGenerator & mScale);
00025     Mixer(unsigned chans, UnitGenerator & mScale);
00026     virtual ~Mixer();
00027                     // Accessing
00028     UGenVector getInputs(void) { return(mSources); };       
00029     unsigned getNumInputs(void) { return(mSources.size()); };       
00030 
00031     void addInput(UnitGenerator & inp);
00032     void addInput(UnitGenerator * inp);
00033     void removeInput(UnitGenerator & inp);
00035     void nextBuffer(Buffer &outputBuffer) throw (CException);
00037     void dump();
00038 
00039 protected:
00040     UGenVector mSources;                    
00041     Buffer mOpBuffer;                       
00042     void allocateOpBuffer(unsigned chans);      
00043 };
00044 
00052 
00053 class Panner : public Effect, public Scalable {
00054 public:
00056     Panner();                                               
00057     Panner(UnitGenerator &input);                           
00058     Panner(UnitGenerator &input, UnitGenerator &position);  
00059     Panner(UnitGenerator &input, float position);               
00060     Panner(UnitGenerator &input, UnitGenerator &position, UnitGenerator &amplitude);    
00061     Panner(UnitGenerator &input, UnitGenerator &position, float amplitude);         
00062     Panner(UnitGenerator &input, float position, float amplitude);                  
00063     ~Panner();
00065     void setPosition(UnitGenerator &pan);                       
00066     void setPosition(float pan);                                
00067     virtual unsigned numChannels() const { return 2; };         
00068 
00069     virtual void nextBuffer(Buffer &outputBuffer) throw (CException);
00070 };
00071 
00072 #ifdef NOT_PORTED_YET
00073 
00074 // N-channel (max 2 at present) input to M-channel output azimuth panner
00075 
00076 #define MAX_OUTPUTS 16
00077 
00078 class NtoMPanner : public Panner {
00079 
00080 protected:
00081     unsigned mInCh, mOutCh;     // the # of input and output channels
00082     CPoint ** mSpeakers;            // the speaker array
00083     SampleStream * mPosY;       // the Y coordinate
00084     float mSpread;              // angle between the channels in stereo inputs
00085     Buffer mOpBuffer;           // a temporary operation Buffer
00086     void initSpeakers(void);
00087 
00088 public:
00089                             // Constructors / destructor
00090                             // Args are: i: input, p: pan, a: ampl, s: spread
00091     NtoMPanner() : Panner() { };
00092     NtoMPanner(UnitGenerator & i, float a, unsigned in_c, unsigned out_c);
00093     NtoMPanner(UnitGenerator & i, SampleStream & pX, SampleStream & pY, SampleStream & a, unsigned in_c, unsigned out_c);
00094     NtoMPanner(UnitGenerator & i, SampleStream & pX, SampleStream & pY, SampleStream & a, unsigned in_c, unsigned out_c, float spr);
00095     NtoMPanner(UnitGenerator & i, SampleStream & pX, SampleStream & pY, float a, unsigned in_c, unsigned out_c, float spr);
00096     ~NtoMPanner();
00097                             // Setup speaker arrays
00098     void init_stereo(float dist);
00099     void init_quad(float dist);
00100     void init_5point1(float dist);
00101     void init_6ch(float x, float y);
00102                             // Operations -- these are only relevant if the positions are static variables
00103     void setX(float x) { _pos->set_value(x); };
00104     void setY(float y) { _posY->set_value(y); };
00105                             // do it!
00106     virtual void nextBuffer(Buffer &outputBuffer) throw (CException);
00107 };
00108 
00109 // Stereo width processor -- can mix stereo channels or subtract the sum from each to widen
00110 
00111 class StereoWidth : public Effect {
00112 
00113 protected:
00114     float mWidth;           // stereo width range: -1->1. -1 -- mix to mono, 0 -- no change 1 -- widen
00115     float mGain;            // amplitude scaler 0->10, 1 -- no scaling
00116     float mPan;             // pan position 0->1 0.5 -- no panning
00117 
00118 public:
00119                             // Constructors / destructor
00120     StereoWidth ();
00121     ~StereoWidth();
00122                 // Operations
00123     void set_width(float width) { _width = width; }             
00124     void set_pan(float pan) { _pan = pan; }
00125     void set_gain(float gain) { _gain = gain; }
00126 
00127     status next_buffer(Buffer & inputBuffer, Buffer & outputBuffer);
00128 };
00129 
00130 #endif NOT_PORTED_YET
00131 
00132 }
00133 
00134 #endif
00135 

Generated on Fri Apr 6 20:18:13 2007 for CSL by  doxygen 1.4.5-20051010