From 3c235e4ca2231541407a9cd926ee3067a84dd355 Mon Sep 17 00:00:00 2001 From: Robert Hargreaves Date: Wed, 17 Jul 2024 15:11:33 +0100 Subject: [PATCH] Format docs --- src/midi_fm.c | 19 ++--- src/synth.c | 65 ++++++---------- tests/unit/test_midi_dynamic.c | 73 +++++++---------- tests/unit/test_midi_fm.c | 107 +++++++++---------------- tests/unit/test_synth.c | 138 +++++++++++---------------------- 5 files changed, 140 insertions(+), 262 deletions(-) diff --git a/src/midi_fm.c b/src/midi_fm.c index faa74c8..8b15aed 100644 --- a/src/midi_fm.c +++ b/src/midi_fm.c @@ -38,8 +38,8 @@ void midi_fm_reset(void); static const FmChannel** presets; static const PercussionPreset** percussionPresets; -void midi_fm_init(const FmChannel** defaultPresets, - const PercussionPreset** defaultPercussionPresets) +void midi_fm_init( + const FmChannel** defaultPresets, const PercussionPreset** defaultPercussionPresets) { presets = defaultPresets; percussionPresets = defaultPercussionPresets; @@ -101,16 +101,12 @@ u16 midi_fm_pitchToFreqNum(u8 pitch, u16 pitchBend) s16 approxFreqDelta; if (bendRelative < 0) { // bend down - u16 boundFreq - = lookupFreqNum(pitch, -GENERAL_MIDI_PITCH_BEND_SEMITONE_RANGE); - approxFreqDelta - = (((freq - boundFreq) * bendRelative) / DEFAULT_MIDI_PITCH_BEND); + u16 boundFreq = lookupFreqNum(pitch, -GENERAL_MIDI_PITCH_BEND_SEMITONE_RANGE); + approxFreqDelta = (((freq - boundFreq) * bendRelative) / DEFAULT_MIDI_PITCH_BEND); } else { // bend up - u16 boundFreq - = lookupFreqNum(pitch, GENERAL_MIDI_PITCH_BEND_SEMITONE_RANGE); - approxFreqDelta - = (((boundFreq - freq) * bendRelative) / DEFAULT_MIDI_PITCH_BEND); + u16 boundFreq = lookupFreqNum(pitch, GENERAL_MIDI_PITCH_BEND_SEMITONE_RANGE); + approxFreqDelta = (((boundFreq - freq) * bendRelative) / DEFAULT_MIDI_PITCH_BEND); } return freq + approxFreqDelta; } @@ -166,8 +162,7 @@ u8 midi_fm_pitchToOctave(u8 pitch) static u16 lookupFreqNum(u8 pitch, s16 offset) { - u16 index = FREQ_NORMAL_RANGE_OFFSET - + ((u8)(pitch - MIN_MIDI_PITCH) % SEMITONES) + offset; + u16 index = FREQ_NORMAL_RANGE_OFFSET + ((u8)(pitch - MIN_MIDI_PITCH) % SEMITONES) + offset; u16 freq = FREQS[index]; return freq; } diff --git a/src/synth.c b/src/synth.c index dd1a99e..1128467 100644 --- a/src/synth.c +++ b/src/synth.c @@ -5,8 +5,7 @@ #include #include "debug.h" -static Global global - = { .lfoEnable = 1, .lfoFrequency = 0, .specialMode = false }; +static Global global = { .lfoEnable = 1, .lfoFrequency = 0, .specialMode = false }; static FmChannel fmChannels[MAX_FM_CHANS]; static u8 noteOn; static u8 volumes[MAX_FM_CHANS]; @@ -15,23 +14,20 @@ static ParameterUpdatedCallback* parameterUpdatedCallback = NULL; static const u8 MAX_VOLUME = 0x7F; -static const u8 VOLUME_TO_TOTAL_LEVELS[] = { 127, 122, 117, 113, 108, 104, 100, - 97, 93, 89, 86, 83, 80, 77, 74, 71, 68, 66, 63, 61, 58, 56, 54, 52, 50, 48, - 46, 44, 43, 41, 40, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, - 22, 21, 20, 19, 19, 18, 17, 17, 16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 11, - 10, 10, 9, 9, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, - 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static const u8 VOLUME_TO_TOTAL_LEVELS[] = { 127, 122, 117, 113, 108, 104, 100, 97, 93, 89, 86, 83, + 80, 77, 74, 71, 68, 66, 63, 61, 58, 56, 54, 52, 50, 48, 46, 44, 43, 41, 40, 38, 37, 35, 34, 32, + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 19, 18, 17, 17, 16, 15, 15, 14, 13, 13, 12, + 12, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, + 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 }; static void updateChannel(u8 chan); static void writeGlobalLfo(void); static void writeAlgorithmAndFeedback(u8 channel); static void writeOperatorMultipleAndDetune(u8 channel, u8 op); static void writeOperatorRateScalingAndAttackRate(u8 channel, u8 operator); -static void writeOperatorAmplitudeModulationAndFirstDecayRate( - u8 channel, u8 operator); -static void writeOperatorReleaseRateAndSecondaryAmplitude( - u8 channel, u8 operator); +static void writeOperatorAmplitudeModulationAndFirstDecayRate(u8 channel, u8 operator); +static void writeOperatorReleaseRateAndSecondaryAmplitude(u8 channel, u8 operator); static void writeOperatorTotalLevel(u8 channel, u8 operator); static void writeOperatorSecondaryDecayRate(u8 channel, u8 operator); static void writeOperatorSsgEg(u8 channel, u8 operator); @@ -47,8 +43,7 @@ static u8 effectiveTotalLevel(u8 channel, u8 operator, u8 totalLevel); static bool isOutputOperator(u8 algorithm, u8 operator); static u8 volumeAdjustedTotalLevel(u8 channel, u8 totalLevel); static void channelParameterUpdated(u8 channel); -static void otherParameterUpdated( - u8 channel, ParameterUpdated parameterUpdated); +static void otherParameterUpdated(u8 channel, ParameterUpdated parameterUpdated); static void writeRegSafe(u8 part, u8 reg, u8 data); void synth_init(const FmChannel* initialPreset) @@ -207,8 +202,7 @@ void synth_operatorFirstDecayRate(u8 channel, u8 op, u8 firstDecayRate) channelParameterUpdated(channel); } -void synth_operatorAmplitudeModulation( - u8 channel, u8 op, u8 amplitudeModulation) +void synth_operatorAmplitudeModulation(u8 channel, u8 op, u8 amplitudeModulation) { getOperator(channel, op)->amplitudeModulation = amplitudeModulation; writeOperatorAmplitudeModulationAndFirstDecayRate(channel, op); @@ -315,8 +309,7 @@ static void writeGlobalLfo(void) static void writeOctaveAndFrequency(u8 channel) { FmChannel* chan = fmChannel(channel); - writeChannelReg( - channel, 0xA4, (chan->freqNumber >> 8) | (chan->octave << 3)); + writeChannelReg(channel, 0xA4, (chan->freqNumber >> 8) | (chan->octave << 3)); writeChannelReg(channel, 0xA0, chan->freqNumber); } @@ -329,8 +322,7 @@ static void writeAlgorithmAndFeedback(u8 channel) static void writeStereoAmsFms(u8 channel) { FmChannel* chan = fmChannel(channel); - writeChannelReg( - channel, 0xB4, (chan->stereo << 6) + (chan->ams << 4) + chan->fms); + writeChannelReg(channel, 0xB4, (chan->stereo << 6) + (chan->ams << 4) + chan->fms); } static void writeOperatorMultipleAndDetune(u8 channel, u8 operator) @@ -342,16 +334,13 @@ static void writeOperatorMultipleAndDetune(u8 channel, u8 operator) static void writeOperatorRateScalingAndAttackRate(u8 channel, u8 operator) { Operator* op = getOperator(channel, operator); - writeOperatorReg( - channel, operator, 0x50, op->attackRate + (op->rateScaling << 6)); + writeOperatorReg(channel, operator, 0x50, op->attackRate + (op->rateScaling << 6)); } -static void writeOperatorAmplitudeModulationAndFirstDecayRate( - u8 channel, u8 operator) +static void writeOperatorAmplitudeModulationAndFirstDecayRate(u8 channel, u8 operator) { Operator* op = getOperator(channel, operator); - writeOperatorReg(channel, operator, 0x60, - op->firstDecayRate + (op->amplitudeModulation << 7)); + writeOperatorReg(channel, operator, 0x60, op->firstDecayRate + (op->amplitudeModulation << 7)); } static void writeOperatorSecondaryDecayRate(u8 channel, u8 operator) @@ -360,12 +349,10 @@ static void writeOperatorSecondaryDecayRate(u8 channel, u8 operator) writeOperatorReg(channel, operator, 0x70, op->secondaryDecayRate); } -static void writeOperatorReleaseRateAndSecondaryAmplitude( - u8 channel, u8 operator) +static void writeOperatorReleaseRateAndSecondaryAmplitude(u8 channel, u8 operator) { Operator* op = getOperator(channel, operator); - writeOperatorReg(channel, operator, 0x80, - op->releaseRate + (op->secondaryAmplitude << 4)); + writeOperatorReg(channel, operator, 0x80, op->releaseRate + (op->secondaryAmplitude << 4)); } static void writeOperatorSsgEg(u8 channel, u8 operator) @@ -377,8 +364,8 @@ static void writeOperatorSsgEg(u8 channel, u8 operator) static void writeOperatorTotalLevel(u8 channel, u8 operator) { Operator* op = getOperator(channel, operator); - writeOperatorReg(channel, operator, 0x40, - effectiveTotalLevel(channel, operator, op->totalLevel)); + writeOperatorReg( + channel, operator, 0x40, effectiveTotalLevel(channel, operator, op->totalLevel)); } static u8 effectiveTotalLevel(u8 channel, u8 operator, u8 totalLevel) @@ -390,8 +377,7 @@ static u8 effectiveTotalLevel(u8 channel, u8 operator, u8 totalLevel) static bool isOutputOperator(u8 algorithm, u8 op) { - return (algorithm < 4 && op == 3) - || (algorithm == 4 && (op == 1 || op == 3)) + return (algorithm < 4 && op == 3) || (algorithm == 4 && (op == 1 || op == 3)) || ((algorithm == 5 || algorithm == 6) && op > 0) || algorithm == 7; } @@ -400,8 +386,7 @@ static u8 volumeAdjustedTotalLevel(u8 channel, u8 totalLevel) u8 volume = volumes[channel]; u8 logarithmicVolume = 0x7F - VOLUME_TO_TOTAL_LEVELS[volume]; u8 inverseTotalLevel = 0x7F - totalLevel; - u8 inverseNewTotalLevel - = (u16)inverseTotalLevel * (u16)logarithmicVolume / (u16)0x7F; + u8 inverseNewTotalLevel = (u16)inverseTotalLevel * (u16)logarithmicVolume / (u16)0x7F; return 0x7F - inverseNewTotalLevel; } @@ -448,8 +433,7 @@ void synth_specialModeVolume(u8 operator, u8 volume) u8 logarithmicVolume = 0x7F - VOLUME_TO_TOTAL_LEVELS[volume]; u8 inverseTotalLevel = 0x7F - op->totalLevel; - u8 inverseNewTotalLevel - = (u16)inverseTotalLevel * (u16)logarithmicVolume / (u16)0x7F; + u8 inverseNewTotalLevel = (u16)inverseTotalLevel * (u16)logarithmicVolume / (u16)0x7F; u8 newTotalLevel = 0x7F - inverseNewTotalLevel; writeOperatorReg(CH_SPECIAL_MODE, operator, 0x40, @@ -468,8 +452,7 @@ void synth_enableDac(bool enable) static void writeRegSafe(u8 part, u8 reg, u8 data) { - debug_message("call: YM2612_writeReg(part=%d, reg=0x%X, data=0x%X)\n", part, - reg, data); + debug_message("call: YM2612_writeReg(part=%d, reg=0x%X, data=0x%X)\n", part, reg, data); bool takenAlready = Z80_getAndRequestBus(TRUE); YM2612_writeReg(part, reg, data); diff --git a/tests/unit/test_midi_dynamic.c b/tests/unit/test_midi_dynamic.c index eddab26..ac73322 100644 --- a/tests/unit/test_midi_dynamic.c +++ b/tests/unit/test_midi_dynamic.c @@ -4,8 +4,8 @@ static void setStickToDeviceType(bool enable) { - const u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, - SYSEX_MANU_ID, SYSEX_COMMAND_STICK_TO_DEVICE_TYPE, enable ? 1 : 0 }; + const u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID, + SYSEX_COMMAND_STICK_TO_DEVICE_TYPE, enable ? 1 : 0 }; __real_midi_sysex(sequence, sizeof(sequence)); } @@ -51,12 +51,10 @@ static void test_midi_dynamic_uses_all_channels(UNUSED void** state) } } -static void test_midi_routing_switches_to_dynamic_on_gm_reset( - UNUSED void** state) +static void test_midi_routing_switches_to_dynamic_on_gm_reset(UNUSED void** state) { const u8 sysExGeneralMidiResetSequence[] = { 0x7E, 0x7F, 0x09, 0x01 }; - __real_midi_sysex( - sysExGeneralMidiResetSequence, sizeof(sysExGeneralMidiResetSequence)); + __real_midi_sysex(sysExGeneralMidiResetSequence, sizeof(sysExGeneralMidiResetSequence)); // Initial note expect_synth_pitch(0, 4, 0x284); @@ -71,8 +69,7 @@ static void test_midi_routing_switches_to_dynamic_on_gm_reset( __real_midi_note_on(0, 61, MAX_MIDI_VOLUME); } -static void test_midi_dynamic_tries_to_reuse_original_midi_channel_if_available( - UNUSED void** state) +static void test_midi_dynamic_tries_to_reuse_original_midi_channel_if_available(UNUSED void** state) { const u8 octave = 4; const u16 freq = 0x284; @@ -98,8 +95,7 @@ static void test_midi_dynamic_tries_to_reuse_original_midi_channel_if_available( __real_midi_note_on(REUSE_MIDI_CHANNEL, pitch, MAX_MIDI_VOLUME); } -static void -test_midi_dynamic_reuses_mapped_midi_channel_even_if_busy_if_sticking_to_device_type( +static void test_midi_dynamic_reuses_mapped_midi_channel_even_if_busy_if_sticking_to_device_type( UNUSED void** state) { setStickToDeviceType(true); @@ -152,8 +148,7 @@ static void test_midi_exposes_dynamic_mode_mappings(UNUSED void** state) } } -static void test_midi_dynamic_enables_percussive_mode_if_needed( - UNUSED void** state) +static void test_midi_dynamic_enables_percussive_mode_if_needed(UNUSED void** state) { const u8 MIDI_KEY = 30; @@ -163,8 +158,7 @@ static void test_midi_dynamic_enables_percussive_mode_if_needed( expect_synth_pitch_any(); expect_synth_volume_any(); expect_value(__wrap_synth_noteOn, channel, 0); - __real_midi_note_on( - GENERAL_MIDI_PERCUSSION_CHANNEL, MIDI_KEY, MAX_MIDI_VOLUME); + __real_midi_note_on(GENERAL_MIDI_PERCUSSION_CHANNEL, MIDI_KEY, MAX_MIDI_VOLUME); // Playing second drum expect_value(__wrap_synth_preset, channel, 1); @@ -172,8 +166,7 @@ static void test_midi_dynamic_enables_percussive_mode_if_needed( expect_synth_pitch_any(); expect_synth_volume_any(); expect_value(__wrap_synth_noteOn, channel, 1); - __real_midi_note_on( - GENERAL_MIDI_PERCUSSION_CHANNEL, MIDI_KEY, MAX_MIDI_VOLUME); + __real_midi_note_on(GENERAL_MIDI_PERCUSSION_CHANNEL, MIDI_KEY, MAX_MIDI_VOLUME); } static void test_midi_sets_presets_on_dynamic_channels(UNUSED void** state) @@ -201,8 +194,7 @@ static void test_midi_sets_presets_on_dynamic_channels(UNUSED void** state) __real_midi_note_on(0, MIDI_PITCH_AS6, MAX_MIDI_VOLUME); } -static void test_midi_dynamic_does_not_send_percussion_to_psg_channels( - UNUSED void** state) +static void test_midi_dynamic_does_not_send_percussion_to_psg_channels(UNUSED void** state) { const u8 MIDI_KEY_IN_PSG_RANGE = MIDI_PITCH_AS6; @@ -215,8 +207,7 @@ static void test_midi_dynamic_does_not_send_percussion_to_psg_channels( } // Drum should be dropped - __real_midi_note_on(GENERAL_MIDI_PERCUSSION_CHANNEL, MIDI_KEY_IN_PSG_RANGE, - MAX_MIDI_VOLUME); + __real_midi_note_on(GENERAL_MIDI_PERCUSSION_CHANNEL, MIDI_KEY_IN_PSG_RANGE, MAX_MIDI_VOLUME); } static void test_midi_sysex_resets_dynamic_mode_state(UNUSED void** state) @@ -241,8 +232,7 @@ static void test_midi_sysex_resets_dynamic_mode_state(UNUSED void** state) expect_value(__wrap_synth_noteOff, channel, 4); expect_value(__wrap_synth_noteOff, channel, 5); - __real_midi_sysex( - sysExGeneralMidiResetSequence, sizeof(sysExGeneralMidiResetSequence)); + __real_midi_sysex(sysExGeneralMidiResetSequence, sizeof(sysExGeneralMidiResetSequence)); DeviceChannel* mappings = __real_midi_channel_mappings(); for (u8 i = 0; i < DEV_CHANS; i++) { @@ -253,8 +243,7 @@ static void test_midi_sysex_resets_dynamic_mode_state(UNUSED void** state) } } -static void test_midi_dynamic_sends_note_off_to_channel_playing_same_pitch( - UNUSED void** state) +static void test_midi_dynamic_sends_note_off_to_channel_playing_same_pitch(UNUSED void** state) { expect_synth_pitch_any(); expect_synth_volume_any(); @@ -280,13 +269,11 @@ static void test_midi_dynamic_limits_percussion_notes(UNUSED void** state) expect_value(__wrap_synth_noteOn, channel, i); expect_value(__wrap_synth_preset, channel, i); expect_any(__wrap_synth_preset, preset); - __real_midi_note_on( - GENERAL_MIDI_PERCUSSION_CHANNEL, DRUM_KEY, MAX_MIDI_VOLUME); + __real_midi_note_on(GENERAL_MIDI_PERCUSSION_CHANNEL, DRUM_KEY, MAX_MIDI_VOLUME); } // Drum 3 (dropped) - __real_midi_note_on( - GENERAL_MIDI_PERCUSSION_CHANNEL, DRUM_KEY, MAX_MIDI_VOLUME); + __real_midi_note_on(GENERAL_MIDI_PERCUSSION_CHANNEL, DRUM_KEY, MAX_MIDI_VOLUME); } static void test_midi_dynamic_maintains_volume_on_remapping(UNUSED void** state) @@ -365,8 +352,7 @@ static void test_midi_dynamic_maintains_pan_on_remapping(UNUSED void** state) __real_midi_note_on(0, MIDI_PITCH_B6, MAX_MIDI_VOLUME); } -static void test_midi_dynamic_maintains_pitch_bend_on_remapping( - UNUSED void** state) +static void test_midi_dynamic_maintains_pitch_bend_on_remapping(UNUSED void** state) { const u16 midi_bend = 0x3000; @@ -440,9 +426,8 @@ static void test_midi_dynamic_sysex_remaps_midi_channel(UNUSED void** state) const u8 MIDI_CHANNEL = 0x01; const u8 DESTINATION_FIRST_PSG_CHANNEL = 0x06; - const u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, - SYSEX_MANU_ID, SYSEX_COMMAND_REMAP, MIDI_CHANNEL, - DESTINATION_FIRST_PSG_CHANNEL }; + const u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID, + SYSEX_COMMAND_REMAP, MIDI_CHANNEL, DESTINATION_FIRST_PSG_CHANNEL }; __real_midi_sysex(sequence, sizeof(sequence)); @@ -452,16 +437,14 @@ static void test_midi_dynamic_sysex_remaps_midi_channel(UNUSED void** state) __real_midi_note_on(MIDI_CHANNEL, 60, MAX_MIDI_VOLUME); } -static void test_midi_dynamic_sysex_removes_mapping_of_midi_channel( - UNUSED void** state) +static void test_midi_dynamic_sysex_removes_mapping_of_midi_channel(UNUSED void** state) { const u8 MIDI_CHANNEL = 0x00; const u8 MIDI_CHANNEL_NO_MAPPING = 0x7F; const u8 DESTINATION_FIRST_PSG_CHANNEL = 0x06; - const u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, - SYSEX_MANU_ID, SYSEX_COMMAND_REMAP, MIDI_CHANNEL, - DESTINATION_FIRST_PSG_CHANNEL }; + const u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID, + SYSEX_COMMAND_REMAP, MIDI_CHANNEL, DESTINATION_FIRST_PSG_CHANNEL }; // Assigning PSG to MIDI Chan 0 __real_midi_sysex(sequence, sizeof(sequence)); @@ -471,9 +454,8 @@ static void test_midi_dynamic_sysex_removes_mapping_of_midi_channel( expect_psg_attenuation(0, PSG_ATTENUATION_LOUDEST); __real_midi_note_on(MIDI_CHANNEL, 60, MAX_MIDI_VOLUME); - const u8 removeMappingSeq[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, - SYSEX_MANU_ID, SYSEX_COMMAND_REMAP, MIDI_CHANNEL_NO_MAPPING, - DESTINATION_FIRST_PSG_CHANNEL }; + const u8 removeMappingSeq[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID, + SYSEX_COMMAND_REMAP, MIDI_CHANNEL_NO_MAPPING, DESTINATION_FIRST_PSG_CHANNEL }; // Remove MIDI Chan 0 assignment __real_midi_sysex(removeMappingSeq, sizeof(removeMappingSeq)); @@ -485,8 +467,7 @@ static void test_midi_dynamic_sysex_removes_mapping_of_midi_channel( __real_midi_note_on(MIDI_CHANNEL, 60, MAX_MIDI_VOLUME); } -static void test_midi_dynamic_prefers_psg_for_square_wave_instruments( - UNUSED void** state) +static void test_midi_dynamic_prefers_psg_for_square_wave_instruments(UNUSED void** state) { const u8 PSG_CHANNEL = 0; const u8 MIDI_CHANNEL = 0; @@ -508,8 +489,7 @@ static void test_midi_dynamic_prefers_psg_for_square_wave_instruments( } } -static void test_midi_dynamic_sticks_to_assigned_device_type_for_midi_channels( - UNUSED void** state) +static void test_midi_dynamic_sticks_to_assigned_device_type_for_midi_channels(UNUSED void** state) { setStickToDeviceType(true); @@ -529,8 +509,7 @@ static void test_midi_dynamic_sticks_to_assigned_device_type_for_midi_channels( __real_midi_note_on(REUSE_MIDI_CHANNEL, MIDI_PITCH_AS6, MAX_MIDI_VOLUME); } -static void -test_midi_dynamic_sticks_to_assigned_psg_device_type_for_midi_channels( +static void test_midi_dynamic_sticks_to_assigned_psg_device_type_for_midi_channels( UNUSED void** state) { setStickToDeviceType(true); diff --git a/tests/unit/test_midi_fm.c b/tests/unit/test_midi_fm.c index b8ea124..d01dec2 100644 --- a/tests/unit/test_midi_fm.c +++ b/tests/unit/test_midi_fm.c @@ -21,8 +21,7 @@ static void test_midi_triggers_synth_note_on_with_velocity(UNUSED void** state) } } -static void test_midi_triggers_synth_note_on_with_velocity_and_channel_volume( - UNUSED void** state) +static void test_midi_triggers_synth_note_on_with_velocity_and_channel_volume(UNUSED void** state) { for (int chan = 0; chan <= MAX_FM_CHAN; chan++) { expect_synth_volume(chan, MAX_MIDI_VOLUME / 2); @@ -35,8 +34,7 @@ static void test_midi_triggers_synth_note_on_with_velocity_and_channel_volume( } } -static void test_midi_changing_volume_during_note_on_respects_velocity( - UNUSED void** state) +static void test_midi_changing_volume_during_note_on_respects_velocity(UNUSED void** state) { for (int chan = 0; chan <= MAX_FM_CHAN; chan++) { expect_synth_pitch(chan, 4, SYNTH_NTSC_C); @@ -52,8 +50,7 @@ static void test_midi_changing_volume_during_note_on_respects_velocity( } } -static void test_midi_triggers_synth_note_on_boundary_values( - UNUSED void** state) +static void test_midi_triggers_synth_note_on_boundary_values(UNUSED void** state) { const u8 keys[] = { 11, 106 }; const u16 expectedFrequencies[] = { 607, SYNTH_NTSC_AS }; @@ -61,8 +58,7 @@ static void test_midi_triggers_synth_note_on_boundary_values( for (int index = 0; index < 2; index++) { for (int chan = 0; chan <= MAX_FM_CHAN; chan++) { - expect_synth_pitch( - chan, expectedOctaves[index], expectedFrequencies[index]); + expect_synth_pitch(chan, expectedOctaves[index], expectedFrequencies[index]); expect_synth_volume_any(); expect_value(__wrap_synth_noteOn, channel, chan); @@ -71,8 +67,7 @@ static void test_midi_triggers_synth_note_on_boundary_values( } } -static void test_midi_does_not_trigger_synth_note_on_out_of_bound_values( - UNUSED void** state) +static void test_midi_does_not_trigger_synth_note_on_out_of_bound_values(UNUSED void** state) { const u8 keys[] = { 0, 10, 107, 127 }; @@ -96,8 +91,7 @@ static void test_midi_triggers_synth_note_off(UNUSED void** state) } } -static void test_midi_triggers_synth_note_off_when_note_on_has_zero_velocity( - UNUSED void** state) +static void test_midi_triggers_synth_note_off_when_note_on_has_zero_velocity(UNUSED void** state) { for (int chan = 0; chan <= MAX_FM_CHAN; chan++) { expect_synth_pitch(chan, 4, SYNTH_NTSC_C); @@ -210,8 +204,7 @@ static void test_midi_sets_operator_total_level(UNUSED void** state) u8 expectedOp = cc - 16; expect_value(__wrap_synth_operatorTotalLevel, channel, chan); expect_value(__wrap_synth_operatorTotalLevel, op, expectedOp); - expect_value( - __wrap_synth_operatorTotalLevel, totalLevel, expectedValue); + expect_value(__wrap_synth_operatorTotalLevel, totalLevel, expectedValue); __real_midi_cc(chan, cc, expectedValue); } @@ -227,8 +220,7 @@ static void test_midi_sets_operator_multiple(UNUSED void** state) u8 expectedOp = cc - 20; expect_value(__wrap_synth_operatorMultiple, channel, chan); expect_value(__wrap_synth_operatorMultiple, op, expectedOp); - expect_value( - __wrap_synth_operatorMultiple, multiple, expectedValue); + expect_value(__wrap_synth_operatorMultiple, multiple, expectedValue); __real_midi_cc(chan, cc, 32); } @@ -260,8 +252,7 @@ static void test_midi_sets_operator_rate_scaling(UNUSED void** state) u8 expectedOp = cc - 39; expect_value(__wrap_synth_operatorRateScaling, channel, chan); expect_value(__wrap_synth_operatorRateScaling, op, expectedOp); - expect_value( - __wrap_synth_operatorRateScaling, rateScaling, expectedValue); + expect_value(__wrap_synth_operatorRateScaling, rateScaling, expectedValue); __real_midi_cc(chan, cc, 64); } @@ -277,8 +268,7 @@ static void test_midi_sets_operator_attack_rate(UNUSED void** state) u8 expectedOp = cc - 43; expect_value(__wrap_synth_operatorAttackRate, channel, chan); expect_value(__wrap_synth_operatorAttackRate, op, expectedOp); - expect_value( - __wrap_synth_operatorAttackRate, attackRate, expectedValue); + expect_value(__wrap_synth_operatorAttackRate, attackRate, expectedValue); __real_midi_cc(chan, cc, 8); } @@ -293,8 +283,7 @@ static void test_midi_sets_operator_first_decay_rate(UNUSED void** state) u8 expectedOp = cc - 47; expect_value(__wrap_synth_operatorFirstDecayRate, channel, chan); expect_value(__wrap_synth_operatorFirstDecayRate, op, expectedOp); - expect_value(__wrap_synth_operatorFirstDecayRate, firstDecayRate, - expectedValue); + expect_value(__wrap_synth_operatorFirstDecayRate, firstDecayRate, expectedValue); __real_midi_cc(chan, cc, 8); } @@ -310,8 +299,7 @@ static void test_midi_sets_operator_second_decay_rate(UNUSED void** state) u8 expectedOp = cc - 51; expect_value(__wrap_synth_operatorSecondDecayRate, channel, chan); expect_value(__wrap_synth_operatorSecondDecayRate, op, expectedOp); - expect_value(__wrap_synth_operatorSecondDecayRate, secondDecayRate, - expectedValue); + expect_value(__wrap_synth_operatorSecondDecayRate, secondDecayRate, expectedValue); __real_midi_cc(chan, cc, 8); } @@ -325,12 +313,10 @@ static void test_midi_sets_operator_secondary_amplitude(UNUSED void** state) for (u8 chan = 0; chan < MAX_FM_CHANS; chan++) { for (u8 cc = 55; cc <= 58; cc++) { u8 expectedOp = cc - 55; + expect_value(__wrap_synth_operatorSecondaryAmplitude, channel, chan); + expect_value(__wrap_synth_operatorSecondaryAmplitude, op, expectedOp); expect_value( - __wrap_synth_operatorSecondaryAmplitude, channel, chan); - expect_value( - __wrap_synth_operatorSecondaryAmplitude, op, expectedOp); - expect_value(__wrap_synth_operatorSecondaryAmplitude, - secondaryAmplitude, expectedValue); + __wrap_synth_operatorSecondaryAmplitude, secondaryAmplitude, expectedValue); __real_midi_cc(chan, cc, 8); } @@ -344,12 +330,10 @@ static void test_midi_sets_operator_amplitude_modulation(UNUSED void** state) for (u8 chan = 0; chan < MAX_FM_CHANS; chan++) { for (u8 cc = 70; cc <= 73; cc++) { u8 expectedOp = cc - 70; + expect_value(__wrap_synth_operatorAmplitudeModulation, channel, chan); + expect_value(__wrap_synth_operatorAmplitudeModulation, op, expectedOp); expect_value( - __wrap_synth_operatorAmplitudeModulation, channel, chan); - expect_value( - __wrap_synth_operatorAmplitudeModulation, op, expectedOp); - expect_value(__wrap_synth_operatorAmplitudeModulation, - amplitudeModulation, expectedValue); + __wrap_synth_operatorAmplitudeModulation, amplitudeModulation, expectedValue); __real_midi_cc(chan, cc, 96); } @@ -365,8 +349,7 @@ static void test_midi_sets_operator_release_rate(UNUSED void** state) u8 expectedOp = cc - 59; expect_value(__wrap_synth_operatorReleaseRate, channel, chan); expect_value(__wrap_synth_operatorReleaseRate, op, expectedOp); - expect_value( - __wrap_synth_operatorReleaseRate, releaseRate, expectedValue); + expect_value(__wrap_synth_operatorReleaseRate, releaseRate, expectedValue); __real_midi_cc(chan, cc, 8); } @@ -487,8 +470,7 @@ static void test_midi_pitch_bends_up_an_octave(UNUSED void** state) } } -static void test_midi_pitch_bends_up_an_octave_upper_freq_limit( - UNUSED void** state) +static void test_midi_pitch_bends_up_an_octave_upper_freq_limit(UNUSED void** state) { const u8 MIDI_PITCH_AS4 = 70; const u16 SYNTH_FREQ_AS4 = 1146; @@ -525,14 +507,13 @@ static void test_midi_persists_pitch_bend_between_notes(UNUSED void** state) static void remap_midi_channel(u8 midiChannel, u8 deviceChannel) { - u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID, - SYSEX_COMMAND_REMAP, midiChannel, deviceChannel }; + u8 sequence[] = { SYSEX_MANU_EXTENDED, SYSEX_MANU_REGION, SYSEX_MANU_ID, SYSEX_COMMAND_REMAP, + midiChannel, deviceChannel }; __real_midi_sysex(sequence, sizeof(sequence) / sizeof(sequence[0])); } -static void test_midi_fm_note_on_percussion_channel_sets_percussion_preset( - UNUSED void** state) +static void test_midi_fm_note_on_percussion_channel_sets_percussion_preset(UNUSED void** state) { const u8 MIDI_PERCUSSION_CHANNEL = 9; const u8 FM_CHANNEL = 5; @@ -541,10 +522,8 @@ static void test_midi_fm_note_on_percussion_channel_sets_percussion_preset( remap_midi_channel(MIDI_PERCUSSION_CHANNEL, FM_CHANNEL); const FmChannel P_BANK_0_INST_30_CASTANETS = { 4, 3, 3, 0, 0, 0, 0, - { { 9, 0, 31, 0, 11, 0, 15, 0, 15, 23, 0 }, - { 1, 0, 31, 0, 19, 0, 15, 0, 15, 15, 0 }, - { 4, 0, 31, 2, 20, 0, 15, 0, 15, 13, 0 }, - { 2, 0, 31, 2, 20, 0, 15, 0, 15, 13, 0 } } }; + { { 9, 0, 31, 0, 11, 0, 15, 0, 15, 23, 0 }, { 1, 0, 31, 0, 19, 0, 15, 0, 15, 15, 0 }, + { 4, 0, 31, 2, 20, 0, 15, 0, 15, 13, 0 }, { 2, 0, 31, 2, 20, 0, 15, 0, 15, 13, 0 } } }; expect_value(__wrap_synth_preset, channel, FM_CHANNEL); expect_memory(__wrap_synth_preset, preset, &P_BANK_0_INST_30_CASTANETS, @@ -564,21 +543,15 @@ static void test_midi_switching_program_retains_pan_setting(UNUSED void** state) expect_value(__wrap_synth_stereo, channel, chan); expect_value(__wrap_synth_stereo, mode, 1); - __real_midi_cc(0, CC_PAN, 127); const FmChannel M_BANK_0_INST_1_BRIGHTPIANO = { 5, 7, 3, 0, 0, 0, 0, - { { 4, 2, 27, 1, 9, 0, 11, 5, 6, 33, 0 }, - { 4, 5, 27, 1, 9, 0, 7, 9, 7, 18, 0 }, - { 1, 2, 27, 1, 5, 1, 10, 5, 6, 8, 0 }, - { 6, 5, 27, 1, 9, 0, 3, 8, 7, 9, 0 } } }; + { { 4, 2, 27, 1, 9, 0, 11, 5, 6, 33, 0 }, { 4, 5, 27, 1, 9, 0, 7, 9, 7, 18, 0 }, + { 1, 2, 27, 1, 5, 1, 10, 5, 6, 8, 0 }, { 6, 5, 27, 1, 9, 0, 3, 8, 7, 9, 0 } } }; expect_value(__wrap_synth_preset, channel, chan); expect_memory(__wrap_synth_preset, preset, &M_BANK_0_INST_1_BRIGHTPIANO, sizeof(M_BANK_0_INST_1_BRIGHTPIANO)); - expect_value(__wrap_synth_stereo, channel, chan); - expect_value(__wrap_synth_stereo, mode, 1); - __real_midi_program(chan, program); } @@ -602,8 +575,7 @@ static void test_midi_disables_fm_special_mode(UNUSED void** state) __real_midi_cc(0, expectedController, expectedValue); } -static void test_midi_sets_pitch_of_special_mode_ch3_operator( - UNUSED void** state) +static void test_midi_sets_pitch_of_special_mode_ch3_operator(UNUSED void** state) { for (u8 op = 0; op < 3; op++) { int midiChannel = 10 + op; @@ -619,8 +591,7 @@ static void test_midi_sets_pitch_of_special_mode_ch3_operator( } } -static void test_midi_sets_volume_of_special_mode_ch3_operator( - UNUSED void** state) +static void test_midi_sets_volume_of_special_mode_ch3_operator(UNUSED void** state) { for (u8 op = 0; op < 3; op++) { int midiChannel = 10 + op; @@ -653,8 +624,7 @@ static void test_midi_pitch_bends_special_mode_operator(UNUSED void** state) __real_midi_pitch_bend(chan, 0x6000); } -static void test_midi_pitch_bends_special_mode_op_independent_of_other_ops( - UNUSED void** state) +static void test_midi_pitch_bends_special_mode_op_independent_of_other_ops(UNUSED void** state) { expect_value(__wrap_synth_specialModePitch, op, 0); expect_value(__wrap_synth_specialModePitch, octave, 4); @@ -676,8 +646,7 @@ static void test_midi_pitch_bends_special_mode_op_independent_of_other_ops( __real_midi_note_on(11, MIDI_PITCH_C4, MAX_MIDI_VOLUME); } -static void test_midi_persists_pitch_bends_for_special_mode_op_between_notes( - UNUSED void** state) +static void test_midi_persists_pitch_bends_for_special_mode_op_between_notes(UNUSED void** state) { int chan = 10; @@ -701,8 +670,7 @@ static void test_midi_persists_pitch_bends_for_special_mode_op_between_notes( __real_midi_note_on(chan, MIDI_PITCH_C4, MAX_MIDI_VOLUME); } -static void test_midi_note_priority_respected_for_multiple_notes( - UNUSED void** state) +static void test_midi_note_priority_respected_for_multiple_notes(UNUSED void** state) { expect_synth_pitch(0, 4, 0x284); expect_synth_volume_any(); @@ -732,19 +700,18 @@ static void test_midi_note_priority_respected_for_multiple_notes( #define NOTE_PRIORITY_LENGTH 10 -static void test_midi_drops_note_when_note_priority_stack_full( - UNUSED void** state) +static void test_midi_drops_note_when_note_priority_stack_full(UNUSED void** state) { - const u16 expectedFreqNum[NOTE_PRIORITY_LENGTH] = { 0x25f, 0x284, 0x2a9, - 0x2d2, 0x2fd, 0x32a, 0x35a, 0x38e, 0x3c4, 0x3fd }; + const u16 expectedFreqNum[NOTE_PRIORITY_LENGTH] + = { 0x25f, 0x284, 0x2a9, 0x2d2, 0x2fd, 0x32a, 0x35a, 0x38e, 0x3c4, 0x3fd }; const u8 expectedOctave = 4; for (u16 i = 0; i < NOTE_PRIORITY_LENGTH; i++) { u8 pitch = 59 + i; u16 freqNum = expectedFreqNum[i]; - print_message("noteOn: pitch = %d, freqNum = 0x%x, octave = %d\n", - pitch, freqNum, expectedOctave); + print_message( + "noteOn: pitch = %d, freqNum = 0x%x, octave = %d\n", pitch, freqNum, expectedOctave); expect_synth_pitch(0, expectedOctave, freqNum); expect_synth_volume_any(); diff --git a/tests/unit/test_synth.c b/tests/unit/test_synth.c index 3c5fbcc..38ed06d 100644 --- a/tests/unit/test_synth.c +++ b/tests/unit/test_synth.c @@ -21,14 +21,10 @@ extern void __real_synth_operatorMultiple(u8 channel, u8 op, u8 multiple); extern void __real_synth_operatorDetune(u8 channel, u8 op, u8 detune); extern void __real_synth_operatorRateScaling(u8 channel, u8 op, u8 rateScaling); extern void __real_synth_operatorAttackRate(u8 channel, u8 op, u8 attackRate); -extern void __real_synth_operatorFirstDecayRate( - u8 channel, u8 op, u8 firstDecayRate); -extern void __real_synth_operatorSecondDecayRate( - u8 channel, u8 op, u8 secondDecayRate); -extern void __real_synth_operatorSecondaryAmplitude( - u8 channel, u8 op, u8 secondaryAmplitude); -extern void __real_synth_operatorAmplitudeModulation( - u8 channel, u8 op, u8 amplitudeModulation); +extern void __real_synth_operatorFirstDecayRate(u8 channel, u8 op, u8 firstDecayRate); +extern void __real_synth_operatorSecondDecayRate(u8 channel, u8 op, u8 secondDecayRate); +extern void __real_synth_operatorSecondaryAmplitude(u8 channel, u8 op, u8 secondaryAmplitude); +extern void __real_synth_operatorAmplitudeModulation(u8 channel, u8 op, u8 amplitudeModulation); extern void __real_synth_operatorReleaseRate(u8 channel, u8 op, u8 releaseRate); extern void __real_synth_operatorSsgEg(u8 channel, u8 op, u8 ssgEg); extern void __real_synth_pitchBend(u8 channel, u16 bend); @@ -62,10 +58,8 @@ static void set_initial_registers(void) expect_function_call(__wrap_Z80_releaseBus); const FmChannel M_BANK_0_INST_0_GRANDPIANO = { 0, 0, 3, 0, 0, 0, 0, - { { 1, 0, 26, 1, 7, 0, 7, 4, 1, 35, 0 }, - { 4, 6, 24, 1, 9, 0, 6, 9, 7, 35, 0 }, - { 2, 7, 31, 3, 23, 0, 9, 15, 1, 35, 0 }, - { 1, 3, 27, 2, 4, 0, 10, 4, 6, 35, 0 } } }; + { { 1, 0, 26, 1, 7, 0, 7, 4, 1, 35, 0 }, { 4, 6, 24, 1, 9, 0, 6, 9, 7, 35, 0 }, + { 2, 7, 31, 3, 23, 0, 9, 15, 1, 35, 0 }, { 1, 3, 27, 2, 4, 0, 10, 4, 6, 35, 0 } } }; __real_synth_init(&M_BANK_0_INST_0_GRANDPIANO); } @@ -141,8 +135,7 @@ static void test_synth_sets_stereo_ams_and_freq(UNUSED void** state) __real_synth_stereo(chan, stereo); expect_ym2612_write_channel_any_data(chan, baseReg); __real_synth_ams(chan, ams); - expect_ym2612_write_channel( - chan, baseReg, (stereo << 6) + (ams << 4) + fms); + expect_ym2612_write_channel(chan, baseReg, (stereo << 6) + (ams << 4) + fms); __real_synth_fms(chan, fms); } } @@ -152,8 +145,7 @@ static void test_synth_sets_algorithm(UNUSED void** state) const u8 defaultFeedback = 0; const u8 algorithm = 1; for (u8 chan = 0; chan < MAX_FM_CHANS; chan++) { - expect_ym2612_write_channel( - chan, 0xB0, (defaultFeedback << 3) + algorithm); + expect_ym2612_write_channel(chan, 0xB0, (defaultFeedback << 3) + algorithm); __real_synth_algorithm(chan, algorithm); } } @@ -163,8 +155,7 @@ static void test_synth_sets_feedback(UNUSED void** state) const u8 defaultAlgorithm = 0; const u8 feedback = 1; for (u8 chan = 0; chan < MAX_FM_CHANS; chan++) { - expect_ym2612_write_channel( - chan, 0xB0, (feedback << 3) + defaultAlgorithm); + expect_ym2612_write_channel(chan, 0xB0, (feedback << 3) + defaultAlgorithm); __real_synth_feedback(chan, feedback); } } @@ -177,8 +168,7 @@ static void test_synth_sets_feedback_and_algorithm(UNUSED void** state) u8 feedback = 1; u8 algorithm = 1; - expect_ym2612_write_channel( - chan, baseReg, (defaultFeedback << 3) + algorithm); + expect_ym2612_write_channel(chan, baseReg, (defaultFeedback << 3) + algorithm); __real_synth_algorithm(chan, feedback); expect_ym2612_write_channel(chan, baseReg, (feedback << 3) + algorithm); __real_synth_feedback(chan, feedback); @@ -188,8 +178,7 @@ static void test_synth_sets_feedback_and_algorithm(UNUSED void** state) } } -static void test_synth_does_not_reset_operator_level_if_equal( - UNUSED void** state) +static void test_synth_does_not_reset_operator_level_if_equal(UNUSED void** state) { const u8 baseReg = 0x40; const u8 totalLevel = 50; @@ -222,8 +211,7 @@ static void test_synth_sets_operator_multiple_and_detune(UNUSED void** state) for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { expect_ym2612_write_operator_any_data(chan, op, baseReg); __real_synth_operatorMultiple(chan, op, multiple); - expect_ym2612_write_operator( - chan, op, baseReg, (detune << 4) | multiple); + expect_ym2612_write_operator(chan, op, baseReg, (detune << 4) | multiple); __real_synth_operatorDetune(chan, op, detune); multiple++; detune++; @@ -231,8 +219,7 @@ static void test_synth_sets_operator_multiple_and_detune(UNUSED void** state) } } -static void test_synth_sets_operator_attack_rate_and_rate_scaling( - UNUSED void** state) +static void test_synth_sets_operator_attack_rate_and_rate_scaling(UNUSED void** state) { const u8 baseReg = 0x50; for (u8 chan = 0; chan < MAX_FM_CHANS; chan++) { @@ -241,8 +228,7 @@ static void test_synth_sets_operator_attack_rate_and_rate_scaling( for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { expect_ym2612_write_operator_any_data(chan, op, baseReg); __real_synth_operatorAttackRate(chan, op, attackRate); - expect_ym2612_write_operator( - chan, op, baseReg, attackRate | (rateScaling << 6)); + expect_ym2612_write_operator(chan, op, baseReg, attackRate | (rateScaling << 6)); __real_synth_operatorRateScaling(chan, op, rateScaling); attackRate++; rateScaling++; @@ -262,8 +248,7 @@ static void test_synth_sets_operator_second_decay_rate(UNUSED void** state) } } -static void test_synth_sets_operator_release_rate_and_secondary_amplitude( - UNUSED void** state) +static void test_synth_sets_operator_release_rate_and_secondary_amplitude(UNUSED void** state) { const u8 baseReg = 0x80; u8 secondaryAmplitude = 15; @@ -271,8 +256,7 @@ static void test_synth_sets_operator_release_rate_and_secondary_amplitude( for (u8 chan = 0; chan < MAX_FM_CHANS; chan++) { for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { expect_ym2612_write_operator_any_data(chan, op, baseReg); - __real_synth_operatorSecondaryAmplitude( - chan, op, secondaryAmplitude); + __real_synth_operatorSecondaryAmplitude(chan, op, secondaryAmplitude); expect_ym2612_write_operator( chan, op, baseReg, releaseRate + (secondaryAmplitude << 4)); __real_synth_operatorReleaseRate(chan, op, releaseRate); @@ -280,8 +264,7 @@ static void test_synth_sets_operator_release_rate_and_secondary_amplitude( } } -static void test_synth_sets_operator_amplitude_modulation_and_first_decay_rate( - UNUSED void** state) +static void test_synth_sets_operator_amplitude_modulation_and_first_decay_rate(UNUSED void** state) { const u8 baseReg = 0x60; u8 amplitudeModulation = 1; @@ -292,8 +275,7 @@ static void test_synth_sets_operator_amplitude_modulation_and_first_decay_rate( __real_synth_operatorFirstDecayRate(chan, op, firstDecayRate); expect_ym2612_write_operator( chan, op, baseReg, firstDecayRate + (amplitudeModulation << 7)); - __real_synth_operatorAmplitudeModulation( - chan, op, amplitudeModulation); + __real_synth_operatorAmplitudeModulation(chan, op, amplitudeModulation); } } } @@ -334,10 +316,8 @@ static void test_synth_sets_preset(UNUSED void** state) const u8 chan = 0; const FmChannel M_BANK_0_INST_7_CLAVINET = { 1, 7, 3, 0, 0, 0, 0, - { { 1, 1, 31, 2, 0, 1, 0, 1, 6, 28, 0 }, - { 1, 3, 31, 2, 0, 0, 0, 1, 7, 33, 0 }, - { 1, 5, 31, 3, 0, 1, 0, 0, 2, 30, 0 }, - { 1, 7, 31, 0, 6, 0, 4, 6, 7, 6, 0 } } }; + { { 1, 1, 31, 2, 0, 1, 0, 1, 6, 28, 0 }, { 1, 3, 31, 2, 0, 0, 0, 1, 7, 33, 0 }, + { 1, 5, 31, 3, 0, 1, 0, 0, 2, 30, 0 }, { 1, 7, 31, 0, 6, 0, 4, 6, 7, 6, 0 } } }; expect_ym2612_write_channel_any_data(chan, 0xB0); expect_ym2612_write_channel_any_data(chan, 0xB4); @@ -386,8 +366,7 @@ static void test_synth_applies_volume_modifier_to_output_operators_algorithm_7( __real_synth_algorithm(chan, algorithm); for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { - expect_ym2612_write_operator( - chan, op, totalLevelReg, loudestTotalLevel); + expect_ym2612_write_operator(chan, op, totalLevelReg, loudestTotalLevel); } for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { __real_synth_operatorTotalLevel(chan, op, loudestTotalLevel); @@ -395,14 +374,12 @@ static void test_synth_applies_volume_modifier_to_output_operators_algorithm_7( const u8 expectedTotalLevel = 0xb; for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { - expect_ym2612_write_operator( - chan, op, totalLevelReg, expectedTotalLevel); + expect_ym2612_write_operator(chan, op, totalLevelReg, expectedTotalLevel); } __real_synth_volume(chan, loudestVolume / 2); for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { - expect_ym2612_write_operator( - chan, op, totalLevelReg, loudestTotalLevel); + expect_ym2612_write_operator(chan, op, totalLevelReg, loudestTotalLevel); } __real_synth_volume(chan, loudestVolume); } @@ -420,8 +397,7 @@ static void test_synth_does_not_apply_volume_if_equal(UNUSED void** state) __real_synth_algorithm(chan, algorithm); for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { - expect_ym2612_write_operator( - chan, op, totalLevelReg, loudestTotalLevel); + expect_ym2612_write_operator(chan, op, totalLevelReg, loudestTotalLevel); } for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { __real_synth_operatorTotalLevel(chan, op, loudestTotalLevel); @@ -429,16 +405,14 @@ static void test_synth_does_not_apply_volume_if_equal(UNUSED void** state) const u8 expectedTotalLevel = 0xb; for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { - expect_ym2612_write_operator( - chan, op, totalLevelReg, expectedTotalLevel); + expect_ym2612_write_operator(chan, op, totalLevelReg, expectedTotalLevel); } __real_synth_volume(chan, loudestVolume / 2); __real_synth_volume(chan, loudestVolume / 2); } -static void -test_synth_applies_volume_modifier_to_output_operators_algorithm_7_quieter( +static void test_synth_applies_volume_modifier_to_output_operators_algorithm_7_quieter( UNUSED void** state) { const u8 algorithm = 7; @@ -451,8 +425,7 @@ test_synth_applies_volume_modifier_to_output_operators_algorithm_7_quieter( __real_synth_algorithm(chan, algorithm); for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { - expect_ym2612_write_operator( - chan, op, totalLevelReg, loudestTotalLevel); + expect_ym2612_write_operator(chan, op, totalLevelReg, loudestTotalLevel); } for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { __real_synth_operatorTotalLevel(chan, op, loudestTotalLevel); @@ -460,15 +433,13 @@ test_synth_applies_volume_modifier_to_output_operators_algorithm_7_quieter( const u8 expectedTotalLevel = 0x26; for (u8 op = 0; op < MAX_FM_OPERATORS; op++) { - expect_ym2612_write_operator( - chan, op, totalLevelReg, expectedTotalLevel); + expect_ym2612_write_operator(chan, op, totalLevelReg, expectedTotalLevel); } __real_synth_volume(chan, loudestVolume / 4); } } -static void -test_synth_applies_volume_modifier_to_output_operators_algorithms_0_to_3( +static void test_synth_applies_volume_modifier_to_output_operators_algorithms_0_to_3( UNUSED void** state) { const u8 totalLevelReg = 0x40; @@ -494,8 +465,7 @@ test_synth_applies_volume_modifier_to_output_operators_algorithms_0_to_3( } } -static void test_synth_applies_volume_modifier_to_output_operators_algorithm_4( - UNUSED void** state) +static void test_synth_applies_volume_modifier_to_output_operators_algorithm_4(UNUSED void** state) { const u8 totalLevelReg = 0x40; const u8 algorithmReg = 0xB0; @@ -514,8 +484,7 @@ static void test_synth_applies_volume_modifier_to_output_operators_algorithm_4( } } -static void -test_synth_applies_volume_modifier_to_output_operators_algorithms_5_and_6( +static void test_synth_applies_volume_modifier_to_output_operators_algorithms_5_and_6( UNUSED void** state) { const u8 totalLevelReg = 0x40; @@ -561,16 +530,14 @@ static void updateCallback(u8 chan, ParameterUpdated parameterUpdated) lastParameterUpdated = parameterUpdated; } -static void test_synth_calls_callback_when_parameter_changes( - UNUSED void** state) +static void test_synth_calls_callback_when_parameter_changes(UNUSED void** state) { synth_setParameterUpdateCallback(&updateCallback); const u8 defaultFeedback = 0; const u8 algorithm = 1; u8 fmChan = 1; - expect_ym2612_write_channel( - fmChan, 0xB0, (defaultFeedback << 3) + algorithm); + expect_ym2612_write_channel(fmChan, 0xB0, (defaultFeedback << 3) + algorithm); __real_synth_algorithm(fmChan, algorithm); assert_true(updated); @@ -589,8 +556,7 @@ static void test_synth_calls_callback_when_lfo_freq_changes(UNUSED void** state) assert_int_equal(lastParameterUpdated, Lfo); } -static void test_synth_calls_callback_when_lfo_enable_changes( - UNUSED void** state) +static void test_synth_calls_callback_when_lfo_enable_changes(UNUSED void** state) { synth_setParameterUpdateCallback(&updateCallback); @@ -601,8 +567,7 @@ static void test_synth_calls_callback_when_lfo_enable_changes( assert_int_equal(lastParameterUpdated, Lfo); } -static void test_synth_calls_callback_when_special_mode_changes( - UNUSED void** state) +static void test_synth_calls_callback_when_special_mode_changes(UNUSED void** state) { synth_setParameterUpdateCallback(&updateCallback); @@ -625,8 +590,7 @@ static void test_synth_disables_ch3_special_mode(UNUSED void** state) __real_synth_setSpecialMode(false); } -static void test_synth_sets_ch3_special_mode_operator_pitches( - UNUSED void** state) +static void test_synth_sets_ch3_special_mode_operator_pitches(UNUSED void** state) { const u8 upperRegs[] = { 0xAD, 0xAE, 0xAC }; const u8 lowerRegs[] = { 0xA9, 0xAA, 0xA8 }; @@ -639,8 +603,7 @@ static void test_synth_sets_ch3_special_mode_operator_pitches( } } -static void test_synth_handles_out_of_range_ch3_special_mode_operator( - UNUSED void** state) +static void test_synth_handles_out_of_range_ch3_special_mode_operator(UNUSED void** state) { const u8 op = 3; // invalid op expect_ym2612_write_reg(0, 0xAD, 0x22); // safely wrap to valid reg @@ -704,57 +667,49 @@ static void synth_sets_ch3_special_mode_op_tl_only_if_output_operator(int alg) } } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_0( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_0( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(0); } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_1( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_1( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(1); } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_2( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_2( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(2); } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_3( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_3( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(3); } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_4( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_4( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(4); } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_5( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_5( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(5); } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_6( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_6( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(6); } -static void -test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_7( +static void test_synth_sets_ch3_special_mode_op_tl_only_if_output_operator_alg_7( UNUSED void** state) { synth_sets_ch3_special_mode_op_tl_only_if_output_operator(7); @@ -788,8 +743,7 @@ static void test_requests_Z80_bus_if_not_already_taken(UNUSED void** state) __real_synth_directWriteYm2612(0, 0x2B, 0); } -static void test_does_not_release_Z80_bus_when_taken_prior_to_call( - UNUSED void** state) +static void test_does_not_release_Z80_bus_when_taken_prior_to_call(UNUSED void** state) { expect_value(__wrap_Z80_getAndRequestBus, wait, TRUE); will_return(__wrap_Z80_getAndRequestBus, true);