Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.9KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. EnvelopeParams.h - Parameters for Envelope
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #ifndef ENVELOPE_PARAMS_H
  12. #define ENVELOPE_PARAMS_H
  13. #include "../globals.h"
  14. #include "../Misc/XMLwrapper.h"
  15. #include "Presets.h"
  16. namespace zyncarla {
  17. class EnvelopeParams:public Presets
  18. {
  19. public:
  20. enum envelope_type_t
  21. {
  22. ad_global_amp_env, // ADSRinit_dB(0, 40, 127, 25);
  23. ad_global_freq_env, // ASRinit(64, 50, 64, 60);
  24. ad_global_filter_env, // ADSRinit_filter(64, 40, 64, 70, 60, 64)
  25. ad_voice_amp_env, // ADSRinit_dB(0, 100, 127, 100);
  26. ad_voice_freq_env, // ASRinit(30, 40, 64, 60);
  27. ad_voice_filter_env, // ADSRinit_filter(90, 70, 40, 70, 10, 40);
  28. ad_voice_fm_freq_env, // ASRinit(20, 90, 40, 80);
  29. ad_voice_fm_amp_env, // ADSRinit(80, 90, 127, 100)
  30. sub_freq_env, // ASRinit(30, 50, 64, 60);
  31. sub_bandwidth_env, // ASRinit_bw(100, 70, 64, 60)
  32. };
  33. EnvelopeParams(unsigned char Penvstretch_=64,
  34. unsigned char Pforcedrelease_=0,
  35. const AbsTime *time_ = nullptr);
  36. ~EnvelopeParams();
  37. void paste(const EnvelopeParams &ep);
  38. void init(envelope_type_t etype);
  39. void converttofree();
  40. void add2XML(XMLwrapper& xml);
  41. void defaults();
  42. void getfromXML(XMLwrapper& xml);
  43. float getdt(char i) const;
  44. static float dt(char val);
  45. static char inv_dt(float val);
  46. //! Defines where it is used and its default settings.
  47. //! Corresponds to envelope_type_t
  48. int envelope_type;
  49. /* MIDI Parameters */
  50. unsigned char Pfreemode; //1 for free mode, 0 otherwise
  51. unsigned char Penvpoints;
  52. unsigned char Penvsustain; //127 for disabled
  53. unsigned char Penvdt[MAX_ENVELOPE_POINTS];
  54. unsigned char Penvval[MAX_ENVELOPE_POINTS];
  55. unsigned char Penvstretch; //64=normal stretch (piano-like), 0=no stretch
  56. unsigned char Pforcedrelease; //0 - OFF, 1 - ON
  57. unsigned char Plinearenvelope; //if the amplitude envelope is linear
  58. unsigned char PA_dt, PD_dt, PR_dt,
  59. PA_val, PD_val, PS_val, PR_val;
  60. int Envmode; // 1 for ADSR parameters (linear amplitude)
  61. // 2 for ADSR_dB parameters (dB amplitude)
  62. // 3 for ASR parameters (frequency LFO)
  63. // 4 for ADSR_filter parameters (filter parameters)
  64. // 5 for ASR_bw parameters (bandwidth parameters)
  65. const AbsTime *time;
  66. int64_t last_update_timestamp;
  67. static const rtosc::Ports &ports;
  68. static float env_rap2dB(float rap);
  69. static float env_dB2rap(float db);
  70. private:
  71. void ADSRinit(char A_dt, char D_dt, char S_val, char R_dt);
  72. void ADSRinit_dB(char A_dt, char D_dt, char S_val, char R_dt);
  73. void ASRinit(char A_val, char A_dt, char R_val, char R_dt);
  74. void ADSRinit_filter(char A_val,
  75. char A_dt,
  76. char D_val,
  77. char D_dt,
  78. char R_dt,
  79. char R_val);
  80. void ASRinit_bw(char A_val, char A_dt, char R_val, char R_dt);
  81. void store2defaults();
  82. /* Default parameters */
  83. unsigned char Denvstretch;
  84. unsigned char Dforcedrelease;
  85. unsigned char Dlinearenvelope;
  86. unsigned char DA_dt, DD_dt, DR_dt,
  87. DA_val, DD_val, DS_val, DR_val;
  88. };
  89. }
  90. #endif