--- linuxsampler/trunk/src/engines/gig/Voice.cpp 2006/11/27 21:34:55 947 +++ linuxsampler/trunk/src/engines/gig/Voice.cpp 2007/09/04 01:12:49 1321 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005, 2006 Christian Schoenebeck * + * Copyright (C) 2005 - 2007 Christian Schoenebeck * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -38,8 +38,8 @@ pLFO3 = new LFOSigned(1200.0f); // pitch EG (-1200..+1200 range) KeyGroup = 0; SynthesisMode = 0; // set all mode bits to 0 first - // select synthesis implementation (currently either pure C++ or MMX+SSE(1)) - #if CONFIG_ASM && ARCH_X86 + // select synthesis implementation (asm core is not supported ATM) + #if 0 // CONFIG_ASM && ARCH_X86 SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, Features::supportsMMX() && Features::supportsSSE()); #else SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, false); @@ -79,6 +79,7 @@ int Voice::Trigger(EngineChannel* pEngineChannel, Pool::Iterator& itNoteOnEvent, int PitchBend, ::gig::DimensionRegion* pDimRgn, type_t VoiceType, int iKeyGroup) { this->pEngineChannel = pEngineChannel; this->pDimRgn = pDimRgn; + Orphan = false; #if CONFIG_DEVMODE if (itNoteOnEvent->FragmentPos() > pEngine->MaxSamplesPerCycle) { // just a sanity check for debugging @@ -103,7 +104,7 @@ // -1.0..1.0). For 24 bit, we downscale from int32. float volume = velocityAttenuation / (pSample->BitDepth == 16 ? 32768.0f : 32768.0f * 65536.0f); - volume *= pDimRgn->SampleAttenuation; + volume *= pDimRgn->SampleAttenuation * pEngineChannel->GlobalVolume * GLOBAL_VOLUME; // the volume of release triggered samples depends on note length if (Type == type_release_trigger) { @@ -141,7 +142,7 @@ float subfragmentRate = pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate); - VolumeSmoother.trigger(pEngineChannel->GlobalVolume * pEngineChannel->MidiVolume, subfragmentRate); + VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate); PanLeftSmoother.trigger(pEngineChannel->GlobalPanLeft, subfragmentRate); PanRightSmoother.trigger(pEngineChannel->GlobalPanRight, subfragmentRate); @@ -241,7 +242,7 @@ else #else { - float finalVolume = pEngineChannel->GlobalVolume * pEngineChannel->MidiVolume * crossfadeVolume * EG1.getLevel(); + float finalVolume = pEngineChannel->MidiVolume * crossfadeVolume * EG1.getLevel(); finalSynthesisParameters.fFinalVolumeLeft = finalVolume * VolumeLeft * pEngineChannel->GlobalPanLeft; finalSynthesisParameters.fFinalVolumeRight = finalVolume * VolumeRight * pEngineChannel->GlobalPanRight; @@ -514,8 +515,8 @@ finalSynthesisParameters.filterLeft.SetType(pDimRgn->VCFType); finalSynthesisParameters.filterRight.SetType(pDimRgn->VCFType); #else // override filter type - FilterLeft.SetType(CONFIG_OVERRIDE_FILTER_TYPE); - FilterRight.SetType(CONFIG_OVERRIDE_FILTER_TYPE); + finalSynthesisParameters.filterLeft.SetType(CONFIG_OVERRIDE_FILTER_TYPE); + finalSynthesisParameters.filterRight.SetType(CONFIG_OVERRIDE_FILTER_TYPE); #endif // CONFIG_OVERRIDE_FILTER_TYPE VCFCutoffCtrl.value = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller]; @@ -768,8 +769,8 @@ * @param Skip - number of sample points to skip in output buffer */ void Voice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) { - finalSynthesisParameters.pOutLeft = &pEngineChannel->pOutputLeft[Skip]; - finalSynthesisParameters.pOutRight = &pEngineChannel->pOutputRight[Skip]; + finalSynthesisParameters.pOutLeft = &pEngineChannel->pChannelLeft->Buffer()[Skip]; + finalSynthesisParameters.pOutRight = &pEngineChannel->pChannelRight->Buffer()[Skip]; finalSynthesisParameters.pSrc = pSrc; RTList::Iterator itCCEvent = pEngineChannel->pEvents->first(); @@ -803,8 +804,11 @@ // process transition events (note on, note off & sustain pedal) processTransitionEvents(itNoteEvent, iSubFragmentEnd); - // if the voice was killed in this subfragment switch EG1 to fade out stage - if (itKillEvent && killPos <= iSubFragmentEnd) { + // if the voice was killed in this subfragment, or if the + // filter EG is finished, switch EG1 to fade out stage + if ((itKillEvent && killPos <= iSubFragmentEnd) || + (SYNTHESIS_MODE_GET_FILTER(SynthesisMode) && + EG2.getSegmentType() == EGADSR::segment_end)) { EG1.enterFadeOutStage(); itKillEvent = Pool::Iterator(); } @@ -917,13 +921,30 @@ * fading down the volume level to avoid clicks and regular processing * until the kill event actually occured! * - * @see Kill() + * If it's necessary to know when the voice's disk stream was actually + * deleted, then one can set the optional @a bRequestNotification + * parameter and this method will then return the handle of the disk + * stream (unique identifier) and one can use this handle to poll the + * disk thread if this stream has been deleted. In any case this method + * will return immediately and will not block until the stream actually + * was deleted. + * + * @param bRequestNotification - (optional) whether the disk thread shall + * provide a notification once it deleted + * the respective disk stream + * (default=false) + * @returns handle to the voice's disk stream or @c Stream::INVALID_HANDLE + * if the voice did not use a disk stream at all + * @see Kill() */ - void Voice::KillImmediately() { + Stream::Handle Voice::KillImmediately(bool bRequestNotification) { + Stream::Handle hStream = Stream::INVALID_HANDLE; if (DiskVoice && DiskStreamRef.State != Stream::state_unused) { - pDiskThread->OrderDeletionOfStream(&DiskStreamRef); + pDiskThread->OrderDeletionOfStream(&DiskStreamRef, bRequestNotification); + hStream = DiskStreamRef.hStream; } Reset(); + return hStream; } /**