--- linuxsampler/trunk/src/engines/gig/Engine.cpp 2006/01/28 16:55:30 831 +++ linuxsampler/trunk/src/engines/gig/Engine.cpp 2006/06/27 22:57:37 880 @@ -116,6 +116,7 @@ * Destructor */ Engine::~Engine() { + MidiInputPort::RemoveSysexListener(this); if (pDiskThread) { dmsg(1,("Stopping disk thread...")); pDiskThread->StopThread(); @@ -165,9 +166,14 @@ /** * Reset all voices and disk thread and clear input event queue and all - * control and status variables. This method is not thread safe! + * control and status variables. This method is protected by a mutex. */ void Engine::ResetInternal() { + ResetInternalMutex.Lock(); + + // make sure that the engine does not get any sysex messages + // while it's reseting + bool sysexDisabled = MidiInputPort::RemoveSysexListener(this); ActiveVoiceCount = 0; ActiveVoiceCountMax = 0; @@ -191,6 +197,8 @@ // delete all input events pEventQueue->init(); pSysexBuffer->init(); + if (sysexDisabled) MidiInputPort::AddSysexListener(this); + ResetInternalMutex.Unlock(); } /** @@ -220,7 +228,7 @@ } catch (AudioOutputException e) { String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message(); - throw LinuxSamplerException(msg); + throw Exception(msg); } this->MaxSamplesPerCycle = pAudioOutputDevice->MaxSamplesPerCycle(); @@ -634,7 +642,7 @@ { const ::gig::Instrument* pInstrument = pEngineChannel->pInstrument; if (key >= pInstrument->DimensionKeyRange.low && key <= pInstrument->DimensionKeyRange.high) - pEngineChannel->CurrentKeyDimension = ((key - pInstrument->DimensionKeyRange.low) * 128) / + pEngineChannel->CurrentKeyDimension = float(key - pInstrument->DimensionKeyRange.low) / (pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1); } @@ -869,7 +877,7 @@ DimValues[i] = (uint) ReleaseTriggerVoice; break; case ::gig::dimension_keyboard: - DimValues[i] = (uint) pEngineChannel->CurrentKeyDimension; + DimValues[i] = (uint) (pEngineChannel->CurrentKeyDimension * pRegion->pDimensionDefinitions[i].zones); break; case ::gig::dimension_roundrobin: DimValues[i] = (uint) pEngineChannel->pMIDIKeyInfo[MIDIKey].RoundRobinIndex; // incremented for each note on @@ -1349,7 +1357,9 @@ break; } case 123: { // all notes off + #if CONFIG_PROCESS_ALL_NOTES_OFF ReleaseAllVoices(pEngineChannel, itControlChangeEvent); + #endif // CONFIG_PROCESS_ALL_NOTES_OFF break; } case 126: { // mono mode on @@ -1557,13 +1567,14 @@ } String Engine::Version() { - String s = "$Revision: 1.58 $"; + String s = "$Revision: 1.63 $"; return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword } // static constant initializers const float* Engine::VolumeCurve(InitVolumeCurve()); const float* Engine::PanCurve(InitPanCurve()); + const float* Engine::CrossfadeCurve(InitCrossfadeCurve()); float* Engine::InitVolumeCurve() { // line-segment approximation @@ -1584,6 +1595,14 @@ return InitCurve(segments, 129); } + float* Engine::InitCrossfadeCurve() { + // line-segment approximation + const float segments[] = { + 0, 0, 1, 0.03, 10, 0.1, 51, 0.58, 127, 1 + }; + return InitCurve(segments); + } + float* Engine::InitCurve(const float* segments, int size) { float* y = new float[size]; for (int x = 0 ; x < size ; x++) {