Skip to content

Commit e8fec31

Browse files
committed
fixed bug where all Lite mk2 fx are shifted by 1 when loading a preset
1 parent 40a9f15 commit e8fec31

File tree

3 files changed

+19
-44
lines changed

3 files changed

+19
-44
lines changed

lib/bluetooth/devices/presets/MightyMk2Preset.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:mighty_plug_manager/bluetooth/devices/presets/preset_constants.d
1212

1313
import '../NuxConstants.dart';
1414
import '../NuxDevice.dart';
15+
import '../NuxFXID.dart';
1516
import '../NuxMightyLiteMk2.dart';
1617
import '../communication/plugProCommunication.dart';
1718
import '../effects/Processor.dart';
@@ -349,6 +350,18 @@ class MightyMk2Preset extends Preset {
349350
super.setSelectedEffectForSlot(slot, index, notifyBT);
350351
}
351352

353+
@override
354+
int getEffectArrayIndexFromNuxIndex(NuxFXID fxid, int nuxIndex) {
355+
List<Processor> list = [];
356+
list = getEffectsForSlot(fxid.value);
357+
358+
for (int i = 0; i < list.length; i++) {
359+
if (list[i].nuxIndex == nuxIndex) return i;
360+
}
361+
362+
return 0;
363+
}
364+
352365
@override
353366
Color effectColor(int index) {
354367
return device.processorList[index].color;
@@ -359,11 +372,6 @@ class MightyMk2Preset extends Preset {
359372
version = LiteMK2Version.values[ver];
360373
}
361374

362-
@override
363-
String getAmpNameByNuxIndex(int index, int version) {
364-
return amplifierList[index].name;
365-
}
366-
367375
@override
368376
void setVolume(double vol, bool btTransmit) {
369377
_volume = vol;

lib/bluetooth/devices/presets/PlugProPreset.dart

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -442,49 +442,15 @@ class PlugProPreset extends Preset {
442442
@override
443443
int getEffectArrayIndexFromNuxIndex(NuxFXID fxid, int nuxIndex) {
444444
List<Processor> list = [];
445-
switch (fxid.value) {
446-
case PresetDataIndexPlugPro.Head_iWAH:
447-
return 0;
448-
case PresetDataIndexPlugPro.Head_iNG:
449-
return 0;
450-
case PresetDataIndexPlugPro.Head_iCMP:
451-
list = _compressorList;
452-
break;
453-
case PresetDataIndexPlugPro.Head_iEFX:
454-
list = efxList;
455-
break;
456-
case PresetDataIndexPlugPro.Head_iAMP:
457-
list = amplifierList;
458-
break;
459-
case PresetDataIndexPlugPro.Head_iCAB:
460-
list = cabinetList;
461-
break;
462-
case PresetDataIndexPlugPro.Head_iMOD:
463-
list = modulationList;
464-
break;
465-
case PresetDataIndexPlugPro.Head_iEQ:
466-
list = eqList;
467-
break;
468-
case PresetDataIndexPlugPro.Head_iDLY:
469-
list = delayList;
470-
break;
471-
case PresetDataIndexPlugPro.Head_iRVB:
472-
list = _reverbList;
473-
break;
474-
}
445+
list = _getEffectsForFXID(fxid);
446+
475447
for (int i = 0; i < list.length; i++) {
476448
if (list[i].nuxIndex == nuxIndex) return i;
477449
}
478450

479451
return 0;
480452
}
481453

482-
@override
483-
String getAmpNameByNuxIndex(int index, int version) {
484-
index = getEffectArrayIndexFromNuxIndex(PlugProFXID.amp, index);
485-
return amplifierList[index].name;
486-
}
487-
488454
@override
489455
Color effectColor(int index) {
490456
var fxid = getFXIDFromSlot(index);

lib/bluetooth/devices/presets/Preset.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ abstract class Preset {
3939
//returns whether the specific slot is on or off
4040
bool slotEnabled(int index);
4141

42-
//used for reorderable fx chain
42+
//override in reorderable fx chain
4343
NuxFXID getFXIDFromSlot(int slot) {
4444
return NuxFXID.fromInt(slot);
4545
}
@@ -130,6 +130,7 @@ abstract class Preset {
130130
}
131131
}
132132

133+
//override in more complex FX chains
133134
int getEffectArrayIndexFromNuxIndex(NuxFXID fxid, int nuxIndex) {
134135
return nuxIndex;
135136
}
@@ -197,8 +198,8 @@ abstract class Preset {
197198
}
198199

199200
String getAmpNameByNuxIndex(int index, int version) {
200-
var ampIndex = NuxFXID.fromInt(device.amplifierSlotIndex);
201-
getEffectArrayIndexFromNuxIndex(ampIndex, index);
201+
var ampIndex = getFXIDFromSlot(device.amplifierSlotIndex);
202+
index = getEffectArrayIndexFromNuxIndex(ampIndex, index);
202203
return amplifierList[index].name;
203204
}
204205

0 commit comments

Comments
 (0)