CSL  5.2
InOut.h
Go to the documentation of this file.
1 //
2 // InOut.h -- copies the input buffer to the output buffer, possibly with channel remap and scaling
3 // Constructor: InOut(UnitGenerator &, unsigned inChan, [unsigned outChan, ch-1 ... ch-outChan]);
4 //
5 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
6 //
7 
8 #ifndef CSL_InOut_H
9 #define CSL_InOut_H
10 
11 #include "CSL_Core.h"
12 #include <stdarg.h> // for varargs
13 
14 namespace csl {
15 
16 #ifdef CSL_ENUMS
17 typedef enum {
18  kNoProc, // tries to keep it mono or stereo if in_chans == out_chans
19  kLR2M, // mixes the L and R inputs down to a mono signal
20  kL2M, // Copies left input to make mono
21  kR2M, // Copies right input to make mono
22  kN2M, // Copies N-channel input to M-channel output using a map
23 } InOutFlags;
24 #else
25  #define kNoProc 0
26  #define kLR2M 1
27  #define kL2M 2
28  #define kR2M 3
29  #define kN2M 4
30  typedef int InOutFlags;
31 #endif
32 
33 ///
34 /// InOut class copies the IO port's input buffer to the output buffer, possibly with channel remap and scaling
35 ///
36 
37 class InOut : public Effect {
38 public:
39  /// Constructor with IO, number of channels in & out, and processing
40  InOut(IO * anIO, unsigned inChans, unsigned outChans, InOutFlags f = kNoProc);
41  InOut(IO * anIO, unsigned inChans, unsigned outChans, InOutFlags f, ...);
42  InOut(UnitGenerator & myInput, unsigned inChans, unsigned outChans, InOutFlags f = kNoProc);
43  InOut(UnitGenerator & myInput, unsigned inChans, unsigned outChans, InOutFlags, ...);
44  ~InOut();
45 
46  void setInChan(unsigned chan) { mInChans = chan; }; ///< set # in/out chans
47  void setOutChan(unsigned chan) { mOutChans = chan; };
48  unsigned getInChan(void) { return mInChans; }; ///< get # in/out chans
49  unsigned getOutChan(void) { return mOutChans; };
50 
51  void setChanMap(unsigned * chans); ///< set channel map
52  void setChanGains(float * values); ///< set gain array
53  void setGain(unsigned index, float value); ///< set gain value at index
54 
55  virtual void nextBuffer(Buffer & outputBuffer) throw (CException);
56 
57 private:
58  IO * mIO; ///< The (Singleton) IO pointer (or NULL, to act as an effect)
59  BufferCMap mMap; ///< the mapped buffer pointers for the output channels
60  unsigned mInChans; ///< # in chans
61  unsigned mOutChans; ///< # out chans
62  InOutFlags mFlags; //< copy/process flag
63  float *mGains; ///< amplitude scales
64 };
65 
66 }
67 
68 #endif