Skip to content

Commit

Permalink
Use latest reaper-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Feb 29, 2024
1 parent 6e8945a commit f922781
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions main/src/domain/midi_types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use reaper_medium::{Hz, MidiFrameOffset};
use reaper_medium::{Hz, MIDI_INPUT_FRAME_RATE};

#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MidiEvent<T> {
Expand Down Expand Up @@ -30,8 +30,8 @@ pub struct SampleOffset(u64);
impl SampleOffset {
pub const ZERO: SampleOffset = SampleOffset(0);

pub fn from_frame_offset(frame_offset: MidiFrameOffset, sample_rate: Hz) -> Self {
let offset_in_secs = frame_offset.get() as f64 / 1024000.0;
pub fn from_midi_input_frame_offset(frame_offset: u32, sample_rate: Hz) -> Self {
let offset_in_secs = frame_offset as f64 / MIDI_INPUT_FRAME_RATE.get();
let offset_in_samples = (offset_in_secs * sample_rate.get()).round() as u64;
SampleOffset(offset_in_samples)
}
Expand Down
2 changes: 1 addition & 1 deletion main/src/domain/real_time_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ impl<'a> MidiEvent<IncomingMidiMessage<'a>> {
) -> Result<Self, &'static str> {
let msg = IncomingMidiMessage::from_reaper(e.message())?;
// Frame offset is given in 1/1024000 of a second, *not* sample frames!
let offset = SampleOffset::from_frame_offset(e.frame_offset(), sample_rate);
let offset = SampleOffset::from_midi_input_frame_offset(e.frame_offset(), sample_rate);
Ok(MidiEvent::new(offset, msg))
}
}
Expand Down
2 changes: 1 addition & 1 deletion playtime-clip-engine

0 comments on commit f922781

Please sign in to comment.