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 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2009 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 * |
321 |
cmd.bChangeInstrument = false; |
cmd.bChangeInstrument = false; |
322 |
} |
} |
323 |
|
|
324 |
|
if (pInstrument != NULL) { |
325 |
|
pInstrument = NULL; |
326 |
|
InstrumentStat = -1; |
327 |
|
InstrumentIdx = -1; |
328 |
|
InstrumentIdxName = ""; |
329 |
|
InstrumentFile = ""; |
330 |
|
bStatusChanged = true; |
331 |
|
} |
332 |
|
|
333 |
for (uint i = 0; i < 128; i++) { |
for (uint i = 0; i < 128; i++) { |
334 |
pMIDIKeyInfo[i].pActiveVoices = new RTList<Voice>(pEngine->pVoicePool); |
pMIDIKeyInfo[i].pActiveVoices = new RTList<Voice>(pEngine->pVoicePool); |
335 |
pMIDIKeyInfo[i].pEvents = new RTList<Event>(pEngine->pEventPool); |
pMIDIKeyInfo[i].pEvents = new RTList<Event>(pEngine->pEventPool); |
353 |
void EngineChannel::DisconnectAudioOutputDevice() { |
void EngineChannel::DisconnectAudioOutputDevice() { |
354 |
if (pEngine) { // if clause to prevent disconnect loops |
if (pEngine) { // if clause to prevent disconnect loops |
355 |
|
|
356 |
|
ResetInternal(); |
357 |
|
|
358 |
// delete the structures used for instrument change |
// delete the structures used for instrument change |
359 |
RTList< ::gig::DimensionRegion*>* d = InstrumentChangeCommand.GetConfigForUpdate().pDimRegionsInUse; |
RTList< ::gig::DimensionRegion*>* d = InstrumentChangeCommand.GetConfigForUpdate().pDimRegionsInUse; |
360 |
if (d) delete d; |
if (d) delete d; |
361 |
EngineChannel::instrument_change_command_t& cmd = InstrumentChangeCommand.SwitchConfig(); |
EngineChannel::instrument_change_command_t& cmd = InstrumentChangeCommand.SwitchConfig(); |
362 |
d = cmd.pDimRegionsInUse; |
d = cmd.pDimRegionsInUse; |
363 |
|
if (d) delete d; |
364 |
|
|
365 |
if (cmd.pInstrument) { |
if (cmd.pInstrument) { |
366 |
// release the currently loaded instrument |
// release the currently loaded instrument |
367 |
Engine::instruments.HandBackInstrument(cmd.pInstrument, this, d); |
Engine::instruments.HandBack(cmd.pInstrument, this); |
|
} |
|
|
|
|
|
if (d) delete d; |
|
|
|
|
|
// release all active dimension regions to resource |
|
|
// manager |
|
|
RTList<uint>::Iterator iuiKey = pActiveKeys->first(); |
|
|
RTList<uint>::Iterator end = pActiveKeys->end(); |
|
|
while (iuiKey != end) { // iterate through all active keys |
|
|
midi_key_info_t* pKey = &pMIDIKeyInfo[*iuiKey]; |
|
|
++iuiKey; |
|
|
|
|
|
RTList<Voice>::Iterator itVoice = pKey->pActiveVoices->first(); |
|
|
RTList<Voice>::Iterator itVoicesEnd = pKey->pActiveVoices->end(); |
|
|
for (; itVoice != itVoicesEnd; ++itVoice) { // iterate through all voices on this key |
|
|
Engine::instruments.HandBackDimReg(itVoice->pDimRgn); |
|
|
} |
|
368 |
} |
} |
369 |
|
|
|
ResetInternal(); |
|
370 |
if (pEvents) { |
if (pEvents) { |
371 |
delete pEvents; |
delete pEvents; |
372 |
pEvents = NULL; |
pEvents = NULL; |
381 |
pMIDIKeyInfo[i].pEvents = NULL; |
pMIDIKeyInfo[i].pEvents = NULL; |
382 |
} |
} |
383 |
} |
} |
|
Engine* oldEngine = pEngine; |
|
384 |
AudioOutputDevice* oldAudioDevice = pEngine->pAudioOutputDevice; |
AudioOutputDevice* oldAudioDevice = pEngine->pAudioOutputDevice; |
385 |
pEngine = NULL; |
pEngine = NULL; |
386 |
Engine::FreeEngine(this, oldAudioDevice); |
Engine::FreeEngine(this, oldAudioDevice); |
736 |
} |
} |
737 |
} |
} |
738 |
|
|
739 |
|
/** |
740 |
|
* Will be called by the MIDIIn Thread to signal that a program |
741 |
|
* change should be performed. As a program change isn't |
742 |
|
* real-time safe, the actual change is performed by the disk |
743 |
|
* thread. |
744 |
|
* |
745 |
|
* @param Program - MIDI program change number |
746 |
|
*/ |
747 |
|
void EngineChannel::SendProgramChange(uint8_t Program) { |
748 |
|
if (pEngine) { |
749 |
|
pEngine->pDiskThread->OrderProgramChange(Program, this); |
750 |
|
} |
751 |
|
} |
752 |
|
|
753 |
void EngineChannel::ClearEventLists() { |
void EngineChannel::ClearEventLists() { |
754 |
pEvents->clear(); |
pEvents->clear(); |
755 |
// empty MIDI key specific event lists |
// empty MIDI key specific event lists |
946 |
return LS_GIG_ENGINE_NAME; |
return LS_GIG_ENGINE_NAME; |
947 |
} |
} |
948 |
|
|
949 |
|
void EngineChannel::ClearDimRegionsInUse() { |
950 |
|
{ |
951 |
|
instrument_change_command_t& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
952 |
|
if(cmd.pDimRegionsInUse != NULL) cmd.pDimRegionsInUse->clear(); |
953 |
|
} |
954 |
|
{ |
955 |
|
instrument_change_command_t& cmd = InstrumentChangeCommand.SwitchConfig(); |
956 |
|
if(cmd.pDimRegionsInUse != NULL) cmd.pDimRegionsInUse->clear(); |
957 |
|
} |
958 |
|
} |
959 |
|
|
960 |
|
void EngineChannel::ResetDimRegionsInUse() { |
961 |
|
{ |
962 |
|
instrument_change_command_t& cmd = InstrumentChangeCommand.GetConfigForUpdate(); |
963 |
|
if(cmd.pDimRegionsInUse != NULL) { |
964 |
|
delete cmd.pDimRegionsInUse; |
965 |
|
cmd.pDimRegionsInUse = new RTList< ::gig::DimensionRegion*>(pEngine->pDimRegionPool[0]); |
966 |
|
} |
967 |
|
} |
968 |
|
{ |
969 |
|
instrument_change_command_t& cmd = InstrumentChangeCommand.SwitchConfig(); |
970 |
|
if(cmd.pDimRegionsInUse != NULL) { |
971 |
|
delete cmd.pDimRegionsInUse; |
972 |
|
cmd.pDimRegionsInUse = new RTList< ::gig::DimensionRegion*>(pEngine->pDimRegionPool[1]); |
973 |
|
} |
974 |
|
} |
975 |
|
} |
976 |
|
|
977 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |