--- linuxsampler/trunk/src/engines/gig/Engine.cpp 2004/12/28 09:43:04 329 +++ linuxsampler/trunk/src/engines/gig/Engine.cpp 2005/02/12 23:48:50 376 @@ -26,7 +26,12 @@ #include "EGADSR.h" #include "Engine.h" -#include + +#if defined(__APPLE__) +# include +#else +# include +#endif namespace LinuxSampler { namespace gig { @@ -82,6 +87,9 @@ delete pDiskThread; dmsg(1,("OK\n")); } + + if (pInstrument) Instruments.HandBack(pInstrument, this); + if (pGig) delete pGig; if (pRIFF) delete pRIFF; for (uint i = 0; i < 128; i++) { @@ -163,6 +171,7 @@ ActiveVoiceCount = 0; ActiveVoiceCountMax = 0; GlobalVolume = 1.0; + CurrentKeyDimension = 0; // reset voice stealing parameters itLastStolenVoice = RTList::Iterator(); @@ -263,6 +272,7 @@ for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion()) if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL; + InstrumentIdxName = pInstrument->pInfo->Name; InstrumentStat = 100; // inform audio driver for the need of two channels @@ -349,7 +359,12 @@ // (re)allocate synthesis parameter matrix if (pSynthesisParameters[0]) free(pSynthesisParameters[0]); + + #if defined(__APPLE__) + pSynthesisParameters[0] = (float *) malloc(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()); + #else pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle())); + #endif for (int dst = 1; dst < Event::destination_count; dst++) pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle(); @@ -659,7 +674,15 @@ * @param itNoteOnEvent - key, velocity and time stamp of the event */ void Engine::ProcessNoteOn(Pool::Iterator& itNoteOnEvent) { - midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key]; + + const int key = itNoteOnEvent->Param.Note.Key; + + // Change key dimension value if key is in keyswitching area + if (key >= pInstrument->DimensionKeyRange.low && key <= pInstrument->DimensionKeyRange.high) + CurrentKeyDimension = ((key - pInstrument->DimensionKeyRange.low) * 128) / + (pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1); + + midi_key_info_t* pKey = &pMIDIKeyInfo[key]; pKey->KeyPressed = true; // the MIDI key was now pressed down @@ -733,7 +756,8 @@ * when there is no free voice * (optional, default = true) * @returns pointer to new voice or NULL if there was no free voice or - * if an error occured while trying to trigger the new voice + * if the voice wasn't triggered (for example when no region is + * defined for the given key). */ Pool::Iterator Engine::LaunchVoice(Pool::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing) { midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key]; @@ -743,7 +767,7 @@ if (itNewVoice) { // launch the new voice if (itNewVoice->Trigger(itNoteOnEvent, this->Pitch, this->pInstrument, iLayer, ReleaseTriggerVoice, VoiceStealing) < 0) { - dmsg(1,("Triggering new voice failed!\n")); + dmsg(4,("Voice not triggered\n")); pKey->pActiveVoices->free(itNewVoice); } else { // on success @@ -1158,6 +1182,10 @@ return InstrumentFile; } + String Engine::InstrumentName() { + return InstrumentIdxName; + } + int Engine::InstrumentIndex() { return InstrumentIdx; } @@ -1171,7 +1199,7 @@ } String Engine::Version() { - String s = "$Revision: 1.20 $"; + String s = "$Revision: 1.24 $"; return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword }