12 auto &
s = this->slots[
i];
20 s.automations[
j].map.control_points =
new float[control_points];
21 s.automations[
j].map.npoints = control_points;
22 s.automations[
j].map.gain = 100.0;
23 s.automations[
j].map.offset = 0.0;
35 const Port *port =
p->apropos(path);
37 fprintf(stderr,
"[Zyn:Error] port '%s' does not exist\n", path);
40 auto meta = port->meta();
41 if(!(meta.find(
"min") && meta.find(
"max"))) {
42 if(!strstr(port->name,
":T")) {
43 fprintf(stderr,
"No bounds for '%s' known\n", path);
47 if(meta.find(
"internal") || meta.find(
"no learn")) {
48 fprintf(stderr,
"[Warning] port '%s' is unlearnable\n", path);
53 if(
slots[slot].automations[
i].used ==
false) {
62 slots[slot].used =
true;
64 auto &au =
slots[slot].automations[ind];
69 if(strstr(port->name,
":f"))
71 else if(strstr(port->name,
":T"))
73 if(au.param_type ==
'T') {
77 au.param_min = atof(meta[
"min"]);
78 au.param_max = atof(meta[
"max"]);
80 strncpy(au.param_path, path,
sizeof(au.param_path));
86 if(start_midi_learn &&
slots[slot].learning == -1 &&
slots[slot].midi_cc == -1)
99 auto &au =
slots[slot_id].automations[sub];
101 float mn = au.param_min;
102 float mx = au.param_max;
103 float center = (mn+mx)*(0.5 + au.map.offset/100.0);
104 float range = (mx-mn)*au.map.gain/100.0;
107 au.map.control_points[0] = 0;
108 au.map.control_points[1] = center-range/2.0;
109 au.map.control_points[2] = 1;
110 au.map.control_points[3] = center+range/2.0;
115 if(slot_id >=
nslots || slot_id < 0)
125 if(slot_id >=
nslots || slot_id < 0 || par >=
per_slot || par < 0)
127 auto &au =
slots[slot_id].automations[par];
130 const char *path = au.param_path;
131 float mn = au.param_min;
132 float mx = au.param_max;
134 float a = au.map.control_points[1];
135 float b = au.map.control_points[3];
137 char type = au.param_type;
148 }
else if(
type ==
'f') {
156 }
else if(
type ==
'T' ||
type ==
'F') {
173 if(slot_id >=
nslots || slot_id < 0)
175 return slots[slot_id].current_state;
181 if(slot_id >=
nslots || slot_id < 0)
189 if(
slots[
i].learning >
s.learning)
194 memset(
s.name, 0,
sizeof(
s.name));
195 sprintf(
s.name,
"Slot %d", slot_id);
203 if(slot_id >=
nslots || slot_id < 0 || sub >=
per_slot || sub < 0)
205 auto &
a =
slots[slot_id].automations[sub];
209 a.param_base_value =
false;
210 memset(
a.param_path, 0,
sizeof(
a.param_path));
223 if(slot_id >=
nslots || slot_id < 0 || sub >=
per_slot || sub < 0)
225 auto &
m =
slots[slot_id].automations[sub].map;
230 if(slot_id >=
nslots || slot_id < 0 || sub >=
per_slot || sub < 0)
232 auto &
m =
slots[slot_id].automations[sub].map;
237 if(slot_id >=
nslots || slot_id < 0 || sub >=
per_slot || sub < 0)
239 auto &
m =
slots[slot_id].automations[sub].map;
244 if(slot_id >=
nslots || slot_id < 0 || sub >=
per_slot || sub < 0)
246 auto &
m =
slots[slot_id].automations[sub].map;
252 if(slot_id >=
nslots || slot_id < 0)
259 if(slot_id >=
nslots || slot_id < 0)
261 return slots[slot_id].name;
265 int ccid = channel*128 + cc;
267 bool bound_cc =
false;
269 if(
slots[
i].midi_cc == ccid) {
280 if(
slots[
i].learning == 1) {
309 if(slot_id >=
nslots || slot_id < 0 || par >=
per_slot || par < 0)
311 auto &map =
slots[slot_id].automations[par].map;
313 map.control_points[0] = 0;
314 map.control_points[1] = -(slope/2)+offset;
315 map.control_points[2] = 1;
316 map.control_points[3] = slope/2+offset;
uint8_t a
Definition Spc_Cpu.h:141
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
AutomationSlot * slots
Definition automations.h:120
void setSlotSubOffset(int slot_id, int sub, float f)
Definition automations.cpp:235
~AutomationMgr(void)
Definition automations.cpp:28
std::function< void(const char *)> backend
Definition automations.h:129
bool handleMidi(int channel, int cc, int val)
Definition automations.cpp:263
void setSlotSubGain(int slot_id, int sub, float f)
Definition automations.cpp:221
void createBinding(int slot, const char *path, bool start_midi_learn)
Definition automations.cpp:32
const rtosc::Ports * p
Definition automations.h:126
float getSlotSubGain(int slot_id, int sub)
Definition automations.cpp:228
int learn_queue_len
Definition automations.h:124
const char * getName(int slot_id)
Definition automations.cpp:257
void setSlot(int slot_id, float value)
Definition automations.cpp:113
int nslots
Definition automations.h:121
void clearSlotSub(int slot_id, int sub)
Definition automations.cpp:201
int per_slot
Definition automations.h:122
int damaged
Definition automations.h:131
float getSlot(int slot_id)
Definition automations.cpp:171
void setName(int slot_id, const char *msg)
Definition automations.cpp:250
void simpleSlope(int slot, int au, float slope, float offset)
Definition automations.cpp:307
void set_ports(const struct Ports &p)
Definition automations.cpp:295
void updateMapping(int slot, int sub)
Definition automations.cpp:93
int free_slot(void) const
Definition automations.cpp:320
int active_slot
Definition automations.h:123
void set_instance(void *v)
Definition automations.cpp:302
AutomationMgr(int slots, int per_slot, int control_points)
Definition automations.cpp:6
void setSlotSub(int slot_id, int sub, float value)
Definition automations.cpp:123
void * instance
Definition automations.h:127
float getSlotSubOffset(int slot_id, int sub)
Definition automations.cpp:242
void clearSlot(int slot_id)
Definition automations.cpp:179
unsigned * m
Definition inflate.c:1559
register unsigned j
Definition inflate.c:1576
unsigned v[N_MAX]
Definition inflate.c:1584
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
unsigned f
Definition inflate.c:1572
static PuglViewHint int value
Definition pugl.h:1708
static const char * name
Definition pugl.h:1582
int val
Definition jpeglib.h:956
const char * msg
Definition missing_descriptor.c:20
size_t rtosc_message(char *buffer, size_t len, const char *address, const char *arguments,...)
Definition rtosc.c:161
Definition automations.h:25
Definition automations.h:48
else sprintf(d_t_str, LoadFarString(shtYMDHMTime), yr%100, monthstr, dy, hh, mm)