00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef TSE3_MIXER_H
00018 #define TSE3_MIXER_H
00019
00020 #include "tse3/listen/Mixer.h"
00021
00022 #include "tse3/Notifier.h"
00023 #include "tse3/Midi.h"
00024 #include "tse3/listen/Transport.h"
00025
00026 #include <cstddef>
00027
00028 namespace TSE3
00029 {
00048 class MixerChannel : public Notifier<MixerChannelListener>
00049 {
00050 public:
00051
00058 unsigned int volume() const { return _volume; }
00059
00067 void setVolume(unsigned int v, bool send = true);
00068
00075 unsigned int pan() const { return _volume; }
00076
00084 void setPan(unsigned int p, bool send = true);
00085
00092 unsigned int chorus() const { return _volume; }
00093
00101 void setChorus(unsigned int c, bool send = true);
00102
00109 unsigned int reverb() const { return _volume; }
00110
00118 void setReverb(unsigned int r, bool send = true);
00119
00126 unsigned int program() const { return _volume; }
00127
00135 void setProgram(unsigned int p, bool send = true);
00136
00143 unsigned int bankLSB() const { return _volume; }
00144
00152 void setBankLSB(unsigned int b, bool send = true);
00153
00160 unsigned int bankMSB() const { return _volume; }
00161
00169 void setBankMSB(unsigned int b, bool send = true);
00170
00181 void command(MidiCommand mc);
00182
00183 friend class MixerPort;
00184
00185 private:
00186
00190 MixerChannel(MixerPort *mixerPort, unsigned int channel);
00191 virtual ~MixerChannel();
00192
00193 MixerChannel(const MixerChannel &);
00194 MixerChannel &operator=(const MixerChannel &);
00195
00196 MixerPort *mixerPort;
00197 unsigned int channel;
00198 unsigned char _volume;
00199 unsigned char _pan;
00200 unsigned char _chorus;
00201 unsigned char _reverb;
00202 unsigned char _program;
00203 unsigned char _bankLSB;
00204 unsigned char _bankMSB;
00205 };
00206
00218 class MixerPort : public Notifier<MixerPortListener>
00219 {
00220 public:
00221
00233 MixerChannel *operator[](size_t n) { return mixerChannels[n]; }
00234
00241 unsigned int volume() const { return _volume; }
00242
00250 void setVolume(unsigned int v, bool send = true);
00251
00263 void command(MidiCommand mc);
00264
00265 friend class Mixer;
00266 friend class MixerChannel;
00267
00268 private:
00269
00270 MixerPort(Mixer *mixer, unsigned int port);
00271 virtual ~MixerPort();
00272
00273 MixerPort(const MixerPort &);
00274 MixerPort &operator=(const MixerPort &);
00275
00280 void txCommand(MidiCommand mc);
00281
00282 MixerChannel *mixerChannels[16];
00283 Mixer *mixer;
00284 unsigned int port;
00285 unsigned char _volume;
00286 };
00287
00307 class Mixer : public Notifier<MixerListener>,
00308 public Listener<TransportListener>,
00309 public TransportCallback
00310 {
00311 public:
00312
00320 Mixer(size_t noPorts, Transport *transport);
00321 virtual ~Mixer();
00322
00334 MixerPort *operator[](size_t n) { return mixerPorts[n]; }
00335
00344 void command(MidiCommand mc);
00345
00349 virtual void Notifier_Deleted(Transport *);
00350
00354 virtual void Transport_MidiIn(MidiCommand mc);
00355
00359 virtual void Transport_MidiOut(MidiCommand mc);
00360
00361 friend class MixerPort;
00362
00363 private:
00364
00365 Mixer(const Mixer &);
00366 Mixer &operator=(const Mixer &);
00367
00372 void txCommand(MidiCommand mc);
00373
00374 size_t noPorts;
00375 MixerPort **mixerPorts;
00376 Transport *transport;
00377 bool _updateWithInput;
00378 bool _updateWithOutput;
00379 };
00380
00381 }
00382
00383 #endif