diff --git a/Cargo.lock b/Cargo.lock index fee6d1d24..43604ebd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2822,7 +2822,6 @@ dependencies = [ [[package]] name = "reaper-high" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#4df234525bf25311e827a0ceef1241002ebb888b" dependencies = [ "backtrace", "c_str_macro", @@ -2848,7 +2847,6 @@ dependencies = [ [[package]] name = "reaper-low" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#4df234525bf25311e827a0ceef1241002ebb888b" dependencies = [ "c_str_macro", "cc", @@ -2862,7 +2860,6 @@ dependencies = [ [[package]] name = "reaper-macros" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#4df234525bf25311e827a0ceef1241002ebb888b" dependencies = [ "darling 0.10.2", "quote 1.0.9", @@ -2872,7 +2869,6 @@ dependencies = [ [[package]] name = "reaper-medium" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#4df234525bf25311e827a0ceef1241002ebb888b" dependencies = [ "c_str_macro", "derive_more", @@ -2890,7 +2886,6 @@ dependencies = [ [[package]] name = "reaper-rx" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#4df234525bf25311e827a0ceef1241002ebb888b" dependencies = [ "crossbeam-channel", "helgoboss-midi", diff --git a/main/Cargo.toml b/main/Cargo.toml index a4f5cee6d..0bcc963df 100644 --- a/main/Cargo.toml +++ b/main/Cargo.toml @@ -16,14 +16,14 @@ generate = [] prometheus = ["serde_prometheus"] [dependencies] -reaper-rx = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master" } -reaper-high = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master", features = ["serde"] } -reaper-medium = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master", features = ["serde"] } -reaper-low = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master" } -#reaper-rx = { path = "../../reaper-rs/main/rx" } -#reaper-high = { path = "../../reaper-rs/main/high", features = ["serde"] } -#reaper-medium= { path = "../../reaper-rs/main/medium", features = ["serde"] } -#reaper-low = { path = "../../reaper-rs/main/low" } +#reaper-rx = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master" } +#reaper-high = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master", features = ["serde"] } +#reaper-medium = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master", features = ["serde"] } +#reaper-low = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master" } +reaper-rx = { path = "../../reaper-rs/main/rx" } +reaper-high = { path = "../../reaper-rs/main/high", features = ["serde"] } +reaper-medium= { path = "../../reaper-rs/main/medium", features = ["serde"] } +reaper-low = { path = "../../reaper-rs/main/low" } swell-ui = { path = "../swell-ui" } rx-util = { path = "../rx-util" } helgoboss-midi = { version = "0.2", features = ["serde", "serde_repr"] } diff --git a/main/lib/helgoboss-learn b/main/lib/helgoboss-learn index a893766dc..0863734ee 160000 --- a/main/lib/helgoboss-learn +++ b/main/lib/helgoboss-learn @@ -1 +1 @@ -Subproject commit a893766dcbacc016a6681db70b3a388a7d9206ca +Subproject commit 0863734eed0070f421e6a5ae2b047b0e350bcea9 diff --git a/main/src/domain/targets/action_target.rs b/main/src/domain/targets/action_target.rs index 01aed9c60..8f672f314 100644 --- a/main/src/domain/targets/action_target.rs +++ b/main/src/domain/targets/action_target.rs @@ -2,9 +2,11 @@ use crate::domain::ui_util::convert_bool_to_unit_value; use crate::domain::{ ActionInvocationType, AdditionalFeedbackEvent, ControlContext, RealearnTarget, TargetCharacter, }; -use helgoboss_learn::{ControlType, ControlValue, Target, UnitValue}; +use helgoboss_learn::{ControlType, ControlValue, Fraction, Target, UnitValue}; +use helgoboss_midi::U14; use reaper_high::{Action, ActionCharacter, Project, Reaper}; -use reaper_medium::CommandId; +use reaper_medium::{ActionValueChange, CommandId, WindowContext}; +use std::convert::TryFrom; #[derive(Clone, Debug, PartialEq)] pub struct ActionTarget { @@ -49,11 +51,11 @@ impl RealearnTarget for ActionTarget { ControlValue::Absolute(v) => match self.invocation_type { ActionInvocationType::Trigger => { if !v.is_zero() { - self.action.invoke(v.get(), false, Some(self.project)); + self.invoke_with_unit_value(v); } } ActionInvocationType::Absolute => { - self.action.invoke(v.get(), false, Some(self.project)) + self.invoke_with_unit_value(v); } ActionInvocationType::Relative => { return Err("relative invocation type can't take absolute values"); @@ -66,6 +68,17 @@ impl RealearnTarget for ActionTarget { return Err("relative values need relative invocation type"); } } + ControlValue::AbsoluteDiscrete(f) => match self.invocation_type { + ActionInvocationType::Trigger => { + if !f.is_zero() { + self.invoke_with_fraction(f) + } + } + ActionInvocationType::Absolute => self.invoke_with_fraction(f), + ActionInvocationType::Relative => { + return Err("relative invocation type can't take absolute values"); + } + }, }; Ok(()) } @@ -114,3 +127,21 @@ impl<'a> Target<'a> for ActionTarget { self.control_type_and_character().0 } } + +impl ActionTarget { + fn invoke_with_fraction(&self, f: Fraction) { + if let Ok(u14) = U14::try_from(f.actual()) { + self.action.invoke_directly( + ActionValueChange::AbsoluteHighRes(u14), + WindowContext::Win(Reaper::get().main_window()), + self.project.context(), + ); + } + } +} + +impl ActionTarget { + fn invoke_with_unit_value(&self, v: UnitValue) { + self.action.invoke(v.get(), false, Some(self.project)) + } +} diff --git a/swell-ui/Cargo.toml b/swell-ui/Cargo.toml index 1fd8a1192..94a5ac447 100644 --- a/swell-ui/Cargo.toml +++ b/swell-ui/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Benjamin Klum "] edition = "2018" [dependencies] - reaper-low = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master" } -#reaper-low = { path = "../../reaper-rs/main/low" } +# reaper-low = { git = "https://github.com/helgoboss/reaper-rs.git", branch = "master" } +reaper-low = { path = "../../reaper-rs/main/low" } rxrust = { git = "https://github.com/rxRust/rxRust", branch = "master" } rx-util = { path = "../rx-util" } scopeguard = "1.1.0"