4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 - 2010 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009 - 2012 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* 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 * |
* it under the terms of the GNU General Public License as published by * |
36 |
#include "../gig/Filter.h" |
#include "../gig/Filter.h" |
37 |
#include "../common/VoiceBase.h" |
#include "../common/VoiceBase.h" |
38 |
#include "../gig/SynthesisParam.h" |
#include "../gig/SynthesisParam.h" |
39 |
|
#include "../sfz/EGADSR.h" |
40 |
|
#include "SF2SignalUnitRack.h" |
41 |
|
|
42 |
namespace LinuxSampler { namespace sf2 { |
namespace LinuxSampler { namespace sf2 { |
43 |
class Engine; |
class Engine; |
53 |
virtual ~Voice(); |
virtual ~Voice(); |
54 |
void SetOutput(AudioOutputDevice* pAudioOutputDevice); |
void SetOutput(AudioOutputDevice* pAudioOutputDevice); |
55 |
void SetEngine(LinuxSampler::Engine* pEngine); |
void SetEngine(LinuxSampler::Engine* pEngine); |
56 |
|
void CalculateFadeOutCoeff(float FadeOutTime, float SampleRate); |
57 |
|
|
58 |
protected: |
protected: |
59 |
virtual SampleInfo GetSampleInfo(); |
virtual SampleInfo GetSampleInfo(); |
63 |
virtual AbstractEngine* GetEngine() { return (AbstractEngine*)pEngine; } |
virtual AbstractEngine* GetEngine() { return (AbstractEngine*)pEngine; } |
64 |
virtual double GetEG1ControllerValue(uint8_t MIDIKeyVelocity); |
virtual double GetEG1ControllerValue(uint8_t MIDIKeyVelocity); |
65 |
virtual EGInfo CalculateEG1ControllerInfluence(double eg1ControllerValue); |
virtual EGInfo CalculateEG1ControllerInfluence(double eg1ControllerValue); |
66 |
virtual void TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity); |
virtual void TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { } |
67 |
virtual double GetEG2ControllerValue(uint8_t MIDIKeyVelocity); |
virtual double GetEG2ControllerValue(uint8_t MIDIKeyVelocity); |
68 |
virtual EGInfo CalculateEG2ControllerInfluence(double eg2ControllerValue); |
virtual EGInfo CalculateEG2ControllerInfluence(double eg2ControllerValue); |
69 |
virtual void InitLFO1(); |
virtual void TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { } |
70 |
virtual void InitLFO2(); |
virtual void InitLFO1() { } |
71 |
virtual void InitLFO3(); |
virtual void InitLFO2() { } |
72 |
|
virtual void InitLFO3() { } |
73 |
virtual float CalculateCutoffBase(uint8_t MIDIKeyVelocity); |
virtual float CalculateCutoffBase(uint8_t MIDIKeyVelocity); |
74 |
virtual float CalculateFinalCutoff(float cutoffBase); |
virtual float CalculateFinalCutoff(float cutoffBase); |
75 |
virtual uint8_t GetVCFCutoffCtrl(); |
virtual uint8_t GetVCFCutoffCtrl(); |
79 |
virtual double GetVelocityAttenuation(uint8_t MIDIKeyVelocity); |
virtual double GetVelocityAttenuation(uint8_t MIDIKeyVelocity); |
80 |
virtual double GetVelocityRelease(uint8_t MIDIKeyVelocity); |
virtual double GetVelocityRelease(uint8_t MIDIKeyVelocity); |
81 |
virtual double GetSampleAttenuation(); |
virtual double GetSampleAttenuation(); |
82 |
|
virtual void ProcessGroupEvent(RTList<Event>::Iterator& itEvent); |
83 |
|
virtual void AboutToTrigger(); |
84 |
|
|
85 |
private: |
private: |
86 |
::LinuxSampler::gig::EGADSR EG1; // TODO: add a fine-tuned version for SF2, or maybe use sfz v1 instead of gig |
::sf2::Region* pPresetRegion; |
87 |
|
SF2SignalUnitRack SignalRack; |
88 |
|
|
89 |
public: // FIXME: just made public for debugging (sanity check in Engine::RenderAudio()), should be changed to private before the final release |
public: // FIXME: just made public for debugging (sanity check in Engine::RenderAudio()), should be changed to private before the final release |
90 |
// Attributes |
// Attributes |
100 |
|
|
101 |
EngineChannel* GetSf2EngineChannel(); |
EngineChannel* GetSf2EngineChannel(); |
102 |
|
|
103 |
|
friend class EGUnit; |
104 |
|
friend class VolEGUnit; |
105 |
|
friend class ModEGUnit; |
106 |
|
friend class ModLfoUnit; |
107 |
|
friend class VibLfoUnit; |
108 |
|
friend class EndpointUnit; |
109 |
|
friend class SF2SignalUnitRack; |
110 |
|
|
111 |
protected: |
protected: |
112 |
virtual uint8_t CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) { |
virtual uint8_t CrossfadeAttenuation(uint8_t& CrossfadeControllerValue) { |
113 |
/*uint8_t c = std::max(CrossfadeControllerValue, pRegion->AttenuationControllerThreshold); |
/*uint8_t c = std::max(CrossfadeControllerValue, pRegion->AttenuationControllerThreshold); |