32 |
#include "../common/EngineChannel.h" |
#include "../common/EngineChannel.h" |
33 |
#include "EngineGlobals.h" |
#include "EngineGlobals.h" |
34 |
#include "Engine.h" |
#include "Engine.h" |
35 |
|
#include "Voice.h" |
36 |
#include "InstrumentResourceManager.h" |
#include "InstrumentResourceManager.h" |
37 |
|
|
38 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
39 |
|
|
40 |
|
// just symbol prototyping |
41 |
class midi_key_info_t; |
class midi_key_info_t; |
42 |
|
class Voice; |
43 |
|
|
44 |
|
/** @brief Engine Channel of a gig::Engine |
45 |
|
* |
46 |
|
* Encapsulates a engine channel for the Gigasampler format capable |
47 |
|
* sampler engine. |
48 |
|
*/ |
49 |
class EngineChannel : public LinuxSampler::EngineChannel, public InstrumentConsumer { |
class EngineChannel : public LinuxSampler::EngineChannel, public InstrumentConsumer { |
50 |
public: |
public: |
51 |
EngineChannel(); |
EngineChannel(); |
52 |
virtual ~EngineChannel(); |
virtual ~EngineChannel(); |
53 |
|
|
54 |
// implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel' |
// implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel' |
|
virtual int RenderAudio(uint Samples); |
|
55 |
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument); |
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument); |
56 |
virtual void LoadInstrument(); |
virtual void LoadInstrument(); |
57 |
|
virtual void Reset(); |
58 |
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity); |
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity); |
59 |
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity); |
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity); |
60 |
virtual void SendPitchbend(int Pitch); |
virtual void SendPitchbend(int Pitch); |
61 |
virtual void SendControlChange(uint8_t Controller, uint8_t Value); |
virtual void SendControlChange(uint8_t Controller, uint8_t Value); |
62 |
|
virtual bool StatusChanged(bool bNewStatus = false); |
63 |
virtual float Volume(); |
virtual float Volume(); |
64 |
virtual void Volume(float f); |
virtual void Volume(float f); |
65 |
virtual uint Channels(); |
virtual uint Channels(); |
71 |
virtual String InstrumentName(); |
virtual String InstrumentName(); |
72 |
virtual int InstrumentIndex(); |
virtual int InstrumentIndex(); |
73 |
virtual int InstrumentStatus(); |
virtual int InstrumentStatus(); |
74 |
virtual LinuxSampler::Engine* GetEngine(); |
virtual LinuxSampler::Engine* GetEngine(); |
75 |
|
virtual String EngineName(); |
76 |
|
|
77 |
// implementation of abstract methods derived from interface class 'InstrumentConsumer' |
// implementation of abstract methods derived from interface class 'InstrumentConsumer' |
78 |
virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg); |
virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg); |
79 |
virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg); |
virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg); |
80 |
|
virtual void OnResourceProgress(float fProgress); |
81 |
//protected: |
|
82 |
|
//protected: |
83 |
Engine* pEngine; |
Engine* pEngine; |
84 |
float* pOutputLeft; ///< Audio output channel buffer (left) |
float* pOutputLeft; ///< Audio output channel buffer (left) |
85 |
float* pOutputRight; ///< Audio output channel buffer (right) |
float* pOutputRight; ///< Audio output channel buffer (right) |
86 |
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 |
87 |
int AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to |
int AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to |
88 |
RingBuffer<Event>* pEventQueue; ///< Input event queue. |
RingBuffer<Event>* pEventQueue; ///< Input event queue. |
89 |
uint8_t ControllerTable[128]; ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel. |
RTList<Event>* pEvents; ///< All engine channel specific events for the current audio fragment. |
90 |
|
RTList<Event>* pCCEvents; ///< All control change events for the current audio fragment on this engine channel. |
91 |
|
RTList<Event>* pSynthesisEvents[Event::destination_count]; ///< Events directly affecting synthesis parameters (like pitch, volume and filter). |
92 |
|
uint8_t ControllerTable[128]; ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel. |
93 |
midi_key_info_t* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key |
midi_key_info_t* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key |
94 |
Pool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices. |
Pool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices. |
95 |
std::map<uint,uint*> ActiveKeyGroups; ///< Contains active keys (in case they belong to a key group) ordered by key group ID. |
std::map<uint,uint*> ActiveKeyGroups; ///< Contains active keys (in case they belong to a key group) ordered by key group ID. |
96 |
::gig::Instrument* pInstrument; |
::gig::Instrument* pInstrument; |
97 |
bool SustainPedal; ///< true if sustain pedal is down |
bool SustainPedal; ///< true if sustain pedal is down |
98 |
double GlobalVolume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
double GlobalVolume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
99 |
|
float GlobalPanLeft; |
100 |
|
float GlobalPanRight; |
101 |
int Pitch; ///< Current (absolute) MIDI pitch value. |
int Pitch; ///< Current (absolute) MIDI pitch value. |
102 |
int CurrentKeyDimension; ///< Current value (0-127) for the keyboard dimension, altered by pressing a keyswitching key. |
int CurrentKeyDimension; ///< Current value (0-127) for the keyboard dimension, altered by pressing a keyswitching key. |
103 |
String InstrumentFile; |
String InstrumentFile; |
104 |
int InstrumentIdx; |
int InstrumentIdx; |
105 |
String InstrumentIdxName; |
String InstrumentIdxName; |
106 |
int InstrumentStat; |
int InstrumentStat; |
107 |
|
int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList. |
108 |
|
bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet) |
109 |
|
|
110 |
|
void ResetControllers(); |
111 |
|
void ClearEventLists(); |
112 |
|
void ImportEvents(uint Samples); |
113 |
|
|
114 |
friend class Engine; |
friend class Engine; |
115 |
friend class Voice; |
friend class Voice; |
116 |
friend class InstrumentResourceManager; |
friend class InstrumentResourceManager; |
117 |
|
|
118 |
private: |
private: |
119 |
void ResetInternal(); |
void ResetInternal(); |
120 |
}; |
}; |