/[svn]/linuxsampler/trunk/src/engines/gig/Voice.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/engines/gig/Voice.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3655 - (hide annotations) (download) (as text)
Fri Dec 13 17:14:48 2019 UTC (4 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 7605 byte(s)
* gig engine: Fixed cutoff controller handling for new filter types.

* Bumped version (2.1.1.svn25).

1 schoenebeck 53 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5 schoenebeck 56 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 persson 2055 * Copyright (C) 2005 - 2008 Christian Schoenebeck *
7 schoenebeck 3054 * Copyright (C) 2009 Christian Schoenebeck and Grigor Iliev *
8     * Copyright (C) 2010 - 2016 Christian Schoenebeck and Andreas Persson *
9 schoenebeck 53 * *
10     * This program is free software; you can redistribute it and/or modify *
11     * it under the terms of the GNU General Public License as published by *
12     * the Free Software Foundation; either version 2 of the License, or *
13     * (at your option) any later version. *
14     * *
15     * This program is distributed in the hope that it will be useful, *
16     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18     * GNU General Public License for more details. *
19     * *
20     * You should have received a copy of the GNU General Public License *
21     * along with this program; if not, write to the Free Software *
22     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
23     * MA 02111-1307 USA *
24     ***************************************************************************/
25    
26     #ifndef __LS_GIG_VOICE_H__
27     #define __LS_GIG_VOICE_H__
28    
29 schoenebeck 1424 #include "../../common/global_private.h"
30 schoenebeck 53
31 schoenebeck 3052 #if AC_APPLE_UNIVERSAL_BUILD
32     # include <libgig/gig.h>
33     #else
34     # include <gig.h>
35     #endif
36 schoenebeck 505
37 schoenebeck 53 #include "../../common/RTMath.h"
38 schoenebeck 273 #include "../../common/Pool.h"
39 schoenebeck 203 #include "../../drivers/audio/AudioOutputDevice.h"
40 schoenebeck 53 #include "Stream.h"
41     #include "DiskThread.h"
42 schoenebeck 738 #include "EGADSR.h"
43 schoenebeck 53 #include "EGDecay.h"
44     #include "Filter.h"
45 iliev 2012 #include "../common/VoiceBase.h"
46 schoenebeck 770 #include "SynthesisParam.h"
47 persson 832 #include "SmoothVolume.h"
48 persson 2390 #include "EngineChannel.h"
49 schoenebeck 53
50     namespace LinuxSampler { namespace gig {
51     class Engine;
52 iliev 2012 class EngineChannel;
53 schoenebeck 53
54     /** Gig Voice
55     *
56     * Renders a voice for the Gigasampler format.
57     */
58 iliev 2015 class Voice : public LinuxSampler::VoiceBase<EngineChannel, ::gig::DimensionRegion, ::gig::Sample, DiskThread> {
59 schoenebeck 53 public:
60     Voice();
61 letz 502 virtual ~Voice();
62 schoenebeck 53 void SetOutput(AudioOutputDevice* pAudioOutputDevice);
63 iliev 2012 void SetEngine(LinuxSampler::Engine* pEngine);
64 persson 2327 void CalculateFadeOutCoeff(float FadeOutTime, float SampleRate);
65 schoenebeck 3444 virtual release_trigger_t GetReleaseTriggerFlags() OVERRIDE;
66 schoenebeck 829
67 iliev 2015 protected:
68 schoenebeck 3054 virtual SampleInfo GetSampleInfo() OVERRIDE;
69     virtual RegionInfo GetRegionInfo() OVERRIDE;
70     virtual InstrumentInfo GetInstrumentInfo() OVERRIDE;
71     virtual double CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) OVERRIDE;
72     virtual AbstractEngine* GetEngine() OVERRIDE { return (AbstractEngine*)pEngine; }
73     virtual double GetEG1ControllerValue(uint8_t MIDIKeyVelocity) OVERRIDE;
74     virtual EGInfo CalculateEG1ControllerInfluence(double eg1ControllerValue) OVERRIDE;
75     virtual void TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) OVERRIDE;
76     virtual double GetEG2ControllerValue(uint8_t MIDIKeyVelocity) OVERRIDE;
77     virtual EGInfo CalculateEG2ControllerInfluence(double eg2ControllerValue) OVERRIDE;
78     virtual void TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) OVERRIDE;
79     virtual void InitLFO1() OVERRIDE;
80     virtual void InitLFO2() OVERRIDE;
81     virtual void InitLFO3() OVERRIDE;
82     virtual float CalculateCutoffBase(uint8_t MIDIKeyVelocity) OVERRIDE;
83     virtual float CalculateFinalCutoff(float cutoffBase) OVERRIDE;
84     virtual uint8_t GetVCFCutoffCtrl() OVERRIDE;
85     virtual uint8_t GetVCFResonanceCtrl() OVERRIDE;
86 schoenebeck 2559 virtual void ProcessCCEvent(RTList<Event>::Iterator& itEvent) OVERRIDE;
87     virtual void ProcessChannelPressureEvent(RTList<Event>::Iterator& itEvent) OVERRIDE;
88     virtual void ProcessPolyphonicKeyPressureEvent(RTList<Event>::Iterator& itEvent) OVERRIDE;
89 schoenebeck 3054 virtual void ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) OVERRIDE;
90     virtual double GetVelocityAttenuation(uint8_t MIDIKeyVelocity) OVERRIDE;
91     virtual double GetVelocityRelease(uint8_t MIDIKeyVelocity) OVERRIDE;
92     virtual double GetSampleAttenuation() OVERRIDE;
93     virtual void ProcessGroupEvent(RTList<Event>::Iterator& itEvent) OVERRIDE;
94     virtual int CalculatePan(uint8_t pan) OVERRIDE;
95 iliev 2012
96 iliev 2015 private:
97 persson 2055 EGADSR EG1;
98 persson 2175 EGADSR EG2;
99 persson 2055
100 iliev 2015 public: // FIXME: just made public for debugging (sanity check in Engine::RenderAudio()), should be changed to private before the final release
101 schoenebeck 53 // Attributes
102 schoenebeck 411 Engine* pEngine; ///< Pointer to the sampler engine, to be able to access the event lists.
103 schoenebeck 770 //uint LoopCyclesLeft; ///< In case there is a RAMLoop and it's not an endless loop; reflects number of loop cycles left to be passed
104 schoenebeck 738
105 schoenebeck 53 // Static Methods
106     static float CalculateFilterCutoffCoeff();
107    
108     // Methods
109 schoenebeck 319 void ProcessEvents(uint Samples);
110 schoenebeck 738 void processCrossFadeEvent(RTList<Event>::Iterator& itEvent);
111 schoenebeck 245
112 iliev 2015 EngineChannel* GetGigEngineChannel();
113    
114     protected:
115 schoenebeck 3054 virtual uint8_t CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) OVERRIDE {
116 iliev 2015 uint8_t c = std::max(CrossfadeControllerValue, pRegion->AttenuationControllerThreshold);
117     c = (!pRegion->Crossfade.out_end) ? c /* 0,0,0,0 means no crossfade defined */
118     : (c < pRegion->Crossfade.in_end) ?
119     ((c <= pRegion->Crossfade.in_start) ? 0
120     : 127 * (c - pRegion->Crossfade.in_start) / (pRegion->Crossfade.in_end - pRegion->Crossfade.in_start))
121     : (c <= pRegion->Crossfade.out_start) ? 127
122     : (c < pRegion->Crossfade.out_end) ? 127 * (pRegion->Crossfade.out_end - c) / (pRegion->Crossfade.out_end - pRegion->Crossfade.out_start)
123 persson 832 : 0;
124 iliev 2015 return pRegion->InvertAttenuationController ? 127 - c : c;
125 schoenebeck 236 }
126    
127 schoenebeck 53 inline float Constrain(float ValueToCheck, float Min, float Max) {
128     if (ValueToCheck > Max) ValueToCheck = Max;
129     else if (ValueToCheck < Min) ValueToCheck = Min;
130     return ValueToCheck;
131     }
132 schoenebeck 3655
133     uint8_t MinCutoff() const;
134 schoenebeck 53 };
135    
136     }} // namespace LinuxSampler::gig
137    
138     #endif // __LS_GIG_VOICE_H__

  ViewVC Help
Powered by ViewVC