Skip to content

Commit

Permalink
Simplify switch_mute_state
Browse files Browse the repository at this point in the history
  • Loading branch information
jmamma committed Oct 25, 2024
1 parent 8dd6720 commit a3303ac
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 40 deletions.
22 changes: 11 additions & 11 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ Please upgrade to Machinedrum OS X.11 & Monomachine OS X.01 before using MCL 4.6
- Grid Page:

It's now possible to reconfigure the Grid Page Encoders to act as the four
Performance Controllers. Via option: Config -> Page -> Grid Encod
Performance Controllers. Via option: Config -> Page Setup -> Grid Encod

When selecting multiple rows for copy/clear/paste operations the corresponding Bank/Pattern id is now displayed on the left.

- Mixer Page:

Performance States (formely Mute Sets):
Performance States (formerly Mute Sets):

As previously, there are 4 Performance State, each mapped to an individual [Arrow Key].
Each Performance State contains Mutes for each device, and 4 Performance Controller Locks

Performance States Manual Load (for a single device):
- Press [ Scale ] to toggle the Mixer Page's active device (MD or External MIDI)
- To load a Performance State for the Mixer Page's active device, hold down an [ Arrow ] Key and press [ YES ]
- To load a Performance State for both devices simultaneously (MD + External MIDI), hold down [ YES ] and then press an [ Arrow ].
Press [Scale] to toggle between the Mixer's active device between MD and External MIDI.

The Mutes, in a Performance State can be permanently disabled for the active device by holding an [Up/Down/Left/Right] key and pressing [Mute/BankA]

Performance States Manual Load:
- To load a Performance State hold down an [Up/Down/Left/Right] Key and press [YES]

Performance State Autoload:
A chosen Performance State can now be made to auto-load when the Perf Slot in Grid Y is loaded:
- From the Mixer Page, Hold an [ Arrow ] key to visually preview the Performance State and then press [ Accent / BANKB ] to enable auto "LOAD".
- From the Mixer Page, Hold an [ Arrow ] key to visually preview the Performance State and then press [Accent/BANKB] to enable auto "LOAD".
- Then save the Perf Slot, in Grid Y.

The Mutes, in a Performance State can be permanantly disabled for the active device by holding an [ Arrow ] key and pressing [ Mute / BankA ]

Performance Controller AutoFill:

- A Perf Controller's assigned right scenes can be auto-filled with modified Kit parameters by holding down the MCL < Encoder Button >
and pressing the MC's < Yes / Load > button.
- A Perf Controller's assigned right scenes can be auto-filled with modified Kit parameters by holding down the MCL <Encoder Button>
and pressing the MC's <Yes / Load> button.

- A Perf Controller's assigned right scenes can be auto-cleared with by holding down the MCL <Encoder Button> and pressing the MC's < Shift > button.

Expand Down
2 changes: 1 addition & 1 deletion avr/cores/megacommand/MCL/MCL.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "Fonts/TomThumb.h"

#define VERSION 4060
#define VERSION_STR "G4.60"
#define VERSION_STR "L4.60"

#define CALLBACK_TIMEOUT 500
#define GUI_NAME_TIMEOUT 800
Expand Down
45 changes: 24 additions & 21 deletions avr/cores/megacommand/MCL/MixerPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void MixerPage::oled_draw_mutes() {
uint8_t fader_x = 0;

bool draw = true;
if (preview_mute_set != 255 && load_types[!is_md_device][preview_mute_set] == 0) { draw = false; }
if (preview_mute_set != 255 && load_types[preview_mute_set][!is_md_device] == 0) { draw = false; }
for (uint8_t i = 0; i < len; ++i) {
// draw routing
SeqTrack *seq_track = is_md_device ? (SeqTrack *)&mcl_seq.md_tracks[i]
Expand Down Expand Up @@ -286,7 +286,7 @@ void MixerPage::display() {
seq_step_page.mute_mask) {

uint16_t mask = mute_sets[!is_md_device].mutes[mute_set];
if (load_types[!is_md_device][mute_set] == 0) { mask = 0; }
if (load_types[mute_set][!is_md_device] == 0) { mask = 0; }
if (!is_md_device) {
mask &= 0b111111;
}
Expand Down Expand Up @@ -417,20 +417,17 @@ void MixerPage::populate_mute_set() {
}
}

void MixerPage::switch_mute_set(uint8_t state, bool all_devices, bool load_perf, bool load_mutes) {
void MixerPage::switch_mute_set(uint8_t state, bool load_perf, bool *load_type) {

MidiDevice *devs[2] = {
midi_active_peering.get_device(UART1_PORT),
midi_active_peering.get_device(UART2_PORT),
};

uint8_t focus_device = (midi_device == &MD);

if (load_mutes) {
if (load_type != nullptr) {
for (uint8_t dev = 0; dev < 2; dev++) {
bool is_md_device = dev == 0;

if (!all_devices && focus_device != dev) continue;
if (!load_type[dev]) continue;

uint8_t len =
(is_md_device) ? mcl_seq.num_md_tracks : mcl_seq.num_ext_tracks;
Expand Down Expand Up @@ -538,7 +535,7 @@ bool MixerPage::handleEvent(gui_event_t *event) {
uint8_t len = is_md_device ? mcl_seq.num_md_tracks : mcl_seq.num_ext_tracks;
if (event->mask == EVENT_BUTTON_PRESSED && track < len) {
if (note_interface.is_note(track)) {
if (show_mixer_menu || preview_mute_set != 255 && load_types[!is_md_device][preview_mute_set] || ext_key_down) {
if (show_mixer_menu || preview_mute_set != 255 && load_types[preview_mute_set][!is_md_device] || ext_key_down) {
if (ext_key_down) { mute_toggle = 1; }
SeqTrack *seq_track = is_md_device
? (SeqTrack *)&mcl_seq.md_tracks[track]
Expand Down Expand Up @@ -641,8 +638,8 @@ bool MixerPage::handleEvent(gui_event_t *event) {
}
case MDX_KEY_BANKA: {
if (preview_mute_set != 255) {
load_types[!is_md_device][preview_mute_set] = !load_types[!is_md_device][preview_mute_set];
if (load_types[!is_md_device][preview_mute_set] == 0) { seq_step_page.mute_mask = 0; }
load_types[preview_mute_set][!is_md_device] = !load_types[preview_mute_set][!is_md_device];
if (load_types[preview_mute_set][!is_md_device] == 0) { seq_step_page.mute_mask = 0; }
redraw_mutes = true;
return true;
}
Expand All @@ -663,19 +660,25 @@ bool MixerPage::handleEvent(gui_event_t *event) {
switch_mute_set(4); //---> Flip mutes
break;
}
uint8_t set = 255;

if (trig_interface.is_key_down(MDX_KEY_LEFT)) {
switch_mute_set(1,true,true,load_types[!is_md_device][1]);
break;
set = 1;
} else if (trig_interface.is_key_down(MDX_KEY_UP)) {
switch_mute_set(2,true,true,load_types[!is_md_device][2]);
break;
set = 2;
} else if (trig_interface.is_key_down(MDX_KEY_RIGHT)) {
switch_mute_set(3,true,true,load_types[!is_md_device][3]);
break;
set = 3;
} else if (trig_interface.is_key_down(MDX_KEY_DOWN)) {
switch_mute_set(0,true,true,load_types[!is_md_device][0]);
break;
} else {
set = 0;
}
if (set != 255) {
//bool load_t[2];
//load_t[0] = load_types[key][0];
//load_t[1] = load_types[key][1];
//load_t[is_md_device] = 0;
switch_mute_set(1,true,load_types[set]);
}
else {
if (!note_interface.notes_on) {
seq_step_page.mute_mask = 0;
show_mixer_menu = true;
Expand All @@ -691,7 +694,7 @@ bool MixerPage::handleEvent(gui_event_t *event) {
case MDX_KEY_DOWN: {
uint8_t set = get_mute_set(key);
if (trig_interface.is_key_down(MDX_KEY_YES)) {
switch_mute_set(set,false,true,load_types[!is_md_device][set]);
switch_mute_set(set,true,load_types[set]);
} else {
preview_mute_set = set;
for (uint8_t n = 0; n < 4; n++) {
Expand Down
4 changes: 2 additions & 2 deletions avr/cores/megacommand/MCL/MixerPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MixerPage : public LightPage {
// Don't change order
MuteSet mute_sets[2];
uint8_t perf_locks[4][4];
bool load_types[2][4];
bool load_types[4][2];
//

uint8_t perf_locks_temp[4];
Expand All @@ -82,7 +82,7 @@ class MixerPage : public LightPage {
void record_mutes_set(bool state);
void disable_record_mutes(bool clear = false);
void oled_draw_mutes();
void switch_mute_set(uint8_t state, bool all_devices = true, bool load_perf = false, bool load_mutes = true);
void switch_mute_set(uint8_t state, bool load_perf = false, bool *load_types = nullptr);
void populate_mute_set();

void load_perf_locks(uint8_t state);
Expand Down
10 changes: 5 additions & 5 deletions avr/cores/megacommand/MCL/PerfTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void PerfTrack::get_perf() {
encs[n].cur = e->cur;
memcpy(encs[n].name,e->name, PERF_NAME_LENGTH);

if (!mixer_page.load_types[0][n]) {
if (!mixer_page.load_types[n][0]) {
CLEAR_BIT16(mute_sets[1].mutes[n],13);
}
if (!mixer_page.load_types[1][n]) {
if (!mixer_page.load_types[n][1]) {
CLEAR_BIT16(mute_sets[1].mutes[n],14);
}

Expand Down Expand Up @@ -76,16 +76,16 @@ void PerfTrack::load_perf(bool immediate, SeqTrack *seq_track) {
if ((mute_sets[1].mutes[n] & 0b1000000000000000) == 0) {
mixer_page.load_mute_set = n;
}
mixer_page.load_types[0][n] = mute_sets[1].mutes[n] & 0b0010000000000000;
mixer_page.load_types[1][n] = mute_sets[1].mutes[n] & 0b0100000000000000;
mixer_page.load_types[n][0] = mute_sets[1].mutes[n] & 0b0010000000000000;
mixer_page.load_types[n][1] = mute_sets[1].mutes[n] & 0b0100000000000000;
mute_sets[1].mutes[n] |= 0b1110000000000000;

}
memcpy(PerfData::scenes, scenes, sizeof(PerfScene) * NUM_SCENES);

memcpy(mixer_page.mute_sets, mute_sets, sizeof(mute_sets) + sizeof(perf_locks));
if (mixer_page.load_mute_set < 4) {
mixer_page.switch_mute_set(mixer_page.load_mute_set, true, immediate, mixer_page.load_types[mixer_page.load_mute_set]); //Mute change is applied outside of sequencer runtime.
mixer_page.switch_mute_set(mixer_page.load_mute_set, immediate, mixer_page.load_types[mixer_page.load_mute_set]); //Mute change is applied outside of sequencer runtime.
if (!immediate) {
PerfSeqTrack *p = (PerfSeqTrack*) seq_track;
memcpy(p->perf_locks, &perf_locks[mixer_page.load_mute_set],4); //Perf change is pre-empted at sequencer runtime.
Expand Down

0 comments on commit a3303ac

Please sign in to comment.