Set instrument and volume before key on, oopsie-woopsie
parent
4001f8d3cc
commit
0b86436ff7
|
@ -215,6 +215,23 @@ fn get_portamento( channel: &mut Channel, portamento_effect: &Effect ) -> Result
|
||||||
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 ) -> Result<Vec<EchoEvent>, Box<dyn Error>> {
|
||||||
let mut events: Vec<EchoEvent> = Vec::new();
|
let mut events: Vec<EchoEvent> = Vec::new();
|
||||||
|
|
||||||
|
// Adjust volume
|
||||||
|
if let Some( volume ) = &row.volume {
|
||||||
|
// https://github.com/sikthehedgehog/Echo/blob/master/doc/esf.txt#L206-L207
|
||||||
|
let volume = get_volume( channel.id, *volume )?;
|
||||||
|
channel.current_volume = Some( volume );
|
||||||
|
events.push( vec![ ESF_SET_VOLUME | channel.id, volume ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the instrument
|
||||||
|
if let Some( instrument ) = &row.instrument_index {
|
||||||
|
// Do not set the same instrument if it was already set before
|
||||||
|
if &row.instrument_index != &channel.active_instrument {
|
||||||
|
events.push( vec![ ESF_SET_INSTRUMENT | channel.id, *instrument as u8 ] );
|
||||||
|
channel.active_instrument = Some( *instrument );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Key on or key off note
|
// Key on or key off note
|
||||||
if let Some( note ) = &row.note {
|
if let Some( note ) = &row.note {
|
||||||
if let Note::NoteOff = note {
|
if let Note::NoteOff = note {
|
||||||
|
@ -241,23 +258,6 @@ fn get_events_for_channel( channel: &mut Channel, row: &PatternRow ) -> Result<V
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust volume
|
|
||||||
if let Some( volume ) = &row.volume {
|
|
||||||
// https://github.com/sikthehedgehog/Echo/blob/master/doc/esf.txt#L206-L207
|
|
||||||
let volume = get_volume( channel.id, *volume )?;
|
|
||||||
channel.current_volume = Some( volume );
|
|
||||||
events.push( vec![ ESF_SET_VOLUME | channel.id, volume ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change instrument
|
|
||||||
if let Some( instrument ) = &row.instrument_index {
|
|
||||||
// Do not set the same instrument if it was already set before
|
|
||||||
if &row.instrument_index != &channel.active_instrument {
|
|
||||||
events.push( vec![ ESF_SET_INSTRUMENT | channel.id, *instrument as u8 ] );
|
|
||||||
channel.active_instrument = Some( *instrument );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok( events )
|
Ok( events )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue