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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ Nothing has been released yet. The first release, 0.1.0, will cover what is on `
whose two handles set Attack, Sustain and their times) and Multiband Compressor (the three bands on a frequency axis
with each band's level, gain, threshold and up threshold, crossovers you can drag, and a rack card for the selected
band with its transfer curve).
- Expanded windows for Delay (its echo train or repeat EQ across the display, the Link, Sync, Hold view, View, Dry and
Mode controls in the header, and a card whose band column edits the repeat-EQ band picked in its Band menu) and Reverb
(a 1200 pt window with the tail picture across the display, a Filter range whose two handles set Low Cut and High Cut,
and the shimmer controls lit in Shimmer mode).
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ Compressor, Limiter, Gate, Glue Compressor, Character Compressor and Mastering L
or 10 seconds of input, output and gain reduction under a draggable threshold, beside a transfer curve (the Mastering
Limiter adds a short-term loudness lane against a target), Transient Shaper, whose window scopes the output with the
gain it applied, and Multiband Compressor, whose window draws each band's level, gain and thresholds on a frequency
axis with draggable crossovers; the other devices open their card in a window for now.
axis with draggable crossovers, and Delay and Reverb, whose window draws the card's echo train, tail picture or repeat
EQ at full size with every control in a row below; 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
1 change: 1 addition & 0 deletions crates/dstudio-app/src/device_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ impl Controller {
crate::device_window::MENU_ANALYZER => self.win_analyzer_rows(device),
crate::device_window::MENU_TARGET => self.win_target_rows(device),
crate::device_window::MENU_MB_BAND => self.win_mb_band_rows(device),
crate::device_window::MENU_DELAY_BAND => self.win_delay_band_rows(device),
crate::device_window::MENU_BANDS => match self.win_band_rows(device) {
Some(rows) => rows,
None => return,
Expand Down
395 changes: 394 additions & 1 deletion crates/dstudio-app/src/device_window.rs

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions crates/dstudio-app/src/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,12 +1679,13 @@ impl Controller {
let fields = &self.devices.panel.fields;
let mut washes = fields.washes.borrow_mut();
let n = washes.len();
washes.retain(|id, _| self.project().device(*id).is_some());
washes.retain(|(id, window), _| self.project().device(*id).is_some() && (!*window || self.devices.windows.contains(id)));
if fields.washes_dirty.replace(false) || washes.len() != n {
let rows: Vec<crate::PanelWash> = washes
.iter()
.map(|(id, w)| crate::PanelWash {
.map(|((id, window), w)| crate::PanelWash {
device: id.0 as i32,
window: *window,
img: w.img.clone(),
x: w.rect[0],
y: w.rect[1],
Expand Down
13 changes: 11 additions & 2 deletions crates/dstudio-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! [--sampler-tab <0..4> (with a sampler state: Sample, Pitch, Filter, Amp or Mod tab)]
//! [--hold-note <0..127> (with a synth state: hold the note and render 0.75 s offline first)]
//! [--screenshot <out.png>] [--offscreen] [--exit-after-frames N] [--frame-stats] [--render-bench N] [--self-test]
//! [--window-width <pt> (OS window width, default 1440)] [--assistant-width <px> (saved docked-assistant width, 297..600)]
//! [--window-width <pt> (OS window width, default 1440)] [--window-height <pt> (default 820)] [--assistant-width <px> (saved docked-assistant width, 297..600)]
//! [--timeline-zoom <percent> (horizontal timeline zoom, 100 = default; 100 is 12.76 pt per beat)]
//! [--zoom <percent> (interface zoom, default 100 or the saved level; 85 = the design units)]
//! [--clip-menu <0|1|3|4|5> (open a clip editor dropdown after --state: Speed, Warp, Grid, Type, Genre; 2, Mode, is disabled)]
Expand Down Expand Up @@ -280,6 +280,8 @@ struct Args {
zoom: Option<u32>,
/// --window-width <pt>: OS window width in points (default 1440), for narrow-window reviews.
window_width: Option<f32>,
/// --window-height <pt>: OS window height in points (default 820), for tall device windows.
window_height: Option<f32>,
/// --assistant-width <px>: saved docked-assistant width in 100%-zoom px (297..600), for reviews.
assistant_width: Option<f32>,
clip_menu: Option<i32>,
Expand Down Expand Up @@ -780,6 +782,13 @@ fn parse_args() -> Result<Args, String> {
}
a.window_width = Some(w);
}
"--window-height" => {
let h: f32 = value(&mut i)?.parse().map_err(|e| format!("--window-height: {e}"))?;
if !(400.0..=3000.0).contains(&h) {
return Err(format!("--window-height: want 400..3000 points, got {h}"));
}
a.window_height = Some(h);
}
"--assistant-width" => {
let w: f32 = value(&mut i)?.parse().map_err(|e| format!("--assistant-width: {e}"))?;
if !w.is_finite() {
Expand Down Expand Up @@ -4195,7 +4204,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
}
// The OS window is 1440×820 pt; interface zoom then sets how much
// of the (85 %-unit) layout fits in it, see `zoom.rs`.
app.window().set_size(slint::LogicalSize::new(args.window_width.unwrap_or(1440.0), 820.0));
app.window().set_size(slint::LogicalSize::new(args.window_width.unwrap_or(1440.0), args.window_height.unwrap_or(820.0)));
app.run()?;
if args.frame_stats && exit_after.is_none() {
println!("{}", stats_json(&frame.borrow(), &app));
Expand Down
59 changes: 42 additions & 17 deletions crates/dstudio-app/src/panel_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ pub struct FieldState {
pub views: HashMap<DeviceId, usize>,
/// Selected repeat-EQ band per delay.
bands: HashMap<DeviceId, usize>,
/// Wash image and its well box per device (Reverb tail), set while its card is built.
pub(crate) washes: std::cell::RefCell<HashMap<DeviceId, Wash>>,
/// Wash image and its well box per device and surface (card, window), set while it is built.
pub(crate) washes: std::cell::RefCell<HashMap<(DeviceId, bool), Wash>>,
/// A wash was added, redrawn or removed since the last push to the UI.
pub(crate) washes_dirty: std::cell::Cell<bool>,
}
Expand Down Expand Up @@ -123,6 +123,8 @@ struct Canvas {
pills: Vec<PanelGrip>,
/// Intensity image, its box (x, y, w, h) in well coordinates and the inputs it was drawn from.
wash: Option<Wash>,
/// Drawn for the device's window (its wash is kept apart from the card's).
window: bool,
}

impl Canvas {
Expand Down Expand Up @@ -271,7 +273,7 @@ fn biquad_db(kind: u8, f0: f32, q: f32, gain: f32, f: f32) -> f32 {

/// Band type of each repeat-EQ band of the delay (High Pass .. Low Pass).
const DELAY_BAND_KIND: [u8; 6] = [0, 1, 2, 2, 3, 4];
const DELAY_BAND_IDS: [[&str; 4]; 6] = [
pub(crate) const DELAY_BAND_IDS: [[&str; 4]; 6] = [
["eq0Freq", "eq0Gain", "eq0Q", "eq0Enabled"],
["eq1Freq", "eq1Gain", "eq1Q", "eq1Enabled"],
["eq2Freq", "eq2Gain", "eq2Q", "eq2Enabled"],
Expand Down Expand Up @@ -508,10 +510,26 @@ impl Controller {
}

pub(crate) fn panel_field(&self, d: &Device, def: &'static DeviceDef, view_right: f32) -> PanelCanvas {
let Some(name) = field_name(def) else { return PanelCanvas::default() };
let (x, y, w, h, well_y) = field_rect(def, view_right);
let wh = h - well_y;
let mut c = Canvas::default();
PanelCanvas { x, y, h, well_y, ..self.field_canvas(d, def, w, h - well_y, false) }
}

/// Size of the well a field pointer event comes from: the window's plot while the
/// event comes from a device window, else the card's well.
pub(crate) fn field_size(&self, def: &DeviceDef) -> (f32, f32) {
if self.devices.panel.canvas.window
&& let Some(size) = crate::device_window::plot_size(def)
{
return size;
}
let (_, _, w, fh, well_y) = field_rect(def, crate::device_panel::view_right(def));
(w, fh - well_y)
}

/// A device's field drawn into a w x wh well (the card's, or its window's display).
pub(crate) fn field_canvas(&self, d: &Device, def: &'static DeviceDef, w: f32, wh: f32, window: bool) -> PanelCanvas {
let Some(name) = field_name(def) else { return PanelCanvas::default() };
let mut c = Canvas { window, ..Canvas::default() };
let fields = &self.devices.panel.fields;
let view = self.card_view(d.id);
let drag = fields.drag.as_ref().filter(|g| g.device == d.id && g.active);
Expand All @@ -529,7 +547,7 @@ impl Controller {
draw_pitch(&mut c, &v, accent, w, wh, hot.is_some());
}
"delay" if view == 1 => {
let selected = fields.bands.get(&d.id).copied().unwrap_or(2);
let selected = self.delay_band(d.id);
draw_delay_eq(&mut c, &v, live, accent, w, wh, hot, selected);
}
"delay" => self.draw_delay_echoes(&mut c, d, def, live, accent, w, wh, drag),
Expand All @@ -554,8 +572,8 @@ impl Controller {
};
let mut washes = fields.washes.borrow_mut();
let changed = match c.wash.take() {
Some(w) => washes.insert(d.id, w.clone()).is_none_or(|old| old.key != w.key),
None => washes.remove(&d.id).is_some(),
Some(w) => washes.insert((d.id, window), w.clone()).is_none_or(|old| old.key != w.key),
None => washes.remove(&(d.id, window)).is_some(),
};
drop(washes);
if changed {
Expand All @@ -564,11 +582,8 @@ impl Controller {
PanelCanvas {
visible: true,
well: true,
x,
y,
w,
h,
well_y,
h: wh,
caption: s(caption),
readout: s(value),
paths: model(c.paths),
Expand Down Expand Up @@ -743,7 +758,7 @@ impl Controller {
.map(|v| v.to_bits())
.chain([u32::from_be_bytes([accent.red(), accent.green(), accent.blue(), accent.alpha()])])
.collect();
if let Some(w) = self.devices.panel.fields.washes.borrow().get(&d.id).filter(|w| w.key == key) {
if let Some(w) = self.devices.panel.fields.washes.borrow().get(&(d.id, c.window)).filter(|w| w.key == key) {
c.wash = Some(w.clone());
}
if c.wash.is_none() {
Expand Down Expand Up @@ -1061,8 +1076,7 @@ impl Controller {
let Some(d) = self.project().device(device).cloned() else { return };
let Some(def) = dstudio_core::builtin::def_of(&d) else { return };
let Some(name) = field_name(def) else { return };
let (_, _, w, fh, well_y) = field_rect(def, crate::device_panel::view_right(def));
let h = fh - well_y;
let (w, h) = self.field_size(def);
match phase {
0 => {
let Some(grab) = self.field_hit(&d, def, name, w, h, x, y) else { return };
Expand Down Expand Up @@ -1221,7 +1235,8 @@ impl Controller {
self.devices.panel.fields.live.retain(|id, _| devs.iter().any(|d| d.0 == *id));
let mut ro = Vec::new();
for (id, name, frozen) in devs {
if self.engine.builtin_readouts(id.0, &mut ro).is_err() {
// A window's Hold view keeps the last picture.
if self.win_held(id) || self.engine.builtin_readouts(id.0, &mut ro).is_err() {
continue;
}
let live = self.devices.panel.fields.live.entry(id).or_default();
Expand Down Expand Up @@ -1270,6 +1285,16 @@ impl Controller {

/// Card view switch (Echoes / EQ, Tail / EQ).
/// Card view switch (picker `Control::Views`, sampler tabs): UI state, no undo step.
/// The delay's selected repeat-EQ band (its card's EQ view and window rack).
pub(crate) fn delay_band(&self, device: DeviceId) -> usize {
self.devices.panel.fields.bands.get(&device).copied().unwrap_or(2)
}

pub(crate) fn set_delay_band(&mut self, device: DeviceId, band: usize) {
self.devices.panel.fields.bands.insert(device, band.min(5));
self.ui_dirty = true;
}

pub fn card_view_select(&mut self, device: DeviceId, view: i32) {
if self.sampler_def(device).is_some() {
return self.sampler_tab(device, view);
Expand Down
2 changes: 1 addition & 1 deletion crates/dstudio-app/ui/device_panel.slint
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ export component DeviceCanvas inherits Rectangle {
clip: root.f.well;
accessible-role: groupbox; accessible-label: root.f.caption; accessible-value: root.f.value != "" ? root.f.value : root.f.readout;
for w in Studio.field-washes: Image {
visible: w.device == root.device;
visible: w.device == root.device && w.window == root.window;
x: w.x; y: w.y; width: w.w; height: w.h;
source: w.img; image-fit: fill; image-rendering: smooth;
}
Expand Down
3 changes: 2 additions & 1 deletion crates/dstudio-app/ui/device_window.slint
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ export component DeviceWindowFace inherits Rectangle {
}
if root.card.win.square.visible: Rectangle {
x: root.card.win.square.x; y: root.card.win.square.y; width: root.card.win.square.w; height: root.card.win.square.h;
border-radius: 6px * zm; background: WinStyle.deep; clip: true;
// well: the square's recessed box (a transfer picture); off for a bare control (a range).
border-radius: 6px * zm; background: root.card.win.square.well ? WinStyle.deep : transparent; clip: root.card.win.square.well;
opacity: root.card.enabled ? 1 : 0.45;
for p in root.card.win.square.paths: Path {
viewbox-width: parent.width / 1px; viewbox-height: parent.height / 1px;
Expand Down
2 changes: 1 addition & 1 deletion crates/dstudio-app/ui/studio.slint
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export struct PanelCanvas {
// Intensity image of a field well (Reverb tail), stretched (bilinear) over the box x/y/w/h in
// well coordinates under the paths. Kept out of PanelCanvas: an image field in that struct
// doubled the first frames' render cost of every card.
export struct PanelWash { device: int, img: image, x: length, y: length, w: length, h: length }
export struct PanelWash { device: int, window: bool, img: image, x: length, y: length, w: length, h: length }
// Freely placed control (custom card bodies): kind 0 latch (On/Off parameter), 1 menu pill
// (choice parameter, opens a menu of its choices).
export struct PanelButton { kind: int, param: int, x: length, y: length, w: length, label: string, on: bool }
Expand Down
14 changes: 12 additions & 2 deletions docs/devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ flowchart LR
Character EQ and the plotted-field family: Tremolo, Auto-Panner, Chorus,
Flanger, Phaser, Ring Mod and Character Mod; and the dynamics family:
Compressor, Limiter, Gate, Glue Compressor, Character Compressor and Mastering
Limiter; Transient Shaper; Multiband Compressor), otherwise the card itself in a window. A
Limiter; Transient Shaper; Multiband Compressor; Delay and Reverb), otherwise the card itself in a window. A
window is a face 960 pt wide (Ring Mod 860): a top bar (power, presets, the device's header pills), a
large display (the card's canvas drawn at window size with its axis and
legend), In / Out meters, and rows of controls laid out with the same
Expand Down Expand Up @@ -103,7 +103,17 @@ flowchart LR
band meters), its Threshold and Up Threshold as lines you drag, and the two
crossovers as vertical handles. Its rack card edits the band picked in its
Band menu (`MENU_MB_BAND`, `ACT_MB_BAND`; the same selection as the card's)
beside that band's transfer square. The
beside that band's transfer square. Delay's and Reverb's windows draw their
card's field (`panel_fields.rs`, `field_canvas`) at the plot's size, with
its own wash image for the window (washes are keyed by device and surface),
and send the display's pointer events through the card's field handlers:
`field_size` hit-tests in the window's plot while the event comes from the
window (`canvas.window`). The header carries the card's View pills
(`ACT_VIEW`), Delay's rack edits the repeat-EQ band picked in its Band menu
(`MENU_DELAY_BAND`, `ACT_DELAY_BAND`), and Reverb's Filter range is a bare
canvas (`range_canvas`, the window square without its well) whose two
handles drag Low Cut and High Cut. `--window-height` sets the OS window's
height for screenshots of the 700 pt Reverb window. The
meters read `se_builtin_set_metering` / `se_builtin_levels`
(`Engine::builtin_levels(id, &mut [f32; 4])`): while a window is open the
audio thread keeps the input and output peak of each block, and the app
Expand Down
Loading