--- linuxsampler/trunk/src/engines/common/AbstractVoice.h 2010/02/23 18:32:31 2061 +++ linuxsampler/trunk/src/engines/common/AbstractVoice.h 2011/07/11 17:52:01 2205 @@ -4,7 +4,7 @@ * * * Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * * Copyright (C) 2005-2008 Christian Schoenebeck * - * Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev * + * Copyright (C) 2009-2011 Christian Schoenebeck and Grigor Iliev * * * * 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 * @@ -23,7 +23,7 @@ ***************************************************************************/ #ifndef __LS_ABSTRACTVOICE_H__ -#define __LS_ABSTRACTVOICE_H__ +#define __LS_ABSTRACTVOICE_H__ #include "Voice.h" @@ -37,6 +37,7 @@ #include "../gig/SmoothVolume.h" #include "../gig/Synthesizer.h" #include "../gig/Profiler.h" +#include "SignalUnitRack.h" // include the appropriate (unsigned) triangle LFO implementation #if CONFIG_UNSIGNED_TRIANG_ALGO == INT_MATH_SOLUTION @@ -80,9 +81,8 @@ class AbstractVoice : public Voice { public: - type_t Type; ///< Voice Type + type_t Type; ///< Voice Type (bit field, a voice may have several types) int MIDIKey; ///< MIDI key number of the key that triggered the voice - uint KeyGroup; AbstractVoice(); virtual ~AbstractVoice(); @@ -101,11 +101,16 @@ ); virtual void Synthesize(uint Samples, sample_t* pSrc, uint Skip); + + uint GetSampleRate() { return GetEngine()->SampleRate; } + + virtual SignalUnitRack* GetSignalUnitRack() { return NULL; } void processCCEvents(RTList::Iterator& itEvent, uint End); void processPitchEvent(RTList::Iterator& itEvent); void processResonanceEvent(RTList::Iterator& itEvent); void processTransitionEvents(RTList::Iterator& itEvent, uint End); + void processGroupEvents(RTList::Iterator& itEvent, uint End); void UpdatePortamentoPos(Pool::Iterator& itNoteOffEvent); void Kill(Pool::Iterator& itKillEvent); @@ -135,7 +140,7 @@ unsigned long MaxRAMPos; ///< The upper allowed limit (not actually the end) in the RAM sample cache, after that point it's not safe to chase the interpolator another time over over the current cache position, instead we switch to disk then. uint Delay; ///< Number of sample points the rendering process of this voice should be delayed (jitter correction), will be set to 0 after the first audio fragment cycle EG* pEG1; ///< Envelope Generator 1 (Amplification) - gig::EGADSR EG2; ///< Envelope Generator 2 (Filter cutoff frequency) TODO: use common EG instead of gig + EG* pEG2; ///< Envelope Generator 2 (Filter cutoff frequency) gig::EGDecay EG3; ///< Envelope Generator 3 (Pitch) TODO: use common EG instead? midi_ctrl VCFCutoffCtrl; midi_ctrl VCFResonanceCtrl; @@ -152,7 +157,7 @@ float fFinalResonance; gig::SynthesisParam finalSynthesisParameters; gig::Loop loop; - + RTList* pGroupEvents; ///< Events directed to an exclusive group virtual AbstractEngine* GetEngine() = 0; virtual SampleInfo GetSampleInfo() = 0; @@ -160,6 +165,19 @@ virtual InstrumentInfo GetInstrumentInfo() = 0; /** + * Most of the important members of the voice are set when the voice + * is triggered (like pEngineChannel, pRegion, pSample, etc). + * This method is called after these members are set and before + * the voice is actually triggered. + * Override this method if you need to do some additional + * initialization which depends on these members before the voice + * is triggered. + */ + virtual void AboutToTrigger() { } + + virtual bool EG1Finished(); + + /** * Gets the sample cache size in bytes. */ virtual unsigned long GetSampleCacheSize() = 0; @@ -188,6 +206,8 @@ */ virtual double CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) = 0; + virtual MidiKeyBase* GetMidiKeyInfo(int MIDIKey) = 0; + virtual int OrderNewStream() = 0; virtual PitchInfo CalculatePitchInfo(int PitchBend); @@ -224,6 +244,8 @@ */ virtual EGInfo CalculateEG2ControllerInfluence(double eg2ControllerValue) = 0; + virtual void TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) = 0; + virtual float CalculateCutoffBase(uint8_t MIDIKeyVelocity) = 0; virtual float CalculateFinalCutoff(float cutoffBase) = 0; @@ -241,7 +263,10 @@ virtual double GetVelocityRelease(uint8_t MIDIKeyVelocity) = 0; virtual unsigned long GetNoteOnTime(int MIDIKey) = 0; + + virtual void ProcessGroupEvent(RTList::Iterator& itEvent) = 0; + void EnterReleaseStage(); }; } // namespace LinuxSampler -#endif /* __LS_ABSTRACTVOICE_H__ */ +#endif /* __LS_ABSTRACTVOICE_H__ */