Add required offset to pcm instrument note triggers

master
Ashley N. 2023-08-25 23:31:16 -04:00
parent 546376cc02
commit 686d44b137
2 changed files with 6 additions and 5 deletions

View File

@ -230,7 +230,7 @@ fn get_portamento( channel: &mut Channel, portamento_effect: &Effect ) -> Result
* For a specific row and channel, get the events this row and channel contribute to the stream. * For a specific row and channel, get the events this row and channel contribute to the stream.
* While doing so, update the state of the channel for future event generation. * While doing so, update the state of the channel for future event generation.
*/ */
fn get_events_for_channel( channel: &mut Channel, row: &PatternRow ) -> Result<Vec<EchoEvent>, Box<dyn Error>> { fn get_events_for_channel( channel: &mut Channel, row: &PatternRow, pcm_offset: u8 ) -> Result<Vec<EchoEvent>, Box<dyn Error>> {
let mut events: Vec<EchoEvent> = Vec::new(); let mut events: Vec<EchoEvent> = Vec::new();
// Adjust volume // Adjust volume
@ -264,7 +264,7 @@ fn get_events_for_channel( channel: &mut Channel, row: &PatternRow ) -> Result<V
); );
if channel.id == ESF_FM_6_PCM { if channel.id == ESF_FM_6_PCM {
events.push( vec![ ESF_NOTE_ON | channel.id, get_pcm_index( note )? ] ); events.push( vec![ ESF_NOTE_ON | channel.id, get_pcm_index( note )? + pcm_offset ] );
} else { } else {
let note = get_note( note, channel.id )?; let note = get_note( note, channel.id )?;
events.push( vec![ ESF_NOTE_ON | channel.id, note ] ); events.push( vec![ ESF_NOTE_ON | channel.id, note ] );
@ -473,7 +473,7 @@ fn get_delays( events: Vec<EchoEvent>, channels: &mut [Channel], ticks_to_wait:
* For an entire row across all channels, generate the events that apply to the row as a whole. This usually means applying * For an entire row across all channels, generate the events that apply to the row as a whole. This usually means applying
* the waits so that the row can be flushed to Echo and played - ESF ticks are until the nearest wait or stop event. * the waits so that the row can be flushed to Echo and played - ESF ticks are until the nearest wait or stop event.
*/ */
pub fn get_events_for_row( channels: &mut [Channel], subrows: Vec<&PatternRow>, ticks_to_wait: u8 ) -> Result<Vec<EchoEvent>, Box<dyn Error>> { pub fn get_events_for_row( channels: &mut [Channel], subrows: Vec<&PatternRow>, ticks_to_wait: u8, pcm_offset: u8 ) -> Result<Vec<EchoEvent>, Box<dyn Error>> {
let mut events: Vec<EchoEvent> = Vec::new(); let mut events: Vec<EchoEvent> = Vec::new();
// Get events for each subrow (part of the total row for each channel) // Get events for each subrow (part of the total row for each channel)
@ -482,7 +482,7 @@ pub fn get_events_for_row( channels: &mut [Channel], subrows: Vec<&PatternRow>,
events.extend( apply_effects_to_channel( &mut channels[ i ], &subrows[ i ].effects )? ); events.extend( apply_effects_to_channel( &mut channels[ i ], &subrows[ i ].effects )? );
// Get the ESF events for this channel's part of the row // Get the ESF events for this channel's part of the row
events.extend( get_events_for_channel( &mut channels[ i ], subrows[ i ] )? ); events.extend( get_events_for_channel( &mut channels[ i ], subrows[ i ], pcm_offset )? );
} }
Ok( get_delays( events, channels, ticks_to_wait )? ) Ok( get_delays( events, channels, ticks_to_wait )? )

View File

@ -935,7 +935,8 @@ impl EchoFormat for DmfModule {
self.speed_a * self.time_base self.speed_a * self.time_base
} else { } else {
self.speed_b * self.time_base self.speed_b * self.time_base
} },
self.instruments.len() as u8
)?; )?;
// Transfer ESF events to the main stream // Transfer ESF events to the main stream