linuxsampler 1.0.0
|
00001 /*************************************************************************** 00002 * * 00003 * LinuxSampler - modular, streaming capable sampler * 00004 * * 00005 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * 00006 * Copyright (C) 2005 - 2009 Christian Schoenebeck * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 00021 * MA 02111-1307 USA * 00022 ***************************************************************************/ 00023 00024 #ifndef __LS_MIDIINPUTPORT_H__ 00025 #define __LS_MIDIINPUTPORT_H__ 00026 00027 #include "../../common/global.h" 00028 #include "../../common/Mutex.h" 00029 #include "../../common/Exception.h" 00030 #include "../DeviceParameter.h" 00031 #include "midi.h" 00032 #include "MidiInputDevice.h" 00033 #include "../../engines/EngineChannel.h" 00034 #include "../../common/SynchronizedConfig.h" 00035 00036 namespace LinuxSampler { 00037 00038 // just symbol prototyping 00039 class MidiInputDevice; 00040 class EngineChannel; 00041 class VirtualMidiDevice; 00042 00043 class MidiInputPort { 00044 public: 00045 00047 // type definitions 00048 00053 class ParameterName : public DeviceRuntimeParameterString { 00054 public: 00055 ParameterName(MidiInputPort* pPort); 00056 ParameterName(MidiInputPort* pPort, String val); 00057 virtual String Description(); 00058 virtual bool Fix(); 00059 virtual std::vector<String> PossibilitiesAsString(); 00060 virtual void OnSetValue(String s) throw (Exception); 00061 protected: 00062 MidiInputPort* pPort; 00063 }; 00064 00065 00066 00068 // normal methods 00069 // (usually not to be overriden by descendant) 00070 00083 void Connect(EngineChannel* pEngineChannel, midi_chan_t MidiChannel); 00084 00092 void Disconnect(EngineChannel* pEngineChannel); 00093 00097 MidiInputDevice* GetDevice(); 00098 00103 uint GetPortNumber(); 00104 00108 std::map<String,DeviceRuntimeParameter*> PortParameters(); 00109 00113 static void AddSysexListener(Engine* engine); 00114 00122 static bool RemoveSysexListener(Engine* engine); 00123 00130 void Connect(VirtualMidiDevice* pDevice); 00131 00135 void Disconnect(VirtualMidiDevice* pDevice); 00136 00137 00139 // dispatch methods 00140 // (should be called by the MidiInputDevice descendant on events) 00141 00157 void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel); 00158 00175 void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel, int32_t FragmentPos); 00176 00192 void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel); 00193 00210 void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel, int32_t FragmentPos); 00211 00225 void DispatchPitchbend(int Pitch, uint MidiChannel); 00226 00241 void DispatchPitchbend(int Pitch, uint MidiChannel, int32_t FragmentPos); 00242 00258 void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel); 00259 00276 void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel, int32_t FragmentPos); 00277 00298 void DispatchProgramChange(uint8_t Program, uint MidiChannel); 00299 00300 void DispatchBankSelectMsb(uint8_t BankMsb, uint MidiChannel); 00301 00302 void DispatchBankSelectLsb(uint8_t BankLsb, uint MidiChannel); 00303 00312 void DispatchSysex(void* pData, uint Size); 00313 00320 void DispatchRaw(uint8_t* pData); 00321 00330 void DispatchRaw(uint8_t* pData, int32_t FragmentPos); 00331 00332 protected: 00333 MidiInputDevice* pDevice; 00334 int portNumber; 00335 std::map<String,DeviceRuntimeParameter*> Parameters; 00336 typedef std::set<EngineChannel*> MidiChannelMap_t[17]; 00337 SynchronizedConfig<MidiChannelMap_t> MidiChannelMap; 00338 SynchronizedConfig<MidiChannelMap_t>::Reader MidiChannelMapReader; 00339 Mutex MidiChannelMapMutex; 00340 SynchronizedConfig<std::set<Engine*> >::Reader SysexListenersReader; 00341 SynchronizedConfig<std::vector<VirtualMidiDevice*> > virtualMidiDevices; 00342 SynchronizedConfig<std::vector<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader; 00343 Mutex virtualMidiDevicesMutex; 00344 00348 MidiInputPort(MidiInputDevice* pDevice, int portNumber); 00349 00353 virtual ~MidiInputPort(); 00354 00355 friend class MidiInputDevice; 00356 00357 private: 00358 static SynchronizedConfig<std::set<Engine*> > SysexListeners; 00359 }; 00360 00361 } // namsepace LinuxSampler 00362 00363 #endif // __LS_MIDIINPUTPORT_H__