1
0
Fork 0

Move standalone WrapperConfig to its own module

This commit is contained in:
Robbert van der Helm 2022-06-14 15:52:31 +02:00
parent 49e683e396
commit d97831649e
4 changed files with 43 additions and 40 deletions

View file

@ -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;

View file

@ -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 {

View file

@ -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,
}

View file

@ -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<P: Plugin, B: Backend> {
backend: AtomicRefCell<B>,