3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 Christian Schoenebeck * |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
29 |
#endif // DEBUG_HEADERS |
#endif // DEBUG_HEADERS |
30 |
|
|
31 |
#include "../common/Event.h" |
#include "../common/Event.h" |
32 |
#include "../common/EngineChannel.h" |
#include "../EngineChannel.h" |
33 |
|
#include "../../common/RingBuffer.h" |
34 |
#include "EngineGlobals.h" |
#include "EngineGlobals.h" |
35 |
#include "Engine.h" |
#include "Engine.h" |
36 |
|
#include "Voice.h" |
37 |
#include "InstrumentResourceManager.h" |
#include "InstrumentResourceManager.h" |
38 |
|
|
39 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
40 |
|
|
41 |
|
// just symbol prototyping |
42 |
class midi_key_info_t; |
class midi_key_info_t; |
43 |
|
class Voice; |
44 |
|
|
45 |
|
/** @brief Engine Channel of a gig::Engine |
46 |
|
* |
47 |
|
* Encapsulates a engine channel for the Gigasampler format capable |
48 |
|
* sampler engine. |
49 |
|
*/ |
50 |
class EngineChannel : public LinuxSampler::EngineChannel, public InstrumentConsumer { |
class EngineChannel : public LinuxSampler::EngineChannel, public InstrumentConsumer { |
51 |
public: |
public: |
52 |
EngineChannel(); |
EngineChannel(); |
53 |
virtual ~EngineChannel(); |
virtual ~EngineChannel(); |
54 |
|
|
55 |
// 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); |
|
56 |
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument); |
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument); |
57 |
virtual void LoadInstrument(); |
virtual void LoadInstrument(); |
58 |
|
virtual void Reset(); |
59 |
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity); |
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity); |
60 |
|
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); |
61 |
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity); |
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity); |
62 |
|
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); |
63 |
virtual void SendPitchbend(int Pitch); |
virtual void SendPitchbend(int Pitch); |
64 |
virtual void SendControlChange(uint8_t Controller, uint8_t Value); |
virtual void SendPitchbend(int Pitch, int32_t FragmentPos); |
65 |
|
virtual void SendControlChange(uint8_t Controller, uint8_t Value); |
66 |
|
virtual void SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos); |
67 |
|
virtual bool StatusChanged(bool bNewStatus = false); |
68 |
virtual float Volume(); |
virtual float Volume(); |
69 |
virtual void Volume(float f); |
virtual void Volume(float f); |
70 |
virtual uint Channels(); |
virtual uint Channels(); |
72 |
virtual void DisconnectAudioOutputDevice(); |
virtual void DisconnectAudioOutputDevice(); |
73 |
virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel); |
virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel); |
74 |
virtual int OutputChannel(uint EngineAudioChannel); |
virtual int OutputChannel(uint EngineAudioChannel); |
75 |
|
virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel); |
76 |
|
virtual void DisconnectMidiInputPort(); |
77 |
|
virtual MidiInputPort* GetMidiInputPort(); |
78 |
|
virtual midi_chan_t MidiChannel(); |
79 |
virtual String InstrumentFileName(); |
virtual String InstrumentFileName(); |
80 |
virtual String InstrumentName(); |
virtual String InstrumentName(); |
81 |
virtual int InstrumentIndex(); |
virtual int InstrumentIndex(); |
82 |
virtual int InstrumentStatus(); |
virtual int InstrumentStatus(); |
83 |
virtual LinuxSampler::Engine* GetEngine(); |
virtual LinuxSampler::Engine* GetEngine(); |
84 |
|
virtual String EngineName(); |
85 |
|
|
86 |
// implementation of abstract methods derived from interface class 'InstrumentConsumer' |
// implementation of abstract methods derived from interface class 'InstrumentConsumer' |
87 |
virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg); |
virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg); |
88 |
virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg); |
virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg); |
89 |
|
virtual void OnResourceProgress(float fProgress); |
90 |
//protected: |
|
91 |
|
//protected: |
92 |
Engine* pEngine; |
Engine* pEngine; |
93 |
float* pOutputLeft; ///< Audio output channel buffer (left) |
float* pOutputLeft; ///< Audio output channel buffer (left) |
94 |
float* pOutputRight; ///< Audio output channel buffer (right) |
float* pOutputRight; ///< Audio output channel buffer (right) |
95 |
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 |
96 |
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 |
97 |
|
MidiInputPort* pMidiInputPort; ///< Points to the connected MIDI input port or NULL if none assigned. |
98 |
|
midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to. |
99 |
RingBuffer<Event>* pEventQueue; ///< Input event queue. |
RingBuffer<Event>* pEventQueue; ///< Input event queue. |
100 |
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. |
101 |
|
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). |
102 |
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 |
103 |
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. |
104 |
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. |
105 |
::gig::Instrument* pInstrument; |
::gig::Instrument* pInstrument; |
106 |
bool SustainPedal; ///< true if sustain pedal is down |
bool SustainPedal; ///< true if sustain pedal is down |
107 |
double GlobalVolume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
bool SostenutoPedal; ///< true if sostenuto pedal is down |
108 |
|
bool SoloMode; ///< in Solo Mode we only play one voice (group) at a time |
109 |
|
int SoloKey; ///< Currently 'active' solo key, that is the key to which the currently sounding voice belongs to (only if SoloMode is enabled) |
110 |
|
bool PortamentoMode; ///< in Portamento Mode we slide the pitch from the last note to the current note. |
111 |
|
float PortamentoTime; ///< How long it will take to glide from the previous note to the current (in seconds) |
112 |
|
float PortamentoPos; ///< Current position on the keyboard, that is integer and fractional part (only used if PortamentoMode is on) |
113 |
|
double GlobalVolume; ///< Master volume factor set through the C++ API / LSCP (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
114 |
|
double MidiVolume; ///< Volume factor altered by MIDI CC#7 (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
115 |
|
float GlobalPanLeft; |
116 |
|
float GlobalPanRight; |
117 |
int Pitch; ///< Current (absolute) MIDI pitch value. |
int Pitch; ///< Current (absolute) MIDI pitch value. |
118 |
int CurrentKeyDimension; ///< Current value (0-127) for the keyboard dimension, altered by pressing a keyswitching key. |
float CurrentKeyDimension; ///< Current value (0-1.0) for the keyboard dimension, altered by pressing a keyswitching key. |
119 |
String InstrumentFile; |
String InstrumentFile; |
120 |
int InstrumentIdx; |
int InstrumentIdx; |
121 |
String InstrumentIdxName; |
String InstrumentIdxName; |
122 |
int InstrumentStat; |
int InstrumentStat; |
123 |
|
int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList. |
124 |
|
bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet) |
125 |
|
|
126 |
|
void ResetControllers(); |
127 |
|
void ClearEventLists(); |
128 |
|
void ImportEvents(uint Samples); |
129 |
|
|
130 |
friend class Engine; |
friend class Engine; |
131 |
friend class Voice; |
friend class Voice; |
132 |
friend class InstrumentResourceManager; |
friend class InstrumentResourceManager; |
133 |
|
|
134 |
private: |
private: |
135 |
void ResetInternal(); |
void ResetInternal(); |
136 |
}; |
}; |