linuxsampler 1.0.0

EngineChannel.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   Copyright (C) 2005 - 2009 Christian Schoenebeck                       *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the Free Software           *
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00018  *   MA  02111-1307  USA                                                   *
00019  ***************************************************************************/
00020 
00021 #ifndef __LS_ENGINECHANNEL_H__
00022 #define __LS_ENGINECHANNEL_H__
00023 
00024 #include "../EventListeners.h"
00025 #include "../drivers/audio/AudioOutputDevice.h"
00026 #include "../drivers/midi/midi.h"
00027 #include "../drivers/midi/MidiInputDevice.h"
00028 #include "../drivers/midi/MidiInputPort.h"
00029 #include "../drivers/midi/VirtualMidiDevice.h"
00030 #include "Engine.h"
00031 #include "FxSend.h"
00032 
00033 namespace LinuxSampler {
00034 
00035     // just symbol prototyping
00036     class Sampler;
00037     class SamplerChannel;
00038     class AudioOutputDevice;
00039     class MidiInputPort;
00040     class FxSend;
00041 
00042 
00054     class EngineChannel {
00055         public:
00056 
00058             // abstract methods
00059             //     (these have to be implemented by the descendant)
00060 
00061             virtual void    PrepareLoadInstrument(const char* FileName, uint Instrument) = 0;
00062             virtual void    LoadInstrument() = 0;
00063             virtual void    Reset() = 0;
00064             virtual void    SendNoteOn(uint8_t Key, uint8_t Velocity) = 0;
00065             virtual void    SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) = 0;
00066             virtual void    SendNoteOff(uint8_t Key, uint8_t Velocity) = 0;
00067             virtual void    SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) = 0;
00068             virtual void    SendPitchbend(int Pitch) = 0;
00069             virtual void    SendPitchbend(int Pitch, int32_t FragmentPos) = 0;
00070             virtual void    SendControlChange(uint8_t Controller, uint8_t Value) = 0;
00071             virtual void    SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos) = 0;
00072             virtual void    SendProgramChange(uint8_t Program) = 0;
00073             virtual bool    StatusChanged(bool bNewStatus = false) = 0;
00074             virtual float   Volume() = 0;
00075             virtual void    Volume(float f) = 0;
00076             virtual float   Pan() = 0;
00077             virtual void    Pan(float f) = 0;
00078             virtual uint    Channels() = 0;
00079             virtual void    Connect(AudioOutputDevice* pAudioOut) = 0;
00080             virtual void    DisconnectAudioOutputDevice() = 0;
00081             virtual AudioOutputDevice* GetAudioOutputDevice() = 0;
00082             virtual void    SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) = 0;
00083             virtual int     OutputChannel(uint EngineAudioChannel) = 0;
00084             virtual void    Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) = 0;
00085             virtual void    DisconnectMidiInputPort() = 0;
00086             virtual MidiInputPort* GetMidiInputPort() = 0;
00087             virtual midi_chan_t MidiChannel() = 0;
00088             virtual String  InstrumentFileName() = 0;
00089             virtual String  InstrumentName() = 0;
00090             virtual int     InstrumentIndex() = 0;
00091             virtual int     InstrumentStatus() = 0;
00092             virtual Engine* GetEngine() = 0;
00093             virtual String  EngineName() = 0;
00094             virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception) = 0;
00095             virtual FxSend* GetFxSend(uint FxSendIndex) = 0;
00096             virtual uint    GetFxSendCount() = 0;
00097             virtual void    RemoveFxSend(FxSend* pFxSend) = 0;
00098             virtual void    Connect(VirtualMidiDevice* pDevice) = 0;
00099             virtual void    Disconnect(VirtualMidiDevice* pDevice) = 0;
00100 
00101 
00103             // normal methods
00104             //     (usually not to be overridden by descendant)
00105 
00113             void SetMute(int state) throw (Exception);
00114 
00122             int GetMute();
00123 
00129             void SetSolo(bool solo);
00130 
00136             bool GetSolo();
00137 
00142             uint8_t GetMidiProgram();
00143 
00147             void SetMidiProgram(uint8_t Program);
00148 
00153             uint8_t GetMidiBankMsb();
00154 
00159             void SetMidiBankMsb(uint8_t BankMSB);
00160 
00165             uint8_t GetMidiBankLsb();
00166 
00171             void SetMidiBankLsb(uint8_t BankLSB);
00172 
00181             bool UsesNoMidiInstrumentMap();
00182 
00190             bool UsesDefaultMidiInstrumentMap();
00191 
00206             int GetMidiInstrumentMap() throw (Exception);
00207 
00215             void SetMidiInstrumentMapToNone();
00216 
00224             void SetMidiInstrumentMapToDefault();
00225 
00235             void SetMidiInstrumentMap(int MidiMap) throw (Exception);
00236 
00241             void SetMidiRpnControllerMsb(uint8_t CtrlMSB);
00242 
00247             void SetMidiRpnControllerLsb(uint8_t CtrlLSB);
00248 
00252             void ResetMidiRpnController();
00253 
00258             void AddFxSendCountListener(FxSendCountListener* l);
00259 
00263             void RemoveFxSendCountListener(FxSendCountListener* l);
00264 
00268             void RemoveAllFxSendCountListeners();
00269 
00283             int GetMidiRpnController();
00284 
00288             uint GetVoiceCount();
00289 
00293             void SetVoiceCount(uint Voices);
00294 
00298             uint GetDiskStreamCount();
00299 
00303             void SetDiskStreamCount(uint Streams);
00304 
00305             SamplerChannel* GetSamplerChannel();
00306 
00307             void SetSamplerChannel(SamplerChannel* pChannel);
00308 
00310             Sampler* GetSampler();
00311 
00317             void ExecuteProgramChange(uint8_t Program);
00318 
00319         protected:
00320             EngineChannel();
00321             virtual ~EngineChannel(); // MUST only be destroyed by EngineChannelFactory
00322 
00329             void fireFxSendCountChanged(int ChannelId, int NewCount);
00330 
00331             friend class EngineChannelFactory;
00332 
00333         private:
00334             struct private_data_t;
00335             private_data_t* const p;
00336     };
00337 
00338 } // namespace LinuxSampler
00339 
00340 #endif // __LS_ENGINECHANNEL_H__