Real Time Open Sound Control librtosc
automations.h
1 #include <rtosc/ports.h>
2 #include <rtosc/rtosc.h>
3 #include <cassert>
4 namespace rtosc {
6 {
7  //0 - linear
8  //1 - log
9  int control_scale;
10 
11  //0 - simple linear (only first four control points are used)
12  //1 - piecewise linear
13  int control_type;
14 
15  float *control_points;
16  int npoints;
17  int upoints;
18 
19  float gain;
20  float offset;
21 };
22 
23 struct Automation
24 {
25  //If automation is allocated to anything or not
26  bool used;
27 
28  //If automation is used or not
29  bool active;
30 
31  //relative or absolute
32  bool relative;
33 
34  //Cached infomation
35  float param_base_value;
36  char param_path[128];
37  char param_type;
38  float param_min;
39  float param_max;
40  float param_step; //resolution of parameter. Useful for:
41  //- integer valued controls
43 };
44 
45 #define RTOSC_AUTOMATION_SLOT_NAME_LEN
47 {
48  //If automation slot has active automations or not
49  bool active;
50 
51  //If automation slot has active automations or not
52  bool used;
53 
54  //Non-negative if a new MIDI binding is being learned
55  int learning;
56 
57  //-1 or a valid MIDI CC + MIDI Channel
58  int midi_cc;
59 
60  //Current state supplied by MIDI value or host
61  float current_state;
62 
63  //Current name
64  char name[128];
65 
66  //Collection of automations
67  Automation *automations;
68 };
69 
71 {
72  public:
73  AutomationMgr(int slots, int per_slot, int control_points);
74  ~AutomationMgr(void);
75 
84  void createBinding(int slot, const char *path, bool start_midi_learn);
85 
86  void updateMapping(int slot, int sub);
87 
88 
89 
90  //Get/Set Automation Slot values 0..1
91  void setSlot(int slot_id, float value);
92  void setSlotSub(int slot_id, int sub, float value);
93  float getSlot(int slot_id);
94 
95  void clearSlot(int slot_id);
96  void clearSlotSub(int slot_id, int sub);
97 
98  void setSlotSubPath(int slot_id, int sub, const char *msg);
99  void setSlotSubGain(int slot_id, int sub, float f);
100  float getSlotSubGain(int slot_id, int sub);
101  void setSlotSubOffset(int slot_id, int sub, float f);
102  float getSlotSubOffset(int slot_id, int sub);
103 
104 
105 
106  void setName(int slot_id, const char *msg);
107  const char * getName(int slot_id);
108 
109  bool handleMidi(int channel, int cc, int val);
110 
111  void set_ports(const struct Ports &p);
112 
113  void set_instance(void *v);
114 
115  void simpleSlope(int slot, int au, float slope, float offset);
116 
117  int free_slot(void) const;
118 
119  AutomationSlot *slots;
120  int nslots;
121  int per_slot;
122  int active_slot;
123  int learn_queue_len;
124  struct AutomationMgrImpl *impl;
125  const rtosc::Ports *p;
126  void *instance;
127 
128  std::function<void(const char *)> backend;
129 
130  int damaged;
131 };
132 };
Ports - a dispatchable collection of Port entries.
Definition: ports.h:157
Definition: automations.h:70
Functions handling messages and arguments.
Collection of functions for ports.
Definition: automations.h:23
Definition: automations.h:5
Definition: automations.h:46
void createBinding(int slot, const char *path, bool start_midi_learn)
Create an Automation binding.