1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
7 |
* * |
8 |
* 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 * |
10 |
* the Free Software Foundation; either version 2 of the License, or * |
11 |
* (at your option) any later version. * |
12 |
* * |
13 |
* This program is distributed in the hope that it will be useful, * |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
* GNU General Public License for more details. * |
17 |
* * |
18 |
* You should have received a copy of the GNU General Public License * |
19 |
* along with this program; if not, write to the Free Software * |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
* MA 02111-1307 USA * |
22 |
***************************************************************************/ |
23 |
|
24 |
#ifndef __LS_GIG_ENGINECHANNEL_H__ |
25 |
#define __LS_GIG_ENGINECHANNEL_H__ |
26 |
|
27 |
#include "../common/Event.h" |
28 |
#include "../EngineChannel.h" |
29 |
#include "../../common/RingBuffer.h" |
30 |
#include "../../drivers/audio/AudioChannel.h" |
31 |
#include "EngineGlobals.h" |
32 |
#include "Engine.h" |
33 |
#include "Voice.h" |
34 |
#include "InstrumentResourceManager.h" |
35 |
|
36 |
namespace LinuxSampler { namespace gig { |
37 |
|
38 |
// just symbol prototyping |
39 |
class midi_key_info_t; |
40 |
class Voice; |
41 |
|
42 |
/** @brief Engine Channel of a gig::Engine |
43 |
* |
44 |
* Encapsulates a engine channel for the Gigasampler format capable |
45 |
* sampler engine. |
46 |
*/ |
47 |
class EngineChannel : public LinuxSampler::EngineChannel, public InstrumentConsumer { |
48 |
public: |
49 |
EngineChannel(); |
50 |
virtual ~EngineChannel(); |
51 |
|
52 |
// implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel' |
53 |
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument); |
54 |
virtual void LoadInstrument(); |
55 |
virtual void Reset(); |
56 |
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity); |
57 |
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); |
58 |
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity); |
59 |
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); |
60 |
virtual void SendPitchbend(int Pitch); |
61 |
virtual void SendPitchbend(int Pitch, int32_t FragmentPos); |
62 |
virtual void SendControlChange(uint8_t Controller, uint8_t Value); |
63 |
virtual void SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos); |
64 |
virtual bool StatusChanged(bool bNewStatus = false); |
65 |
virtual float Volume(); |
66 |
virtual void Volume(float f); |
67 |
virtual uint Channels(); |
68 |
virtual void Connect(AudioOutputDevice* pAudioOut); |
69 |
virtual void DisconnectAudioOutputDevice(); |
70 |
virtual AudioOutputDevice* GetAudioOutputDevice(); |
71 |
virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel); |
72 |
virtual int OutputChannel(uint EngineAudioChannel); |
73 |
virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel); |
74 |
virtual void DisconnectMidiInputPort(); |
75 |
virtual MidiInputPort* GetMidiInputPort(); |
76 |
virtual midi_chan_t MidiChannel(); |
77 |
virtual String InstrumentFileName(); |
78 |
virtual String InstrumentName(); |
79 |
virtual int InstrumentIndex(); |
80 |
virtual int InstrumentStatus(); |
81 |
virtual LinuxSampler::Engine* GetEngine(); |
82 |
virtual String EngineName(); |
83 |
virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception); |
84 |
virtual FxSend* GetFxSend(uint FxSendIndex); |
85 |
virtual uint GetFxSendCount(); |
86 |
virtual void RemoveFxSend(FxSend* pFxSend); |
87 |
|
88 |
// implementation of abstract methods derived from interface class 'InstrumentConsumer' |
89 |
virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg); |
90 |
virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg); |
91 |
virtual void OnResourceProgress(float fProgress); |
92 |
|
93 |
//protected: |
94 |
Engine* pEngine; |
95 |
AudioChannel* pChannelLeft; ///< encapsulates the audio rendering buffer (left) |
96 |
AudioChannel* pChannelRight; ///< encapsulates the audio rendering buffer (right) |
97 |
int AudioDeviceChannelLeft; ///< audio device channel number to which the left channel is connected to |
98 |
int AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to |
99 |
MidiInputPort* pMidiInputPort; ///< Points to the connected MIDI input port or NULL if none assigned. |
100 |
midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to. |
101 |
RingBuffer<Event,false>* pEventQueue; ///< Input event queue. |
102 |
RTList<Event>* pEvents; ///< All engine channel specific events for the current audio fragment. |
103 |
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). |
104 |
midi_key_info_t* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key |
105 |
Pool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices. |
106 |
std::map<uint,uint*> ActiveKeyGroups; ///< Contains active keys (in case they belong to a key group) ordered by key group ID. |
107 |
::gig::Instrument* pInstrument; |
108 |
bool SustainPedal; ///< true if sustain pedal is down |
109 |
bool SostenutoPedal; ///< true if sostenuto pedal is down |
110 |
bool SoloMode; ///< in Solo Mode we only play one voice (group) at a time |
111 |
int SoloKey; ///< Currently 'active' solo key, that is the key to which the currently sounding voice belongs to (only if SoloMode is enabled) |
112 |
bool PortamentoMode; ///< in Portamento Mode we slide the pitch from the last note to the current note. |
113 |
float PortamentoTime; ///< How long it will take to glide from the previous note to the current (in seconds) |
114 |
float PortamentoPos; ///< Current position on the keyboard, that is integer and fractional part (only used if PortamentoMode is on) |
115 |
double GlobalVolume; ///< Master volume factor set through the C++ API / LSCP (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
116 |
double MidiVolume; ///< Volume factor altered by MIDI CC#7 (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
117 |
float GlobalPanLeft; |
118 |
float GlobalPanRight; |
119 |
int Pitch; ///< Current (absolute) MIDI pitch value. |
120 |
float CurrentKeyDimension; ///< Current value (0-1.0) for the keyboard dimension, altered by pressing a keyswitching key. |
121 |
String InstrumentFile; |
122 |
int InstrumentIdx; |
123 |
String InstrumentIdxName; |
124 |
int InstrumentStat; |
125 |
int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList. |
126 |
bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet) |
127 |
std::vector<FxSend*> fxSends; |
128 |
int GlobalTranspose; ///< amount of semi tones all notes should be transposed |
129 |
|
130 |
void ResetControllers(); |
131 |
void ClearEventLists(); |
132 |
void ImportEvents(uint Samples); |
133 |
|
134 |
friend class Engine; |
135 |
friend class Voice; |
136 |
friend class InstrumentResourceManager; |
137 |
|
138 |
private: |
139 |
void ResetInternal(); |
140 |
void RemoveAllFxSends(); |
141 |
}; |
142 |
|
143 |
}} // namespace LinuxSampler::gig |
144 |
|
145 |
#endif // __LS_GIG_ENGINECHANNEL_H__ |