Skip to content

Commit 87723de

Browse files
author
Friedolino
committed
add handleGenericControlers
1 parent e74fc01 commit 87723de

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

include/rtosc/automations.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
#include <rtosc/rtosc.h>
33
#include <cassert>
44
namespace rtosc {
5-
5+
66
#define C_dataentryhi 0x06
77
#define C_dataentrylo 0x26
88
#define C_nrpnhi 99
99
#define C_nrpnlo 98
10-
10+
11+
#define CONTROLER_TYPE_LFO 1
12+
#define CONTROLER_TYPE_ENV 2
13+
1114
struct AutomationMapping
1215
{
1316
//0 - linear
@@ -62,10 +65,13 @@ struct AutomationSlot
6265

6366
//-1 or a valid MIDI CC + MIDI Channel
6467
int midi_cc;
65-
68+
6669
//-1 or a valid NRPN ID Channel
6770
int midi_nrpn;
6871

72+
//-1 or a valid generic controller type
73+
int internal;
74+
6975
//Current state supplied by MIDI value or host
7076
float current_state;
7177

@@ -74,7 +80,7 @@ struct AutomationSlot
7480

7581
//Collection of automations
7682
Automation *automations;
77-
83+
7884
};
7985

8086
class AutomationMgr
@@ -105,7 +111,7 @@ class AutomationMgr
105111
void clearSlot(int slot_id);
106112
void clearSlotSub(int slot_id, int sub);
107113

108-
void setSlotSubPath(int slot_id, int sub, const char *msg);
114+
void setSlotSubPath(int slot_id, int sub, const char *msg);
109115
void setSlotSubGain(int slot_id, int sub, float f);
110116
float getSlotSubGain(int slot_id, int sub);
111117
void setSlotSubOffset(int slot_id, int sub, float f);
@@ -117,7 +123,8 @@ class AutomationMgr
117123
const char * getName(int slot_id);
118124

119125
bool handleMidi(int channel, int cc, int val);
120-
126+
void handleGenericControlers(int type, float val);
127+
121128
void setparameternumber(unsigned int type, int value); //used for RPN and NRPN's
122129
int getnrpn(int *parhi, int *parlo, int *valhi, int *vallo);
123130

@@ -142,7 +149,7 @@ class AutomationMgr
142149

143150
int damaged;
144151
private:
145-
152+
146153
/** RPN and NPRPN */
147154
struct { //nrpn
148155
int parhi, parlo;

src/cpp/automations.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,23 @@ const char *AutomationMgr::getName(int slot_id)
336336
return "";
337337
return slots[slot_id].name;
338338
}
339+
void AutomationMgr::handleGenericControlers(int type, float val)
340+
{
341+
for(int i=0; i<nslots; ++i) {
342+
if (slots[i].internal == type) {
343+
if (val==getSlot(i)) return;
344+
setSlot(i, val);
345+
}
346+
}
347+
}
339348
bool AutomationMgr::handleMidi(int channel, int type, int val)
340349
{
341350
bool is_nrpn = false;
342351
int par_id = 0;
343352
int value;
344353
if((type == C_dataentryhi) || (type == C_dataentrylo)
345354
|| (type == C_nrpnhi) || (type == C_nrpnlo)) { //Process RPN and NRPN by the Master (ignore the chan)
346-
355+
347356
setparameternumber(type, val);
348357

349358
int parhi = -1, parlo = -1, valhi = -1, vallo = -1;
@@ -362,10 +371,10 @@ bool AutomationMgr::handleMidi(int channel, int type, int val)
362371
if(bound_nrpn)
363372
return 1;
364373
}
365-
374+
366375
}
367376
else {
368-
377+
369378
par_id = channel*128 + type;
370379

371380
bool bound_cc = false;
@@ -378,7 +387,7 @@ bool AutomationMgr::handleMidi(int channel, int type, int val)
378387

379388
if(bound_cc)
380389
return 1;
381-
390+
382391
}
383392

384393
//No bound CC, now to see if there's something to learn

0 commit comments

Comments
 (0)