13
0

Maschine Mikro MK2 support

This commit is contained in:
Daniel Ceregatti 2021-04-01 10:24:50 -07:00 committed by Robin Gareus
parent c51d810d65
commit 362b9cb4fa
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 97 additions and 16 deletions

View File

@ -45,14 +45,14 @@ class Maschine2Mikro : public M2Device
#endif
struct machine_mk2_input {
unsigned int trs_restart : 1; // 0
unsigned int trs_left : 1;
unsigned int trs_right : 1;
unsigned int trs_grid : 1;
unsigned int trs_play : 1;
unsigned int trs_rec : 1;
unsigned int trs_shift : 1; // 0
unsigned int trs_erase : 1;
unsigned int trs_shift : 1;
unsigned int trs_rec : 1;
unsigned int trs_play : 1;
unsigned int trs_grid : 1;
unsigned int trs_right : 1;
unsigned int trs_left : 1;
unsigned int trs_restart : 1;
unsigned int group : 1; // 8
unsigned int browse : 1;
unsigned int sampling : 1;
@ -67,14 +67,14 @@ class Maschine2Mikro : public M2Device
unsigned int nav_left : 1;
unsigned int nav_right : 1;
unsigned int main : 1;
unsigned int pads_scene : 1; // 24
unsigned int pads_pattern : 1;
unsigned int pads_mode : 1;
unsigned int pads_navigate : 1;
unsigned int pads_duplicate : 1;
unsigned int pads_select : 1;
unsigned int pads_mute : 1; // 24
unsigned int pads_solo : 1;
unsigned int pads_mute : 1; // 31
unsigned int pads_select : 1;
unsigned int pads_duplicate : 1;
unsigned int pads_navigate : 1;
unsigned int pads_mode : 1;
unsigned int pads_pattern : 1;
unsigned int pads_scene : 1; // 31
unsigned int mst_wheel_pos : 8; // 32..40 // range: 0..15
} ATTRIBUTE_PACKED ctrl_in;

View File

@ -19,21 +19,76 @@
#include "m2_map_mikro.h"
using namespace ArdourSurface;
using namespace std;
M2MapMikro::M2MapMikro ()
: M2Contols ()
, enc_master (16)
{}
{
#define PSMAP(MOD, PHYS, SEM, BTN) \
pmap[MOD].insert (make_pair (PHYS, BTN)); \
smap.insert (make_pair (SEM, BTN));
#define PSMAPALL(PHYS, SEM, BTN) \
pmap[ModNone].insert (make_pair (PHYS, BTN)); \
pmap[ModShift].insert (make_pair (PHYS, BTN)); \
smap.insert (make_pair (SEM, BTN)); \
PSMAP(ModNone, BtnPlay, Play, &tr[0]);
PSMAP(ModShift, BtnPlay, Metronom, &tr[1]);
PSMAP(ModNone, BtnRec, Rec, &tr[2]);
PSMAP(ModNone, BtnGrid, Grid, &tr[3]);
PSMAP(ModNone, BtnRestart, GotoStart, &ts[0]);
PSMAP(ModShift, BtnRestart, Loop, &tr[4]);
PSMAP(ModNone, BtnStepLeft, FastRewind, &ts[1]);
PSMAP(ModNone, BtnStepRight, FastForward, &ts[2]);
PSMAP(ModShift, BtnStepLeft, JumpBackward, &ts[3]);
PSMAP(ModShift, BtnStepRight, JumpForward, &ts[4]);
PSMAPALL(BtnWheel, EncoderWheel, &mst[0]);
PSMAPALL(BtnVolume, MasterVolume, &mst[1]);
//PSMAPALL(BtnSwing, Master?????, &mst[2]);
PSMAPALL(BtnTempo, MasterTempo, &mst[3]);
PSMAP(ModShift, BtnAll, Save, &save);
PSMAP(ModShift, BtnNavLeft, Undo, &undoredo[0]);
PSMAP(ModShift, BtnNavRight, Redo, &undoredo[1]);
PSMAP(ModNone, BtnMute, Mute, &sm[7]);
PSMAP(ModShift, BtnMute, Panic, &panic);
PSMAPALL(BtnScene, Scene, &sm[0]);
PSMAPALL(BtnPattern, Pattern, &sm[1]);
PSMAPALL(BtnPadMode, PadMode, &sm[2]);
PSMAPALL(BtnNavigate, Navigate, &sm[3]);
PSMAPALL(BtnDuplicate, Duplicate, &sm[4]);
PSMAPALL(BtnSelect, Select, &sm[5]);
PSMAPALL(BtnSolo, Solo, &sm[6]);
// TODO:
pmap[ModNone].insert (make_pair (BtnErase, &ts[5]));
pmap[ModShift].insert (make_pair (BtnErase, &ts[5]));
}
M2ButtonInterface*
M2MapMikro::button (PhysicalButtonId id, Modifier m)
{
PhysicalMap::const_iterator i = pmap[m].find (id);
if (i != pmap[m].end()) {
return i->second;
}
return M2Contols::button (id, m);
}
M2ButtonInterface*
M2MapMikro::button (SemanticButtonId id)
{
SematicMap::const_iterator i = smap.find (id);
if (i != smap.end()) {
return i->second;
}
return M2Contols::button (id);
}
@ -43,6 +98,9 @@ M2MapMikro::encoder (unsigned int id)
if (id == 0) {
return &enc_master;
}
else if (id < 9) {
return &enc_top[id - 1];
}
// TODO map "nav" (select) and Left/Right to encoder(s) delta.
return M2Contols::encoder (id);
}

View File

@ -34,7 +34,23 @@ class M2MapMikro : public M2Contols
M2PadInterface* pad (unsigned int id);
private:
PhysicalMap pmap[2]; // 2: Modifiers
SematicMap smap;
M2Button tr[5]; // transport controlables
M2StatelessButton ts[6]; // transport pushbuttons
M2Button mst[4]; // master "volume", "swing", "tempo", "encoder-push"
M2Button save;
M2Button undoredo[2];
M2Button sm[8]; // scene, pattern, pad mode, navigate (AKA view), duplicate, select, solo, mute
M2StatelessButton panic;
M2Encoder enc_master;
M2Encoder enc_top[16];
M2Pad pads[16];
};

View File

@ -131,7 +131,14 @@ class M2Contols
EncoderWheel, // multi-purpose
MasterVolume,
MasterTempo,
Solo, Mute,
Scene,
Pattern,
PadMode,
Navigate,
Duplicate,
Select,
Solo,
Mute,
Panic
} SemanticButtonId;