aboutsummaryrefslogtreecommitdiff
path: root/src/convert.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/convert.rs')
-rw-r--r--src/convert.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/convert.rs b/src/convert.rs
index 2cbe15b..ca45e4a 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -2,7 +2,7 @@ use std::collections::{BTreeMap, BTreeSet};
use std::any::Any;
use std::cell::RefCell;
use crate::itfile;
-use crate::utils;
+use crate::utils::Rational;
use crate::midifile;
use crate::portmod::Effect;
@@ -41,7 +41,7 @@ trait CellHandler
trait EffectHandler
{
- fn process(&mut self, ch: u8, cell: itfile::Cell, chmem: &mut ChannelMemory) -> Vec<midifile::TimedMidiEvent>;
+ fn process(&mut self, ch: u8, cell: itfile::Cell, chmem: &mut ChannelMemory, ps: PlayerState, mt: Rational) -> Vec<midifile::TimedMidiEvent>;
fn handled_effects(&self) -> Vec<u8>;
}
@@ -57,11 +57,12 @@ struct ChannelMemory
note: u8,
vol: u8,
efxmem: [u8; 32],
- pitch: utils::Rational
+ pitch: Rational
}
struct ConvertCellHandler<'a>
{
+ miditick: Rational,
chmem: [ChannelMemory; 64],
fx_handlers: Vec<Box<RefCell<dyn EffectHandler + 'a>>>
}
@@ -228,6 +229,10 @@ impl<'a> CellHandler for ConvertCellHandler<'a>
fn process(&mut self, ch: u8, cell: itfile::Cell, ps: PlayerState) -> PlayerState
{
let itfile::Cell{mask, note, inst, vol, efx, fxp} = cell;
+ if !ch == 0
+ {
+ self.miditick += <Rational as From<u32>>::from(960) / (ps.speed as u16 * 4).into();
+ }
ps
}
fn result_data(&mut self) -> Box<dyn Any>