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.

82 lines
1.7KB

  1. /*************************************************************************************
  2. * Original code copyright (C) 2012 Steve Folta
  3. * Converted to Juce module (C) 2016 Leo Olivers
  4. * Forked from https://github.com/stevefolta/SFZero
  5. * For license info please see the LICENSE file distributed with this source code
  6. *************************************************************************************/
  7. #include "SFZRegion.h"
  8. #include "SFZSample.h"
  9. namespace sfzero
  10. {
  11. void EGParameters::clear()
  12. {
  13. delay = 0.0;
  14. start = 0.0;
  15. attack = 0.0;
  16. hold = 0.0;
  17. decay = 0.0;
  18. sustain = 100.0;
  19. release = 0.0;
  20. }
  21. void EGParameters::clearMod()
  22. {
  23. // Clear for velocity or other modification.
  24. delay = start = attack = hold = decay = sustain = release = 0.0;
  25. }
  26. Region::Region() { clear(); }
  27. void Region::clear()
  28. {
  29. #if 1
  30. sample = nullptr;
  31. lokey = 0;
  32. lovel = 0;
  33. trigger = attack;
  34. group = 0;
  35. off_by = 0;
  36. off_mode = fast;
  37. offset = 0;
  38. end = 0;
  39. negative_end = false;
  40. loop_mode = no_loop;
  41. loop_start = 0;
  42. loop_end = 0;
  43. transpose = 0;
  44. tune = 0;
  45. #else
  46. memset(this, 0, sizeof(*this));
  47. #endif
  48. hikey = 127;
  49. hivel = 127;
  50. pitch_keycenter = 60; // C4
  51. pitch_keytrack = 100;
  52. bend_up = 200;
  53. bend_down = -200;
  54. volume = pan = 0.0f;
  55. amp_veltrack = 100.0f;
  56. ampeg.clear();
  57. ampeg_veltrack.clearMod();
  58. }
  59. water::String Region::dump()
  60. {
  61. water::String info = water::String::formatted("%d - %d, vel %d - %d", lokey, hikey, lovel, hivel);
  62. if (sample)
  63. {
  64. info << sample->getShortName();
  65. }
  66. info << "\n";
  67. return info;
  68. }
  69. float Region::timecents2Secs(int timecents) { return static_cast<float>(pow(2.0, timecents / 1200.0)); }
  70. }