116 |
* Destructor |
* Destructor |
117 |
*/ |
*/ |
118 |
Engine::~Engine() { |
Engine::~Engine() { |
119 |
|
MidiInputPort::RemoveSysexListener(this); |
120 |
if (pDiskThread) { |
if (pDiskThread) { |
121 |
dmsg(1,("Stopping disk thread...")); |
dmsg(1,("Stopping disk thread...")); |
122 |
pDiskThread->StopThread(); |
pDiskThread->StopThread(); |
166 |
|
|
167 |
/** |
/** |
168 |
* Reset all voices and disk thread and clear input event queue and all |
* Reset all voices and disk thread and clear input event queue and all |
169 |
* control and status variables. This method is not thread safe! |
* control and status variables. This method is protected by a mutex. |
170 |
*/ |
*/ |
171 |
void Engine::ResetInternal() { |
void Engine::ResetInternal() { |
172 |
|
ResetInternalMutex.Lock(); |
173 |
|
|
174 |
|
// make sure that the engine does not get any sysex messages |
175 |
|
// while it's reseting |
176 |
|
bool sysexDisabled = MidiInputPort::RemoveSysexListener(this); |
177 |
ActiveVoiceCount = 0; |
ActiveVoiceCount = 0; |
178 |
ActiveVoiceCountMax = 0; |
ActiveVoiceCountMax = 0; |
179 |
|
|
197 |
// delete all input events |
// delete all input events |
198 |
pEventQueue->init(); |
pEventQueue->init(); |
199 |
pSysexBuffer->init(); |
pSysexBuffer->init(); |
200 |
|
if (sysexDisabled) MidiInputPort::AddSysexListener(this); |
201 |
|
ResetInternalMutex.Unlock(); |
202 |
} |
} |
203 |
|
|
204 |
/** |
/** |
228 |
} |
} |
229 |
catch (AudioOutputException e) { |
catch (AudioOutputException e) { |
230 |
String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message(); |
String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message(); |
231 |
throw LinuxSamplerException(msg); |
throw Exception(msg); |
232 |
} |
} |
233 |
|
|
234 |
this->MaxSamplesPerCycle = pAudioOutputDevice->MaxSamplesPerCycle(); |
this->MaxSamplesPerCycle = pAudioOutputDevice->MaxSamplesPerCycle(); |
642 |
{ |
{ |
643 |
const ::gig::Instrument* pInstrument = pEngineChannel->pInstrument; |
const ::gig::Instrument* pInstrument = pEngineChannel->pInstrument; |
644 |
if (key >= pInstrument->DimensionKeyRange.low && key <= pInstrument->DimensionKeyRange.high) |
if (key >= pInstrument->DimensionKeyRange.low && key <= pInstrument->DimensionKeyRange.high) |
645 |
pEngineChannel->CurrentKeyDimension = ((key - pInstrument->DimensionKeyRange.low) * 128) / |
pEngineChannel->CurrentKeyDimension = float(key - pInstrument->DimensionKeyRange.low) / |
646 |
(pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1); |
(pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1); |
647 |
} |
} |
648 |
|
|
870 |
DimValues[i] = itNoteOnEvent->Param.Note.Velocity; |
DimValues[i] = itNoteOnEvent->Param.Note.Velocity; |
871 |
break; |
break; |
872 |
case ::gig::dimension_channelaftertouch: |
case ::gig::dimension_channelaftertouch: |
873 |
DimValues[i] = 0; //TODO: we currently ignore this dimension |
DimValues[i] = pEngineChannel->ControllerTable[128]; |
874 |
break; |
break; |
875 |
case ::gig::dimension_releasetrigger: |
case ::gig::dimension_releasetrigger: |
876 |
VoiceType = (ReleaseTriggerVoice) ? Voice::type_release_trigger : (!iLayer) ? Voice::type_release_trigger_required : Voice::type_normal; |
VoiceType = (ReleaseTriggerVoice) ? Voice::type_release_trigger : (!iLayer) ? Voice::type_release_trigger_required : Voice::type_normal; |
877 |
DimValues[i] = (uint) ReleaseTriggerVoice; |
DimValues[i] = (uint) ReleaseTriggerVoice; |
878 |
break; |
break; |
879 |
case ::gig::dimension_keyboard: |
case ::gig::dimension_keyboard: |
880 |
DimValues[i] = (uint) pEngineChannel->CurrentKeyDimension; |
DimValues[i] = (uint) (pEngineChannel->CurrentKeyDimension * pRegion->pDimensionDefinitions[i].zones); |
881 |
break; |
break; |
882 |
case ::gig::dimension_roundrobin: |
case ::gig::dimension_roundrobin: |
883 |
DimValues[i] = (uint) pEngineChannel->pMIDIKeyInfo[MIDIKey].RoundRobinIndex; // incremented for each note on |
DimValues[i] = (uint) pEngineChannel->pMIDIKeyInfo[MIDIKey].RoundRobinIndex; // incremented for each note on |
1357 |
break; |
break; |
1358 |
} |
} |
1359 |
case 123: { // all notes off |
case 123: { // all notes off |
1360 |
|
#if CONFIG_PROCESS_ALL_NOTES_OFF |
1361 |
ReleaseAllVoices(pEngineChannel, itControlChangeEvent); |
ReleaseAllVoices(pEngineChannel, itControlChangeEvent); |
1362 |
|
#endif // CONFIG_PROCESS_ALL_NOTES_OFF |
1363 |
break; |
break; |
1364 |
} |
} |
1365 |
case 126: { // mono mode on |
case 126: { // mono mode on |
1567 |
} |
} |
1568 |
|
|
1569 |
String Engine::Version() { |
String Engine::Version() { |
1570 |
String s = "$Revision: 1.58 $"; |
String s = "$Revision: 1.64 $"; |
1571 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
1572 |
} |
} |
1573 |
|
|
1574 |
// static constant initializers |
// static constant initializers |
1575 |
const float* Engine::VolumeCurve(InitVolumeCurve()); |
const float* Engine::VolumeCurve(InitVolumeCurve()); |
1576 |
const float* Engine::PanCurve(InitPanCurve()); |
const float* Engine::PanCurve(InitPanCurve()); |
1577 |
|
const float* Engine::CrossfadeCurve(InitCrossfadeCurve()); |
1578 |
|
|
1579 |
float* Engine::InitVolumeCurve() { |
float* Engine::InitVolumeCurve() { |
1580 |
// line-segment approximation |
// line-segment approximation |
1595 |
return InitCurve(segments, 129); |
return InitCurve(segments, 129); |
1596 |
} |
} |
1597 |
|
|
1598 |
|
float* Engine::InitCrossfadeCurve() { |
1599 |
|
// line-segment approximation |
1600 |
|
const float segments[] = { |
1601 |
|
0, 0, 1, 0.03, 10, 0.1, 51, 0.58, 127, 1 |
1602 |
|
}; |
1603 |
|
return InitCurve(segments); |
1604 |
|
} |
1605 |
|
|
1606 |
float* Engine::InitCurve(const float* segments, int size) { |
float* Engine::InitCurve(const float* segments, int size) { |
1607 |
float* y = new float[size]; |
float* y = new float[size]; |
1608 |
for (int x = 0 ; x < size ; x++) { |
for (int x = 0 ; x < size ; x++) { |