1 |
iliev |
2012 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
|
* Copyright (C) 2005-2009 Christian Schoenebeck * |
7 |
|
|
* Copyright (C) 2009 Grigor Iliev * |
8 |
|
|
* * |
9 |
|
|
* This program is free software; you can redistribute it and/or modify * |
10 |
|
|
* it under the terms of the GNU General Public License as published by * |
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
12 |
|
|
* (at your option) any later version. * |
13 |
|
|
* * |
14 |
|
|
* This program is distributed in the hope that it will be useful, * |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
17 |
|
|
* GNU General Public License for more details. * |
18 |
|
|
* * |
19 |
|
|
* You should have received a copy of the GNU General Public License * |
20 |
|
|
* along with this program; if not, write to the Free Software * |
21 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
22 |
|
|
* MA 02111-1307 USA * |
23 |
|
|
***************************************************************************/ |
24 |
|
|
|
25 |
|
|
#ifndef __LS_ABSTRACTENGINECHANNEL_H__ |
26 |
|
|
#define __LS_ABSTRACTENGINECHANNEL_H__ |
27 |
|
|
|
28 |
|
|
#include "EngineChannel.h" |
29 |
|
|
#include "AbstractEngine.h" |
30 |
|
|
|
31 |
|
|
#include "../common/Pool.h" |
32 |
|
|
#include "../common/RingBuffer.h" |
33 |
|
|
|
34 |
|
|
namespace LinuxSampler { |
35 |
|
|
|
36 |
|
|
class AbstractEngineChannel: public EngineChannel { |
37 |
|
|
public: |
38 |
|
|
// implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel' |
39 |
|
|
virtual void PrepareLoadInstrument(const char* FileName, uint Instrument); |
40 |
|
|
virtual void Reset(); |
41 |
|
|
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity); |
42 |
|
|
virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); |
43 |
|
|
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity); |
44 |
|
|
virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); |
45 |
|
|
virtual void SendPitchbend(int Pitch); |
46 |
|
|
virtual void SendPitchbend(int Pitch, int32_t FragmentPos); |
47 |
|
|
virtual void SendControlChange(uint8_t Controller, uint8_t Value); |
48 |
|
|
virtual void SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos); |
49 |
|
|
virtual bool StatusChanged(bool bNewStatus = false); |
50 |
|
|
virtual float Volume(); |
51 |
|
|
virtual void Volume(float f); |
52 |
|
|
virtual float Pan(); |
53 |
|
|
virtual void Pan(float f); |
54 |
|
|
virtual uint Channels(); |
55 |
|
|
virtual AudioOutputDevice* GetAudioOutputDevice(); |
56 |
|
|
virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel); |
57 |
|
|
virtual int OutputChannel(uint EngineAudioChannel); |
58 |
|
|
virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel); |
59 |
|
|
virtual void DisconnectMidiInputPort(); |
60 |
|
|
virtual MidiInputPort* GetMidiInputPort(); |
61 |
|
|
virtual midi_chan_t MidiChannel(); |
62 |
|
|
virtual String InstrumentFileName(); |
63 |
|
|
virtual String InstrumentName(); |
64 |
|
|
virtual int InstrumentIndex(); |
65 |
|
|
virtual int InstrumentStatus(); |
66 |
|
|
virtual LinuxSampler::Engine* GetEngine(); |
67 |
|
|
virtual String EngineName(); |
68 |
|
|
virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception); |
69 |
|
|
virtual FxSend* GetFxSend(uint FxSendIndex); |
70 |
|
|
virtual uint GetFxSendCount(); |
71 |
|
|
virtual void RemoveFxSend(FxSend* pFxSend); |
72 |
|
|
virtual void Connect(VirtualMidiDevice* pDevice); |
73 |
|
|
virtual void Disconnect(VirtualMidiDevice* pDevice); |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
virtual AbstractEngine::Format GetEngineFormat() = 0; |
77 |
|
|
|
78 |
iliev |
2015 |
friend class AbstractVoice; |
79 |
iliev |
2012 |
friend class AbstractEngine; |
80 |
|
|
template<class TV, class TRR, class TR, class TD, class TIM, class TI> friend class EngineBase; |
81 |
iliev |
2015 |
template<class EC, class R, class S, class D> friend class VoiceBase; |
82 |
iliev |
2012 |
|
83 |
|
|
protected: |
84 |
|
|
AbstractEngineChannel(); |
85 |
|
|
virtual ~AbstractEngineChannel(); |
86 |
|
|
|
87 |
|
|
AbstractEngine* pEngine; |
88 |
persson |
2013 |
public: // TODO: should be protected |
89 |
iliev |
2012 |
AudioChannel* pChannelLeft; ///< encapsulates the audio rendering buffer (left) |
90 |
|
|
AudioChannel* pChannelRight; ///< encapsulates the audio rendering buffer (right) |
91 |
persson |
2013 |
protected: |
92 |
iliev |
2012 |
int AudioDeviceChannelLeft; ///< audio device channel number to which the left channel is connected to |
93 |
|
|
int AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to |
94 |
|
|
MidiInputPort* pMidiInputPort; ///< Points to the connected MIDI input port or NULL if none assigned. |
95 |
|
|
midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to. |
96 |
|
|
RingBuffer<Event,false>* pEventQueue; ///< Input event queue. |
97 |
|
|
RTList<Event>* pEvents; ///< All engine channel specific events for the current audio fragment. |
98 |
|
|
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). |
99 |
|
|
String InstrumentFile; |
100 |
|
|
int InstrumentIdx; |
101 |
|
|
String InstrumentIdxName; |
102 |
|
|
int InstrumentStat; |
103 |
|
|
double GlobalVolume; ///< Master volume factor set through the C++ API / LSCP (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
104 |
|
|
double MidiVolume; ///< Volume factor altered by MIDI CC#7 (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
105 |
|
|
float GlobalPanLeft; |
106 |
|
|
float GlobalPanRight; |
107 |
|
|
int Pitch; ///< Current (absolute) MIDI pitch value. |
108 |
|
|
float CurrentKeyDimension; ///< Current value (0-1.0) for the keyboard dimension, altered by pressing a keyswitching key. |
109 |
|
|
bool PortamentoMode; ///< in Portamento Mode we slide the pitch from the last note to the current note. |
110 |
|
|
float PortamentoTime; ///< How long it will take to glide from the previous note to the current (in seconds) |
111 |
|
|
float PortamentoPos; ///< Current position on the keyboard, that is integer and fractional part (only used if PortamentoMode is on) |
112 |
|
|
std::vector<FxSend*> fxSends; |
113 |
|
|
int GlobalTranspose; ///< amount of semi tones all notes should be transposed |
114 |
|
|
int iLastPanRequest; ///< just for the return value of Pan(), so we don't have to make an injective function |
115 |
|
|
int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList. |
116 |
|
|
bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet) |
117 |
persson |
2043 |
uint32_t RoundRobinIndex; ///< counter for round robin sample selection, incremented for each note on |
118 |
iliev |
2012 |
|
119 |
|
|
SynchronizedConfig< ArrayList<VirtualMidiDevice*> > virtualMidiDevices; |
120 |
|
|
SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_AudioThread; |
121 |
|
|
SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_MidiThread; |
122 |
|
|
|
123 |
|
|
virtual void ResetControllers(); |
124 |
|
|
virtual void ResetInternal(); |
125 |
|
|
virtual void RemoveAllFxSends(); |
126 |
|
|
|
127 |
|
|
void ImportEvents(uint Samples); |
128 |
|
|
}; |
129 |
|
|
|
130 |
|
|
} // namespace LinuxSampler |
131 |
|
|
|
132 |
|
|
#endif /* __LS_ABSTRACTENGINECHANNEL_H__ */ |
133 |
|
|
|