Prohibit trigger of note on instrument-less FM channel

master
Ashley N. 2023-08-28 22:37:34 -04:00
parent a44a986009
commit 6886040535
1 changed files with 12 additions and 1 deletions

View File

@ -312,7 +312,18 @@ pub fn get_events_for_channel( channels: &mut [Channel], active_channel: usize,
channels[ active_channel ].note_keyed = false;
events.push( vec![ ESF_NOTE_OFF | channels[ active_channel ].id ] );
} else {
channels[ active_channel ].note_keyed = true;
// Determine if we can key on. We can't key on if we are in FM1..FM6, and no instrument was ever set
// on the channel either here or previously. (We can do that for psg, using the default instrument.)
channels[ active_channel ].note_keyed = if ( ESF_FM_1..=ESF_FM_3 ).contains( &channels[ active_channel ].id ) | ( ESF_FM_4..=ESF_FM_6 ).contains( &channels[ active_channel ].id ) {
if channels[ active_channel ].active_instrument.is_none() {
print_warning( "no instrument set on this fm channel - cannot trigger the note!" );
false
} else {
true
}
} else {
true
};
channels[ active_channel ].active_note = Some(
OctaveFrequency {
octave: note.get_octave()?,