-
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.
- Loading branch information
Showing
2 changed files
with
55 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,48 @@ | ||
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 struct Vst3Host { | ||
pub handler: RwLock<Option<ComPtr<IComponentHandler>>>, | ||
} | ||
|
||
impl Vst3Host { | ||
pub fn new() -> Vst3Host { | ||
Vst3Host { | ||
handler: RwLock::new(None), | ||
} | ||
} | ||
} | ||
|
||
impl HostInner for Vst3Host { | ||
fn begin_gesture(&self, _id: ParamId) {} | ||
fn end_gesture(&self, _id: ParamId) {} | ||
fn set_param(&self, _id: ParamId, _value: ParamValue) {} | ||
fn begin_gesture(&self, id: ParamId) { | ||
let handler = self.handler.read().unwrap(); | ||
if let Some(handler) = &*handler { | ||
unsafe { | ||
handler.beginEdit(id); | ||
} | ||
} | ||
} | ||
|
||
fn end_gesture(&self, id: ParamId) { | ||
let handler = self.handler.read().unwrap(); | ||
if let Some(handler) = &*handler { | ||
unsafe { | ||
handler.endEdit(id); | ||
} | ||
} | ||
} | ||
|
||
fn set_param(&self, id: ParamId, value: ParamValue) { | ||
let handler = self.handler.read().unwrap(); | ||
if let Some(handler) = &*handler { | ||
unsafe { | ||
handler.performEdit(id, value); | ||
} | ||
} | ||
} | ||
} |