Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ Nothing has been released yet. The first release, 0.1.0, will cover what is on `
beside two cycles of a sine through it, with the Reduction lit against unity) and De-Esser, De-Hummer and De-Noiser
(the card's graph at full size with its handles, over a dB ladder and frequency axis, captioned and with a legend),
each with one card of every control.
- Expanded windows for the pitch devices: Pitch Shifter (the interval field with the In and Out notes against an A4
reference, the semitone axis, the formant strip and a legend), Grains (the buffer with Position and Spray readouts,
a pitch axis and a time axis, Cloud / Rhythm and Freeze in the header, and two cards of controls that follow the
mode) and Pitch Corrector (the correction trace over cent rules labelled from +100 to −100, with Follow, Key,
Scale, Speed, Retune Speed, Humanize and Mix below).
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ the transfer curve beside a sine through the device, Bit Crusher, whose window d
field over a live correlation lane, Tuner, and Spectrum, whose window shows the spectrum flat, as a 3D waterfall of its
history, or split over a spectrogram, and Trance Gate, whose window draws its step ring and pattern track on a
panel beside the envelope, De-Clipper, whose window draws its transfer beside a sine, and De-Esser, De-Hummer and
De-Noiser, whose window draws the card's graph at full size over a dB ladder; the other devices open their card in a window for now.
De-Noiser, whose window draws the card's graph at full size over a dB ladder, Pitch Shifter, whose window shows the
interval against an A4 reference with the formant strip, Grains, whose window draws the buffer with its pitch and time
axes over two cards of controls, and Pitch Corrector, whose window draws the correction trace over labelled cent rules; the other devices open their card in a window for now.
[docs/devices.md](docs/devices.md) explains how they work and how to add one.

| Kind | Devices |
Expand Down
52 changes: 49 additions & 3 deletions crates/dstudio-app/src/analyzer_views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,53 @@ impl Controller {
}
layers.push(line(g, white(a), 1.0));
}
let over = self.trace_layers(d, def, x0, w, &y_of, accent, &mut layers);
canvas(FIELD_X * Z, FIELD_Y * Z, w, h, body_y, "Pitch", String::new(), [Vec::new(), layers, over], Vec::new())
}

/// The Pitch Corrector's window display (w x h px): the trace over rules every 25 ct,
/// the ±100 / ±50 / 0 rules labelled in the left gutter and "ct" under them.
pub(crate) fn trace_window_canvas(&self, d: &Device, def: &'static DeviceDef, w: f32, h: f32, accent: Color) -> PanelCanvas {
let edge = 43.0 * Z;
let mid = h / 2.0;
let y_of = |ct: f32| (mid - ct / 100.0 * (mid - edge)).clamp(2.0 * Z, h - 2.0 * Z);
let gutter = 34.0 * Z;
let mut layers = Vec::new();
let mut texts = Vec::new();
for (cts, a) in [(&[0.0][..], 0.2), (&[50.0, -50.0, 100.0, -100.0][..], 0.09), (&[25.0, -25.0, 75.0, -75.0][..], 0.045)] {
let mut g = String::new();
for c in cts {
let labelled = (*c as i32) % 50 == 0;
hline(&mut g, if labelled { gutter } else { 0.0 }, w, y_of(*c).round() + 0.5);
if labelled {
let t = match *c as i32 {
0 => "0".to_string(),
v if v > 0 => format!("+{v}"),
v => format!("\u{2212}{}", -v),
};
texts.push(text(6.0 * Z, y_of(*c) - 7.0 * Z, gutter, 14.0 * Z, &t, white(0.4), 9.5 * Z, 600, 0));
}
}
layers.push(line(g, white(a), 1.0));
}
texts.push(text(6.0 * Z, y_of(-100.0) + 8.0 * Z, gutter, 14.0 * Z, "ct", white(0.4), 9.5 * Z, 600, 0));
let over = self.trace_layers(d, def, gutter, w, &y_of, accent, &mut layers);
PanelCanvas { well: false, ..canvas(0.0, 0.0, w, h, 0.0, "", String::new(), [Vec::new(), layers, over], texts) }
}

/// The trace's runs (input against corrected, per target note) into `layers`, from x0 to
/// the now edge at w; returns the marker of the newest voiced frame.
#[allow(clippy::too_many_arguments)]
fn trace_layers(
&self,
d: &Device,
def: &'static DeviceDef,
x0: f32,
w: f32,
y_of: &dyn Fn(f32) -> f32,
accent: Color,
layers: &mut Vec<PanelPath>,
) -> Vec<PanelPath> {
let mixv = def.param("mix").map_or(100.0, |p| self.panel_value(d, def, p)) / 100.0;
let corr_color = alpha(accent, 0.25 + 0.75 * mixv);
let mut over = Vec::new();
Expand Down Expand Up @@ -479,14 +526,13 @@ impl Controller {
layers.push(area(fill, alpha(accent, 0.09), alpha(accent, 0.09)));
layers.push(line(raw_l, white(0.55), 1.4 * Z));
layers.push(line(fix_l, corr_color, 1.6 * Z));
if let Some(f) = frames.back().filter(|f| f.voiced)
if frames.back().is_some_and(|f| f.voiced)
&& let Some(p) = runs.last().and_then(|r| r.last())
{
let _ = f;
over.push(rect(p.0 - 2.0 * Z, p.2 - 2.0 * Z, 4.0 * Z, 4.0 * Z, 2.0 * Z, corr_color));
}
}
canvas(FIELD_X * Z, FIELD_Y * Z, w, h, body_y, "Pitch", String::new(), [Vec::new(), layers, over], Vec::new())
over
}

/// A Spectrum card's newest frame: (analyser sequence, shown curve, peak hold), dB per band.
Expand Down
Loading
Loading