Skip to content

Commit

Permalink
Use the latest obs-wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorisano committed Sep 23, 2022
1 parent 89f830e commit 7d658d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# obs-wrapper = "0.3.4"
obs-wrapper = { path = "../rust-obs-plugins"}
obs-wrapper = "0.4.0"
# obs-wrapper = { path = "../rust-obs-plugins"}

[lib]
name = "biquadfilter"
Expand Down
17 changes: 10 additions & 7 deletions src/lib.rs
Expand Up @@ -8,7 +8,9 @@ use obs_wrapper::{

use std::f32::consts::PI;

#[allow(dead_code)]
const DEFAULT_FILTER_TYPE: ObsString = obs_string!("low_pass");

const DEFAULT_CUTOFF_FREQ: f32 = 200.0;
const DEFAULT_Q: f32 = 0.7;

Expand Down Expand Up @@ -133,7 +135,7 @@ impl Sourceable for BiquadFilter {
let (sample_rate, channels) =
create.with_audio(|audio| (audio.output_sample_rate(), audio.output_channels()));
let settings = &create.settings;
let filter_type = if let Some(filter_type) = settings.get::<std::borrow::Cow<'_, str>, _>(obs_string!("filter_type")) {
let filter_type = if let Some(filter_type) = settings.get::<std::borrow::Cow<'_, str>>(obs_string!("filter_type")) {
filter_type.to_string().into()
} else {
FilterType::LowPass
Expand Down Expand Up @@ -164,9 +166,10 @@ impl GetNameSource for BiquadFilter {

impl GetDefaultsSource for BiquadFilter {
fn get_defaults(settings: &mut DataObj) {
settings.set_default(obs_string!("filter_type"), DEFAULT_FILTER_TYPE);
settings.set_default(obs_string!("cutoff_freq"), DEFAULT_CUTOFF_FREQ);
settings.set_default(obs_string!("q"), DEFAULT_Q);
// TODO: Use DEFAULT_FILTER_TYPE.
settings.set_default::<std::borrow::Cow<'_, str>>(obs_string!("filter_type"), std::borrow::Cow::Borrowed("low_pass"));
settings.set_default::<f32>(obs_string!("cutoff_freq"), DEFAULT_CUTOFF_FREQ);
settings.set_default::<f32>(obs_string!("q"), DEFAULT_Q);
}
}

Expand Down Expand Up @@ -202,13 +205,13 @@ impl GetPropertiesSource for BiquadFilter {

impl UpdateSource for BiquadFilter {
fn update(&mut self, settings: &mut DataObj, _context: &mut GlobalContext) {
if let Some(filter_type) = settings.get::<std::borrow::Cow<'_, str>, _>(obs_string!("filter_type")) {
if let Some(filter_type) = settings.get::<std::borrow::Cow<'_, str>>(obs_string!("filter_type")) {
self.filter_type = filter_type.to_string().into();
}
if let Some(cutoff_freq) = settings.get::<f32, _>(obs_string!("cutoff_freq")) {
if let Some(cutoff_freq) = settings.get::<f32>(obs_string!("cutoff_freq")) {
self.cutoff_freq = cutoff_freq;
}
if let Some(q) = settings.get::<f32, _>(obs_string!("q")) {
if let Some(q) = settings.get::<f32>(obs_string!("q")) {
self.q = q;
}

Expand Down

0 comments on commit 7d658d9

Please sign in to comment.