Skip to content

Commit

Permalink
Ignore NRPN, RPN & sustain pedal CCs
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Oct 10, 2021
1 parent 9602789 commit 326da72
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,14 @@ static void setFmChanParameter(DeviceChannel* devChan, u8 controller, u8 value)
break;
synth_stereo(devChan->number, RANGE(value, 4));
break;
case CC_SUSTAIN_PEDAL:
case CC_DATA_ENTRY_LSB:
case CC_DATA_ENTRY_MSB:
case CC_NRPN_LSB:
case CC_NRPN_MSB:
case CC_RPN_LSB:
case CC_RPN_MSB:
break;
default:
log_warn("Ch %d: CC 0x%02X 0x%02X?", devChan->midiChannel, controller,
value);
Expand Down
7 changes: 7 additions & 0 deletions src/midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define DEV_CHAN_PSG_NOISE 9
#define DEV_CHAN_MAX_PSG 9

#define CC_DATA_ENTRY_MSB 6
#define CC_VOLUME 7
#define CC_PAN 10
#define CC_GENMDM_FM_ALGORITHM 14
Expand All @@ -41,6 +42,7 @@
#define CC_GENMDM_DETUNE_OP2 25
#define CC_GENMDM_DETUNE_OP3 26
#define CC_GENMDM_DETUNE_OP4 27
#define CC_DATA_ENTRY_LSB 38
#define CC_GENMDM_RATE_SCALING_OP1 39
#define CC_GENMDM_RATE_SCALING_OP2 40
#define CC_GENMDM_RATE_SCALING_OP3 41
Expand All @@ -65,6 +67,7 @@
#define CC_GENMDM_RELEASE_RATE_OP2 60
#define CC_GENMDM_RELEASE_RATE_OP3 61
#define CC_GENMDM_RELEASE_RATE_OP4 62
#define CC_SUSTAIN_PEDAL 64
#define CC_GENMDM_AMPLITUDE_MODULATION_OP1 70
#define CC_GENMDM_AMPLITUDE_MODULATION_OP2 71
#define CC_GENMDM_AMPLITUDE_MODULATION_OP3 72
Expand All @@ -80,6 +83,10 @@
#define CC_GENMDM_SSG_EG_OP2 91
#define CC_GENMDM_SSG_EG_OP3 92
#define CC_GENMDM_SSG_EG_OP4 93
#define CC_NRPN_LSB 98
#define CC_NRPN_MSB 99
#define CC_RPN_LSB 100
#define CC_RPN_MSB 101
#define CC_GENMDM_GLOBAL_LFO_FREQUENCY 1
#define CC_RESET_ALL_CONTROLLERS 121
#define CC_ALL_SOUND_OFF 120
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ int main(void)
midi_test(test_midi_sets_polyphonic_mode),
midi_test(test_midi_unsets_polyphonic_mode),
midi_test(test_midi_sets_unknown_CC),
midi_test(test_midi_ignores_sustain_pedal_cc),
midi_test(test_midi_ignores_sysex_nrpn_ccs),
midi_test(test_midi_polyphonic_mode_sends_CCs_to_all_FM_channels),
midi_test(test_midi_set_overflow_flag_on_polyphony_breach),
midi_test(test_midi_sets_fm_preset),
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/test_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ void test_midi_sets_unknown_CC(UNUSED void** state)
__real_midi_cc(0, expectedController, expectedValue);
}

void test_midi_ignores_sustain_pedal_cc(UNUSED void** state)
{
wraps_enable_logging_checks();

u8 cc = 64;

__real_midi_cc(0, cc, 1);
}

void test_midi_ignores_sysex_nrpn_ccs(UNUSED void** state)
{
wraps_enable_logging_checks();

__real_midi_cc(0, 6, 1);
__real_midi_cc(0, 38, 1);
__real_midi_cc(0, 98, 1);
__real_midi_cc(0, 99, 1);
__real_midi_cc(0, 100, 1);
__real_midi_cc(0, 101, 1);
}

void test_midi_shows_fm_parameter_ui(UNUSED void** state)
{
u8 midiChan = 0;
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ void test_midi_sets_unknown_CC(UNUSED void** state);
void test_midi_shows_fm_parameter_ui(UNUSED void** state);
void test_midi_hides_fm_parameter_ui(UNUSED void** state);
void test_midi_reset_reinitialises_module(UNUSED void** state);
void test_midi_ignores_sustain_pedal_cc(UNUSED void** state);
void test_midi_ignores_sysex_nrpn_ccs(UNUSED void** state);

0 comments on commit 326da72

Please sign in to comment.