31 |
|
|
32 |
#include "../common/Pool.h" |
#include "../common/Pool.h" |
33 |
#include "../common/RingBuffer.h" |
#include "../common/RingBuffer.h" |
34 |
|
#include "../common/ResourceManager.h" |
35 |
|
#include "common/AbstractInstrumentManager.h" |
36 |
|
#include "common/InstrumentScriptVM.h" |
37 |
|
|
38 |
|
#define CTRL_TABLE_IDX_AFTERTOUCH 128 |
39 |
|
#define CTRL_TABLE_IDX_PITCHBEND 129 |
40 |
|
|
41 |
namespace LinuxSampler { |
namespace LinuxSampler { |
42 |
|
|
43 |
class AbstractEngineChannel: public EngineChannel { |
class MidiKeyboardManagerBase; |
44 |
|
|
45 |
|
class AbstractEngineChannel: public EngineChannel, public InstrumentScriptConsumer { |
46 |
public: |
public: |
47 |
// implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel' |
// implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel' |
48 |
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument) OVERRIDE; |
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument) OVERRIDE; |
91 |
virtual void Connect(VirtualMidiDevice* pDevice) OVERRIDE; |
virtual void Connect(VirtualMidiDevice* pDevice) OVERRIDE; |
92 |
virtual void Disconnect(VirtualMidiDevice* pDevice) OVERRIDE; |
virtual void Disconnect(VirtualMidiDevice* pDevice) OVERRIDE; |
93 |
|
|
94 |
|
// implementation of abstract methods derived from AbstractEngine::ScriptConsumer |
95 |
|
virtual void ResourceToBeUpdated(VMParserContext* pResource, void*& pUpdateArg) OVERRIDE {} |
96 |
|
virtual void ResourceUpdated(VMParserContext* pOldResource, VMParserContext* pNewResource, void* pUpdateArg) OVERRIDE {} |
97 |
|
virtual void OnResourceProgress(float fProgress) OVERRIDE {} |
98 |
|
|
99 |
virtual AbstractEngine::Format GetEngineFormat() = 0; |
virtual AbstractEngine::Format GetEngineFormat() = 0; |
100 |
|
virtual MidiKeyboardManagerBase* GetMidiKeyboardManager() = 0; |
101 |
|
|
102 |
AudioOutputDevice* GetAudioOutputDeviceSafe(); |
AudioOutputDevice* GetAudioOutputDeviceSafe(); |
103 |
|
|
106 |
template<class TV, class TRR, class TR, class TD, class TIM, class TI> friend class EngineBase; |
template<class TV, class TRR, class TR, class TD, class TIM, class TI> friend class EngineBase; |
107 |
template<class EC, class R, class S, class D> friend class VoiceBase; |
template<class EC, class R, class S, class D> friend class VoiceBase; |
108 |
|
|
109 |
protected: |
//protected: |
110 |
AbstractEngineChannel(); |
AbstractEngineChannel(); |
111 |
virtual ~AbstractEngineChannel(); |
virtual ~AbstractEngineChannel(); |
112 |
|
|
114 |
Mutex EngineMutex; ///< protects the Engine from access by the instrument loader thread when lscp is disconnecting |
Mutex EngineMutex; ///< protects the Engine from access by the instrument loader thread when lscp is disconnecting |
115 |
Mutex MidiInputMutex; ///< Introduced when support for multiple MIDI inputs per engine channel was added: protects the MIDI event input ringbuffer on this engine channel to be accessed concurrently by multiple midi input threads. As alternative one might also move the ringbuffer from this engine channel to the individual MIDI ports/devices and let the sampler engine read the events from there instead of receiving them here. |
Mutex MidiInputMutex; ///< Introduced when support for multiple MIDI inputs per engine channel was added: protects the MIDI event input ringbuffer on this engine channel to be accessed concurrently by multiple midi input threads. As alternative one might also move the ringbuffer from this engine channel to the individual MIDI ports/devices and let the sampler engine read the events from there instead of receiving them here. |
116 |
|
|
117 |
protected: |
//protected: |
118 |
AudioChannel* pChannelLeft; ///< encapsulates the audio rendering buffer (left) |
AudioChannel* pChannelLeft; ///< encapsulates the audio rendering buffer (left) |
119 |
AudioChannel* pChannelRight; ///< encapsulates the audio rendering buffer (right) |
AudioChannel* pChannelRight; ///< encapsulates the audio rendering buffer (right) |
120 |
int AudioDeviceChannelLeft; ///< audio device channel number to which the left channel is connected to |
int AudioDeviceChannelLeft; ///< audio device channel number to which the left channel is connected to |
123 |
midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to (on all MIDI input ports). |
midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to (on all MIDI input ports). |
124 |
RingBuffer<Event,false>* pEventQueue; ///< Input event queue. |
RingBuffer<Event,false>* pEventQueue; ///< Input event queue. |
125 |
RTList<Event>* pEvents; ///< All engine channel specific events for the current audio fragment. |
RTList<Event>* pEvents; ///< All engine channel specific events for the current audio fragment. |
126 |
uint8_t ControllerTable[129]; ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel. Number 128 is for channel pressure (mono aftertouch). |
uint8_t ControllerTable[130]; ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel. Number 128 is for channel pressure (mono aftertouch), 129 for pitch bend. |
127 |
String InstrumentFile; |
String InstrumentFile; |
128 |
int InstrumentIdx; |
int InstrumentIdx; |
129 |
String InstrumentIdxName; |
String InstrumentIdxName; |
141 |
int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList. |
int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList. |
142 |
bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet) |
bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet) |
143 |
uint32_t RoundRobinIndex; ///< counter for round robin sample selection, incremented for each note on |
uint32_t RoundRobinIndex; ///< counter for round robin sample selection, incremented for each note on |
144 |
|
InstrumentScript* pScript; ///< Points to the real-time instrument script(s) to be executed, NULL if current instrument does not have an instrument script. |
145 |
|
|
146 |
SynchronizedConfig< ArrayList<VirtualMidiDevice*> > virtualMidiDevices; |
SynchronizedConfig< ArrayList<VirtualMidiDevice*> > virtualMidiDevices; |
147 |
SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_AudioThread; |
SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_AudioThread; |
170 |
virtual void RemoveAllFxSends(); |
virtual void RemoveAllFxSends(); |
171 |
|
|
172 |
void ImportEvents(uint Samples); |
void ImportEvents(uint Samples); |
173 |
|
int ScheduleEvent(const Event* pEvent, int delay); //TODO: delay not implemented yet |
174 |
|
void IgnoreEvent(int id); |
175 |
|
|
176 |
void AddGroup(uint group); |
void AddGroup(uint group); |
177 |
void HandleKeyGroupConflicts(uint KeyGroup, Pool<Event>::Iterator& itNoteOnEvent); |
void HandleKeyGroupConflicts(uint KeyGroup, Pool<Event>::Iterator& itNoteOnEvent); |