1 |
schoenebeck |
40 |
/*************************************************************************** |
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_D_H__ |
24 |
|
|
#define __EG_D_H__ |
25 |
|
|
|
26 |
|
|
#include "global.h" |
27 |
|
|
#include "modulationsystem.h" |
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* Decay Envelope Generator |
31 |
|
|
* |
32 |
|
|
* Simple Envelope Generator with only one stage: 'Decay'. We currently use |
33 |
|
|
* this specific EG only for pitch and thus it's not generalized yet, means |
34 |
|
|
* the initial envelope level (given by 'Depth') will raise / drop in |
35 |
|
|
* 'DecayTime' seconds to a level of exactly 1.0. If the initial level |
36 |
|
|
* ('Depth') is already 1.0, nothing happens. Beside that, the EG just |
37 |
|
|
* multiplies it's levels to the synthesis parameter sequence. |
38 |
|
|
*/ |
39 |
|
|
class EG_D { |
40 |
|
|
public: |
41 |
|
|
EG_D(ModulationSystem::destination_t ModulationDestination); |
42 |
|
|
void Process(uint Samples); |
43 |
|
|
void Trigger(float Depth, double DecayTime, uint Delay); |
44 |
|
|
protected: |
45 |
|
|
ModulationSystem::destination_t ModulationDestination; |
46 |
|
|
uint TriggerDelay; ///< number of sample points triggering should be delayed |
47 |
|
|
float Level; |
48 |
|
|
float DecayCoeff; |
49 |
|
|
long DecayStepsLeft; |
50 |
|
|
|
51 |
|
|
inline long Min(long A, long B) { |
52 |
|
|
return (A > B) ? B : A; |
53 |
|
|
} |
54 |
|
|
}; |
55 |
|
|
|
56 |
|
|
#endif // __EG_D_H__ |