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 |
49 |
InstrumentStat = -1; |
InstrumentStat = -1; |
50 |
AudioDeviceChannelLeft = -1; |
AudioDeviceChannelLeft = -1; |
51 |
AudioDeviceChannelRight = -1; |
AudioDeviceChannelRight = -1; |
52 |
|
pMidiInputPort = NULL; |
53 |
|
midiChannel = midi_chan_all; |
54 |
|
ResetControllers(); |
55 |
} |
} |
56 |
|
|
57 |
EngineChannel::~EngineChannel() { |
EngineChannel::~EngineChannel() { |
63 |
} |
} |
64 |
|
|
65 |
/** |
/** |
66 |
|
* Implementation of virtual method from abstract EngineChannel interface. |
67 |
|
* This method will periodically be polled (e.g. by the LSCP server) to |
68 |
|
* check if some engine channel parameter has changed since the last |
69 |
|
* StatusChanged() call. |
70 |
|
* |
71 |
|
* This method can also be used to mark the engine channel as changed |
72 |
|
* from outside, e.g. by a MIDI input device. The optional argument |
73 |
|
* \a nNewStatus can be used for this. |
74 |
|
* |
75 |
|
* TODO: This "poll method" is just a lazy solution and might be |
76 |
|
* replaced in future. |
77 |
|
* @param bNewStatus - (optional, default: false) sets the new status flag |
78 |
|
* @returns true if engine channel status has changed since last |
79 |
|
* StatusChanged() call |
80 |
|
*/ |
81 |
|
bool EngineChannel::StatusChanged(bool bNewStatus) { |
82 |
|
bool b = bStatusChanged; |
83 |
|
bStatusChanged = bNewStatus; |
84 |
|
return b; |
85 |
|
} |
86 |
|
|
87 |
|
void EngineChannel::Reset() { |
88 |
|
if (pEngine) pEngine->DisableAndLock(); |
89 |
|
ResetInternal(); |
90 |
|
ResetControllers(); |
91 |
|
if (pEngine) { |
92 |
|
pEngine->Enable(); |
93 |
|
pEngine->Reset(); |
94 |
|
} |
95 |
|
} |
96 |
|
|
97 |
|
/** |
98 |
* This method is not thread safe! |
* This method is not thread safe! |
99 |
*/ |
*/ |
100 |
void EngineChannel::ResetInternal() { |
void EngineChannel::ResetInternal() { |
|
Pitch = 0; |
|
|
SustainPedal = false; |
|
|
GlobalVolume = 1.0; |
|
|
GlobalPanLeft = 1.0f; |
|
|
GlobalPanRight = 1.0f; |
|
101 |
CurrentKeyDimension = 0; |
CurrentKeyDimension = 0; |
102 |
|
|
|
ResetControllers(); |
|
|
|
|
103 |
// reset key info |
// reset key info |
104 |
for (uint i = 0; i < 128; i++) { |
for (uint i = 0; i < 128; i++) { |
105 |
if (pMIDIKeyInfo[i].pActiveVoices) |
if (pMIDIKeyInfo[i].pActiveVoices) |
124 |
pEventQueue->init(); |
pEventQueue->init(); |
125 |
|
|
126 |
if (pEngine) pEngine->ResetInternal(); |
if (pEngine) pEngine->ResetInternal(); |
127 |
|
|
128 |
|
// status of engine channel has changed, so set notify flag |
129 |
|
bStatusChanged = true; |
130 |
} |
} |
131 |
|
|
132 |
LinuxSampler::Engine* EngineChannel::GetEngine() { |
LinuxSampler::Engine* EngineChannel::GetEngine() { |
239 |
void EngineChannel::ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg) { |
void EngineChannel::ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg) { |
240 |
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()) |
241 |
if (pEngine) pEngine->Enable(); |
if (pEngine) pEngine->Enable(); |
242 |
|
bStatusChanged = true; // status of engine has changed, so set notify flag |
243 |
} |
} |
244 |
|
|
245 |
/** |
/** |
251 |
void EngineChannel::OnResourceProgress(float fProgress) { |
void EngineChannel::OnResourceProgress(float fProgress) { |
252 |
this->InstrumentStat = int(fProgress * 100.0f); |
this->InstrumentStat = int(fProgress * 100.0f); |
253 |
dmsg(7,("gig::EngineChannel: progress %d%", InstrumentStat)); |
dmsg(7,("gig::EngineChannel: progress %d%", InstrumentStat)); |
254 |
|
bStatusChanged = true; // status of engine has changed, so set notify flag |
255 |
} |
} |
256 |
|
|
257 |
void EngineChannel::Connect(AudioOutputDevice* pAudioOut) { |
void EngineChannel::Connect(AudioOutputDevice* pAudioOut) { |
342 |
} |
} |
343 |
} |
} |
344 |
|
|
345 |
|
void EngineChannel::Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) { |
346 |
|
if (!pMidiPort || pMidiPort == this->pMidiInputPort) return; |
347 |
|
DisconnectMidiInputPort(); |
348 |
|
this->pMidiInputPort = pMidiPort; |
349 |
|
this->midiChannel = MidiChannel; |
350 |
|
pMidiPort->Connect(this, MidiChannel); |
351 |
|
} |
352 |
|
|
353 |
|
void EngineChannel::DisconnectMidiInputPort() { |
354 |
|
MidiInputPort* pOldPort = this->pMidiInputPort; |
355 |
|
this->pMidiInputPort = NULL; |
356 |
|
if (pOldPort) pOldPort->Disconnect(this); |
357 |
|
} |
358 |
|
|
359 |
|
MidiInputPort* EngineChannel::GetMidiInputPort() { |
360 |
|
return pMidiInputPort; |
361 |
|
} |
362 |
|
|
363 |
|
midi_chan_t EngineChannel::MidiChannel() { |
364 |
|
return midiChannel; |
365 |
|
} |
366 |
|
|
367 |
/** |
/** |
368 |
* Will be called by the MIDIIn Thread to let the audio thread trigger a new |
* Will be called by the MIDIIn Thread to let the audio thread trigger a new |
369 |
* voice for the given key. |
* voice for the given key. |
455 |
} |
} |
456 |
|
|
457 |
void EngineChannel::ResetControllers() { |
void EngineChannel::ResetControllers() { |
458 |
|
Pitch = 0; |
459 |
|
SustainPedal = false; |
460 |
|
GlobalVolume = 1.0; |
461 |
|
GlobalPanLeft = 1.0f; |
462 |
|
GlobalPanRight = 1.0f; |
463 |
// set all MIDI controller values to zero |
// set all MIDI controller values to zero |
464 |
memset(ControllerTable, 0x00, 128); |
memset(ControllerTable, 0x00, 128); |
465 |
} |
} |
506 |
|
|
507 |
void EngineChannel::Volume(float f) { |
void EngineChannel::Volume(float f) { |
508 |
GlobalVolume = f; |
GlobalVolume = f; |
509 |
|
bStatusChanged = true; // status of engine channel has changed, so set notify flag |
510 |
} |
} |
511 |
|
|
512 |
uint EngineChannel::Channels() { |
uint EngineChannel::Channels() { |
532 |
String EngineChannel::EngineName() { |
String EngineChannel::EngineName() { |
533 |
return LS_GIG_ENGINE_NAME; |
return LS_GIG_ENGINE_NAME; |
534 |
} |
} |
535 |
|
|
536 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |