CSL  6.0
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
InOut class copies the IO port's input buffer to the output buffer, possibly with channel remap and s...
Definition: InOut.h:37
BufferCMap mMap
the mapped buffer pointers for the output channels
Definition: InOut.h:59
#define kNoProc
Definition: InOut.h:25
unsigned getInChan(void)
Definition: InOut.h:48
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
void setChanGains(float *values)
set gain array
Definition: InOut.cpp:66
Effect – mix-in for classes that have unit generators as inputs (like filters).
Definition: CSL_Core.h:466
void setGain(unsigned index, float value)
set gain value at index
Definition: InOut.cpp:71
IO * mIO
The (Singleton) IO pointer (or NULL, to act as an effect)
Definition: InOut.h:58
BufferCMap is a Sample buffer with channel map and count.
Definition: CSL_Core.h:191
unsigned mOutChans
out chans
Definition: InOut.h:61
virtual void nextBuffer(Buffer &outputBuffer)
get a buffer of Frames – this is the core CSL "pull" function; the given buffer can be written into...
Definition: InOut.cpp:77
void setChanMap(unsigned *chans)
set channel map
Definition: InOut.cpp:61
int InOutFlags
Definition: InOut.h:30
void setOutChan(unsigned chan)
set # in/out chans
Definition: InOut.h:47
float * mGains
amplitude scales
Definition: InOut.h:63
unsigned mInChans
in chans
Definition: InOut.h:60
IO – the abstract I/O scheduling class; subclasses interface to specific I/O APIs.
Definition: CSL_Core.h:752
~InOut()
Definition: InOut.cpp:59
#define kR2M
Definition: InOut.h:28
unsigned getOutChan(void)
get # in/out chans
Definition: InOut.h:49
#define kN2M
Definition: InOut.h:29
#define kL2M
Definition: InOut.h:27
#define kLR2M
Definition: InOut.h:26
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
virtual sample value()
Definition: CSL_Core.h:285
forward declaration
Definition: CSL_Core.h:241
InOut(IO *anIO, unsigned inChans, unsigned outChans, InOutFlags f=kNoProc)
Constructor with IO, number of channels in & out, and processing.
Definition: InOut.cpp:17
InOutFlags mFlags
Definition: InOut.h:62
void setInChan(unsigned chan)
Definition: InOut.h:46
Base class of CSL exceptions (written upper-case). Has a string message.