Skip to content

Commit c821ac9

Browse files
committed
refactor: rename 'save' to 'dump' to make purpose clearer
1 parent 8346188 commit c821ac9

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

src/midi.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -701,28 +701,6 @@ static void midi_remap_channel_sysex(const u8* data, u16 length)
701701
midi_remap_channel(data[0], data[1]);
702702
}
703703

704-
static void save_preset_request(const u8* data, u16 length)
705-
{
706-
u8 type = data[0];
707-
u8 program = data[1];
708-
709-
switch (type) {
710-
case STORE_PROGRAM_TYPE_FM: {
711-
const FmPreset* preset = midi_fm_get_stored_preset(program);
712-
if (preset != NULL) {
713-
send_preset_data(type, program, preset);
714-
log_info("Prg %d: FM preset sent", program + 1);
715-
} else {
716-
log_warn("Prg %d: No FM preset stored", program + 1);
717-
}
718-
break;
719-
}
720-
default:
721-
log_warn("Invalid save preset request type: %d", type);
722-
break;
723-
}
724-
}
725-
726704
static void send_preset_data(u8 type, u8 program, const FmPreset* preset)
727705
{
728706
u8 sysexData[4 + 2 + 4 + (MAX_FM_OPERATORS * 11)];
@@ -731,7 +709,7 @@ static void send_preset_data(u8 type, u8 program, const FmPreset* preset)
731709
sysexData[index++] = SYSEX_MANU_EXTENDED;
732710
sysexData[index++] = SYSEX_MANU_REGION;
733711
sysexData[index++] = SYSEX_MANU_ID;
734-
sysexData[index++] = SYSEX_COMMAND_SEND_PRESET_DATA;
712+
sysexData[index++] = SYSEX_COMMAND_PRESET_DATA;
735713

736714
sysexData[index++] = type;
737715
sysexData[index++] = program;
@@ -758,6 +736,28 @@ static void send_preset_data(u8 type, u8 program, const FmPreset* preset)
758736
midi_tx_send_sysex(sysexData, index);
759737
}
760738

739+
static void dump_preset_request(const u8* data, u16 length)
740+
{
741+
u8 type = data[0];
742+
u8 program = data[1];
743+
744+
switch (type) {
745+
case STORE_PROGRAM_TYPE_FM: {
746+
const FmPreset* preset = midi_fm_get_stored_preset(program);
747+
if (preset != NULL) {
748+
send_preset_data(type, program, preset);
749+
log_info("Prg %d: FM preset dumped", program + 1);
750+
} else {
751+
log_warn("Prg %d: No FM preset to dump", program + 1);
752+
}
753+
break;
754+
}
755+
default:
756+
log_warn("Invalid dump preset request type: %d", type);
757+
break;
758+
}
759+
}
760+
761761
typedef struct SysexCommand {
762762
u8 command;
763763
void (*handler)(const u8* data, u16 length);
@@ -779,8 +779,8 @@ static const SysexCommand SYSEX_COMMANDS[] = {
779779
{ SYSEX_COMMAND_STORE_PROGRAM, store_program, 6 + (MAX_FM_OPERATORS * 11), true },
780780
{ SYSEX_COMMAND_CLEAR_PROGRAM, clear_program, 2, true },
781781
{ SYSEX_COMMAND_CLEAR_ALL_PROGRAMS, clear_all_programs, 1, true },
782-
{ SYSEX_COMMAND_SAVE_PRESET_REQUEST, save_preset_request, 2, true },
783-
{ SYSEX_COMMAND_SEND_PRESET_DATA, NULL, 0, false },
782+
{ SYSEX_COMMAND_DUMP_PRESET, dump_preset_request, 2, true },
783+
{ SYSEX_COMMAND_PRESET_DATA, NULL, 0, false },
784784
};
785785

786786
void midi_sysex(const u8* data, u16 length)

src/midi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@
128128
#define SYSEX_COMMAND_STORE_PROGRAM 0x0A
129129
#define SYSEX_COMMAND_CLEAR_PROGRAM 0x0B
130130
#define SYSEX_COMMAND_CLEAR_ALL_PROGRAMS 0x0C
131-
#define SYSEX_COMMAND_SAVE_PRESET_REQUEST 0x0D
132-
#define SYSEX_COMMAND_SEND_PRESET_DATA 0x0E
131+
#define SYSEX_COMMAND_DUMP_PRESET 0x0D
132+
#define SYSEX_COMMAND_PRESET_DATA 0x0E
133133

134134
#define STORE_PROGRAM_TYPE_FM 0x00
135135
#define STORE_PROGRAM_TYPE_PSG 0x01

tests/system/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main(void)
2727
e2e_test(test_midi_changing_program_retains_volume),
2828
e2e_test(test_midi_changing_program_retains_pan),
2929
e2e_test(test_midi_portamento_glides_note),
30-
e2e_test(test_save_preset_to_callee),
30+
e2e_test(test_dump_preset_to_callee),
3131
// WIP: e2e_test(test_midi_pitch_bend_range_configurable_per_channel),
3232
// clang-format on
3333
};

tests/system/test_e2e.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -438,40 +438,40 @@ void test_midi_pitch_bend_range_configurable_per_channel(void** state)
438438
midi_rx_read();
439439
}
440440

441-
void test_save_preset_to_callee(void** state)
441+
void test_dump_preset_to_callee(void** state)
442442
{
443443
stub_everdrive_as_present();
444444

445445
// First store a preset to channel
446446
const u8 program = 0x05;
447447
const u8 storeSeq[] = { SYSEX_START, SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID,
448448
SYSEX_COMMAND_STORE_PROGRAM, STORE_PROGRAM_TYPE_FM, program, 0x07, 0x00, 0x00, 0x00, 0x01,
449-
0x00, 0x26, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x26, 0x01, 0x07,
450-
0x00, 0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x26, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01,
451-
0x30, 0x00, 0x01, 0x00, 0x26, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00, SYSEX_END };
449+
0x00, 0x1F, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x1F, 0x01, 0x07,
450+
0x00, 0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x1F, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01,
451+
0x30, 0x00, 0x01, 0x00, 0x1F, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00, SYSEX_END };
452452

453453
for (u16 i = 0; i < sizeof(storeSeq); i++) {
454454
stub_usb_receive_byte(storeSeq[i]);
455455
}
456456
midi_rx_read();
457457

458-
// Send save preset request (PC requests preset from MDMI)
459-
const u8 saveRequestSeq[] = { SYSEX_START, SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION,
458+
// Send dump preset request (PC requests preset from MDMI)
459+
const u8 dumpRequestSeq[] = { SYSEX_START, SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION,
460460
SYSEX_MANU_ID, 0x0D, STORE_PROGRAM_TYPE_FM, program, SYSEX_END };
461461

462-
for (u16 i = 0; i < sizeof(saveRequestSeq); i++) {
463-
stub_usb_receive_byte(saveRequestSeq[i]);
462+
for (u16 i = 0; i < sizeof(dumpRequestSeq); i++) {
463+
stub_usb_receive_byte(dumpRequestSeq[i]);
464464
}
465465

466466
// Expect MDMI to send back the preset data with command 0x0E
467-
const u8 saveResponseSeq[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID, 0x0E,
468-
STORE_PROGRAM_TYPE_FM, program, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x26, 0x01, 0x07, 0x00,
469-
0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x26, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30,
470-
0x00, 0x01, 0x00, 0x26, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x26,
471-
0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00 };
472-
473-
for (u16 i = 0; i < sizeof(saveResponseSeq); i++) {
474-
expect_usb_sent_byte(saveResponseSeq[i]);
467+
const u8 dumpResponseSeq[] = { SYSEX_START, SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION,
468+
SYSEX_MANU_ID, 0x0E, STORE_PROGRAM_TYPE_FM, program, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00,
469+
0x1F, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x1F, 0x01, 0x07, 0x00,
470+
0x07, 0x04, 0x01, 0x30, 0x00, 0x01, 0x00, 0x1F, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30,
471+
0x00, 0x01, 0x00, 0x1F, 0x01, 0x07, 0x00, 0x07, 0x04, 0x01, 0x30, 0x00, SYSEX_END };
472+
473+
for (u16 i = 0; i < sizeof(dumpResponseSeq); i++) {
474+
expect_usb_sent_byte(dumpResponseSeq[i]);
475475
}
476476

477477
midi_rx_read();

tests/system/test_e2e.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ void test_midi_changing_program_retains_volume(void** state);
2222
void test_midi_portamento_glides_note(void** state);
2323
void test_pitch_bends_ch3_special_mode_operators(void** state);
2424
void test_midi_pitch_bend_range_configurable_per_channel(void** state);
25-
void test_save_preset_to_callee(void** state);
25+
void test_dump_preset_to_callee(void** state);

0 commit comments

Comments
 (0)