Skip to content

Commit 50b156a

Browse files
committed
test: confirm PSG support for extreme pitch bend ranges
1 parent 03dbecb commit 50b156a

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

tests/test_helpers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define MIDI_CHANNEL_1 0
1010
#define MIDI_CHANNEL_3 2
1111
#define MIDI_CHANNEL_6 5
12+
#define MIDI_CHANNEL_7 6
1213
#define MIDI_CHANNEL_11 10
1314

1415
#define MIDI_VOLUME_MAX 127
@@ -101,8 +102,8 @@
101102
#define PSG_CH3 2
102103
#define PSG_NOISE_CH4 3
103104

104-
#define TONE_NTSC_AS4 479
105+
#define TONE_NTSC_AS3 479
105106
#define TONE_NTSC_C4 427
106107
#define TONE_NTSC_CS4 403
107108
#define TONE_NTSC_DS4 380
108-
#define TONE_NTSC_A2 1016
109+
#define TONE_NTSC_A2 1016

tests/unit/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ int main(void)
199199
midi_test(test_midi_ignores_further_data_entry_messages_after_null_rpn),
200200
midi_test(test_midi_sets_pitch_bend_sensitivity_with_odd_ordering),
201201
midi_test(test_midi_logs_invalid_rpn_upon_data_entry),
202+
midi_test(test_midi_psg_supports_extreme_pitch_bend_sensitivity),
202203

203204
midi_dac_test(test_midi_dac_plays_note),
204205
midi_dac_test(test_midi_dac_stops_note),

tests/unit/test_midi_psg.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void test_midi_sets_psg_pitch_bend_down(UNUSED void** state)
165165
expect_psg_attenuation(expectedPsgChan, PSG_ATTENUATION_LOUDEST);
166166
__real_midi_note_on(chan, MIDI_PITCH_C4, MAX_MIDI_VOLUME);
167167

168-
expect_psg_tone(expectedPsgChan, TONE_NTSC_AS4);
168+
expect_psg_tone(expectedPsgChan, TONE_NTSC_AS3);
169169
__real_midi_pitch_bend(chan, 0);
170170
}
171171
}
@@ -428,3 +428,21 @@ void test_midi_psg_sets_busy_indicators(UNUSED void** state)
428428
u8 busy = midi_psg_busy();
429429
assert_int_equal(busy, 0b1010);
430430
}
431+
432+
void test_midi_psg_supports_extreme_pitch_bend_sensitivity(UNUSED void** state)
433+
{
434+
expect_psg_tone(PSG_CH1, TONE_NTSC_C4);
435+
expect_psg_attenuation(PSG_CH1, PSG_ATTENUATION_LOUDEST);
436+
__real_midi_note_on(MIDI_CHANNEL_7, MIDI_PITCH_C4, MAX_MIDI_VOLUME);
437+
438+
__real_midi_cc(MIDI_CHANNEL_7, CC_RPN_MSB, RPN_PITCH_BEND_SENSITIVITY_MSB);
439+
__real_midi_cc(MIDI_CHANNEL_7, CC_RPN_LSB, RPN_PITCH_BEND_SENSITIVITY_LSB);
440+
__real_midi_cc(MIDI_CHANNEL_7, CC_DATA_ENTRY_MSB, 48);
441+
__real_midi_cc(MIDI_CHANNEL_7, CC_DATA_ENTRY_LSB, 0);
442+
443+
expect_psg_tone(PSG_CH1, 0x1a);
444+
__real_midi_pitch_bend(MIDI_CHANNEL_7, MIDI_PITCH_BEND_MAX);
445+
446+
expect_psg_tone(PSG_CH1, TONE_NTSC_A2);
447+
__real_midi_pitch_bend(MIDI_CHANNEL_7, MIDI_PITCH_BEND_MIN);
448+
}

tests/unit/test_midi_psg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ void test_midi_pitch_shift_handles_upper_limit_psg_envelope(UNUSED void** state)
2727
void test_midi_pitch_shift_handles_lower_limit_psg_envelope(UNUSED void** state);
2828
void test_midi_loads_psg_envelope(UNUSED void** state);
2929
void test_midi_psg_sets_busy_indicators(UNUSED void** state);
30+
void test_midi_psg_supports_extreme_pitch_bend_sensitivity(UNUSED void** state);

0 commit comments

Comments
 (0)