finish addsynth ENVs sustaining at 0 with 0 release to free up cpu (#55)
[zynaddsubfx-code.git] / src / Params / EnvelopeParams.h
blob004d17bf67d97495d1a07a163e996bfd11785b51
1 /*
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"
19 #include "Presets.h"
21 namespace zyn {
23 enum envmode_enum {
24 ADSR_lin = 1,
25 ADSR_dB = 2,
26 ASR_freqlfo = 3,
27 ADSR_filter = 4,
28 ASR_bw = 5
31 class EnvelopeParams:public Presets
33 public:
34 EnvelopeParams(unsigned char Penvstretch_=64,
35 unsigned char Pforcedrelease_=0,
36 const AbsTime *time_ = nullptr);
37 ~EnvelopeParams();
38 void paste(const EnvelopeParams &ep);
40 void init(consumer_location_t loc);
41 void converttofree();
43 void add2XML(XMLwrapper& xml);
44 void defaults();
45 void getfromXML(XMLwrapper& xml);
47 float getdt(char i) const;
50 int loc; //!< consumer location
52 /* MIDI Parameters */
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)
76 const AbsTime *time;
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);
84 private:
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,
90 float A_dt,
91 char D_val,
92 float D_dt,
93 float R_dt,
94 char R_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;
109 #endif