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

Contents of /linuxsampler/trunk/src/engines/gig/EGADSR.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 271 - (show annotations) (download) (as text)
Fri Oct 8 20:51:39 2004 UTC (19 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4029 byte(s)
* libgig: fixed panorama value in DimensionRegion (invalid conversion
  from signed 7 bit to signed 8 bit)
* src/linuxsampler.cpp: stacktrace is now automatically shown on fatal
  errors (that is  segmentation faults, etc.), gdb should be installed for
  this to work
* gig::Voice: tiny accuracy fix of pan calculation
* replaced old pool classes by completely new ones which now offer
  Iterator abstraction

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #ifndef __LS_GIG_EGADSR_H__
24 #define __LS_GIG_EGADSR_H__
25
26 #include <math.h>
27
28 #include "../../common/global.h"
29 #include "../../common/RTMath.h"
30 #include "../../common/RTELMemoryPool.h"
31 #include "../common/Event.h"
32 #include "Manipulator.h"
33 #include "Engine.h"
34
35 #define EG_ENVELOPE_LIMIT 0.001
36 #define EG_MIN_RELEASE_TIME 0.0001
37
38 namespace LinuxSampler { namespace gig {
39
40 /**
41 * ADSR Envelope Generator
42 *
43 * Envelope Generator with stage 'Attack', 'Attack_Hold', 'Decay_1',
44 * 'Decay_2', 'Sustain' and 'Release' for modulating arbitrary synthesis
45 * parameters.
46 */
47 class EGADSR {
48 public:
49 enum stage_t {
50 stage_attack,
51 stage_attack_hold,
52 stage_decay1,
53 stage_decay2,
54 stage_sustain,
55 stage_release,
56 stage_fadeout,
57 stage_end
58 };
59
60 EGADSR(gig::Engine* pEngine, Event::destination_t ModulationDestination);
61 void Process(uint TotalSamples, RTList<Event>* pEvents, RTList<Event>::Iterator itTriggerEvent, double SamplePos, double CurrentPitch, RTList<Event>::Iterator itKillEvent = RTList<Event>::Iterator());
62 void Trigger(uint PreAttack, double AttackTime, bool HoldAttack, long LoopStart, double Decay1Time, double Decay2Time, bool InfiniteSustain, uint SustainLevel, double ReleaseTime, uint Delay);
63 inline EGADSR::stage_t GetStage() { return Stage; }
64 protected:
65 gig::Engine* pEngine;
66 Event::destination_t ModulationDestination;
67 uint TriggerDelay; ///< number of sample points triggering should be delayed
68 float Level;
69 stage_t Stage;
70 float AttackCoeff;
71 long AttackStepsLeft; ///< number of sample points til end of attack stage
72 bool HoldAttack;
73 long LoopStart;
74 float Decay1Coeff;
75 long Decay1StepsLeft; ///< number of sample points in Decay1 stage
76 float Decay2Coeff;
77 bool InfiniteSustain;
78 float SustainLevel;
79 float ReleaseCoeff;
80 long ReleaseStepsLeft; ///< number of sample points til end of release stage
81 bool ReleasePostponed; ///< If a "release" event occured in the previous audio fragment, but wasn't processed yet.
82 const static float FadeOutCoeff;
83 private:
84 static float CalculateFadeOutCoeff();
85 };
86
87 }} // namespace LinuxSampler::gig
88
89 #endif // __LS_GIG_EGADSR_H__

  ViewVC Help
Powered by ViewVC