add alternate option

main
annieversary 2022-12-17 02:53:00 +01:00
parent 3cce56550e
commit 34caf19fdd
1 changed files with 14 additions and 3 deletions

View File

@ -10,12 +10,18 @@ baseplug::model! {
#[model(min = 0.0, max = 1.0)] #[model(min = 0.0, max = 1.0)]
#[parameter(name = "offset")] #[parameter(name = "offset")]
offset: f32, offset: f32,
#[model(min = 0.0, max = 1.0)]
#[parameter(name = "alternate")]
alternate: f32,
} }
} }
impl Default for GainModel { impl Default for GainModel {
fn default() -> Self { fn default() -> Self {
Self { offset: 0.0 } Self {
offset: 0.0,
alternate: 0.0,
}
} }
} }
@ -42,8 +48,13 @@ impl Plugin for Gain {
let output = &mut ctx.outputs[0].buffers; let output = &mut ctx.outputs[0].buffers;
for i in 0..ctx.nframes { for i in 0..ctx.nframes {
if model.alternate[i] < 0.5 {
output[0][i] = input[0][i] + model.offset[i]; output[0][i] = input[0][i] + model.offset[i];
output[1][i] = input[1][i] - model.offset[i]; output[1][i] = input[1][i] - model.offset[i];
} else {
output[0][i] = input[0][i] - model.offset[i];
output[1][i] = input[1][i] + model.offset[i];
}
} }
} }
} }