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