31 |
pInstrument = NULL; |
pInstrument = NULL; |
32 |
pEvents = NULL; // we allocate when we retrieve the right Engine object |
pEvents = NULL; // we allocate when we retrieve the right Engine object |
33 |
pCCEvents = NULL; // we allocate when we retrieve the right Engine object |
pCCEvents = NULL; // we allocate when we retrieve the right Engine object |
34 |
pEventQueue = new RingBuffer<Event>(MAX_EVENTS_PER_FRAGMENT, 0); |
pEventQueue = new RingBuffer<Event>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0); |
35 |
pActiveKeys = new Pool<uint>(128); |
pActiveKeys = new Pool<uint>(128); |
36 |
for (uint i = 0; i < 128; i++) { |
for (uint i = 0; i < 128; i++) { |
37 |
pMIDIKeyInfo[i].pActiveVoices = NULL; // we allocate when we retrieve the right Engine object |
pMIDIKeyInfo[i].pActiveVoices = NULL; // we allocate when we retrieve the right Engine object |
39 |
pMIDIKeyInfo[i].Active = false; |
pMIDIKeyInfo[i].Active = false; |
40 |
pMIDIKeyInfo[i].ReleaseTrigger = false; |
pMIDIKeyInfo[i].ReleaseTrigger = false; |
41 |
pMIDIKeyInfo[i].pEvents = NULL; // we allocate when we retrieve the right Engine object |
pMIDIKeyInfo[i].pEvents = NULL; // we allocate when we retrieve the right Engine object |
42 |
|
pMIDIKeyInfo[i].VoiceTheftsQueued = 0; |
43 |
pMIDIKeyInfo[i].RoundRobinIndex = 0; |
pMIDIKeyInfo[i].RoundRobinIndex = 0; |
44 |
} |
} |
45 |
for (uint i = 0; i < Event::destination_count; i++) { |
for (uint i = 0; i < Event::destination_count; i++) { |
49 |
InstrumentStat = -1; |
InstrumentStat = -1; |
50 |
AudioDeviceChannelLeft = -1; |
AudioDeviceChannelLeft = -1; |
51 |
AudioDeviceChannelRight = -1; |
AudioDeviceChannelRight = -1; |
52 |
|
ResetControllers(); |
53 |
} |
} |
54 |
|
|
55 |
EngineChannel::~EngineChannel() { |
EngineChannel::~EngineChannel() { |
61 |
} |
} |
62 |
|
|
63 |
/** |
/** |
64 |
|
* Implementation of virtual method from abstract EngineChannel interface. |
65 |
|
* This method will periodically be polled (e.g. by the LSCP server) to |
66 |
|
* check if some engine channel parameter has changed since the last |
67 |
|
* StatusChanged() call. |
68 |
|
* |
69 |
|
* This method can also be used to mark the engine channel as changed |
70 |
|
* from outside, e.g. by a MIDI input device. The optional argument |
71 |
|
* \a nNewStatus can be used for this. |
72 |
|
* |
73 |
|
* TODO: This "poll method" is just a lazy solution and might be |
74 |
|
* replaced in future. |
75 |
|
* @param bNewStatus - (optional, default: false) sets the new status flag |
76 |
|
* @returns true if engine channel status has changed since last |
77 |
|
* StatusChanged() call |
78 |
|
*/ |
79 |
|
bool EngineChannel::StatusChanged(bool bNewStatus) { |
80 |
|
bool b = bStatusChanged; |
81 |
|
bStatusChanged = bNewStatus; |
82 |
|
return b; |
83 |
|
} |
84 |
|
|
85 |
|
void EngineChannel::Reset() { |
86 |
|
if (pEngine) pEngine->DisableAndLock(); |
87 |
|
ResetInternal(); |
88 |
|
ResetControllers(); |
89 |
|
if (pEngine) { |
90 |
|
pEngine->Enable(); |
91 |
|
pEngine->Reset(); |
92 |
|
} |
93 |
|
} |
94 |
|
|
95 |
|
/** |
96 |
* This method is not thread safe! |
* This method is not thread safe! |
97 |
*/ |
*/ |
98 |
void EngineChannel::ResetInternal() { |
void EngineChannel::ResetInternal() { |
|
Pitch = 0; |
|
|
SustainPedal = false; |
|
|
GlobalVolume = 1.0; |
|
|
GlobalPanLeft = 1.0f; |
|
|
GlobalPanRight = 1.0f; |
|
99 |
CurrentKeyDimension = 0; |
CurrentKeyDimension = 0; |
100 |
|
|
|
// set all MIDI controller values to zero |
|
|
memset(ControllerTable, 0x00, 128); |
|
|
|
|
101 |
// reset key info |
// reset key info |
102 |
for (uint i = 0; i < 128; i++) { |
for (uint i = 0; i < 128; i++) { |
103 |
if (pMIDIKeyInfo[i].pActiveVoices) |
if (pMIDIKeyInfo[i].pActiveVoices) |
108 |
pMIDIKeyInfo[i].Active = false; |
pMIDIKeyInfo[i].Active = false; |
109 |
pMIDIKeyInfo[i].ReleaseTrigger = false; |
pMIDIKeyInfo[i].ReleaseTrigger = false; |
110 |
pMIDIKeyInfo[i].itSelf = Pool<uint>::Iterator(); |
pMIDIKeyInfo[i].itSelf = Pool<uint>::Iterator(); |
111 |
|
pMIDIKeyInfo[i].VoiceTheftsQueued = 0; |
112 |
} |
} |
113 |
|
|
114 |
// reset all key groups |
// reset all key groups |
122 |
pEventQueue->init(); |
pEventQueue->init(); |
123 |
|
|
124 |
if (pEngine) pEngine->ResetInternal(); |
if (pEngine) pEngine->ResetInternal(); |
125 |
|
|
126 |
|
// status of engine channel has changed, so set notify flag |
127 |
|
bStatusChanged = true; |
128 |
} |
} |
129 |
|
|
130 |
LinuxSampler::Engine* EngineChannel::GetEngine() { |
LinuxSampler::Engine* EngineChannel::GetEngine() { |
220 |
|
|
221 |
/** |
/** |
222 |
* Will be called by the InstrumentResourceManager when the instrument |
* Will be called by the InstrumentResourceManager when the instrument |
223 |
* we are currently using in this engine is going to be updated, so we |
* we are currently using on this EngineChannel is going to be updated, |
224 |
* can stop playback before that happens. |
* so we can stop playback before that happens. |
225 |
*/ |
*/ |
226 |
void EngineChannel::ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg) { |
void EngineChannel::ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg) { |
227 |
dmsg(3,("gig::Engine: Received instrument update message.\n")); |
dmsg(3,("gig::Engine: Received instrument update message.\n")); |
237 |
void EngineChannel::ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg) { |
void EngineChannel::ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg) { |
238 |
this->pInstrument = pNewResource; //TODO: there are couple of engine parameters we should update here as well if the instrument was updated (see LoadInstrument()) |
this->pInstrument = pNewResource; //TODO: there are couple of engine parameters we should update here as well if the instrument was updated (see LoadInstrument()) |
239 |
if (pEngine) pEngine->Enable(); |
if (pEngine) pEngine->Enable(); |
240 |
|
bStatusChanged = true; // status of engine has changed, so set notify flag |
241 |
|
} |
242 |
|
|
243 |
|
/** |
244 |
|
* Will be called by the InstrumentResourceManager on progress changes |
245 |
|
* while loading or realoading an instrument for this EngineChannel. |
246 |
|
* |
247 |
|
* @param fProgress - current progress as value between 0.0 and 1.0 |
248 |
|
*/ |
249 |
|
void EngineChannel::OnResourceProgress(float fProgress) { |
250 |
|
this->InstrumentStat = int(fProgress * 100.0f); |
251 |
|
dmsg(7,("gig::EngineChannel: progress %d%", InstrumentStat)); |
252 |
|
bStatusChanged = true; // status of engine has changed, so set notify flag |
253 |
} |
} |
254 |
|
|
255 |
void EngineChannel::Connect(AudioOutputDevice* pAudioOut) { |
void EngineChannel::Connect(AudioOutputDevice* pAudioOut) { |
430 |
} |
} |
431 |
} |
} |
432 |
|
|
433 |
|
void EngineChannel::ResetControllers() { |
434 |
|
Pitch = 0; |
435 |
|
SustainPedal = false; |
436 |
|
GlobalVolume = 1.0; |
437 |
|
GlobalPanLeft = 1.0f; |
438 |
|
GlobalPanRight = 1.0f; |
439 |
|
// set all MIDI controller values to zero |
440 |
|
memset(ControllerTable, 0x00, 128); |
441 |
|
} |
442 |
|
|
443 |
/** |
/** |
444 |
* Copy all events from the engine channel's input event queue buffer to |
* Copy all events from the engine channel's input event queue buffer to |
445 |
* the internal event list. This will be done at the beginning of each |
* the internal event list. This will be done at the beginning of each |
482 |
|
|
483 |
void EngineChannel::Volume(float f) { |
void EngineChannel::Volume(float f) { |
484 |
GlobalVolume = f; |
GlobalVolume = f; |
485 |
|
bStatusChanged = true; // status of engine channel has changed, so set notify flag |
486 |
} |
} |
487 |
|
|
488 |
uint EngineChannel::Channels() { |
uint EngineChannel::Channels() { |
505 |
return InstrumentStat; |
return InstrumentStat; |
506 |
} |
} |
507 |
|
|
508 |
|
String EngineChannel::EngineName() { |
509 |
|
return LS_GIG_ENGINE_NAME; |
510 |
|
} |
511 |
|
|
512 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |