Skip to content

Commit

Permalink
Ability to set max banks
Browse files Browse the repository at this point in the history
  • Loading branch information
tysonlt committed Sep 20, 2023
1 parent 8388f95 commit 9be2d2f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/SwitchPreset/SwitchPreset.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void setup() {
void loop() {

static PresetNumber preset = 0;
if (preset >= AxeSystem::MAX_PRESETS) {
if (preset >= AxeSystem::maxPresets()) {
preset = 0;
}

Expand Down
11 changes: 10 additions & 1 deletion src/interface/AxeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class AxeSystem {
void sendProgramChange(byte value, byte channel);
void sendSysEx(const byte *sysex, const byte length);

// Used to calculate max presets. Defaults to 4.
// You can set this at any time.
void setMaxBanks(const byte max);

// Max presets depending on how many banks we have
PresetNumber maxPresets();

// Well is it, or isn't it? As far as we know! This is pretty accurate
// even if you enable/disable the tuner from the front panel.
bool isTunerEngaged() { return _tunerEngaged; }
Expand Down Expand Up @@ -222,12 +229,14 @@ class AxeSystem {

// These are values supported by the AxeFX 3, and can't be changed.
const static byte BANK_SIZE = 128;
const static byte MAX_BANKS = 4;
const static byte MAX_SCENES = 8;
const static byte TEMPO_MIN = 24;
const static byte TEMPO_MAX = 250;
const static byte MIDI_CHANNEL_OMNI = 0;
const static byte DEFAULT_MIDI_CHANNEL = MIDI_CHANNEL_OMNI;

// These are deprecated but still here in case old code is using them
const static byte MAX_BANKS = 4;
constexpr static PresetNumber MAX_PRESETS = (MAX_BANKS * BANK_SIZE) - 1;

// OK, there ends the tour! Continue on to AxePreset.h,
Expand Down
9 changes: 9 additions & 0 deletions src/interface/private/AxeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ int AxeSystem::midiBytesToInt(const byte lsb, const byte msb) {
return lsb + (msb * BANK_SIZE);
}

void AxeSystem::setMaxBanks(const byte max) {
_maxBanks = max;
_maxPresets = (_maxBanks * BANK_SIZE) - 1;
}

PresetNumber AxeSystem::maxPresets() {
return _maxPresets;
}

#ifdef AXE_DEBUG_SYSEX
void AxeSystem::debugSysex(const byte *sysex, const byte length, const char *message) {
char buf[6];
Expand Down
4 changes: 2 additions & 2 deletions src/interface/private/AxeSystem_Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void AxeSystem::sendEffectChannelDecrement(const EffectId effectId) {
void AxeSystem::sendPresetIncrement() {
int number = _preset.getPresetNumber();
if (isValidPresetNumber(number)) {
if (++number > MAX_PRESETS) {
if (++number > maxPresets()) {
number = 0;
}
sendPresetChange(number);
Expand All @@ -142,7 +142,7 @@ void AxeSystem::sendPresetDecrement() {
int number = _preset.getPresetNumber();
if (isValidPresetNumber(number)) {
if (number == 0) {
number = MAX_PRESETS;
number = maxPresets();
} else {
number--;
}
Expand Down
2 changes: 1 addition & 1 deletion src/interface/private/AxeSystem_Handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void AxeSystem::parseName(const byte *sysex, const byte length, const byte offse
}

bool AxeSystem::isValidPresetNumber(const PresetNumber preset) {
return preset >= 0 && preset <= MAX_PRESETS;
return preset >= 0 && preset <= maxPresets();
}

bool AxeSystem::isValidSceneNumber(const SceneNumber scene) {
Expand Down
2 changes: 2 additions & 0 deletions src/interface/private/AxeSystem_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ byte _sysexFractalVersion;
byte _tempo;
byte _bank;
byte _midiChannel;
byte _maxBanks = 4; //default to MkI
PresetNumber _maxPresets = (4 * BANK_SIZE) - 1; //default to MkI
bool _firmwareRequested = false;
bool _tunerEngaged = false;
bool _systemConnected = false;
Expand Down

0 comments on commit 9be2d2f

Please sign in to comment.