Skip to content

Commit

Permalink
Disable FM Ch 3 special mode with CC 80
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Jun 24, 2024
1 parent 1ab70c5 commit a01922d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,13 @@ void synth_setParameterUpdateCallback(ParameterUpdatedCallback* cb)
parameterUpdatedCallback = cb;
}

void writeSpecialModeReg(void)
{
YM2612_writeReg(0, 0x27, global.ch3SpecialMode << 6);
}

void synth_setCh3SpecialMode(bool enable)
{
global.ch3SpecialMode = enable;

YM2612_writeReg(0, 0x27, (1 << 6));
writeSpecialModeReg();
}
2 changes: 1 addition & 1 deletion tests/system/test_e2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static void test_enables_ch3_special_mode(void** state)
{
const u8 status = 0xB0;
const u8 specialModeCC = 80;
const u8 specialModeEnable = 1;
const u8 specialModeEnable = 64;

stub_usb_receive_byte(status);
stub_usb_receive_byte(specialModeCC);
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ int main(void)
midi_test(
test_midi_fm_note_on_percussion_channel_sets_percussion_preset),
midi_test(test_midi_switching_program_retains_pan_setting),
midi_test(test_midi_sets_fm_special_mode),
midi_test(test_midi_enables_fm_special_mode),
midi_test(test_midi_disables_fm_special_mode),

midi_test(test_midi_sets_genmdm_stereo_mode),
midi_test(test_midi_sysex_enables_dynamic_channel_mode),
Expand Down Expand Up @@ -199,6 +200,7 @@ int main(void)
synth_test(test_synth_calls_callback_when_lfo_freq_changes),
synth_test(test_synth_calls_callback_when_lfo_enable_changes),
synth_test(test_synth_enables_ch3_special_mode),
synth_test(test_synth_disables_ch3_special_mode),

comm_test(test_comm_reads_from_serial_when_ready),
comm_test(test_comm_reads_when_ready),
Expand Down
12 changes: 11 additions & 1 deletion tests/unit/test_midi_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ static void test_midi_switching_program_retains_pan_setting(UNUSED void** state)
__real_midi_program(chan, program);
}

static void test_midi_sets_fm_special_mode(UNUSED void** state)
static void test_midi_enables_fm_special_mode(UNUSED void** state)
{
u8 expectedController = 80;
u8 expectedValue = 64;
Expand All @@ -520,3 +520,13 @@ static void test_midi_sets_fm_special_mode(UNUSED void** state)

__real_midi_cc(0, expectedController, expectedValue);
}

static void test_midi_disables_fm_special_mode(UNUSED void** state)
{
u8 expectedController = 80;
u8 expectedValue = 0;

expect_value(__wrap_synth_setCh3SpecialMode, enable, false);

__real_midi_cc(0, expectedController, expectedValue);
}
8 changes: 7 additions & 1 deletion tests/unit/test_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,12 @@ static void test_synth_calls_callback_when_lfo_enable_changes(

static void test_synth_enables_ch3_special_mode(UNUSED void** state)
{
expect_ym2612_write_reg(0, 0x27, (1 << 6));
expect_ym2612_write_reg(0, 0x27, 0x40);
__real_synth_setCh3SpecialMode(true);
}

static void test_synth_disables_ch3_special_mode(UNUSED void** state)
{
expect_ym2612_write_reg(0, 0x27, 0);
__real_synth_setCh3SpecialMode(false);
}

0 comments on commit a01922d

Please sign in to comment.