zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

EnvelopeParams.h (3345B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   EnvelopeParams.h - Parameters for Envelope
      5   Copyright (C) 2002-2005 Nasca Octavian Paul
      6   Author: Nasca Octavian Paul
      7 
      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.
     12 */
     13 
     14 #ifndef ENVELOPE_PARAMS_H
     15 #define ENVELOPE_PARAMS_H
     16 
     17 #include "../globals.h"
     18 #include "../Misc/XMLwrapper.h"
     19 #include "Presets.h"
     20 #include <cstdint>
     21 
     22 namespace zyn {
     23 
     24    enum envmode_enum {
     25         ADSR_lin = 1,
     26         ADSR_dB = 2,
     27         ASR_freqlfo = 3,
     28         ADSR_filter = 4,
     29         ASR_bw = 5
     30     };
     31 
     32 class EnvelopeParams:public Presets
     33 {
     34     public:
     35         EnvelopeParams(unsigned char Penvstretch_=64,
     36                        unsigned char Pforcedrelease_=0,
     37                        const AbsTime *time_ = nullptr);
     38         ~EnvelopeParams() override;
     39         void paste(const EnvelopeParams &ep);
     40 
     41         void init(consumer_location_t loc);
     42         void converttofree();
     43 
     44         void add2XML(XMLwrapper& xml) override;
     45         void defaults();
     46         void getfromXML(XMLwrapper& xml);
     47 
     48         float getdt(char i) const;
     49 
     50 
     51         int loc; //!< consumer location
     52 
     53         /* MIDI Parameters */
     54         unsigned char Pfreemode; //1 for free mode, 0 otherwise
     55         unsigned char Penvpoints;
     56         unsigned char Penvsustain; //127 for disabled
     57         float         envdt[MAX_ENVELOPE_POINTS];
     58         unsigned char Penvval[MAX_ENVELOPE_POINTS];
     59         unsigned char Penvstretch; //64=normal stretch (piano-like), 0=no stretch
     60         unsigned char Pforcedrelease; //0 - OFF, 1 - ON
     61         unsigned char Plinearenvelope; //1 for linear AMP ENV, 0 otherwise
     62         unsigned char Prepeating; //0 - OFF, 1 - ON
     63 
     64         float A_dt, D_dt, R_dt;
     65         unsigned char PA_val, PD_val, PS_val, PR_val;
     66 
     67 
     68 
     69 
     70         envmode_enum Envmode; // 1 for ADSR parameters (linear amplitude)
     71                      // 2 for ADSR_dB parameters (dB amplitude)
     72                      // 3 for ASR parameters (frequency LFO)
     73                      // 4 for ADSR_filter parameters (filter parameters)
     74                      // 5 for ASR_bw parameters (bandwidth parameters)
     75 
     76 
     77 
     78         const AbsTime *time;
     79         int64_t last_update_timestamp;
     80 
     81         static const rtosc::Ports &ports;
     82 
     83         static float env_rap2dB(float rap);
     84         static float env_dB2rap(float db);
     85 
     86     private:
     87 
     88         void ADSRinit(float A_dt, float D_dt, char S_val, float R_dt);
     89         void ADSRinit_dB(float A_dt, float D_dt, char S_val, float R_dt);
     90         void ASRinit(char A_val, float A_dt, char R_val, float R_dt);
     91         void ADSRinit_filter(char A_val,
     92                              float A_dt,
     93                              char D_val,
     94                              float D_dt,
     95                              float R_dt,
     96                              char R_val);
     97         void ASRinit_bw(char A_val, float A_dt, char R_val, float R_dt);
     98 
     99         void store2defaults();
    100 
    101         /* Default parameters */
    102         unsigned char Denvstretch;
    103         unsigned char Dforcedrelease;
    104         unsigned char Dlinearenvelope;
    105         unsigned char Drepeating;
    106         float DA_dt, DD_dt, DR_dt;
    107         unsigned char DA_val, DD_val, DS_val, DR_val;
    108 };
    109 
    110 }
    111 
    112 #endif