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.

automations.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #pragma once
  2. #include <rtosc/ports.h>
  3. #include <rtosc/rtosc.h>
  4. #include <cassert>
  5. namespace rtosc {
  6. struct AutomationMapping
  7. {
  8. //0 - linear
  9. //1 - log
  10. int control_scale;
  11. //0 - simple linear (only first four control points are used)
  12. //1 - piecewise linear
  13. int control_type;
  14. float *control_points;
  15. int npoints;
  16. int upoints;
  17. float gain;
  18. float offset;
  19. };
  20. struct Automation
  21. {
  22. //If automation is allocated to anything or not
  23. bool used;
  24. //If automation is used or not
  25. bool active;
  26. //relative or absolute
  27. bool relative;
  28. //Cached infomation
  29. float param_base_value;
  30. char param_path[128];
  31. char param_type;
  32. float param_min;
  33. float param_max;
  34. float param_step; //resolution of parameter. Useful for:
  35. //- integer valued controls
  36. AutomationMapping map;
  37. };
  38. #define RTOSC_AUTOMATION_SLOT_NAME_LEN
  39. struct AutomationSlot
  40. {
  41. //If automation slot has active automations or not
  42. bool active;
  43. //If automation slot has active automations or not
  44. bool used;
  45. //Non-negative if a new MIDI binding is being learned
  46. int learning;
  47. //-1 or a valid MIDI CC + MIDI Channel
  48. int midi_cc;
  49. //Current state supplied by MIDI value or host
  50. float current_state;
  51. //Current name
  52. char name[128];
  53. //Collection of automations
  54. Automation *automations;
  55. };
  56. class AutomationMgr
  57. {
  58. public:
  59. AutomationMgr(int slots, int per_slot, int control_points);
  60. ~AutomationMgr(void);
  61. /**
  62. * Create an Automation binding
  63. *
  64. * - Assumes that each binding takes a new automation slot unless learning
  65. * a macro
  66. * - Can trigger a MIDI learn (recommended for standalone and not
  67. * recommended for plugin modes)
  68. */
  69. void createBinding(int slot, const char *path, bool start_midi_learn);
  70. void updateMapping(int slot, int sub);
  71. //Get/Set Automation Slot values 0..1
  72. void setSlot(int slot_id, float value);
  73. void setSlotSub(int slot_id, int sub, float value);
  74. float getSlot(int slot_id);
  75. void clearSlot(int slot_id);
  76. void clearSlotSub(int slot_id, int sub);
  77. void setSlotSubGain(int slot_id, int sub, float f);
  78. float getSlotSubGain(int slot_id, int sub);
  79. void setSlotSubOffset(int slot_id, int sub, float f);
  80. float getSlotSubOffset(int slot_id, int sub);
  81. void setName(int slot_id, const char *msg);
  82. const char * getName(int slot_id);
  83. bool handleMidi(int channel, int cc, int val);
  84. void set_ports(const struct Ports &p);
  85. void set_instance(void *v);
  86. void simpleSlope(int slot, int au, float slope, float offset);
  87. int free_slot(void) const;
  88. AutomationSlot *slots;
  89. int nslots;
  90. int per_slot;
  91. int active_slot;
  92. int learn_queue_len;
  93. struct AutomationMgrImpl *impl;
  94. const rtosc::Ports *p;
  95. void *instance;
  96. std::function<void(const char *)> backend;
  97. int damaged;
  98. };
  99. };