/[svn]/linuxsampler/trunk/src/eg_vca.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/eg_vca.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations) (download) (as text)
Wed Mar 31 10:28:42 2004 UTC (20 years ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3851 byte(s)
removed unnecessary dependencies

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003 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 __EG_VCA_H__
24 #define __EG_VCA_H__
25
26 #include <math.h>
27
28 #include "global.h"
29 #include "rtelmemorypool.h"
30 #include "modulationsystem.h"
31
32 #define EG_ENVELOPE_LIMIT 0.001
33 #define EG_MIN_RELEASE_TIME 0.005
34
35 //FIXME: class should be renamed to 'EG_ADSR' or something, as it's not only a VCA EG anymore; we do that when we restructure the source tree
36
37 /**
38 * ADSR Envelope Generator
39 *
40 * Envelope Generator with stage 'Attack', 'Attack_Hold', 'Decay_1',
41 * 'Decay_2', 'Sustain' and 'Release' for modulating arbitrary synthesis
42 * parameters.
43 */
44 class EG_VCA {
45 public:
46 enum stage_t {
47 stage_attack,
48 stage_attack_hold,
49 stage_decay1,
50 stage_decay2,
51 stage_sustain,
52 stage_release,
53 stage_end
54 };
55
56 EG_VCA(ModulationSystem::destination_t ModulationDestination);
57 void Process(uint Samples, RTEList<ModulationSystem::Event>* pEvents, ModulationSystem::Event* pTriggerEvent, double SamplePos, double CurrentPitch);
58 void Trigger(uint PreAttack, double AttackTime, bool HoldAttack, long LoopStart, double Decay1Time, double Decay2Time, bool InfiniteSustain, uint SustainLevel, double ReleaseTime, uint Delay);
59 inline EG_VCA::stage_t GetStage() { return Stage; }
60 protected:
61 ModulationSystem::destination_t ModulationDestination;
62 uint TriggerDelay; ///< number of sample points triggering should be delayed
63 float Level;
64 stage_t Stage;
65 float AttackCoeff;
66 long AttackStepsLeft; ///< number of sample points til end of attack stage
67 bool HoldAttack;
68 long LoopStart;
69 float Decay1Coeff;
70 long Decay1StepsLeft; ///< number of sample points in Decay1 stage
71 float Decay2Coeff;
72 bool InfiniteSustain;
73 float SustainLevel;
74 float ReleaseCoeff;
75 long ReleaseStepsLeft; ///< number of sample points til end of release stage
76 bool ReleasePostponed; ///< If a "release" event occured in the previous audio fragment, but wasn't processed yet.
77
78 inline long Min(long A, long B) {
79 return (A > B) ? B : A;
80 }
81 };
82
83 #endif // __EG_VCA_H__

  ViewVC Help
Powered by ViewVC