forked from Furumi/furumi-tui
Add VFD panel effects and a local-time clock for visualizations
The VFD panel gains a dot-matrix title line (5x7 Latin and Cyrillic in braille, smooth scrolling), palettes, optional needle VU meters, a night dimmer, a filament "breath" and loudness brightening, uneven digit brightness, a mesh behind the big digits, a tape counter, LOUDNESS / MUTE / SEARCH lamps, a burst of static on track and source changes, and a standby clock with a sweep at the top of every minute. The visualization clock now shows local time (it showed UTC), and scripts get clock_hour, clock_minute, clock_second and clock_millis from the same reading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8606f08a36
commit
61027d22ca
6 files changed
+722
-181
No files matched your search
+1
-1
@@ -507,7 +507,7 @@ Protocol v3 adds what front-panel displays need: a third-octave spectrum
|
||||
partition the FFT bins) with per-band peak hold, left/right RMS and held
|
||||
sample peaks, the analyzed sample rate, and track, queue and transport
|
||||
details (format, bit depth, bitrate, track number, queue position, repeat,
|
||||
shuffle, source). The audio thread only appends mono samples to a lock-free
|
||||
shuffle, source), and the local wall-clock time. The audio thread only appends mono samples to a lock-free
|
||||
ring and accumulates per-window channel levels; the FFT (an ~85 ms window
|
||||
whose length follows the sample rate) and all ballistics run when the UI
|
||||
takes a snapshot, under a mutex the audio thread never touches. Ballistics
|
||||
|
||||
+12
-2
@@ -13,14 +13,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
thin segment digits, a stereo peak level meter, a 25-band analyzer with
|
||||
peak hold, tone fans, a routing diagram and transport lamps, plus a
|
||||
power-on segment test, a counter "search" on track changes and an OVER
|
||||
lamp.
|
||||
lamp. It also has a dot-matrix title line (Latin and Cyrillic), palettes
|
||||
("classic", "green", "amber", "ice"), needle VU meters as an option, a
|
||||
night dimmer, a slow filament "breath", slightly uneven digit brightness,
|
||||
a mesh behind the big digits, a tape counter, LOUDNESS / MUTE / SEARCH
|
||||
lamps, a burst of static on track changes and a standby clock when
|
||||
nothing is loaded.
|
||||
- Visualization protocol v3: a real third-octave spectrum (31 bands) with
|
||||
peak hold, left/right RMS and held peaks, the sample rate, and track,
|
||||
queue and transport details in the script input; `render` may return
|
||||
`#{ commands, state }` to keep state between frames (with `dt` and
|
||||
`frame`); new braille `dots` and `line` commands for thin drawing; bold,
|
||||
dim, italic, underline and reversed attributes on any command. v2 scripts
|
||||
keep working unchanged.
|
||||
keep working unchanged. Scripts also get the local time as
|
||||
`clock_hour`, `clock_minute`, `clock_second` and `clock_millis`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- The visualization clock shows local time instead of UTC.
|
||||
|
||||
## [0.5.0] - 2026-11-20
|
||||
|
||||
|
||||
Generated
+1
@@ -1720,6 +1720,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"base64",
|
||||
"blake3",
|
||||
"chrono",
|
||||
"core-foundation 0.10.1",
|
||||
"crokey",
|
||||
"crossterm",
|
||||
|
||||
@@ -23,6 +23,8 @@ object = { version = "0.36", default-features = false, features = ["read", "std"
|
||||
|
||||
anyhow = "1.0.102"
|
||||
blake3 = "1"
|
||||
# Local wall-clock time for visualizations (the clock and its hour/minute).
|
||||
chrono = { version = "0.4.45", default-features = false, features = ["clock"] }
|
||||
crokey = "1.4.0"
|
||||
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
||||
directories = "6.0.0"
|
||||
|
||||
+575
-166
File diff suppressed because it is too large.
Load diff
+131
-12
@@ -58,7 +58,7 @@ const BUNDLED_SCRIPTS: &[BundledScript] = &[
|
||||
id: "vfd_panel",
|
||||
file_name: "vfd_panel.rhai",
|
||||
display_name: "VFD panel",
|
||||
version: 1,
|
||||
version: 2,
|
||||
source: include_str!("visualizations/vfd_panel.rhai"),
|
||||
},
|
||||
];
|
||||
@@ -348,7 +348,15 @@ fn input_map_with_features(area: Rect, state: &AppState, features: AudioFeatures
|
||||
"show_clock".into(),
|
||||
state.visualizer.config.show_clock.into(),
|
||||
);
|
||||
input.insert("clock".into(), clock_label().into());
|
||||
let (hour, minute, second, millis) = clock_now();
|
||||
input.insert(
|
||||
"clock".into(),
|
||||
format!("{hour:02}:{minute:02}:{second:02}").into(),
|
||||
);
|
||||
insert_int(&mut input, "clock_hour", i64::from(hour));
|
||||
insert_int(&mut input, "clock_minute", i64::from(minute));
|
||||
insert_int(&mut input, "clock_second", i64::from(second));
|
||||
insert_int(&mut input, "clock_millis", i64::from(millis));
|
||||
let (title, artist) = state
|
||||
.player
|
||||
.current
|
||||
@@ -1275,16 +1283,16 @@ fn insert_float(map: &mut Map, key: &str, value: f64) {
|
||||
map.insert(key.into(), Dynamic::from_float(value as FLOAT));
|
||||
}
|
||||
|
||||
fn clock_label() -> String {
|
||||
let secs = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.map(|duration| duration.as_secs())
|
||||
.unwrap_or(0);
|
||||
format!(
|
||||
"{:02}:{:02}:{:02}",
|
||||
secs / 3600 % 24,
|
||||
secs / 60 % 60,
|
||||
secs % 60
|
||||
/// Local wall-clock time as (hour, minute, second, millisecond), read once
|
||||
/// so all clock inputs of a frame agree.
|
||||
fn clock_now() -> (u32, u32, u32, u32) {
|
||||
use chrono::Timelike as _;
|
||||
let now = chrono::Local::now();
|
||||
(
|
||||
now.hour(),
|
||||
now.minute(),
|
||||
now.second(),
|
||||
now.timestamp_subsec_millis().min(999),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2005,6 +2013,117 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vfd_panel_options_standby_and_effects_render() {
|
||||
let base = BUNDLED_SCRIPTS
|
||||
.iter()
|
||||
.find(|script| script.id == "vfd_panel")
|
||||
.unwrap()
|
||||
.source;
|
||||
let variants = [
|
||||
base.to_string(),
|
||||
base.replacen(
|
||||
r#"fn METER_STYLE() { "bars" }"#,
|
||||
r#"fn METER_STYLE() { "needles" }"#,
|
||||
1,
|
||||
),
|
||||
base.replacen(
|
||||
r#"fn PALETTE() { "classic" }"#,
|
||||
r#"fn PALETTE() { "green" }"#,
|
||||
1,
|
||||
),
|
||||
base.replacen(
|
||||
r#"fn PALETTE() { "classic" }"#,
|
||||
r#"fn PALETTE() { "ice" }"#,
|
||||
1,
|
||||
),
|
||||
];
|
||||
assert_ne!(variants[0], variants[1]);
|
||||
assert_ne!(variants[0], variants[2]);
|
||||
for source in variants {
|
||||
let file = tempfile::NamedTempFile::new().unwrap();
|
||||
std::fs::write(file.path(), &source).unwrap();
|
||||
for (width, height) in [(30, 8), (80, 24), (160, 45), (240, 70)] {
|
||||
for title in ["", "Даже не думай — Ёлка", "Track"] {
|
||||
let mut runtime = ScriptRuntime::default();
|
||||
// Past the power-on test, with static and a seek pending.
|
||||
let state: Map = [
|
||||
("boot".into(), Dynamic::from_float(-1.0)),
|
||||
("spin".into(), Dynamic::from_float(0.3)),
|
||||
("over".into(), Dynamic::from_float(0.5)),
|
||||
("noise".into(), Dynamic::from_float(0.2)),
|
||||
("search".into(), Dynamic::from_float(0.4)),
|
||||
("key".into(), "another track".into()),
|
||||
("source".into(), "local".into()),
|
||||
("last_pos".into(), Dynamic::from_float(5.0)),
|
||||
]
|
||||
.into_iter()
|
||||
.collect();
|
||||
runtime.load(file.path()).unwrap();
|
||||
runtime.script_state = Dynamic::from_map(state);
|
||||
let mut input = test_input();
|
||||
insert_int(&mut input, "width", width);
|
||||
insert_int(&mut input, "height", height);
|
||||
input.insert("track_title".into(), title.into());
|
||||
insert_float(&mut input, "volume", 0.2);
|
||||
insert_int(&mut input, "clock_hour", 23);
|
||||
insert_int(&mut input, "clock_second", 1);
|
||||
let commands = runtime
|
||||
.render(file.path(), input)
|
||||
.unwrap_or_else(|err| panic!("{width}x{height} {title:?}: {err}"));
|
||||
let area = Rect::new(0, 0, width as u16, height as u16);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
render_commands_to_buffer(&mut buffer, area, &commands);
|
||||
if title.is_empty() && width >= 80 {
|
||||
let text = rendered_text(&commands);
|
||||
assert!(
|
||||
text.contains("STANDBY"),
|
||||
"{width}x{height}: no standby clock"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vfd_panel_clock_keeps_clear_of_the_lamps() {
|
||||
let script = BUNDLED_SCRIPTS
|
||||
.iter()
|
||||
.find(|script| script.id == "vfd_panel")
|
||||
.unwrap();
|
||||
let file = tempfile::NamedTempFile::new().unwrap();
|
||||
std::fs::write(file.path(), script.source).unwrap();
|
||||
for (width, height) in [(120, 34), (160, 34), (180, 40)] {
|
||||
let mut runtime = ScriptRuntime::default();
|
||||
runtime.load(file.path()).unwrap();
|
||||
runtime.script_state = Dynamic::from_map(
|
||||
[("boot".into(), Dynamic::from_float(-1.0))]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
);
|
||||
let mut input = test_input();
|
||||
insert_int(&mut input, "width", width);
|
||||
insert_int(&mut input, "height", height);
|
||||
let commands = runtime.render(file.path(), input).unwrap();
|
||||
let area = Rect::new(0, 0, width as u16, height as u16);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
render_commands_to_buffer(&mut buffer, area, &commands);
|
||||
let rows: Vec<String> = (0..area.height)
|
||||
.map(|y| {
|
||||
(0..area.width)
|
||||
.map(|x| buffer[(x, y)].symbol().to_string())
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
assert!(rows[0].contains("12:34:56"), "{width}x{height}: clock");
|
||||
assert!(
|
||||
rows.iter().any(|row| row.contains("HIGH")),
|
||||
"{width}x{height}: lamps overdrawn"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_modifiers_reach_the_buffer() {
|
||||
let command = DrawCommand::from_dynamic(Dynamic::from_map(
|
||||
|
||||
Reference in new issue
Block a user