/[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 3052 - (hide annotations) (download) (as text)
Wed Dec 14 17:34:54 2016 UTC (7 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 7190 byte(s)
- Preparations for Xcode project update.

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

  ViewVC Help
Powered by ViewVC