Skip to content

Commit

Permalink
add handleGenericControlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Friedolino committed May 7, 2022
1 parent 42e91c8 commit 0df324f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
21 changes: 14 additions & 7 deletions include/rtosc/automations.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
#include <rtosc/rtosc.h>
#include <cassert>
namespace rtosc {

#define C_dataentryhi 0x06
#define C_dataentrylo 0x26
#define C_nrpnhi 99
#define C_nrpnlo 98


#define CONTROLER_TYPE_LFO 1
#define CONTROLER_TYPE_ENV 2

struct AutomationMapping
{
//0 - linear
Expand Down Expand Up @@ -62,10 +65,13 @@ struct AutomationSlot

//-1 or a valid MIDI CC + MIDI Channel
int midi_cc;

//-1 or a valid NRPN ID Channel
int midi_nrpn;

//-1 or a valid generic controller type
int internal;

//Current state supplied by MIDI value or host
float current_state;

Expand All @@ -74,7 +80,7 @@ struct AutomationSlot

//Collection of automations
Automation *automations;

};

class AutomationMgr
Expand Down Expand Up @@ -105,7 +111,7 @@ class AutomationMgr
void clearSlot(int slot_id);
void clearSlotSub(int slot_id, int sub);

void setSlotSubPath(int slot_id, int sub, const char *msg);
void setSlotSubPath(int slot_id, int sub, const char *msg);
void setSlotSubGain(int slot_id, int sub, float f);
float getSlotSubGain(int slot_id, int sub);
void setSlotSubOffset(int slot_id, int sub, float f);
Expand All @@ -117,7 +123,8 @@ class AutomationMgr
const char * getName(int slot_id);

bool handleMidi(int channel, int cc, int val);

void handleGenericControlers(int type, float val);

void setparameternumber(unsigned int type, int value); //used for RPN and NRPN's
int getnrpn(int *parhi, int *parlo, int *valhi, int *vallo);

Expand All @@ -142,7 +149,7 @@ class AutomationMgr

int damaged;
private:

/** RPN and NPRPN */
struct { //nrpn
int parhi, parlo;
Expand Down
17 changes: 13 additions & 4 deletions src/cpp/automations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,23 @@ const char *AutomationMgr::getName(int slot_id)
return "";
return slots[slot_id].name;
}
void AutomationMgr::handleGenericControlers(int type, float val)
{
for(int i=0; i<nslots; ++i) {
if (slots[i].internal == type) {
if (val==getSlot(i)) return;
setSlot(i, val);
}
}
}
bool AutomationMgr::handleMidi(int channel, int type, int val)
{
bool is_nrpn = false;
int par_id = 0;
int value;
if((type == C_dataentryhi) || (type == C_dataentrylo)
|| (type == C_nrpnhi) || (type == C_nrpnlo)) { //Process RPN and NRPN by the Master (ignore the chan)

setparameternumber(type, val);

int parhi = -1, parlo = -1, valhi = -1, vallo = -1;
Expand All @@ -362,10 +371,10 @@ bool AutomationMgr::handleMidi(int channel, int type, int val)
if(bound_nrpn)
return 1;
}

}
else {

par_id = channel*128 + type;

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

if(bound_cc)
return 1;

}

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

0 comments on commit 0df324f

Please sign in to comment.