--- linuxsampler/trunk/src/engines/gig/Voice.h 2004/08/22 14:46:47 225 +++ linuxsampler/trunk/src/engines/gig/Voice.h 2004/09/12 14:48:19 239 @@ -82,17 +82,19 @@ public: // Attributes int MIDIKey; ///< MIDI key number of the key that triggered the voice + uint KeyGroup; DiskThread* pDiskThread; ///< Pointer to the disk thread, to be able to order a disk stream and later to delete the stream again // Methods Voice(); ~Voice(); - void Kill(); + void Kill(Event* pKillEvent); + void KillImmediately(); void Render(uint Samples); void Reset(); void SetOutput(AudioOutputDevice* pAudioOutputDevice); void SetEngine(Engine* pEngine); - int Trigger(Event* pNoteOnEvent, int PitchBend, ::gig::Instrument* pInstrument); + int Trigger(Event* pNoteOnEvent, int PitchBend, ::gig::Instrument* pInstrument, int iLayer = 0); inline bool IsActive() { return Active; } private: // Types @@ -105,11 +107,13 @@ // Attributes gig::Engine* pEngine; ///< Pointer to the sampler engine, to be able to access the event lists. float Volume; ///< Volume level of the voice + 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 PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice double PitchBend; ///< Current pitch value of the pitchbend wheel ::gig::Sample* pSample; ///< Pointer to the sample to be played back ::gig::Region* pRegion; ///< Pointer to the articulation information of the respective keyboard region of this voice + ::gig::DimensionRegion* pDimRgn; ///< Pointer to the articulation information of current dimension region of this voice bool Active; ///< If this voice object is currently in usage playback_state_t PlaybackState; ///< When a sample will be triggered, it will be first played from RAM cache and after a couple of sample points it will switch to disk streaming and at the end of a disk stream we have to add null samples, so the interpolator can do it's work correctly bool DiskVoice; ///< If the sample is very short it completely fits into the RAM cache and doesn't need to be streamed from disk, in that case this flag is set to false @@ -135,6 +139,7 @@ LFO* pLFO2; ///< Low Frequency Oscillator 2 (Filter cutoff frequency) LFO* pLFO3; ///< Low Frequency Oscillator 3 (Pitch) Event* pTriggerEvent; ///< First event on the key's list the voice should process (only needed for the first audio fragment in which voice was triggered, after that it will be set to NULL). + Event* pKillEvent; ///< Event which caused this voice to be killed // Static Methods static float CalculateFilterCutoffCoeff(); @@ -224,6 +229,14 @@ this->Pos += pitch; } + inline float CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) { + return (CrossfadeControllerValue <= pDimRgn->Crossfade.in_start) ? 0.0f + : (CrossfadeControllerValue < pDimRgn->Crossfade.in_end) ? 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(CrossfadeControllerValue - pDimRgn->Crossfade.out_start) / float(pDimRgn->Crossfade.out_end - pDimRgn->Crossfade.out_start) + : 0.0f; + } + inline float Constrain(float ValueToCheck, float Min, float Max) { if (ValueToCheck > Max) ValueToCheck = Max; else if (ValueToCheck < Min) ValueToCheck = Min;