/[svn]/linuxsampler/tags/v0_1_0/src/eg_vca.h
ViewVC logotype

Annotation of /linuxsampler/tags/v0_1_0/src/eg_vca.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (hide annotations) (download) (as text)
Sun Apr 11 17:25:40 2004 UTC (20 years, 1 month ago) by (unknown author)
File MIME type: text/x-c++hdr
File size: 3851 byte(s)
This commit was manufactured by cvs2svn to create tag 'v0_1_0'.
1 schoenebeck 30 /***************************************************************************
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 schoenebeck 33 #include "rtelmemorypool.h"
30 schoenebeck 30 #include "modulationsystem.h"
31    
32     #define EG_ENVELOPE_LIMIT 0.001
33     #define EG_MIN_RELEASE_TIME 0.005
34    
35 schoenebeck 40 //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 schoenebeck 30 /**
38 schoenebeck 40 * ADSR Envelope Generator
39 schoenebeck 30 *
40 schoenebeck 40 * Envelope Generator with stage 'Attack', 'Attack_Hold', 'Decay_1',
41     * 'Decay_2', 'Sustain' and 'Release' for modulating arbitrary synthesis
42     * parameters.
43 schoenebeck 30 */
44     class EG_VCA {
45     public:
46     enum stage_t {
47     stage_attack,
48 schoenebeck 33 stage_attack_hold,
49     stage_decay1,
50     stage_decay2,
51 schoenebeck 30 stage_sustain,
52     stage_release,
53     stage_end
54     };
55    
56 schoenebeck 40 EG_VCA(ModulationSystem::destination_t ModulationDestination);
57 schoenebeck 33 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 schoenebeck 30 protected:
61 schoenebeck 40 ModulationSystem::destination_t ModulationDestination;
62 schoenebeck 33 uint TriggerDelay; ///< number of sample points triggering should be delayed
63 schoenebeck 30 float Level;
64     stage_t Stage;
65     float AttackCoeff;
66     long AttackStepsLeft; ///< number of sample points til end of attack stage
67 schoenebeck 33 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 schoenebeck 30 float ReleaseCoeff;
75     long ReleaseStepsLeft; ///< number of sample points til end of release stage
76 schoenebeck 33 bool ReleasePostponed; ///< If a "release" event occured in the previous audio fragment, but wasn't processed yet.
77 schoenebeck 30
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