--- linuxsampler/trunk/src/engines/gig/Voice.h 2005/09/11 15:56:29 770 +++ linuxsampler/trunk/src/engines/gig/Voice.h 2006/01/28 16:55:30 831 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005 Christian Schoenebeck * + * Copyright (C) 2005, 2006 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 * @@ -122,6 +122,8 @@ int Trigger(EngineChannel* pEngineChannel, Pool::Iterator& itNoteOnEvent, int PitchBend, ::gig::DimensionRegion* pDimRgn, type_t VoiceType, int iKeyGroup); inline bool IsActive() { return PlaybackState; } inline bool IsStealable() { return !itKillEvent && PlaybackState >= playback_state_ram; } + void UpdatePortamentoPos(Pool::Iterator& itNoteOffEvent); + //private: // Types enum playback_state_t { @@ -138,7 +140,7 @@ float PanLeft; float PanRight; float CrossfadeVolume; ///< Current attenuation level caused by a crossfade (only if a crossfade is defined of course) - //double Pos; ///< Current playback position in sample + double Pos; ///< Current playback position in sample float PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice float PitchBend; ///< Current pitch value of the pitchbend wheel float CutoffBase; ///< Cutoff frequency before control change, EG and LFO are applied @@ -188,14 +190,16 @@ void processCrossFadeEvent(RTList::Iterator& itEvent); void processCutoffEvent(RTList::Iterator& itEvent); void processResonanceEvent(RTList::Iterator& itEvent); + float getVolume(); inline float CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) { - float att = (!pDimRgn->Crossfade.out_end) ? CrossfadeControllerValue / 127.0f /* 0,0,0,0 means no crossfade defined */ - : (CrossfadeControllerValue < pDimRgn->Crossfade.in_end) ? - ((CrossfadeControllerValue <= pDimRgn->Crossfade.in_start) ? 0.0f - : float(CrossfadeControllerValue - pDimRgn->Crossfade.in_start) / float(pDimRgn->Crossfade.in_end - pDimRgn->Crossfade.in_start)) - : (CrossfadeControllerValue <= pDimRgn->Crossfade.out_start) ? 1.0f - : (CrossfadeControllerValue < pDimRgn->Crossfade.out_end) ? float(pDimRgn->Crossfade.out_end - CrossfadeControllerValue) / float(pDimRgn->Crossfade.out_end - pDimRgn->Crossfade.out_start) + uint8_t c = std::max(CrossfadeControllerValue, pDimRgn->AttenuationControllerThreshold); + float att = (!pDimRgn->Crossfade.out_end) ? c / 127.0f /* 0,0,0,0 means no crossfade defined */ + : (c < pDimRgn->Crossfade.in_end) ? + ((c <= pDimRgn->Crossfade.in_start) ? 0.0f + : float(c - pDimRgn->Crossfade.in_start) / float(pDimRgn->Crossfade.in_end - pDimRgn->Crossfade.in_start)) + : (c <= pDimRgn->Crossfade.out_start) ? 1.0f + : (c < pDimRgn->Crossfade.out_end) ? float(pDimRgn->Crossfade.out_end - c) / float(pDimRgn->Crossfade.out_end - pDimRgn->Crossfade.out_start) : 0.0f; return pDimRgn->InvertAttenuationController ? 1 - att : att; }