add mono line type

This commit is contained in:
Hailey Somerville
2020-04-04 00:51:10 +11:00
parent 3b2e72b470
commit 466a034c4c
4 changed files with 11 additions and 5 deletions
+7 -3
View File
@@ -27,21 +27,25 @@ impl Module for Amplifier {
fn run_tick(&mut self, _t: u64, inputs: &[Option<&[Sample]>], outputs: &mut [&mut [Sample]]) -> Option<Self::Indication> {
let AmplifierParams {mod_depth, amplitude} = self.params;
let len = outputs[0].len();
let input = &inputs[0].unwrap_or(&ZERO_BUFFER);
let mod_input = &inputs[1].unwrap_or(&ONE_BUFFER);
let output = &mut outputs[0];
let len = input.len();
for i in 0..len {
output[i] = input[i] * depth(mod_input[i], mod_depth) * amplitude;
// mod input is a mono channel and so half the length:
let mod_value = mod_input[i / 2];
output[i] = input[i] * depth(mod_value, mod_depth) * amplitude;
}
None
}
fn inputs(&self) -> &[LineType] {
&[LineType::Stereo, LineType::Stereo]
&[LineType::Stereo, LineType::Mono]
}
fn outputs(&self) -> &[LineType] {
+1 -1
View File
@@ -45,6 +45,6 @@ impl Module for Trigger {
}
fn outputs(&self) -> &[LineType] {
&[LineType::Stereo]
&[LineType::Mono]
}
}