Skip to content

Commit

Permalink
Muteset mute and perf transmission
Browse files Browse the repository at this point in the history
  • Loading branch information
jmamma committed Oct 17, 2024
1 parent d5c00d9 commit 78f0fe7
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 13 deletions.
2 changes: 1 addition & 1 deletion avr/cores/megacommand/MCL/MCLMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ constexpr size_t NUM_EXT_TRACKS = 0;

constexpr size_t NUM_INSTRUMENT_TRACKS = (NUM_MD_TRACKS + NUM_EXT_TRACKS);

constexpr size_t NUM_AUX_TRACKS = 4;
constexpr size_t NUM_AUX_TRACKS = 3;

constexpr size_t GRIDCHAIN_TRACK_NUM = 10;
constexpr size_t PERF_TRACK_NUM = 11;
Expand Down
9 changes: 5 additions & 4 deletions avr/cores/megacommand/MCL/MCLSeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ void MCLSeq::setup() {
mdfx_track.length = 16;
mdfx_track.speed = SEQ_SPEED_1X;

perf_track.length = 16;
perf_track.speed = SEQ_SPEED_1X;

enable();

MidiClock.addOnMidiStopCallback(
Expand Down Expand Up @@ -108,7 +111,7 @@ void MCLSeq::onMidiStartImmediateCallback() {
aux_tracks[i].reset();
}
mdfx_track.reset();

perf_track.reset();
#ifdef LFO_TRACKS
for (uint8_t i = 0; i < num_lfo_tracks; i++) {
lfo_tracks[i].sample_hold = 0;
Expand Down Expand Up @@ -242,7 +245,6 @@ void MCLSeq::seq() {
}

mdfx_track.seq();

if (MDSeqTrack::load_machine_cache) {
MD.setKitName(grid_task.kit_names[0], uart);
MD.loadMachinesCache(MDSeqTrack::load_machine_cache, uart);
Expand All @@ -251,8 +253,7 @@ void MCLSeq::seq() {
for (uint8_t i = 0; i < NUM_AUX_TRACKS; i++) {
aux_tracks[i].seq();
}
// Arp

perf_track.seq();
#ifdef LFO_TRACKS
for (uint8_t i = 0; i < num_lfo_tracks; i++) {
lfo_tracks[i].seq(uart, uart2);
Expand Down
2 changes: 2 additions & 0 deletions avr/cores/megacommand/MCL/MCLSeq.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ArpSeqTrack.h"
#include "ExtSeqTrack.h"
#include "MDFXseqTrack.h"
#include "PerfSeqTrack.h"

#define SEQ_MUTE_ON 1
#define SEQ_MUTE_OFF 0
Expand Down Expand Up @@ -63,6 +64,7 @@ class MCLSeq : public ClockCallback {

SeqTrackBase aux_tracks[NUM_AUX_TRACKS];

PerfSeqTrack perf_track;
MDFXSeqTrack mdfx_track;

MCLSeqMidiEvents midi_events;
Expand Down
1 change: 1 addition & 0 deletions avr/cores/megacommand/MCL/MCL_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#include "ArpSeqTrack.h"
#include "EmptyTrack.h"
#include "LFOSeqTrack.h"
#include "PerfSeqTrack.h"
#include "MNMTrack.h"

#include "MCLActions.h"
Expand Down
13 changes: 12 additions & 1 deletion avr/cores/megacommand/MCL/MixerPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ void MixerPage::adjust_param(EncoderParent *enc, uint8_t param) {
void MixerPage::display() {

auto oldfont = oled_display.getFont();
//oled_display.setFont();
if (oled_display.textbox_enabled) {
oled_display.clearDisplay();
oled_draw_mutes();
Expand Down Expand Up @@ -296,6 +297,12 @@ void MixerPage::display() {
if (draw_encoders || preview_mute_set != 255) {
// oled_display.clearDisplay();
draw_encs();
if (load_mute_set != 255 && load_mute_set == preview_mute_set) {
oled_display.setFont(&TomThumb);
oled_display.setCursor(111, 31);
oled_display.print("LOAD");
oled_display.setFont();
}
oled_display.display();
} else {

Expand Down Expand Up @@ -708,7 +715,11 @@ bool MixerPage::handleEvent(gui_event_t *event) {
}
break;
}

case MDX_KEY_FUNC: {
if (load_mute_set == preview_mute_set) { load_mute_set = 255; }
else { load_mute_set = preview_mute_set; }
break;
}
case MDX_KEY_LEFT:
case MDX_KEY_UP:
case MDX_KEY_RIGHT:
Expand Down
1 change: 1 addition & 0 deletions avr/cores/megacommand/MCL/MixerPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class MixerPage : public LightPage {

uint8_t current_mute_set = 255;
uint8_t preview_mute_set = 255;
uint8_t load_mute_set = 255;
void send_fx(uint8_t param, Encoder *enc, uint8_t type);

// Don't change order
Expand Down
11 changes: 9 additions & 2 deletions avr/cores/megacommand/MCL/PerfData.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ class PerfData {
if (MD.kit.params[track][param] != MD.kit.params_orig[track][param]) {
scene = MD.kit.params[track][param] >= MD.kit.params_orig[track][param];
if (add_param(track,param,scene,MD.kit.params[track][param]) != 255) {
MD.kit.params[track][param] = MD.kit.params_orig[track][param];
//Kit encoders go back to normal, for save.
uint8_t val = MD.kit.params[track][param];
MD.setTrackParam(track, param, MD.kit.params_orig[track][param], nullptr,
true);
MD.setTrackParam(track, param, val, nullptr,
false);
}
}

Expand All @@ -240,7 +245,9 @@ class PerfData {
if (fxs[n] != fxs_orig[n]) {
scene = fxs[n] >= fxs_orig[n];
if (add_param(fx + NUM_MD_TRACKS,param,scene,fxs[n]) != 255) {
fxs[n] = fxs_orig[n];
uint8_t val = fxs[n];
MD.setFXParam(param, fxs_orig[n], fx + MD_FX_ECHO, true);
MD.setFXParam(param, val, fx + MD_FX_ECHO, false);
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions avr/cores/megacommand/MCL/PerfSeqTrack.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "MCL_impl.h"

void PerfSeqTrack::seq() {
uint8_t timing_mid = get_timing_mid();
mod12_counter++;
if (mod12_counter == timing_mid) {
mod12_counter = 0;
step_count_inc();
}
if (count_down) {
count_down--;
if (count_down == 0) {
if (load_sound) {
for (uint8_t n = 0; n < 4; n++) {
if (perf_locks[n] != 255) {
mixer_page.encoders[n]->cur = perf_locks[n];
mixer_page.encoders[n]->old = perf_locks[n] + 1;
}
perf_locks[n] = 255;
}
}
reset();
mod12_counter = 0;
}
}
}
28 changes: 28 additions & 0 deletions avr/cores/megacommand/MCL/PerfSeqTrack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Justin Mammarella [email protected] 2021 */

#pragma once

#include "MidiUartParent.h"
#include "SeqTrack.h"
#include "WProgram.h"
#include "GridTrack.h"

//Ephemeral
class PerfSeqTrack : public SeqTrackBase {

public:

uint8_t perf_locks[4];

PerfSeqTrack() : SeqTrackBase() {
active = PERF_TRACK_TYPE;
init();
}
void reset() {
memset(perf_locks,255,sizeof(perf_locks));
SeqTrackBase::reset();
}

void seq();

};
23 changes: 20 additions & 3 deletions avr/cores/megacommand/MCL/PerfTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void PerfTrack::transition_load(uint8_t tracknumber, SeqTrack *seq_track,
DEBUG_PRINTLN("transition send");
GridTrack::transition_load(tracknumber, seq_track, slotnumber);
if (mcl_actions.send_machine[slotnumber]) {
load_perf();
load_perf(seq_track);
}
}

Expand All @@ -34,10 +34,14 @@ void PerfTrack::get_perf() {
DEBUG_PRINTLN(sizeof(scenes));
memcpy(scenes, PerfData::scenes, sizeof(PerfScene) * NUM_SCENES);
memcpy(mute_sets,mixer_page.mute_sets, sizeof(mute_sets) + sizeof(perf_locks));
//Encode the load_mute_set value into the high bit of the corresponding ext mutes.
if (mixer_page.load_mute_set < 4) {
mute_sets[1].mutes[mixer_page.load_mute_set] &= 0b01111111;
}
}


void PerfTrack::load_perf() {
void PerfTrack::load_perf(SeqTrack *seq_track) {
DEBUG_PRINTLN("load perf");
DEBUG_PRINTLN( sizeof(scenes));
for (uint8_t n = 0; n < 4; n++) {
Expand All @@ -53,13 +57,26 @@ void PerfTrack::load_perf() {
memcpy(e->name,encs[n].name, PERF_NAME_LENGTH);
}
memcpy(PerfData::scenes, scenes, sizeof(PerfScene) * NUM_SCENES);

mixer_page.load_mute_set = 255;
for (uint8_t n = 0; n < 4; n++) {
if ((mute_sets[1].mutes[n] & 0b10000000) == 0) {
mixer_page.load_mute_set = n;
mute_sets[1].mutes[n] |= 0b11000000;
}
}
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); //Mute change is applied outside of sequencer runtime.
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.
}
}

void PerfTrack::load_immediate(uint8_t tracknumber, SeqTrack *seq_track) {
DEBUG_PRINTLN("load immediate");
load_link_data(seq_track);
load_perf();
load_perf(seq_track);
}

bool PerfTrack::store_in_grid(uint8_t column, uint16_t row,
Expand Down
2 changes: 1 addition & 1 deletion avr/cores/megacommand/MCL/PerfTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PerfTrack : public AUXTrack, public PerfTrackData {
memset(perf_locks, 255, sizeof(perf_locks));
}

void load_perf();
void load_perf(SeqTrack *seq_track);
void get_perf();

uint16_t calc_latency(uint8_t tracknumber);
Expand Down
2 changes: 1 addition & 1 deletion avr/cores/megacommand/MD/MD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void MDClass::init_grid_devices(uint8_t device_idx) {
add_track_to_grid(grid_idx, MDTEMPO_TRACK_NUM, &gdt);

gdt.init(PERF_TRACK_TYPE, GROUP_PERF, device_idx,
(SeqTrack *)&(mcl_seq.aux_tracks[3]), 0);
(SeqTrack *)&(mcl_seq.perf_track), 0);
add_track_to_grid(grid_idx, PERF_TRACK_NUM, &gdt);
}

Expand Down

0 comments on commit 78f0fe7

Please sign in to comment.