/[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 56 - (show annotations) (download) (as text)
Tue Apr 27 09:21:58 2004 UTC (19 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3814 byte(s)
updated copyright header for 2004

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.005
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_end
57 };
58
59 EGADSR(gig::Engine* pEngine, Event::destination_t ModulationDestination);
60 void Process(uint Samples, RTEList<Event>* pEvents, Event* pTriggerEvent, double SamplePos, double CurrentPitch);
61 void Trigger(uint PreAttack, double AttackTime, bool HoldAttack, long LoopStart, double Decay1Time, double Decay2Time, bool InfiniteSustain, uint SustainLevel, double ReleaseTime, uint Delay);
62 inline EGADSR::stage_t GetStage() { return Stage; }
63 protected:
64 gig::Engine* pEngine;
65 Event::destination_t ModulationDestination;
66 uint TriggerDelay; ///< number of sample points triggering should be delayed
67 float Level;
68 stage_t Stage;
69 float AttackCoeff;
70 long AttackStepsLeft; ///< number of sample points til end of attack stage
71 bool HoldAttack;
72 long LoopStart;
73 float Decay1Coeff;
74 long Decay1StepsLeft; ///< number of sample points in Decay1 stage
75 float Decay2Coeff;
76 bool InfiniteSustain;
77 float SustainLevel;
78 float ReleaseCoeff;
79 long ReleaseStepsLeft; ///< number of sample points til end of release stage
80 bool ReleasePostponed; ///< If a "release" event occured in the previous audio fragment, but wasn't processed yet.
81 };
82
83 }} // namespace LinuxSampler::gig
84
85 #endif // __LS_GIG_EGADSR_H__

  ViewVC Help
Powered by ViewVC