From 01da82a42824824dd449f81412e7e6be6658b34e Mon Sep 17 00:00:00 2001 From: ashley Date: Mon, 28 Aug 2023 23:38:15 -0400 Subject: [PATCH] Set the default instrument on psg channel if you attempted to set an invalid instrument on it before and it failed --- src/reskit/soundtrack/engines/echo/engine.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/reskit/soundtrack/engines/echo/engine.rs b/src/reskit/soundtrack/engines/echo/engine.rs index 99fe120..3fbf161 100644 --- a/src/reskit/soundtrack/engines/echo/engine.rs +++ b/src/reskit/soundtrack/engines/echo/engine.rs @@ -311,6 +311,17 @@ fn get_events_for_channel( channels: &mut [Channel], active_channel: usize, row: channels[ active_channel ].active_instrument = Some( *instrument ); } else { print_warning( "attempted to set an fm instrument on a psg channel, or vice versa. the instrument was not set - your soundtrack may sound different than expected." ); + // Now if current channel is PSG1 through PSG4, it's gonna need an instrument set on it. + if channels[ active_channel ].active_instrument.is_none() && ( ESF_PSG_1..=ESF_PSG_4 ).contains( &channels[ active_channel ].id ) { + print_warning( "this is a psg channel, seting the default psg instrument so your note can still play..." ); + if row.note.is_some() { + // Set "__reskit_default_psg_instrument" + let instrument = instrument_set.default_psg_id.ok_or( "internal error: no default psg instrument to apply" )?; + + events.push( vec![ ESF_SET_INSTRUMENT | channels[ active_channel ].id, instrument as u8 ] ); + channels[ active_channel ].active_instrument = Some( instrument ); + } + } } } } else {