Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(meters): VU meters beside the timeline, so you can see how loud it plays

Jareerf1f2f3eab310
diff --git a/src/crates/concat-host/src/playback.rs b/src/crates/concat-host/src/playback.rs
index 5f49ae2e..87cabc7a 100644
--- a/src/crates/concat-host/src/playback.rs
+++ b/src/crates/concat-host/src/playback.rs
@@ -44,7 +44,7 @@
use std::collections::{HashMap, HashSet, VecDeque};
use std::path::{Path, PathBuf};
-use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, Ordering};
+use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU32, AtomicU64, Ordering};
use std::sync::{Arc, Condvar, Mutex, mpsc};
use concat_core::animate::{Ease, Key, Track};
@@ -294,6 +294,11 @@ struct Shared {
/// voiceover takes the picture without the timeline's sound, so the
/// speakers do not bleed into the microphone.
muted: AtomicBool,
+ /// The loudest sample each side has sent the speakers since the meters
+ /// last looked, before the hard limit, as f32 bits: what the VU meters
+ /// show. Above 1.0 is a mix that clipped.
+ peak_left: AtomicU32,
+ peak_right: AtomicU32,
}
/// The longest the clock runs on past the callback's last word. A callback
@@ -309,6 +314,8 @@ impl Shared {
epoch: std::time::Instant::now(),
playing: AtomicBool::new(false),
muted: AtomicBool::new(false),
+ peak_left: AtomicU32::new(0),
+ peak_right: AtomicU32::new(0),
}
}
@@ -538,6 +545,16 @@ impl Playback {
self.shared.playing.load(Ordering::Relaxed)
}
+ /// The loudest sample each side has played since the last call, left
+ /// and right, linear: 1.0 is full scale and above it a mix that
+ /// clipped. Reading resets them: the meters' feed.
+ pub fn take_levels(&self) -> (f32, f32) {
+ (
+ f32::from_bits(self.shared.peak_left.swap(0, Ordering::Relaxed)),
+ f32::from_bits(self.shared.peak_right.swap(0, Ordering::Relaxed)),
+ )
+ }
+
/// Silences the output, or lets it speak again. The clock is not
/// touched: the picture plays on in time either way.
pub fn set_muted(&self, muted: bool) {
@@ -1114,6 +1131,7 @@ where
}
let silent = shared.muted.load(Ordering::Relaxed);
+ let (mut loudest_left, mut loudest_right) = (0.0f32, 0.0f32);
for frame in data.chunks_mut(channels) {
let mut left = 0.0f32;
let mut right = 0.0f32;
@@ -1147,6 +1165,8 @@ where
left = 0.0;
right = 0.0;
}
+ loudest_left = loudest_left.max(left.abs());
+ loudest_right = loudest_right.max(right.abs());
// Hard limit. A mix of boosted clips can exceed full
// scale; wrapping would be far worse than flattening.
frame[0] = T::from_sample(left.clamp(-1.0, 1.0));
@@ -1160,6 +1180,18 @@ where
position += step;
}
+ // One writer, so a load and a store keep the larger without
+ // a compare loop; the meters' swap may land between them and
+ // lose one buffer's peak, which no eye can see.
+ for (cell, loudest) in [
+ (&shared.peak_left, loudest_left),
+ (&shared.peak_right, loudest_right),
+ ] {
+ if loudest > f32::from_bits(cell.load(Ordering::Relaxed)) {
+ cell.store(loudest.to_bits(), Ordering::Relaxed);
+ }
+ }
+
shared.stamp(position);
},
{
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index 7a57bb40..0b463c39 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "Übergang",
"mediaPane.transitions": "Übergänge",
"mediaPane.videoEffects": "Videoeffekte",
+ "meters.clipLight": "Übersteuerungsanzeige: wird rot, wenn der Mix Vollaussteuerung erreicht.",
+ "meters.clipped": "Der Mix hat übersteuert: ein Sample hat Vollaussteuerung erreicht. Zum Zurücksetzen klicken.",
+ "meters.meters": "Pegel",
"modal.copied": "Kopiert",
"monitor.previewFailed": "Vorschau fehlgeschlagen: {0}",
"paneSwitcher.addAPanel": "Panel hinzufügen",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 6da6e722..9b189378 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "transition",
"mediaPane.transitions": "Transitions",
"mediaPane.videoEffects": "Video Effects",
+ "meters.clipLight": "Clip light: turns red when the mix reaches full scale.",
+ "meters.clipped": "The mix clipped: a sample reached full scale. Click to clear.",
+ "meters.meters": "Meters",
"modal.copied": "Copied",
"monitor.previewFailed": "Preview failed: {0}",
"paneSwitcher.addAPanel": "Add a panel",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 56a0ba44..bad7ab79 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "transición",
"mediaPane.transitions": "Transiciones",
"mediaPane.videoEffects": "Efectos de vídeo",
+ "meters.clipLight": "Indicador de saturación: se pone rojo cuando la mezcla llega a escala completa.",
+ "meters.clipped": "La mezcla saturó: una muestra llegó a escala completa. Haz clic para borrar.",
+ "meters.meters": "Medidores",
"modal.copied": "Copiado",
"monitor.previewFailed": "La vista previa falló: {0}",
"paneSwitcher.addAPanel": "Añadir un panel",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index fa1bdc45..55775d30 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "Transition",
"mediaPane.transitions": "Transitionها",
"mediaPane.videoEffects": "افکت‌های ویدئویی",
+ "meters.clipLight": "چراغ کلیپ: وقتی میکس به حداکثر سطح برسد قرمز می‌شود.",
+ "meters.clipped": "میکس کلیپ شد: یک نمونه به حداکثر سطح رسید. برای پاک کردن کلیک کنید.",
+ "meters.meters": "سطح‌سنج",
"modal.copied": "کپی شد",
"monitor.previewFailed": "پیش‌نمایش ناموفق بود: {0}",
"paneSwitcher.addAPanel": "افزودن پنل",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index be9aaa51..5c34c1cb 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "transition",
"mediaPane.transitions": "Transitions",
"mediaPane.videoEffects": "Effets vidéo",
+ "meters.clipLight": "Témoin de saturation : devient rouge quand le mixage atteint la pleine échelle.",
+ "meters.clipped": "Le mixage a saturé : un échantillon a atteint la pleine échelle. Cliquez pour effacer.",
+ "meters.meters": "Vumètres",
"modal.copied": "Copié",
"monitor.previewFailed": "L'aperçu a échoué : {0}",
"paneSwitcher.addAPanel": "Ajouter un panneau",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 8aa39ffc..7ca8c23e 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "prijelaz",
"mediaPane.transitions": "Prijelazi",
"mediaPane.videoEffects": "Video efekti",
+ "meters.clipLight": "Svjetlo odrezivanja: postaje crveno kad miks dosegne punu razinu.",
+ "meters.clipped": "Miks je odrezan: uzorak je dosegao punu razinu. Kliknite za brisanje.",
+ "meters.meters": "Mjerači",
"modal.copied": "Kopirano",
"monitor.previewFailed": "Pregled nije uspio: {0}",
"paneSwitcher.addAPanel": "Dodaj ploču",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 718c8fe9..e7f36300 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "transizione",
"mediaPane.transitions": "Transizioni",
"mediaPane.videoEffects": "Effetti video",
+ "meters.clipLight": "Spia di clip: diventa rossa quando il mix raggiunge il fondo scala.",
+ "meters.clipped": "Il mix è andato in clip: un campione ha raggiunto il fondo scala. Fai clic per azzerare.",
+ "meters.meters": "Indicatori",
"modal.copied": "Copiato",
"monitor.previewFailed": "Anteprima fallita: {0}",
"paneSwitcher.addAPanel": "Aggiungi un pannello",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index c5adde4f..456fa7a6 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "トランジション",
"mediaPane.transitions": "トランジション",
"mediaPane.videoEffects": "ビデオエフェクト",
+ "meters.clipLight": "クリップランプ:ミックスがフルスケールに達すると赤くなります。",
+ "meters.clipped": "ミックスがクリップしました:サンプルがフルスケールに達しました。クリックで解除。",
+ "meters.meters": "メーター",
"modal.copied": "コピーしました",
"monitor.previewFailed": "プレビューに失敗しました:{0}",
"paneSwitcher.addAPanel": "パネルを追加",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index a6bf6a26..96ff4e12 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "전환",
"mediaPane.transitions": "전환",
"mediaPane.videoEffects": "비디오 효과",
+ "meters.clipLight": "클립 표시등: 믹스가 최대치에 도달하면 빨간색이 됩니다.",
+ "meters.clipped": "믹스가 클리핑되었습니다: 샘플이 최대치에 도달했습니다. 클릭하여 지우기.",
+ "meters.meters": "미터",
"modal.copied": "복사됨",
"monitor.previewFailed": "미리보기 실패: {0}",
"paneSwitcher.addAPanel": "패널 추가",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 2ef93875..e1dc94a4 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "transição",
"mediaPane.transitions": "Transições",
"mediaPane.videoEffects": "Efeitos de vídeo",
+ "meters.clipLight": "Luz de clipe: fica vermelha quando a mixagem atinge o fundo de escala.",
+ "meters.clipped": "A mixagem clipou: uma amostra atingiu o fundo de escala. Clique para limpar.",
+ "meters.meters": "Medidores",
"modal.copied": "Copiado",
"monitor.previewFailed": "A pré-visualização falhou: {0}",
"paneSwitcher.addAPanel": "Adicionar um painel",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index e8b71e28..e8d915b6 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "переход",
"mediaPane.transitions": "Переходы",
"mediaPane.videoEffects": "Видеоэффекты",
+ "meters.clipLight": "Индикатор перегрузки: загорается красным, когда микс достигает полной шкалы.",
+ "meters.clipped": "Микс перегружен: сэмпл достиг полной шкалы. Нажмите, чтобы сбросить.",
+ "meters.meters": "Индикаторы",
"modal.copied": "Скопировано",
"monitor.previewFailed": "Просмотр не удался: {0}",
"paneSwitcher.addAPanel": "Добавить панель",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 3c3176c8..8b75d3fd 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "geçiş",
"mediaPane.transitions": "Geçişler",
"mediaPane.videoEffects": "Video efektleri",
+ "meters.clipLight": "Kırpma ışığı: miks tam ölçeğe ulaştığında kırmızı olur.",
+ "meters.clipped": "Miks kırpıldı: bir örnek tam ölçeğe ulaştı. Temizlemek için tıklayın.",
+ "meters.meters": "Ölçerler",
"modal.copied": "Kopyalandı",
"monitor.previewFailed": "Önizleme başarısız: {0}",
"paneSwitcher.addAPanel": "Panel ekle",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 07c818db..e3339273 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "转场",
"mediaPane.transitions": "转场",
"mediaPane.videoEffects": "视频效果",
+ "meters.clipLight": "削波指示灯:混音达到满刻度时变红。",
+ "meters.clipped": "混音削波:有采样达到满刻度。点击清除。",
+ "meters.meters": "电平表",
"modal.copied": "已复制",
"monitor.previewFailed": "预览失败:{0}",
"paneSwitcher.addAPanel": "添加面板",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index d63bda09..538c7800 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -654,6 +654,9 @@
"mediaPane.transition": "轉場",
"mediaPane.transitions": "轉場",
"mediaPane.videoEffects": "影片效果",
+ "meters.clipLight": "削波指示燈:混音達到滿刻度時變紅。",
+ "meters.clipped": "混音削波:有取樣達到滿刻度。點擊清除。",
+ "meters.meters": "電平表",
"modal.copied": "已拷貝",
"monitor.previewFailed": "預覽失敗:{0}",
"paneSwitcher.addAPanel": "加入面板",
diff --git a/src/crates/concat/src/chips.rs b/src/crates/concat/src/chips.rs
index 4de26607..5d51a0ed 100644
--- a/src/crates/concat/src/chips.rs
+++ b/src/crates/concat/src/chips.rs
@@ -45,6 +45,8 @@ pub fn pane_glyph(slug: &str) -> &'static str {
"M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2Z \
M7 9a2 2 0 1 0 4 0a2 2 0 1 0 -4 0 M21 15l-3.086-3.086a2 2 0 0 0-2.828 0L6 21"
}
+ // lucide/chart-no-axes-column
+ "meters" => "M5 21v-6 M12 21V3 M19 21V9",
// lucide/diamond
"keyframes" => "M12 2.5l9.5 9.5-9.5 9.5-9.5-9.5z",
// lucide/sliders-horizontal
diff --git a/src/crates/concat/src/dock.rs b/src/crates/concat/src/dock.rs
index 01481a75..471d363b 100644
--- a/src/crates/concat/src/dock.rs
+++ b/src/crates/concat/src/dock.rs
@@ -14,6 +14,11 @@ pub const SEAT_MIN_H: f32 = 140.0;
pub const SEAT_MIN_GRAB: f32 = 64.0;
/// The gutter between the halves of a split, and the margin round the lot.
pub const SEAT_GAP: f32 = 8.0;
+/// The VU meters' column needs only its bars and its scale.
+pub const METERS_MIN_W: f32 = 64.0;
+/// The meters' share of the bottom row in the default layout: a slim
+/// column beside the timeline, at its full height.
+const METERS_SHARE: f32 = 0.045;
pub enum Dock {
/// One view, filling its box.
@@ -266,7 +271,13 @@ pub fn default_dock() -> Dock {
second: Dock::leaf(PaneKind::Inspector),
}),
}),
- second: Dock::leaf(PaneKind::Timeline),
+ // The timeline, and the VU meters in a slim column beside it.
+ second: Box::new(Dock::Split {
+ columns: true,
+ ratio: 1.0 - METERS_SHARE,
+ first: Dock::leaf(PaneKind::Timeline),
+ second: Dock::leaf(PaneKind::Meters),
+ }),
}
}
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index b8c0e65a..f959490c 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -39,6 +39,7 @@ mod gpu;
mod grading;
mod host;
mod i18n;
+mod meters;
mod platform;
/// What a phone's own crate installs before the window runs: the way to
/// the system's file picker. See `platform::pick_files_async`.
@@ -76,7 +77,7 @@ mod wayland_drop {
}
}
-use dock::{Dock, SEAT_MIN_GRAB, SEAT_MIN_H, SEAT_MIN_W};
+use dock::{Dock, METERS_MIN_W, SEAT_MIN_GRAB, SEAT_MIN_H, SEAT_MIN_W};
use host::{Host, Shell, on_ui};
use panes::Msg;
use panes::captions::CaptionsMsg;
@@ -606,16 +607,31 @@ pub fn run() -> Result<(), slint::PlatformError> {
let Some(path) = state.dock.split_path(held) else {
return;
};
+ // A side that is only the meters may be as narrow as its bars;
+ // every other seat keeps the width its controls need.
+ let narrow = |node: &Dock| matches!(node, Dock::Leaf(PaneKind::Meters));
+ let (first_narrow, second_narrow) = match state.dock.at(&path) {
+ Dock::Split { first, second, .. } => (narrow(first), narrow(second)),
+ Dock::Leaf(_) => (false, false),
+ };
let Dock::Split { columns, ratio, .. } = state.dock.at_mut(&path) else {
return;
};
let wanted = if *columns { SEAT_MIN_W } else { SEAT_MIN_H };
- let floor = if wanted * 2.0 <= extent {
- wanted
- } else {
- SEAT_MIN_GRAB.min(extent / 2.0)
- } / extent;
- *ratio = (from + delta / extent).clamp(floor, 1.0 - floor);
+ let side = |is_narrow: bool| {
+ if is_narrow && *columns {
+ METERS_MIN_W
+ } else if wanted * 2.0 <= extent {
+ wanted
+ } else {
+ SEAT_MIN_GRAB.min(extent / 2.0)
+ }
+ };
+ let (low, high) = (
+ side(first_narrow) / extent,
+ 1.0 - side(second_narrow) / extent,
+ );
+ *ratio = (from + delta / extent).clamp(low, high.max(low));
}));
// ── the bin ──
@@ -1132,6 +1148,16 @@ pub fn run() -> Result<(), slint::PlatformError> {
.on_query_changed(on_window!(|state, text: SharedString| {
state.font_query = text.to_string();
}));
+ app.global::<Meters>().on_clip_cleared({
+ let weak = app.as_weak();
+ move || {
+ if let Some(app) = weak.upgrade() {
+ crate::host::Shell::with(|shell, _| {
+ shell.studio.borrow_mut().meters.clear_clip(&app);
+ });
+ }
+ }
+ });
app.global::<SourcePreview>().on_closed(on_window!(|state| {
state.close_source();
}));
diff --git a/src/crates/concat/src/meters.rs b/src/crates/concat/src/meters.rs
new file mode 100644
index 00000000..cc19afb2
--- /dev/null
+++ b/src/crates/concat/src/meters.rs
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! The VU meters' feed: playback's peaks, thirty times a second, onto the
+//! Meters global, with the ballistics a meter needs - up at once, down at
+//! a steady rate, the loudest of the last moment held as a line, and the
+//! clip light latched until it is clicked.
+//!
+//! The timer runs only while something plays, and for the moment after it
+//! takes the bars to fall; it stops itself once they are down.
+
+use slint::ComponentHandle;
+
+use crate::ui::Meters;
+
+/// The meters' floor in dB: their 0. Their 1 is 0 dB.
+const FLOOR_DB: f32 = -60.0;
+/// How fast a bar falls, in dB a second.
+const FALL_DB_PER_SECOND: f32 = 24.0;
+/// How long the held peak stays before it starts to fall.
+const HOLD_SECONDS: f32 = 1.5;
+const TICK: std::time::Duration = std::time::Duration::from_millis(33);
+
+/// A linear sample level as the meters' `0..1` decibel scale.
+pub fn scale(level: f32) -> f32 {
+ if level <= 0.0 {
+ return 0.0;
+ }
+ let db = 20.0 * level.log10();
+ ((db - FLOOR_DB) / -FLOOR_DB).clamp(0.0, 1.0)
+}
+
+/// One side's bar and its held peak, on the meters' scale.
+#[derive(Default, Clone, Copy)]
+struct Side {
+ shown: f32,
+ held: f32,
+ held_for: f32,
+}
+
+impl Side {
+ /// One tick: `level` is the loudest sample since the last.
+ fn tick(&mut self, level: f32, seconds: f32) {
+ let fall = FALL_DB_PER_SECOND * seconds / -FLOOR_DB;
+ let now = scale(level);
+ self.shown = now.max(self.shown - fall).max(0.0);
+ if now >= self.held {
+ self.held = now;
+ self.held_for = 0.0;
+ } else {
+ self.held_for += seconds;
+ if self.held_for > HOLD_SECONDS {
+ self.held = (self.held - fall).max(self.shown);
+ }
+ }
+ }
+
+ fn quiet(&self) -> bool {
+ self.shown <= 0.0 && self.held <= 0.0
+ }
+}
+
+/// The meters' state, kept by the studio.
+#[derive(Default)]
+pub struct MeterFeed {
+ left: Side,
+ right: Side,
+ pub clipped: bool,
+ timer: slint::Timer,
+}
+
+impl MeterFeed {
+ /// Something started playing: the meters follow it.
+ pub fn wake(&self) {
+ if self.timer.running() {
+ return;
+ }
+ self.timer.start(slint::TimerMode::Repeated, TICK, || {
+ crate::host::Shell::with(|shell, app| {
+ let mut studio = shell.studio.borrow_mut();
+ let rolling =
+ studio.playing || studio.source.as_ref().is_some_and(|source| source.playing);
+ let (left, right) = studio.host.playback.take_levels();
+ let feed = &mut studio.meters;
+ feed.left.tick(left, TICK.as_secs_f32());
+ feed.right.tick(right, TICK.as_secs_f32());
+ feed.clipped |= left >= 1.0 || right >= 1.0;
+ feed.publish(&app);
+ if !rolling && feed.left.quiet() && feed.right.quiet() {
+ feed.timer.stop();
+ }
+ });
+ });
+ }
+
+ /// The clip light was clicked.
+ pub fn clear_clip(&mut self, app: &crate::ui::App) {
+ self.clipped = false;
+ self.publish(app);
+ }
+
+ fn publish(&self, app: &crate::ui::App) {
+ let meters = app.global::<Meters>();
+ meters.set_left(self.left.shown);
+ meters.set_right(self.right.shown);
+ let hold = |side: &Side| if side.held > 0.0 { side.held } else { -1.0 };
+ meters.set_hold_left(hold(&self.left));
+ meters.set_hold_right(hold(&self.right));
+ meters.set_clipped(self.clipped);
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn full_scale_is_the_top_and_the_floor_is_the_foot() {
+ assert_eq!(scale(1.0), 1.0);
+ assert_eq!(scale(0.0), 0.0);
+ assert!((scale(0.5) - (1.0 - 6.0206 / 60.0)).abs() < 1e-3, "-6 dB");
+ assert_eq!(scale(0.0001), 0.0, "below -60 dB sits on the floor");
+ assert_eq!(scale(2.0), 1.0, "a clipped mix stops at the top");
+ }
+
+ #[test]
+ fn a_bar_rises_at_once_and_falls_steadily_while_its_peak_holds() {
+ let mut side = Side::default();
+ side.tick(1.0, 0.033);
+ assert_eq!(side.shown, 1.0);
+ side.tick(0.0, 0.5);
+ // Twenty-four dB a second for half a second is twelve dB down.
+ assert!((side.shown - (1.0 - 12.0 / 60.0)).abs() < 1e-4);
+ assert_eq!(side.held, 1.0, "the peak holds");
+ side.tick(0.0, 1.1);
+ assert!(side.held < 1.0, "past the hold it falls too");
+ }
+}
diff --git a/src/crates/concat/src/source.rs b/src/crates/concat/src/source.rs
index fe770f51..5b35c4ee 100644
--- a/src/crates/concat/src/source.rs
+++ b/src/crates/concat/src/source.rs
@@ -151,6 +151,7 @@ impl Studio {
}
source.playing = true;
self.host.playback.play(source.time);
+ self.meters.wake();
source.timer.start(
slint::TimerMode::Repeated,
std::time::Duration::from_millis(16),
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 88f79e1e..a19b2443 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -905,6 +905,8 @@ pub struct Studio {
/// A file from the library lent the monitor and the speakers; see
/// `crate::source`.
pub source: Option<crate::source::Source>,
+ /// The VU meters' feed; see `crate::meters`.
+ pub meters: crate::meters::MeterFeed,
/// The voiceover take, while one runs.
pub voiceover: crate::panes::voiceover::VoiceoverPane,
/// Every speaker the voice engine offers, in its own order.
@@ -2011,6 +2013,7 @@ impl Studio {
captions: crate::panes::captions::CaptionsPane::default(),
speech: crate::panes::speech::SpeechPane::default(),
source: None,
+ meters: crate::meters::MeterFeed::default(),
voiceover: crate::panes::voiceover::VoiceoverPane::default(),
text_presets,
installed_fonts: presets::installed_fonts(&host.dirs),
@@ -2628,6 +2631,7 @@ impl Studio {
self.playing = true;
log::debug!("playback: playing from {:.3}s", self.playhead);
self.host.playback.play(f64::from(self.playhead));
+ self.meters.wake();
// The clock is the audio device's. This looks at it far more often
// than any timeline's frame rate and acts only when the frame under
// it changes, so each frame is asked for within a few milliseconds of
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index 130c44bb..725e94f3 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -41,6 +41,7 @@ import { ParamFormat } from "inspector/controls.slint";
import { ToastData, ToastLayer } from "primitives/toast.slint";
import { TooltipLayer } from "primitives/tooltip.slint";
import { FontSearch } from "inspector/font-picker.slint";
+import { Meters } from "workspace/meters-pane.slint";
import { Workspace } from "workspace/workspace.slint";
import {
ClipData, ClipField, ClipKeyData, ClipKind, ClipTextField, DropData, Keyframes,
@@ -55,7 +56,7 @@ export {
Curves, Fmt, Focus, Payload, Theme, Bezier, Editor, I18n,
AppliedEntryData, AppliedParamData, CatalogueEntryData, Library, LibraryViewData, ParamFormat,
DockDivider, DockSide, PaneKind, SeatBox,
- EffectData, FontSearch, MediaFilter, MediaItemData, MediaKind, SourcePreview, TextPresetData,
+ EffectData, FontSearch, Meters, MediaFilter, MediaItemData, MediaKind, SourcePreview, TextPresetData,
ClipData, ClipField, ClipKeyData, ClipKind, ClipTextField, DropData, Keyframes,
KeyEditor, KeyMarkData, KeyRowData,
SelectedClipData, SelectedTransitionData, StageGuideData, StageItemData, TextAlignment, TimelineTabData,
diff --git a/src/crates/concat/ui/icons.slint b/src/crates/concat/ui/icons.slint
index 37f756f1..6591d56b 100644
--- a/src/crates/concat/ui/icons.slint
+++ b/src/crates/concat/ui/icons.slint
@@ -118,6 +118,8 @@ export enum Glyph {
waveform,
filter,
eye-off,
+ /// three bars of different heights: the VU meters
+ meter,
/// a microphone: the tray's voiceover
mic,
/// a square: stop, as on any recorder
@@ -392,6 +394,12 @@ export component Icon inherits Rectangle {
+ " 0 0 0 8.268 8.268c.344-.215.825-.004.803.401";
}
+ // lucide/chart-no-axes-column
+ if root.glyph == Glyph.meter: Stroked {
+ size: root.size; tint: root.tint; weight: root.weight;
+ commands: "M5 21v-6 M12 21V3 M19 21V9";
+ }
+
// lucide/mic
if root.glyph == Glyph.mic: Stroked {
size: root.size; tint: root.tint; weight: root.weight;
diff --git a/src/crates/concat/ui/workspace/meters-pane.slint b/src/crates/concat/ui/workspace/meters-pane.slint
new file mode 100644
index 00000000..e9d16fdf
--- /dev/null
+++ b/src/crates/concat/ui/workspace/meters-pane.slint
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+// The VU meters: how loud the timeline plays, left and right, while it
+// plays. A slim column beside the timeline by default. Each bar is the
+// peak level on a decibel scale - 0 dB at the top, -60 at the foot -
+// with the loudest of the last moment held as a line, and a light at the
+// top that stays red once the mix has clipped, until it is clicked.
+
+import { I18n } from "../i18n.slint";
+import { Theme } from "../theme/theme.slint";
+import { LevelMeter } from "../primitives/level-meter.slint";
+import { Tip } from "../primitives/tooltip.slint";
+import { Pane } from "pane.slint";
+import { PaneKind, PaneSwitcher } from "pane-switcher.slint";
+
+/// The levels, published by Rust (concat's meters.rs) thirty times a second
+/// while anything plays. Each is `0..1` on the meter's decibel scale.
+export global Meters {
+ in property <float> left;
+ in property <float> right;
+ /// The loudest of the last moment, held; negative hides it.
+ in property <float> hold-left: -1;
+ in property <float> hold-right: -1;
+ /// A sample reached full scale since the light was last cleared.
+ in property <bool> clipped;
+ callback clip-cleared();
+}
+
+export component MetersPane inherits Pane {
+ in property <int> pane-seat;
+ in property <bool> pane-removable;
+ callback pane-picked(kind: PaneKind);
+ callback pane-removed();
+
+ /// The scale's floor, in dB: the meters' 0 is this, their 1 is 0 dB.
+ property <float> floor-db: -60;
+ property <[float]> marks: [0, -6, -12, -24, -36, -48];
+
+ VerticalLayout {
+ // The other panes' bar height, and only the switcher in it: the
+ // column is too narrow for a name, and the bars say what it is.
+ Rectangle {
+ height: 52px;
+ Rectangle {
+ y: parent.height - 1px;
+ height: 1px;
+ background: Theme.line;
+ }
+ HorizontalLayout {
+ alignment: center;
+ VerticalLayout {
+ alignment: center;
+ PaneSwitcher {
+ kind: PaneKind.meters;
+ seat: root.pane-seat;
+ removable: root.pane-removable;
+ picked(kind) => { root.pane-picked(kind); }
+ removed => { root.pane-removed(); }
+ }
+ }
+ }
+ }
+
+ VerticalLayout {
+ padding: 8px;
+ spacing: 6px;
+
+ // The clip light: red once the mix has hit full scale, until
+ // clicked.
+ HorizontalLayout {
+ alignment: center;
+ light := Rectangle {
+ width: 30px;
+ height: 8px;
+ border-radius: 2px;
+ background: Meters.clipped ? Theme.danger : Theme.field;
+ border-width: 1px;
+ border-color: Meters.clipped ? Theme.danger : Theme.line;
+
+ light-touch := TouchArea {
+ mouse-cursor: pointer;
+ clicked => { Meters.clip-cleared(); }
+ }
+ Tip {
+ text: Meters.clipped ? I18n.t("meters.clipped") : I18n.t("meters.clipLight");
+ active: light-touch.has-hover;
+ }
+ }
+ }
+
+ // The bars, and the scale beside them.
+ HorizontalLayout {
+ vertical-stretch: 1;
+ alignment: center;
+ spacing: 3px;
+
+ scale := Rectangle {
+ width: 20px;
+ for db in root.marks: Text {
+ x: parent.width - self.width;
+ y: (1 - (db - root.floor-db) / (0 - root.floor-db)) * parent.height
+ - self.height / 2;
+ text: "\{-db}";
+ color: Theme.fg-dim;
+ font-family: Theme.font-technical;
+ font-size: Theme.fs-xs;
+ }
+ }
+ LevelMeter {
+ vertical: true;
+ thickness: 10px;
+ value: Meters.left;
+ peak: Meters.hold-left;
+ }
+ LevelMeter {
+ vertical: true;
+ thickness: 10px;
+ value: Meters.right;
+ peak: Meters.hold-right;
+ }
+ }
+
+ HorizontalLayout {
+ alignment: center;
+ spacing: 3px;
+ Rectangle { width: 20px; }
+ Text {
+ width: 10px;
+ text: "L";
+ color: Theme.fg-dim;
+ font-size: Theme.fs-xs;
+ horizontal-alignment: center;
+ }
+ Text {
+ width: 10px;
+ text: "R";
+ color: Theme.fg-dim;
+ font-size: Theme.fs-xs;
+ horizontal-alignment: center;
+ }
+ }
+ }
+ }
+}
diff --git a/src/crates/concat/ui/workspace/pane-switcher.slint b/src/crates/concat/ui/workspace/pane-switcher.slint
index 88c0f8d9..62144850 100644
--- a/src/crates/concat/ui/workspace/pane-switcher.slint
+++ b/src/crates/concat/ui/workspace/pane-switcher.slint
@@ -39,6 +39,8 @@ export enum PaneKind {
timeline,
/// the selected clip's keys: a dopesheet and a curve editor
keyframes,
+ /// the VU meters: how loud the timeline plays, left and right
+ meters,
}
export global Panes {
@@ -60,6 +62,7 @@ export global Panes {
: kind == PaneKind.preview ? I18n.t("common.preview")
: kind == PaneKind.inspector ? I18n.t("paneSwitcher.inspector")
: kind == PaneKind.keyframes ? I18n.t("common.keyframes")
+ : kind == PaneKind.meters ? I18n.t("meters.meters")
: I18n.t("paneSwitcher.timeline");
}
@@ -71,6 +74,7 @@ export global Panes {
: kind == PaneKind.preview ? "preview"
: kind == PaneKind.inspector ? "inspector"
: kind == PaneKind.keyframes ? "keyframes"
+ : kind == PaneKind.meters ? "meters"
: "timeline";
}
@@ -83,6 +87,7 @@ export global Panes {
: kind == PaneKind.preview ? Glyph.image
: kind == PaneKind.inspector ? Glyph.settings
: kind == PaneKind.keyframes ? Glyph.keyframe
+ : kind == PaneKind.meters ? Glyph.meter
: Glyph.rows;
}
}
@@ -247,14 +252,14 @@ export component PaneSwitcher inherits Rectangle {
"pane:\{root.seat}:\{Panes.label(root.kind)}:\{Panes.id(root.kind)}";
property <length> menu-w: 168px;
- /// Five view rows, then the rule and the row that removes the panel, then
+ /// Six view rows, then the rule and the row that removes the panel, then
/// the surface's own padding. Summed here because a PopupWindow is sized
/// by whoever places it — the same rule the context menu follows, and the
/// same reason: a layout cannot report its height back up before it has
/// somewhere to be laid out. When the Keyframes row arrived this still
/// said four, and the row that removes the panel was the one under the
/// clip.
- property <length> list-h: 5 * 26px + 9px + 26px + 8px;
+ property <length> list-h: 6 * 26px + 9px + 26px + 8px;
/// The whole list when the window has room for it under the button, and
/// the room otherwise, with the rest reached by scrolling. Never under
/// three rows: shorter than that is not a list worth scrolling, and
@@ -394,6 +399,11 @@ export component PaneSwitcher inherits Rectangle {
current: root.kind == PaneKind.keyframes;
chosen => { menu.close(); root.picked(PaneKind.keyframes); }
}
+ SwitchRow {
+ kind: PaneKind.meters;
+ current: root.kind == PaneKind.meters;
+ chosen => { menu.close(); root.picked(PaneKind.meters); }
+ }
SwitchRow {
kind: PaneKind.timeline;
current: root.kind == PaneKind.timeline;
@@ -425,7 +435,7 @@ export component AddPaneButton inherits Rectangle {
property <length> menu-w: 168px;
/// Five view rows and the surface's padding; held to the room under the
/// button the way the seat's own menu is.
- property <length> list-h: 5 * 26px + 8px;
+ property <length> list-h: 6 * 26px + 8px;
property <length> menu-h: Math.min(root.list-h, Math.max(3 * 26px + 8px,
Panes.room-below(root.absolute-position.y + root.height + 4px)));
@@ -497,6 +507,10 @@ export component AddPaneButton inherits Rectangle {
kind: PaneKind.keyframes;
chosen => { menu.close(); root.added(PaneKind.keyframes); }
}
+ SwitchRow {
+ kind: PaneKind.meters;
+ chosen => { menu.close(); root.added(PaneKind.meters); }
+ }
SwitchRow {
kind: PaneKind.timeline;
chosen => { menu.close(); root.added(PaneKind.timeline); }
diff --git a/src/crates/concat/ui/workspace/seat.slint b/src/crates/concat/ui/workspace/seat.slint
index a6b5f9d8..3ef91fdf 100644
--- a/src/crates/concat/ui/workspace/seat.slint
+++ b/src/crates/concat/ui/workspace/seat.slint
@@ -11,6 +11,7 @@ import { MediaPane, SourcePreview } from "media-pane.slint";
import { PreviewPane } from "preview-pane.slint";
import { TimelinePane } from "timeline-pane.slint";
import { KeyframesPane } from "keyframes-pane.slint";
+import { MetersPane } from "meters-pane.slint";
// One box of the workspace, showing whichever view its `kind` names.
//
@@ -330,6 +331,18 @@ export component Seat inherits Rectangle {
}
}
+ if root.kind == PaneKind.meters: MetersPane {
+ x: 0;
+ y: 0;
+ width: root.width;
+ height: root.height;
+
+ pane-picked(kind) => { root.picked(kind); }
+ pane-seat: root.index;
+ pane-removable: Editor.seats.length > 1;
+ pane-removed => { root.removed(); }
+ }
+
if root.kind == PaneKind.keyframes: KeyframesPane {
x: 0;
y: 0;