Panners.h

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

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