1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2010 Andreas Persson * |
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., 51 Franklin St, Fifth Floor, Boston, * |
20 |
* MA 02110-1301 USA * |
21 |
***************************************************************************/ |
22 |
|
23 |
#ifndef LS_SFZ_EG_H |
24 |
#define LS_SFZ_EG_H |
25 |
|
26 |
#include "../common/EG.h" |
27 |
#include "../../common/global.h" |
28 |
#include "../../common/RTMath.h" |
29 |
#include "sfz.h" |
30 |
|
31 |
namespace LinuxSampler { namespace sfz { |
32 |
|
33 |
/** |
34 |
* Multi Stage Envelope Generator |
35 |
* |
36 |
* SFZ v2 envelope generator with multiple stages for modulating |
37 |
* arbitrary synthesis parameters. |
38 |
*/ |
39 |
class EG : public ::LinuxSampler::EG { |
40 |
public: |
41 |
/** |
42 |
* Will be called by the voice when the key / voice was triggered. |
43 |
* |
44 |
* @param eg - EG from sfz::Definition |
45 |
* @param SampleRate - sample rate of used audio output driver |
46 |
* @param Velocity - MIDI velocity |
47 |
*/ |
48 |
void trigger(::sfz::EG& eg, uint SampleRate, uint8_t Velocity); |
49 |
|
50 |
/** |
51 |
* Should be called to inform the EG about an external event and |
52 |
* also whenever an envelope stage is completed. This will handle |
53 |
* the envelope's transition to the respective next stage. |
54 |
* |
55 |
* @param Event - what happened |
56 |
* @param SampleRate - sample rate |
57 |
*/ |
58 |
void update(event_t Event, uint SampleRate); |
59 |
|
60 |
private: |
61 |
int Stage; |
62 |
::sfz::EG* eg; |
63 |
float TimeCoeff; |
64 |
|
65 |
void enterSustainStage(); |
66 |
}; |
67 |
|
68 |
}} // namespace LinuxSampler::sfz |
69 |
|
70 |
#endif |