diff --git a/src/device/sequencer.rs b/src/device/sequencer.rs index 7470ba74..47a8018e 100644 --- a/src/device/sequencer.rs +++ b/src/device/sequencer.rs @@ -70,12 +70,13 @@ pub fn process (state: &mut Sequencer, client: &Client, scope: &ProcessScope) -> } fn process_in (state: &mut Sequencer, scope: &ProcessScope) { - let pos = state.transport.query().unwrap().pos; - let usecs = Frame(pos.frame()).to_usec(&state.rate).0; - let beat = usecs / state.tempo.usec_per_beat().0; - let step = usecs / state.tempo.usec_per_step(state.divisions as u64).0; - let tick_usec = state.tempo.usec_per_step(state.ppq).0; - let tick = usecs / tick_usec; + let pos = state.transport.query().unwrap().pos; + let usecs = Frame(pos.frame()).to_usec(&state.rate).0; + let step = state.tempo.usec_per_step(state.divisions as u64).0; + let steps = usecs / step; + let step = steps % state.steps; + let tick = step * state.ppq / state.divisions; + for event in state.input_port.iter(scope) { match midly::live::LiveEvent::parse(event.bytes).unwrap() { midly::live::LiveEvent::Midi { channel, message } => match message {