Have all linear input be controllable by an LFO

This commit is contained in:
2026-03-26 10:55:37 +00:00
parent f26ecda58c
commit d47cae5a95
5 changed files with 68 additions and 19 deletions

View File

@@ -34,6 +34,8 @@ const MOD_HEADER: f32 = 26.0;
const JACK_ROW: f32 = 24.0;
const PARAM_ROW: f32 = 20.0;
const JACK_R: f32 = 7.0;
/// Smaller jack used for per-parameter CV inputs, rendered in the param area.
const CV_JACK_R: f32 = 4.5;
const PALETTE_H: f32 = 48.0;
const PALETTE_BTN_W: f32 = 76.0;
const PALETTE_PAD: f32 = 8.0;
@@ -106,6 +108,18 @@ impl Module {
out_idx += 1;
}
}
// Virtual per-parameter CV input jacks: id = "cv_{param_id}"
if let Some(param_id) = jack_id.strip_prefix("cv_") {
let n_in = desc.jacks.iter().filter(|j| j.direction == Direction::Input).count();
let n_out = desc.jacks.iter().filter(|j| j.direction == Direction::Output).count();
let params_top = self.y + MOD_HEADER + n_in.max(n_out) as f32 * JACK_ROW + 3.0;
for (pi, p) in desc.params.iter().enumerate() {
if p.id == param_id && p.labels.is_empty() {
let jy = params_top + 4.0 + pi as f32 * PARAM_ROW + PARAM_ROW * 0.5;
return Some((self.x, jy));
}
}
}
None
}
@@ -158,6 +172,18 @@ impl Module {
return Some((j.id.to_string(), j.direction, j.signal));
}
}
// Virtual per-parameter CV input jacks
let n_in = desc.jacks.iter().filter(|j| j.direction == Direction::Input).count();
let n_out = desc.jacks.iter().filter(|j| j.direction == Direction::Output).count();
let params_top = self.y + MOD_HEADER + n_in.max(n_out) as f32 * JACK_ROW + 3.0;
for (pi, p) in desc.params.iter().enumerate() {
if p.labels.is_empty() {
let jy = params_top + 4.0 + pi as f32 * PARAM_ROW + PARAM_ROW * 0.5;
if hypot(x - self.x, y - jy) <= CV_JACK_R * 2.5 {
return Some((format!("cv_{}", p.id), Direction::Input, SignalKind::Cv));
}
}
}
None
}
}
@@ -730,6 +756,11 @@ impl PatchBay {
}
} else {
// ── Continuous slider ─────────────────────────────────────────
// Small CV input jack on the left edge of the param row
let jy = py + PARAM_ROW * 0.5;
draw_jack(ctx, m.x as f64, jy as f64, CV_JACK_R as f64,
signal_color(SignalKind::Cv), false);
let ratio = ((val - p.min) / (p.max - p.min)).clamp(0.0, 1.0);
let track_y = py + 13.0;