diff --git a/Cargo.lock b/Cargo.lock index 282c92f3a..381a425f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5562,7 +5562,6 @@ dependencies = [ [[package]] name = "reaper-common-types" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "hex-literal", "nutype", @@ -5573,7 +5572,6 @@ dependencies = [ [[package]] name = "reaper-fluent" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "fragile", "reaper-low", @@ -5584,7 +5582,6 @@ dependencies = [ [[package]] name = "reaper-high" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "backtrace", "base64 0.13.0", @@ -5613,7 +5610,6 @@ dependencies = [ [[package]] name = "reaper-low" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "c_str_macro", "cc 1.0.83", @@ -5627,7 +5623,6 @@ dependencies = [ [[package]] name = "reaper-macros" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "darling 0.10.2", "quote", @@ -5637,7 +5632,6 @@ dependencies = [ [[package]] name = "reaper-medium" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "c_str_macro", "camino", @@ -5658,7 +5652,6 @@ dependencies = [ [[package]] name = "reaper-rx" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "crossbeam-channel", "helgoboss-midi", @@ -5912,7 +5905,6 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" [[package]] name = "rppxml-parser" version = "0.1.0" -source = "git+https://github.com/helgoboss/reaper-rs.git?branch=master#73dc35cf71548a5649d1655b514b2d8a7b5860e9" dependencies = [ "splitty", ] diff --git a/Cargo.toml b/Cargo.toml index b7234e8a2..859dd53fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -182,15 +182,15 @@ vst = { git = "https://github.com/helgoboss/vst-rs.git", branch = "feature/param #vst = { path = "../vst-rs" } # This is for temporary development with local reaper-rs. -#[patch.'https://github.com/helgoboss/reaper-rs.git'] -#reaper-common-types = { path = "../reaper-rs/main/common-types" } -#reaper-fluent = { path = "../reaper-rs/main/fluent" } -#reaper-high = { path = "../reaper-rs/main/high" } -#reaper-medium = { path = "../reaper-rs/main/medium" } -#reaper-macros = { path = "../reaper-rs/main/macros" } -#reaper-low = { path = "../reaper-rs/main/low" } -#reaper-rx = { path = "../reaper-rs/main/rx" } -#rppxml-parser = { path = "../reaper-rs/main/rppxml-parser" } +[patch.'https://github.com/helgoboss/reaper-rs.git'] +reaper-common-types = { path = "../reaper-rs/main/common-types" } +reaper-fluent = { path = "../reaper-rs/main/fluent" } +reaper-high = { path = "../reaper-rs/main/high" } +reaper-medium = { path = "../reaper-rs/main/medium" } +reaper-macros = { path = "../reaper-rs/main/macros" } +reaper-low = { path = "../reaper-rs/main/low" } +reaper-rx = { path = "../reaper-rs/main/rx" } +rppxml-parser = { path = "../reaper-rs/main/rppxml-parser" } ## This is for temporary development with local egui-baseview. #[patch.'https://github.com/helgoboss/egui-baseview.git'] diff --git a/main/src/domain/control_surface.rs b/main/src/domain/control_surface.rs index 6feca888e..171563e5d 100644 --- a/main/src/domain/control_surface.rs +++ b/main/src/domain/control_surface.rs @@ -660,6 +660,7 @@ impl RealearnControlSurfaceMiddleware { } } + #[allow(deprecated)] fn detect_focus_switch_between_main_and_fx_as_feedback_event_deprecated(&mut self) -> bool { let reaper = Reaper::get().medium_reaper(); let new = reaper.get_focused_fx_2(); diff --git a/main/src/domain/realearn_target_context.rs b/main/src/domain/realearn_target_context.rs index a8aa2ec46..543b29ec7 100644 --- a/main/src/domain/realearn_target_context.rs +++ b/main/src/domain/realearn_target_context.rs @@ -4,8 +4,8 @@ use crate::domain::{ }; use base::hash_util::{NonCryptoHashMap, NonCryptoHashSet}; use base::{NamedChannelSender, SenderToNormalThread}; -use reaper_high::{Fx, GroupingBehavior, Track}; -use reaper_medium::{GangBehavior, MediaTrack}; +use reaper_high::{Fx, GroupingBehavior, Reaper, Track}; +use reaper_medium::{GangBehavior, MediaTrack, NotificationBehavior, ValueChange}; /// Feedback for most targets comes from REAPER itself but there are some targets for which ReaLearn /// holds the state. It's in this struct. @@ -127,6 +127,7 @@ impl RealearnTargetState { ) { self.touched_things .remove(&TouchedThing::new(track.raw(), parameter_type)); + self.post_process_touch(track, parameter_type); self.additional_feedback_event_sender.send_complaining( AdditionalFeedbackEvent::ParameterAutomationTouchStateChanged( ParameterAutomationTouchStateChangedEvent { @@ -141,25 +142,34 @@ impl RealearnTargetState { fn post_process_touch(&mut self, track: &Track, parameter_type: TouchedTrackParameterType) { match parameter_type { TouchedTrackParameterType::Volume => { - track.set_volume( - track.volume(), + let resulting_value = track.csurf_on_volume_change_ex( + ValueChange::Absolute(track.volume()), GangBehavior::DenyGang, - GroupingBehavior::PreventGrouping, ); + if let Ok(v) = resulting_value { + let _ = track.csurf_set_surface_volume(v, NotificationBehavior::NotifyAll); + } } TouchedTrackParameterType::Pan => { - track.set_pan( - track.pan(), + let resulting_value = track.csurf_on_pan_change_ex( + ValueChange::Absolute(track.pan().reaper_value()), GangBehavior::DenyGang, - GroupingBehavior::PreventGrouping, ); + if let Ok(v) = resulting_value { + let _ = track.csurf_set_surface_pan(v, NotificationBehavior::NotifyAll); + } } TouchedTrackParameterType::Width => { - track.set_width( - track.width(), + let result = track.csurf_on_width_change_ex( + ValueChange::Absolute(track.width().reaper_value()), GangBehavior::DenyGang, - GroupingBehavior::PreventGrouping, ); + if result.is_ok() { + let _ = track.csurf_set_surface_pan( + track.pan().reaper_value(), + NotificationBehavior::NotifyAll, + ); + } } } } diff --git a/main/src/domain/reaper_target.rs b/main/src/domain/reaper_target.rs index 03d22a79c..f85dac199 100644 --- a/main/src/domain/reaper_target.rs +++ b/main/src/domain/reaper_target.rs @@ -7,7 +7,8 @@ use enum_dispatch::enum_dispatch; use num_enum::{IntoPrimitive, TryFromPrimitive}; use reaper_high::{ Action, AvailablePanValue, BookmarkType, ChangeEvent, Fx, FxChain, FxParameter, - GroupingBehavior, Pan, PanExt, PlayRate, Project, Reaper, Tempo, Track, TrackRoute, Width, + GroupingBehavior, Pan, PanExt, PlayRate, Project, Reaper, ReaperError, Tempo, Track, + TrackRoute, Width, }; use reaper_medium::{ AutomationMode, Bpm, GangBehavior, GlobalAutomationModeOverride, NormalizedPlayRate, ParamId, @@ -1506,12 +1507,12 @@ pub fn with_gang_behavior( project: Project, behavior: TrackGangBehavior, target_type_def: &TargetTypeDef, - f: impl FnOnce(GangBehavior, GroupingBehavior), + f: impl FnOnce(GangBehavior, GroupingBehavior) -> Result<(), ReaperError>, ) -> Result<(), &'static str> { let (gang_behavior, grouping_behavior) = behavior.gang_and_grouping_behavior(); if new_set_track_ui_functions_are_available() { // REAPER >= 6.69+dev1027 makes things much easier. - f(gang_behavior, grouping_behavior); + f(gang_behavior, grouping_behavior)?; return Ok(()); } use TrackGangBehavior::*; @@ -1521,22 +1522,26 @@ pub fn with_gang_behavior( // CSurf_OnMuteChangeEx, CSurf_OnSoloChangeEx, CSurf_OnRecArmChangeEx respect // track grouping even when passing DenyGang. So we need to switch it off // temporarily. - project.with_track_grouping(false, || f(gang_behavior, grouping_behavior)) + project.with_track_grouping(false, || f(gang_behavior, grouping_behavior))?; } else { - f(gang_behavior, grouping_behavior) + f(gang_behavior, grouping_behavior)?; } } - SelectionOnly => project.with_track_grouping(false, || f(gang_behavior, grouping_behavior)), + SelectionOnly => { + project.with_track_grouping(false, || f(gang_behavior, grouping_behavior))?; + } GroupingOnly => { if target_type_def.supports_track_grouping_only_gang_behavior { // CSurf_OnMuteChangeEx, CSurf_OnSoloChangeEx, CSurf_OnRecArmChangeEx respect // track grouping even when passing DenyGang. Perfect. - f(gang_behavior, grouping_behavior) + f(gang_behavior, grouping_behavior)?; } else { return Err("grouping-only is not supported for this target"); } } - SelectionAndGrouping => f(GangBehavior::AllowGang, GroupingBehavior::UseGrouping), + SelectionAndGrouping => { + f(GangBehavior::AllowGang, GroupingBehavior::UseGrouping)?; + } }; Ok(()) } diff --git a/main/src/domain/targets/track_arm_target.rs b/main/src/domain/targets/track_arm_target.rs index 84745ae70..c9430ef0b 100644 --- a/main/src/domain/targets/track_arm_target.rs +++ b/main/src/domain/targets/track_arm_target.rs @@ -76,6 +76,7 @@ impl RealearnTarget for TrackArmTarget { |t| t.arm(false, gang_behavior, grouping_behavior), |t| t.disarm(false, gang_behavior, grouping_behavior), ); + Ok(()) }, )?; Ok(HitResponse::processed_with_effect()) diff --git a/main/src/domain/targets/track_monitoring_mode_target.rs b/main/src/domain/targets/track_monitoring_mode_target.rs index cbbb9198b..70e324a77 100644 --- a/main/src/domain/targets/track_monitoring_mode_target.rs +++ b/main/src/domain/targets/track_monitoring_mode_target.rs @@ -97,6 +97,7 @@ impl RealearnTarget for TrackMonitoringModeTarget { ) }, ); + Ok(()) }, )?; Ok(HitResponse::processed_with_effect()) diff --git a/main/src/domain/targets/track_mute_target.rs b/main/src/domain/targets/track_mute_target.rs index 509199727..ddf1139ed 100644 --- a/main/src/domain/targets/track_mute_target.rs +++ b/main/src/domain/targets/track_mute_target.rs @@ -76,6 +76,7 @@ impl RealearnTarget for TrackMuteTarget { |t| t.mute(gang_behavior, grouping_behavior), |t| t.unmute(gang_behavior, grouping_behavior), ); + Ok(()) }, )?; Ok(HitResponse::processed_with_effect()) diff --git a/main/src/domain/targets/track_pan_target.rs b/main/src/domain/targets/track_pan_target.rs index 9ce7926d3..1a7a027c4 100644 --- a/main/src/domain/targets/track_pan_target.rs +++ b/main/src/domain/targets/track_pan_target.rs @@ -104,7 +104,8 @@ impl RealearnTarget for TrackPanTarget { self.gang_behavior, &TRACK_PAN_TARGET, |gang_behavior, grouping_behavior| { - self.track.set_pan(pan, gang_behavior, grouping_behavior); + self.track + .set_pan_smart(pan, gang_behavior, grouping_behavior) }, )?; Ok(HitResponse::processed_with_effect()) diff --git a/main/src/domain/targets/track_solo_target.rs b/main/src/domain/targets/track_solo_target.rs index cc8e8ef42..5dc60cbfb 100644 --- a/main/src/domain/targets/track_solo_target.rs +++ b/main/src/domain/targets/track_solo_target.rs @@ -82,6 +82,7 @@ impl RealearnTarget for TrackSoloTarget { |t| t.unsolo(gang_behavior, grouping_behavior), ); }); + Ok(()) }, )?; Ok(HitResponse::processed_with_effect()) diff --git a/main/src/domain/targets/track_volume_target.rs b/main/src/domain/targets/track_volume_target.rs index 4efa4b0ea..c02a28421 100644 --- a/main/src/domain/targets/track_volume_target.rs +++ b/main/src/domain/targets/track_volume_target.rs @@ -87,11 +87,11 @@ impl RealearnTarget for TrackVolumeTarget { self.gang_behavior, &TRACK_VOLUME_TARGET, |gang_behavior, grouping_behavior| { - self.track.set_volume( + self.track.set_volume_smart( volume.unwrap_or(SliderVolume::MIN).reaper_value(), gang_behavior, grouping_behavior, - ); + ) }, )?; Ok(HitResponse::processed_with_effect()) diff --git a/main/src/domain/targets/track_width_target.rs b/main/src/domain/targets/track_width_target.rs index 9d9c7d4f9..03ebad1fa 100644 --- a/main/src/domain/targets/track_width_target.rs +++ b/main/src/domain/targets/track_width_target.rs @@ -104,7 +104,7 @@ impl RealearnTarget for TrackWidthTarget { &TRACK_WIDTH_TARGET, |gang_behavior, grouping_behavior| { self.track - .set_width(width, gang_behavior, grouping_behavior); + .set_width_smart(width, gang_behavior, grouping_behavior) }, )?; Ok(HitResponse::processed_with_effect()) diff --git a/main/src/infrastructure/proto/playtime_request_handler.rs b/main/src/infrastructure/proto/playtime_request_handler.rs index f0e0cd11a..ff2b62e1c 100644 --- a/main/src/infrastructure/proto/playtime_request_handler.rs +++ b/main/src/infrastructure/proto/playtime_request_handler.rs @@ -587,11 +587,11 @@ impl PlaytimeProtoRequestHandler { match kind { MatrixVolumeKind::Master => { let project = matrix.project(); - project.master_track()?.set_volume( + project.master_track()?.set_volume_smart( db.to_linear_volume_value(), GangBehavior::DenyGang, GroupingBehavior::PreventGrouping, - ); + )?; } MatrixVolumeKind::Click => { matrix.set_click_volume(db); @@ -609,11 +609,11 @@ impl PlaytimeProtoRequestHandler { .map_err(|e| Status::invalid_argument(e.to_string()))?; self.handle_matrix_command(req.matrix_id, |matrix| { let project = matrix.project(); - project.master_track()?.set_pan( + project.master_track()?.set_pan_smart( Pan::from_reaper_value(pan), GangBehavior::DenyGang, GroupingBehavior::PreventGrouping, - ); + )?; Ok(()) }) } @@ -621,11 +621,11 @@ impl PlaytimeProtoRequestHandler { pub fn set_track_volume(&self, req: SetTrackVolumeRequest) -> Result, Status> { let db = Db::try_from(req.db).map_err(|e| Status::invalid_argument(e.to_string()))?; self.handle_track_command(&req.track_address, |_matrix, track| { - track.set_volume( + track.set_volume_smart( db.to_linear_volume_value(), GangBehavior::DenyGang, GroupingBehavior::PreventGrouping, - ); + )?; Ok(()) }) } @@ -633,11 +633,11 @@ impl PlaytimeProtoRequestHandler { pub fn set_track_pan(&self, req: SetTrackPanRequest) -> Result, Status> { let pan = ReaperPanValue::new_panic(req.pan.clamp(-1.0, 1.0)); self.handle_track_command(&req.track_address, |_matrix, track| { - track.set_pan( + track.set_pan_smart( Pan::from_reaper_value(pan), GangBehavior::DenyGang, GroupingBehavior::PreventGrouping, - ); + )?; Ok(()) }) }