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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2311 - (show annotations) (download) (as text)
Sat Feb 11 11:08:09 2012 UTC (12 years, 2 months ago) by persson
File MIME type: text/x-c++hdr
File size: 4209 byte(s)
* more LV2 "state" extension support fixes (patch by David Robillard)
* sfz parser: allow double spaces in sample filenames
* sfz parser: allow absolute paths for sample filenames
* MME driver: fixed memory handling bug found with cppcheck
* sfz/sf2 engines: use linear decay and release for filter and pitch
  envelope generators

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2012 Christian Schoenebeck *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
21 * MA 02110-1301 USA *
22 ***************************************************************************/
23
24 #ifndef LS_SFZ_EGADSR_H
25 #define LS_SFZ_EGADSR_H
26
27 #include "../common/EG.h"
28
29 namespace LinuxSampler { namespace sfz {
30
31 /**
32 * ADSR Envelope Generator
33 *
34 * SFZ v1 envelope generator with 'Attack', 'Hold', 'Decay', 'Sustain'
35 * and 'Release' stages for modulating arbitrary synthesis parameters.
36 */
37 class EGADSR : public ::LinuxSampler::EG {
38 public:
39
40 /**
41 * Will be called by the voice when the key / voice was triggered.
42 *
43 * @param PreAttack - Preattack value for the envelope
44 * (0 - 1000 permille)
45 * @param AttackTime - Attack time for the envelope
46 * @param HoldTime - Hold time for the envelope
47 * @param DecayTime - Decay1 time of the sample amplitude EG
48 * @param SustainLevel - Sustain level of the sample amplitude EG
49 * (0 - 1000 permille)
50 * @param ReleaseTIme - Release time for the envelope
51 * @param SampleRate - sample rate of used audio output driver
52 * @param LinearRelease - true if decay and release is linear
53 */
54 void trigger(uint PreAttack, float AttackTime, float HoldTime, float DecayTime, uint SustainLevel, float ReleaseTime, uint SampleRate, bool LinearRelease); //FIXME: we should better use 'float' for SampleRate
55
56 /**
57 * Should be called to inform the EG about an external event and
58 * also whenever an envelope stage is completed. This will handle
59 * the envelope's transition to the respective next stage.
60 *
61 * @param Event - what happened
62 * @param SampleRate - sample rate of used audio output driver
63 */
64 void update(event_t Event, uint SampleRate);
65
66 private:
67
68 enum stage_t {
69 stage_attack,
70 stage_attack_hold,
71 stage_decay,
72 stage_sustain,
73 stage_release,
74 stage_fadeout,
75 stage_end
76 };
77
78 stage_t Stage;
79 int HoldSteps;
80 float DecayTime;
81 float SustainLevel;
82 float ReleaseTime;
83 bool LinearRelease;
84
85 void enterAttackStage(const uint PreAttack, const float AttackTime, const uint SampleRate);
86 void enterAttackHoldStage();
87 void enterDecayStage(const uint SampleRate);
88 void enterSustainStage();
89 void enterReleaseStage();
90 };
91
92 }} // namespace LinuxSampler::sfz
93
94 #endif // LS_SFZ_EGADSR_H

  ViewVC Help
Powered by ViewVC