Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor out Playtime #874

Merged
merged 5 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ 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-high = { path = "../reaper-rs/main/high" }
reaper-medium = { path = "../reaper-rs/main/medium" }
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-high = { path = "../reaper-rs/main/high" }
#reaper-medium = { path = "../reaper-rs/main/medium" }
#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']
Expand Down
6 changes: 5 additions & 1 deletion api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ version = "0.1.0"
authors = ["Benjamin Klum <benjamin.klum@helgoboss.org>"]
edition = "2021"

[features]
default = []
playtime = ["playtime-api"]

[dependencies]
serde.workspace = true
semver.workspace = true
schemars.workspace = true
serde_json.workspace = true
playtime-api.workspace = true
playtime-api = { workspace = true, optional = true }
derive_more.workspace = true
enum-iterator.workspace = true
num_enum.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions api/src/persistence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub use session::*;
pub use source::*;
pub use target::*;

use playtime_api::persistence::Matrix;
use semver::Version;
use serde::{Deserialize, Serialize};

Expand All @@ -38,7 +37,8 @@ impl<T> Envelope<T> {
#[derive(Serialize, Deserialize)]
#[serde(tag = "kind")]
pub enum ApiObject {
ClipMatrix(Envelope<Box<Option<Matrix>>>),
#[cfg(feature = "playtime")]
ClipMatrix(Envelope<Box<Option<playtime_api::persistence::Matrix>>>),
MainCompartment(Envelope<Box<Compartment>>),
ControllerCompartment(Envelope<Box<Compartment>>),
Mappings(Envelope<Vec<Mapping>>),
Expand Down
3 changes: 2 additions & 1 deletion api/src/persistence/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use schemars::JsonSchema;
#[derive(JsonSchema)]
pub struct Session {
_main_compartment: Option<Compartment>,
_clip_matrix: Option<Matrix>,
#[cfg(feature = "playtime")]
_clip_matrix: Option<playtime_api::persistence::Matrix>,
_mapping_snapshots: Vec<MappingSnapshot>,
}

Expand Down
31 changes: 28 additions & 3 deletions api/src/persistence/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use derive_more::Display;
use enum_iterator::IntoEnumIterator;
use enumset::EnumSet;
use num_enum::{IntoPrimitive, TryFromPrimitive};
use playtime_api::persistence::{ClipPlayStartTiming, ClipPlayStopTiming};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
Expand Down Expand Up @@ -143,12 +142,19 @@ pub enum Target {
RoutePan(RoutePanTarget),
RouteVolume(RouteVolumeTarget),
RouteTouchState(RouteTouchStateTarget),
#[cfg(feature = "playtime")]
ClipTransportAction(ClipTransportActionTarget),
#[cfg(feature = "playtime")]
ClipColumnAction(ClipColumnTarget),
#[cfg(feature = "playtime")]
ClipRowAction(ClipRowTarget),
#[cfg(feature = "playtime")]
ClipMatrixAction(ClipMatrixTarget),
#[cfg(feature = "playtime")]
ClipSeek(ClipSeekTarget),
#[cfg(feature = "playtime")]
ClipVolume(ClipVolumeTarget),
#[cfg(feature = "playtime")]
ClipManagement(ClipManagementTarget),
SendMidi(SendMidiTarget),
SendOsc(SendOscTarget),
Expand Down Expand Up @@ -832,6 +838,7 @@ pub struct RouteTouchStateTarget {
pub touched_parameter: TouchedRouteParameter,
}

#[cfg(feature = "playtime")]
#[derive(Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ClipTransportActionTarget {
#[serde(flatten)]
Expand All @@ -843,11 +850,12 @@ pub struct ClipTransportActionTarget {
#[serde(skip_serializing_if = "Option::is_none")]
pub stop_column_if_slot_empty: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub play_start_timing: Option<ClipPlayStartTiming>,
pub play_start_timing: Option<playtime_api::persistence::ClipPlayStartTiming>,
#[serde(skip_serializing_if = "Option::is_none")]
pub play_stop_timing: Option<ClipPlayStopTiming>,
pub play_stop_timing: Option<playtime_api::persistence::ClipPlayStopTiming>,
}

#[cfg(feature = "playtime")]
#[derive(Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ClipColumnTarget {
#[serde(flatten)]
Expand All @@ -856,6 +864,7 @@ pub struct ClipColumnTarget {
pub action: ClipColumnAction,
}

#[cfg(feature = "playtime")]
#[derive(Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ClipRowTarget {
#[serde(flatten)]
Expand All @@ -864,13 +873,15 @@ pub struct ClipRowTarget {
pub action: ClipRowAction,
}

#[cfg(feature = "playtime")]
#[derive(Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ClipMatrixTarget {
#[serde(flatten)]
pub commons: TargetCommons,
pub action: ClipMatrixAction,
}

#[cfg(feature = "playtime")]
#[derive(Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ClipSeekTarget {
#[serde(flatten)]
Expand All @@ -880,13 +891,15 @@ pub struct ClipSeekTarget {
pub feedback_resolution: Option<FeedbackResolution>,
}

#[cfg(feature = "playtime")]
#[derive(Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ClipVolumeTarget {
#[serde(flatten)]
pub commons: TargetCommons,
pub slot: ClipSlotDescriptor,
}

#[cfg(feature = "playtime")]
#[derive(PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ClipManagementTarget {
#[serde(flatten)]
Expand All @@ -895,6 +908,7 @@ pub struct ClipManagementTarget {
pub action: ClipManagementAction,
}

#[cfg(feature = "playtime")]
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "kind")]
pub enum ClipManagementAction {
Expand All @@ -905,12 +919,14 @@ pub enum ClipManagementAction {
AdjustClipSectionLength(AdjustClipSectionLengthAction),
}

#[cfg(feature = "playtime")]
impl Default for ClipManagementAction {
fn default() -> Self {
Self::ClearSlot
}
}

#[cfg(feature = "playtime")]
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
pub struct AdjustClipSectionLengthAction {
pub factor: f64,
Expand Down Expand Up @@ -1606,6 +1622,7 @@ pub enum TrackDescriptor {
#[serde(skip_serializing_if = "Option::is_none")]
allow_multiple: Option<bool>,
},
#[cfg(feature = "playtime")]
FromClipColumn {
#[serde(flatten)]
commons: TrackDescriptorCommons,
Expand All @@ -1614,12 +1631,14 @@ pub enum TrackDescriptor {
},
}

#[cfg(feature = "playtime")]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
pub enum ClipColumnTrackContext {
Playback,
Recording,
}

#[cfg(feature = "playtime")]
impl Default for ClipColumnTrackContext {
fn default() -> Self {
Self::Playback
Expand Down Expand Up @@ -1932,6 +1951,7 @@ impl Default for TrackRouteKind {
}
}

#[cfg(feature = "playtime")]
#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "address")]
pub enum ClipSlotDescriptor {
Expand All @@ -1946,12 +1966,14 @@ pub enum ClipSlotDescriptor {
},
}

#[cfg(feature = "playtime")]
impl Default for ClipSlotDescriptor {
fn default() -> Self {
Self::Selected
}
}

#[cfg(feature = "playtime")]
#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "address")]
pub enum ClipColumnDescriptor {
Expand All @@ -1960,12 +1982,14 @@ pub enum ClipColumnDescriptor {
Dynamic { expression: String },
}

#[cfg(feature = "playtime")]
impl Default for ClipColumnDescriptor {
fn default() -> Self {
Self::Selected
}
}

#[cfg(feature = "playtime")]
#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "address")]
pub enum ClipRowDescriptor {
Expand All @@ -1974,6 +1998,7 @@ pub enum ClipRowDescriptor {
Dynamic { expression: String },
}

#[cfg(feature = "playtime")]
impl Default for ClipRowDescriptor {
fn default() -> Self {
Self::Selected
Expand Down
1 change: 1 addition & 0 deletions api/src/runtime/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ use schemars::JsonSchema;
/// Only used for JSON schema generation.
#[derive(JsonSchema)]
pub struct RealearnRuntimeRoot {
#[cfg(feature = "playtime")]
_playtime_api: playtime_api::runtime::PlaytimeRuntimeRoot,
}
7 changes: 4 additions & 3 deletions main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ license = "GPL-3.0"
rust-version = "1.68.2"

[features]
default = []
default = ["playtime"]
playtime = ["playtime-clip-engine", "playtime-api", "realearn-api/playtime"]

# Regenerate bindings (for dialog resource IDs and EEL functions)
generate = []
Expand All @@ -22,14 +23,14 @@ reaper-medium.workspace = true
reaper-low.workspace = true
swell-ui.workspace = true
rx-util.workspace = true
playtime-clip-engine.workspace = true
pot.workspace = true
realearn-api.workspace = true
playtime-api.workspace = true
realearn-csi.workspace = true
# In future (when helgoboss-learn has matured), this will become a crates.io dependency
helgoboss-learn.workspace = true
helgoboss-midi.workspace = true
playtime-api = { workspace = true, optional = true }
playtime-clip-engine = { workspace = true, optional = true }

# 3rd-party
# For being able to (de)serialize using FromStr and Display
Expand Down
20 changes: 12 additions & 8 deletions main/src/application/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ use crate::domain::{
LastTouchedTargetFilter, MainMapping, MappingId, MappingKey, MappingMatchedEvent,
MessageCaptureEvent, MidiControlInput, NormalMainTask, NormalRealTimeTask, OscFeedbackTask,
ParamSetting, PluginParams, ProcessorContext, ProjectionFeedbackValue, QualifiedMappingId,
RealearnClipMatrix, RealearnControlSurfaceMainTask, RealearnTarget, ReaperTarget,
ReaperTargetType, SharedInstanceState, StayActiveWhenProjectInBackground, Tag,
TargetControlEvent, TargetTouchEvent, TargetValueChangedEvent, VirtualControlElementId,
VirtualFx, VirtualSource, VirtualSourceValue,
RealearnControlSurfaceMainTask, RealearnTarget, ReaperTarget, ReaperTargetType,
SharedInstanceState, StayActiveWhenProjectInBackground, Tag, TargetControlEvent,
TargetTouchEvent, TargetValueChangedEvent, VirtualControlElementId, VirtualFx, VirtualSource,
VirtualSourceValue,
};
use base::{Global, NamedChannelSender, SenderToNormalThread, SenderToRealTimeThread};
use derivative::Derivative;
use enum_map::EnumMap;

use reaper_high::{ChangeEvent, Reaper};
use reaper_high::Reaper;
use rx_util::Notifier;
use rxrust::prelude::*;
use slog::{debug, trace};
Expand Down Expand Up @@ -54,18 +54,20 @@ pub trait SessionUi {
fn celebrate_success(&self);
fn conditions_changed(&self);
fn send_projection_feedback(&self, session: &Session, value: ProjectionFeedbackValue);
#[cfg(feature = "playtime")]
fn clip_matrix_changed(
&self,
session: &Session,
matrix: &RealearnClipMatrix,
matrix: &playtime_clip_engine::base::Matrix,
events: &[playtime_clip_engine::base::ClipMatrixEvent],
is_poll: bool,
);
#[cfg(feature = "playtime")]
fn process_control_surface_change_event_for_clip_engine(
&self,
session: &Session,
matrix: &RealearnClipMatrix,
event: &ChangeEvent,
matrix: &playtime_clip_engine::base::Matrix,
event: &reaper_high::ChangeEvent,
);
fn mapping_matched(&self, event: MappingMatchedEvent);
fn target_controlled(&self, event: TargetControlEvent);
Expand Down Expand Up @@ -2618,6 +2620,7 @@ impl DomainEventHandler for WeakSession {
let s = session.try_borrow()?;
s.ui.send_projection_feedback(&s, value);
}
#[cfg(feature = "playtime")]
ClipMatrixChanged {
matrix,
events,
Expand All @@ -2626,6 +2629,7 @@ impl DomainEventHandler for WeakSession {
let s = session.try_borrow()?;
s.ui.clip_matrix_changed(&s, matrix, events, is_poll);
}
#[cfg(feature = "playtime")]
ControlSurfaceChangeEventForClipEngine(matrix, event) => {
let s = session.try_borrow()?;
s.ui.process_control_surface_change_event_for_clip_engine(&s, matrix, event);
Expand Down
Loading
Loading