-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce EditorHost type; move param gesture methods from Host to Ed…
…itorHost
- Loading branch information
Showing
9 changed files
with
118 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
use crate::host::HostInner; | ||
use crate::params::{ParamId, ParamValue}; | ||
|
||
pub struct ClapHost {} | ||
|
||
impl HostInner for ClapHost { | ||
fn begin_gesture(&self, _id: ParamId) {} | ||
fn end_gesture(&self, _id: ParamId) {} | ||
fn set_param(&self, _id: ParamId, _value: ParamValue) {} | ||
} | ||
impl HostInner for ClapHost {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,11 @@ | ||
use std::sync::RwLock; | ||
|
||
use vst3::ComPtr; | ||
use vst3::Steinberg::Vst::{IComponentHandler, IComponentHandlerTrait}; | ||
|
||
use crate::host::HostInner; | ||
use crate::params::{ParamId, ParamValue}; | ||
|
||
pub struct Vst3Host { | ||
pub handler: RwLock<Option<ComPtr<IComponentHandler>>>, | ||
} | ||
pub struct Vst3Host {} | ||
|
||
impl Vst3Host { | ||
pub fn new() -> Vst3Host { | ||
Vst3Host { | ||
handler: RwLock::new(None), | ||
} | ||
Vst3Host {} | ||
} | ||
} | ||
|
||
impl HostInner for Vst3Host { | ||
fn begin_gesture(&self, id: ParamId) { | ||
let handler = self.handler.read().unwrap(); | ||
if let Some(handler) = &*handler { | ||
// TODO: only call this on main thread | ||
unsafe { | ||
handler.beginEdit(id); | ||
} | ||
} | ||
} | ||
|
||
fn end_gesture(&self, id: ParamId) { | ||
let handler = self.handler.read().unwrap(); | ||
if let Some(handler) = &*handler { | ||
// TODO: only call this on main thread | ||
unsafe { | ||
handler.endEdit(id); | ||
} | ||
} | ||
} | ||
|
||
fn set_param(&self, id: ParamId, value: ParamValue) { | ||
let handler = self.handler.read().unwrap(); | ||
if let Some(handler) = &*handler { | ||
// TODO: only call this on main thread | ||
unsafe { | ||
handler.performEdit(id, value); | ||
} | ||
} | ||
} | ||
} | ||
impl HostInner for Vst3Host {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,14 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::params::{ParamId, ParamValue}; | ||
|
||
pub trait HostInner { | ||
fn begin_gesture(&self, id: ParamId); | ||
fn end_gesture(&self, id: ParamId); | ||
fn set_param(&self, id: ParamId, value: ParamValue); | ||
} | ||
pub trait HostInner {} | ||
|
||
#[derive(Clone)] | ||
pub struct Host { | ||
inner: Arc<dyn HostInner + Send + Sync>, | ||
_inner: Arc<dyn HostInner + Send + Sync>, | ||
} | ||
|
||
impl Host { | ||
pub fn from_inner(inner: Arc<dyn HostInner + Send + Sync>) -> Host { | ||
Host { inner } | ||
} | ||
|
||
pub fn begin_gesture(&self, id: ParamId) { | ||
self.inner.begin_gesture(id); | ||
} | ||
|
||
pub fn end_gesture(&self, id: ParamId) { | ||
self.inner.end_gesture(id); | ||
} | ||
|
||
pub fn set_param(&self, id: ParamId, value: ParamValue) { | ||
self.inner.set_param(id, value); | ||
Host { _inner: inner } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters