2 ZynAddSubFX - a software synthesizer
4 EnvelopeParams.h - Parameters for Envelope
5 Copyright (C) 2002-2005 Nasca Octavian Paul
6 Author: Nasca Octavian Paul
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
14 #ifndef ENVELOPE_PARAMS_H
15 #define ENVELOPE_PARAMS_H
17 #include "../globals.h"
18 #include "../Misc/XMLwrapper.h"
31 class EnvelopeParams
:public Presets
34 EnvelopeParams(unsigned char Penvstretch_
=64,
35 unsigned char Pforcedrelease_
=0,
36 const AbsTime
*time_
= nullptr);
38 void paste(const EnvelopeParams
&ep
);
40 void init(consumer_location_t loc
);
43 void add2XML(XMLwrapper
& xml
);
45 void getfromXML(XMLwrapper
& xml
);
47 float getdt(char i
) const;
50 int loc
; //!< consumer location
53 unsigned char Pfreemode
; //1 for free mode, 0 otherwise
54 unsigned char Penvpoints
;
55 unsigned char Penvsustain
; //127 for disabled
56 float envdt
[MAX_ENVELOPE_POINTS
];
57 unsigned char Penvval
[MAX_ENVELOPE_POINTS
];
58 unsigned char Penvstretch
; //64=normal stretch (piano-like), 0=no stretch
59 unsigned char Pforcedrelease
; //0 - OFF, 1 - ON
60 unsigned char Plinearenvelope
; //if the amplitude envelope is linear
62 float A_dt
, D_dt
, R_dt
;
63 unsigned char PA_val
, PD_val
, PS_val
, PR_val
;
68 envmode_enum Envmode
; // 1 for ADSR parameters (linear amplitude)
69 // 2 for ADSR_dB parameters (dB amplitude)
70 // 3 for ASR parameters (frequency LFO)
71 // 4 for ADSR_filter parameters (filter parameters)
72 // 5 for ASR_bw parameters (bandwidth parameters)
77 int64_t last_update_timestamp
;
79 static const rtosc::Ports
&ports
;
81 static float env_rap2dB(float rap
);
82 static float env_dB2rap(float db
);
86 void ADSRinit(float A_dt
, float D_dt
, char S_val
, float R_dt
);
87 void ADSRinit_dB(float A_dt
, float D_dt
, char S_val
, float R_dt
);
88 void ASRinit(char A_val
, float A_dt
, char R_val
, float R_dt
);
89 void ADSRinit_filter(char A_val
,
95 void ASRinit_bw(char A_val
, float A_dt
, char R_val
, float R_dt
);
97 void store2defaults();
99 /* Default parameters */
100 unsigned char Denvstretch
;
101 unsigned char Dforcedrelease
;
102 unsigned char Dlinearenvelope
;
103 float DA_dt
, DD_dt
, DR_dt
;
104 unsigned char DA_val
, DD_val
, DS_val
, DR_val
;