From d97831649e4004ed04df8cc488d717434385c157 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 14 Jun 2022 15:52:31 +0200 Subject: [PATCH] Move standalone WrapperConfig to its own module --- src/wrapper/standalone.rs | 4 +++- src/wrapper/standalone/backend.rs | 2 +- src/wrapper/standalone/config.rs | 38 ++++++++++++++++++++++++++++++ src/wrapper/standalone/wrapper.rs | 39 +------------------------------ 4 files changed, 43 insertions(+), 40 deletions(-) create mode 100644 src/wrapper/standalone/config.rs diff --git a/src/wrapper/standalone.rs b/src/wrapper/standalone.rs index 37b3a732..515b7120 100644 --- a/src/wrapper/standalone.rs +++ b/src/wrapper/standalone.rs @@ -3,11 +3,13 @@ use clap::{FromArgMatches, IntoApp}; -use self::wrapper::{Wrapper, WrapperConfig, WrapperError}; +use self::config::WrapperConfig; +use self::wrapper::{Wrapper, WrapperError}; use super::util::setup_logger; use crate::plugin::Plugin; mod backend; +mod config; mod context; mod wrapper; diff --git a/src/wrapper/standalone/backend.rs b/src/wrapper/standalone/backend.rs index f27c1bff..b6cdf2e9 100644 --- a/src/wrapper/standalone/backend.rs +++ b/src/wrapper/standalone/backend.rs @@ -2,7 +2,7 @@ use std::time::{Duration, Instant}; use crate::buffer::Buffer; -use super::wrapper::WrapperConfig; +use super::config::WrapperConfig; /// An audio+MIDI backend for the standalone wrapper. pub trait Backend: 'static + Send + Sync { diff --git a/src/wrapper/standalone/config.rs b/src/wrapper/standalone/config.rs new file mode 100644 index 00000000..1f4ffb28 --- /dev/null +++ b/src/wrapper/standalone/config.rs @@ -0,0 +1,38 @@ +use clap::Parser; + +/// Configuration for a standalone plugin that would normally be provided by the DAW. +#[derive(Debug, Clone, Parser)] +#[clap(about = None, long_about = None)] +pub struct WrapperConfig { + /// The number of input channels. + #[clap(value_parser, short = 'i', long, default_value = "2")] + pub input_channels: u32, + /// The number of output channels. + #[clap(value_parser, short = 'o', long, default_value = "2")] + pub output_channels: u32, + /// The audio backend's sample rate. + #[clap(value_parser, short = 'r', long, default_value = "44100")] + pub sample_rate: f32, + /// The audio backend's period size. + #[clap(value_parser, short = 'p', long, default_value = "512")] + pub period_size: u32, + + /// The editor's DPI scaling factor. + /// + /// This option is ignored on macOS. + // + // Currently baseview has no way to report this to us, so we'll expose it as a command line + // option instead. + #[clap(value_parser, long, default_value = "1.0")] + pub dpi_scale: f32, + + /// The transport's tempo. + #[clap(value_parser, long, default_value = "120")] + pub tempo: f32, + /// The time signature's numerator. + #[clap(value_parser, long, default_value = "4")] + pub timesig_num: u32, + /// The time signature's denominator. + #[clap(value_parser, long, default_value = "4")] + pub timesig_denom: u32, +} diff --git a/src/wrapper/standalone/wrapper.rs b/src/wrapper/standalone/wrapper.rs index ecb03206..90730ad8 100644 --- a/src/wrapper/standalone/wrapper.rs +++ b/src/wrapper/standalone/wrapper.rs @@ -1,6 +1,5 @@ use atomic_refcell::AtomicRefCell; use baseview::{EventStatus, Window, WindowHandler, WindowOpenOptions}; -use clap::Parser; use crossbeam::channel; use crossbeam::queue::ArrayQueue; use parking_lot::RwLock; @@ -12,6 +11,7 @@ use std::sync::Arc; use std::thread; use super::backend::Backend; +use super::config::WrapperConfig; use super::context::{WrapperGuiContext, WrapperInitContext, WrapperProcessContext}; use crate::context::Transport; use crate::param::internals::{ParamPtr, Params}; @@ -27,43 +27,6 @@ use crate::wrapper::state::{self, PluginState}; /// than this many parameters at a time will cause changes to get lost. const EVENT_QUEUE_CAPACITY: usize = 2048; -/// Configuration for a standalone plugin that would normally be provided by the DAW. -#[derive(Debug, Clone, Parser)] -#[clap(about = None, long_about = None)] -pub struct WrapperConfig { - /// The number of input channels. - #[clap(value_parser, short = 'i', long, default_value = "2")] - pub input_channels: u32, - /// The number of output channels. - #[clap(value_parser, short = 'o', long, default_value = "2")] - pub output_channels: u32, - /// The audio backend's sample rate. - #[clap(value_parser, short = 'r', long, default_value = "44100")] - pub sample_rate: f32, - /// The audio backend's period size. - #[clap(value_parser, short = 'p', long, default_value = "512")] - pub period_size: u32, - - /// The editor's DPI scaling factor. - /// - /// This option is ignored on macOS. - // - // Currently baseview has no way to report this to us, so we'll expose it as a command line - // option instead. - #[clap(value_parser, long, default_value = "1.0")] - pub dpi_scale: f32, - - /// The transport's tempo. - #[clap(value_parser, long, default_value = "120")] - pub tempo: f32, - /// The time signature's numerator. - #[clap(value_parser, long, default_value = "4")] - pub timesig_num: u32, - /// The time signature's denominator. - #[clap(value_parser, long, default_value = "4")] - pub timesig_denom: u32, -} - pub struct Wrapper { backend: AtomicRefCell,