VFD panel: live signal path output row

The lower row of the signal path schematic was decoration (TONE, AMP,
SPEAKERS A). It now shows what leaves the player, read right to left
after the volume stage: the sample rate, STEREO or MONO, and the output
peak after the volume (the analyzer measures before rodio's gain, which
is volume cubed), refreshed four times a second and red near full scale.
The compact strip line and the transport STEREO lamp use the same values.

Comparing the L and R levels cannot tell stereo from mono: a wide mix
with balanced channels has equal levels. The analyzer therefore also
accumulates the side signal (L - R) / 2 per window, exposed as
level_side, and the meter decides stereo or mono on loud raw windows
(side within 30 dB of the louder channel), before any ballistics, and
keeps the decision through silence; scripts get it as channel_mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-21 22:12:41 +02:00
1 parent 5a00a1c8e8
commit 3e60195352
6 files changed
+233 -31

No files matched your search

+2 -1
View File
@@ -505,7 +505,8 @@ ratatui frame or audio engine directly.
Protocol v3 adds what front-panel displays need: a third-octave spectrum
(31 bands, 20 Hz to 20 kHz, nominal ISO labels with exact base-2 edges that
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
sample peaks, the RMS of the side signal (L - R) / 2 and a
stereo/mono decision made on loud windows, the analyzed sample rate, and track, queue and transport
details (format, bit depth, bitrate, track number, queue position, repeat,
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
+5 -2
View File
@@ -13,7 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
thin segment digits, a stereo peak level meter (bars or needle VU meters),
a 25-band analyzer with three levels of glow, a nonlinear scale and peak
hold, a peak frequency readout with hold, tone fans, a signal path
schematic with a travelling pulse, the transport word in segment letters,
schematic with a travelling pulse (source, format, volume, sample rate,
stereo or mono, and the output level in dBFS), the transport word in segment letters,
mode lamps (REPEAT, SHUFFLE, source, LOUDNESS, MUTE, SEARCH, OVER), a tape
counter and a dot-matrix title line (Latin and Cyrillic). Effects: a
power-on segment test, a counter "search" on track changes, static on
@@ -36,7 +37,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Shift+M` in the fullscreen visualizer switches its display mode; the
choice is saved in `visualizations.toml`.
- Visualization protocol v3: a real third-octave spectrum (31 bands) with
peak hold, left/right RMS and held peaks, the sample rate, and track,
peak hold, left/right RMS and held peaks, the side-signal level
(`level_side`, the floor for mono) and `channel_mode` ("stereo" or
"mono"), 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,
+63 -7
View File
@@ -33,6 +33,12 @@ pub struct AudioAnalysisSnapshot {
pub level_r: f64,
pub peak_l: f64,
pub peak_r: f64,
/// RMS of the side signal (L - R) / 2 on the same scale: the floor for
/// mono sources and for stereo files that carry the same signal twice.
pub level_side: f64,
/// Whether the channels carry different signals: decided on loud windows
/// only (side within 30 dB of the louder channel), `None` until then.
pub stereo: Option<bool>,
/// Sample rate of the analyzed stream in Hz (0 when nothing has played
/// since the player last stopped).
pub sample_rate: u32,
@@ -56,6 +62,7 @@ pub struct AnalyzerShared {
/// with `fetch_max` until the meter consumes them.
rms_l: AtomicU32,
rms_r: AtomicU32,
rms_side: AtomicU32,
peak_l: AtomicU32,
peak_r: AtomicU32,
/// Ballistics and FFT state. Only snapshot readers (the UI side) lock it;
@@ -79,6 +86,7 @@ impl Default for AnalyzerShared {
sample_rate: AtomicU32::new(0),
rms_l: AtomicU32::new(0),
rms_r: AtomicU32::new(0),
rms_side: AtomicU32::new(0),
peak_l: AtomicU32::new(0),
peak_r: AtomicU32::new(0),
meter: Mutex::new(Meter::default()),
@@ -108,7 +116,13 @@ impl AnalyzerShared {
for sample in self.pcm.iter() {
sample.store(0, Ordering::Relaxed);
}
for level in [&self.rms_l, &self.rms_r, &self.peak_l, &self.peak_r] {
for level in [
&self.rms_l,
&self.rms_r,
&self.rms_side,
&self.peak_l,
&self.peak_r,
] {
level.store(0, Ordering::Relaxed);
}
self.sequence.store(0, Ordering::Relaxed);
@@ -143,6 +157,7 @@ impl AnalyzerShared {
let stereo = StereoReading {
rms_l: load_norm(&self.rms_l) as f32,
rms_r: load_norm(&self.rms_r) as f32,
rms_side: load_norm(&self.rms_side) as f32,
peak_l: f64::from(self.peak_l.swap(0, Ordering::Relaxed)) as f32 / LEVEL_SCALE,
peak_r: f64::from(self.peak_r.swap(0, Ordering::Relaxed)) as f32 / LEVEL_SCALE,
};
@@ -170,6 +185,8 @@ impl AnalyzerShared {
level_r: reading.level_r,
peak_l: reading.peak_l,
peak_r: reading.peak_r,
level_side: reading.level_side,
stereo: reading.stereo,
sample_rate,
}
}
@@ -205,11 +222,12 @@ impl AnalyzerShared {
self.pcm[index].store(value, Ordering::Relaxed);
}
fn store_channels(&self, sample_rate: f32, rms: [f32; 2], peak: [f32; 2]) {
fn store_channels(&self, sample_rate: f32, rms: [f32; 3], peak: [f32; 2]) {
self.sample_rate
.store(sample_rate.round() as u32, Ordering::Relaxed);
store_norm(&self.rms_l, rms[0]);
store_norm(&self.rms_r, rms[1]);
store_norm(&self.rms_side, rms[2]);
self.peak_l.fetch_max(norm_bits(peak[0]), Ordering::Relaxed);
self.peak_r.fetch_max(norm_bits(peak[1]), Ordering::Relaxed);
}
@@ -302,6 +320,8 @@ struct AnalyzerState {
/// Left/right of the current frame (mono feeds both).
frame_lr: [f32; 2],
channel_sq: [f32; 2],
/// Sum of squared side samples (L - R) / 2 in the current window.
side_sq: f32,
channel_peak: [f32; 2],
frame_count: usize,
window_frames: usize,
@@ -332,6 +352,7 @@ impl AnalyzerState {
frame_sum: 0.0,
frame_lr: [0.0; 2],
channel_sq: [0.0; 2],
side_sq: 0.0,
channel_peak: [0.0; 2],
frame_count: 0,
window_frames: 0,
@@ -379,6 +400,7 @@ impl AnalyzerState {
self.frame_sum = 0.0;
self.frame_lr = [0.0; 2];
self.channel_sq = [0.0; 2];
self.side_sq = 0.0;
self.channel_peak = [0.0; 2];
self.frame_count = 0;
self.scope_counter = 0;
@@ -418,6 +440,8 @@ impl AnalyzerState {
self.channel_sq[channel] += value * value;
self.channel_peak[channel] = self.channel_peak[channel].max(value.abs());
}
let side = (self.frame_lr[0] - self.frame_lr[1]) * 0.5;
self.side_sq += side * side;
let mono = self.frame_sum / self.channels as f32;
self.channel_index = 0;
@@ -484,6 +508,7 @@ impl AnalyzerState {
[
(self.channel_sq[0] / frames).sqrt(),
(self.channel_sq[1] / frames).sqrt(),
(self.side_sq / frames).sqrt(),
],
self.channel_peak,
);
@@ -493,6 +518,7 @@ impl AnalyzerState {
self.mid_sq = 0.0;
self.treble_sq = 0.0;
self.channel_sq = [0.0; 2];
self.side_sq = 0.0;
self.channel_peak = [0.0; 2];
self.frame_count = 0;
}
@@ -536,19 +562,24 @@ mod tests {
impl TestSource {
fn sine(frames: usize, channels: u16, sample_rate: u32, frequency: f32) -> Self {
let channels_count = channels.max(1);
let mut samples = Vec::with_capacity(frames * usize::from(channels_count));
let gains = vec![1.0; usize::from(channels.max(1))];
Self::sine_gains(frames, sample_rate, frequency, &gains)
}
/// A sine with a gain per channel (one entry per channel).
fn sine_gains(frames: usize, sample_rate: u32, frequency: f32, gains: &[f32]) -> Self {
let mut samples = Vec::with_capacity(frames * gains.len());
for frame in 0..frames {
let time = frame as f32 / sample_rate as f32;
let sample = (std::f32::consts::TAU * frequency * time).sin() * 0.5;
for _ in 0..channels_count {
samples.push(sample as Sample);
for gain in gains {
samples.push((sample * gain) as Sample);
}
}
Self {
samples,
cursor: 0,
channels: ChannelCount::new(channels_count).unwrap(),
channels: ChannelCount::new(u16::try_from(gains.len()).unwrap()).unwrap(),
sample_rate: SampleRate::new(sample_rate).unwrap(),
}
}
@@ -625,9 +656,34 @@ mod tests {
.map(|(index, _)| index);
assert_eq!(loudest, Some(at_1k));
assert!(snapshot.level_l > 0.5 && (snapshot.level_l - snapshot.level_r).abs() < 1e-6);
// the same signal in both channels has no side component
assert_eq!(snapshot.level_side, 0.0);
assert_eq!(snapshot.stereo, Some(false));
assert!(snapshot.peak_l >= snapshot.level_l);
}
#[test]
fn analyzed_source_measures_the_side_signal() {
let measure = |gains: &[f32]| {
let shared = Arc::new(AnalyzerShared::default());
let source = TestSource::sine_gains(48_000, 48_000, 1_000.0, gains);
for _ in AnalyzedSource::new(source, Arc::clone(&shared)) {}
shared.snapshot()
};
// R = -L: the side signal (L - R) / 2 equals L
let opposite = measure(&[1.0, -1.0]);
assert!(opposite.level_side > 0.5);
assert!((opposite.level_side - opposite.level_l).abs() < 1e-3);
assert_eq!(opposite.stereo, Some(true));
// mono duplicates L into R
let mono = measure(&[1.0]);
assert_eq!(mono.level_side, 0.0);
assert_eq!(mono.stereo, Some(false));
// a third channel only feeds the mono sum
let surround = measure(&[1.0, 0.0, 1.0]);
assert!(surround.level_side > 0.0 && surround.level_side < surround.level_l);
}
#[test]
fn pcm_history_reads_newest_samples_and_silence_before_the_first() {
let shared = AnalyzerShared::default();
+86 -9
View File
@@ -39,6 +39,14 @@ const PEAK_HOLD_SECS: f32 = 1.2;
const PEAK_FALL_DB_PER_SEC: f32 = 18.0;
const LEVEL_ATTACK_SECS: f32 = 0.05;
const LEVEL_RELEASE_SECS: f32 = 0.3;
/// A window counts as stereo when its side signal (L - R) / 2 is no more
/// than this far below the louder channel: lossy coding of a mono recording
/// leaves a side signal far below that, real stereo mixes sit well above it.
const STEREO_SIDE_DB: f32 = -30.0;
/// Only windows this far above the floor decide; quieter ones keep the last
/// decision, since their side signal is lost in the floor.
const STEREO_DECIDE_ABOVE_FLOOR_DB: f32 = 30.0;
/// Longest step applied at once; a stalled reader must not fast-forward a
/// whole second of decay in one frame.
const MAX_STEP_SECS: f32 = 0.25;
@@ -64,6 +72,8 @@ fn exact_center(index: usize) -> f32 {
pub struct StereoReading {
pub rms_l: f32,
pub rms_r: f32,
/// RMS of the side signal (L - R) / 2.
pub rms_side: f32,
/// Highest sample peaks since the previous reading.
pub peak_l: f32,
pub peak_r: f32,
@@ -77,6 +87,10 @@ pub struct MeterReading {
pub level_r: f64,
pub peak_l: f64,
pub peak_r: f64,
pub level_side: f64,
/// Whether the two channels carry different signals (see
/// `STEREO_SIDE_DB`); `None` until a loud enough window was measured.
pub stereo: Option<bool>,
}
struct Hold {
@@ -204,7 +218,8 @@ pub struct Meter {
analysis: Option<Analysis>,
bands_db: [f32; BANDS],
band_peaks: [Hold; BANDS],
level_db: [f32; 2],
/// Left, right and side RMS levels.
level_db: [f32; 3],
level_peaks: [Hold; 2],
last_update: Option<Instant>,
last_write: usize,
@@ -212,7 +227,9 @@ pub struct Meter {
/// between device callbacks until `STALL_SECS` pass.
last_fresh: Option<Instant>,
held_targets: [f32; BANDS],
held_rms: [f32; 2],
held_rms: [f32; 3],
/// Last stereo decision; kept through silence, pauses and stalls.
stereo: Option<bool>,
}
impl std::fmt::Debug for Meter {
@@ -230,13 +247,14 @@ impl Default for Meter {
analysis: None,
bands_db: [FLOOR_DB; BANDS],
band_peaks: std::array::from_fn(|_| Hold::new()),
level_db: [FLOOR_DB; 2],
level_db: [FLOOR_DB; 3],
level_peaks: std::array::from_fn(|_| Hold::new()),
last_update: None,
last_write: 0,
last_fresh: None,
held_targets: [FLOOR_DB; BANDS],
held_rms: [0.0; 2],
held_rms: [0.0; 3],
stereo: None,
}
}
}
@@ -275,7 +293,13 @@ impl Meter {
let analysis = self.analysis.as_mut().expect("analysis was just set");
fill_pcm(&mut analysis.pcm);
self.held_targets = analysis.band_targets();
self.held_rms = [stereo.rms_l, stereo.rms_r];
self.held_rms = [stereo.rms_l, stereo.rms_r, stereo.rms_side];
// decided on the raw window, before ballistics: smoothed levels
// converge on the floor together and would read as stereo
let loud = stereo.rms_l.max(stereo.rms_r);
if to_db(loud) > FLOOR_DB + STEREO_DECIDE_ABOVE_FLOOR_DB {
self.stereo = Some(to_db(stereo.rms_side) > to_db(loud) + STEREO_SIDE_DB);
}
self.last_fresh = Some(now);
(
self.held_targets,
@@ -288,7 +312,7 @@ impl Meter {
{
(self.held_targets, self.held_rms, [0.0; 2])
} else {
([FLOOR_DB; BANDS], [0.0; 2], [0.0; 2])
([FLOOR_DB; BANDS], [0.0; 3], [0.0; 2])
};
for ((current, target), peak) in self
@@ -300,9 +324,11 @@ impl Meter {
*current = follow_band(*current, target, dt);
peak.update(*current, dt);
}
for channel in 0..2 {
self.level_db[channel] = follow_level(self.level_db[channel], to_db(rms[channel]), dt);
self.level_peaks[channel].update(to_db(peaks[channel]), dt);
for (level, value) in self.level_db.iter_mut().zip(rms) {
*level = follow_level(*level, to_db(value), dt);
}
for (hold, value) in self.level_peaks.iter_mut().zip(peaks) {
hold.update(to_db(value), dt);
}
MeterReading {
@@ -316,6 +342,8 @@ impl Meter {
level_r: normalize(self.level_db[1]),
peak_l: normalize(self.level_peaks[0].db),
peak_r: normalize(self.level_peaks[1].db),
level_side: normalize(self.level_db[2]),
stereo: self.stereo,
}
}
}
@@ -467,6 +495,7 @@ mod tests {
let tone = StereoReading {
rms_l: 0.35,
rms_r: 0.35,
rms_side: 0.0,
peak_l: 0.5,
peak_r: 0.5,
};
@@ -534,6 +563,7 @@ mod tests {
let loud_left = StereoReading {
rms_l: 0.5,
rms_r: 0.05,
rms_side: 0.2,
peak_l: 0.9,
peak_r: 0.1,
};
@@ -551,6 +581,52 @@ mod tests {
assert!((reading.level_l - normalize(to_db(0.5))).abs() < 0.02);
assert!((reading.peak_l - normalize(to_db(0.9))).abs() < 0.01);
assert!(reading.peak_l >= reading.level_l);
assert!((reading.level_side - normalize(to_db(0.2))).abs() < 0.02);
assert_eq!(reading.stereo, Some(true));
}
#[test]
fn stereo_is_decided_on_loud_windows_and_kept_through_silence() {
let mut meter = Meter::default();
let start = Instant::now();
let mut read = |step: u64, stereo: StereoReading| {
meter.update(
start + Duration::from_millis(50 * step),
step as usize,
48_000,
stereo,
|out| out.fill(0.0),
)
};
let quiet = StereoReading {
rms_l: 0.0005,
rms_r: 0.0001,
rms_side: 0.0002,
..StereoReading::default()
};
assert_eq!(read(1, quiet).stereo, None);
let near_mono = StereoReading {
rms_l: 0.3,
rms_r: 0.3,
rms_side: 0.003,
..StereoReading::default()
};
assert_eq!(read(2, near_mono).stereo, Some(false));
// silence and then a stall keep the decision
assert_eq!(read(3, StereoReading::default()).stereo, Some(false));
let wide = StereoReading {
rms_side: 0.1,
..near_mono
};
assert_eq!(read(4, wide).stereo, Some(true));
let later = meter.update(
start + Duration::from_secs(5),
4,
48_000,
StereoReading::default(),
|out| out.fill(0.0),
);
assert_eq!(later.stereo, Some(true));
}
#[test]
@@ -559,6 +635,7 @@ mod tests {
let reading = meter.update(Instant::now(), 1, 0, StereoReading::default(), |_| {});
assert!(reading.spectrum.iter().all(|value| *value == 0.0));
assert_eq!(reading.level_l, 0.0);
assert_eq!(reading.level_side, 0.0);
assert_eq!(reading.spectrum.len(), BAND_CENTERS_HZ.len());
}
+65 -11
View File
@@ -1,6 +1,6 @@
// name: VFD panel
// protocol: furumi-visualizer-v3
// bundle-version: 7
// bundle-version: 8
//
// A hi-fi front panel in the style of a vacuum fluorescent display: thin
// segment digits, a peak level meter (bars or needles), a third-octave
@@ -63,6 +63,10 @@ fn DECK_LAMPS() { true } // AMS / NR / AUTO REVERSE / REW-FF lamps in d
// 20 kHz), 0.0..1.0 over spectrum_floor_db..0
// dBFS, with analyzer fall and peak hold
// level_l, level_r channel RMS on the same scale
// level_side RMS of (L - R) / 2 on the same scale: the
// floor when both channels carry one signal
// channel_mode "stereo" or "mono" (decided on loud
// passages, kept through silence), "" unknown
// peak_l, peak_r held channel sample peaks on the same scale
// sample_rate analyzed sample rate in Hz (0 = none)
// duration, track_number, disc_number, year, release_title
@@ -797,10 +801,53 @@ fn sbox(x, y, label, fg) {
fn sbox_width(label) { label.len() + 5 }
// What leaves the player, for the lower row of the signal path: the held
// output peak in dBFS after the volume stage (the analyzer measures before
// it; the player's gain is volume cubed, 60 * log10(volume) dB), refreshed
// four times a second like a hardware readout,
// and whether the two channels differ (STEREO) or carry the same signal
// (MONO), from the host's channel_mode. Stereo in the last second keeps
// STEREO, so a near-mono moment in a stereo track does not flip it.
fn update_output(st, input, hot, dt) {
if !("out_t" in st) { st.out_t = 0.0; st.out_db = -99; st.stereo_t = 0.0; st.chan = ""; }
st.out_t -= dt;
if st.out_t <= 0.0 {
st.out_t = 0.25;
let vol = input.volume;
// -99 means silent; a live level is clamped to the readout's -60
st.out_db = if hot > 0.0 && vol > 0.0 {
mx(to_int(dbfs(input, hot) + 60.0 * ln(vol) / ln(10.0) - 0.5), -60)
} else { -99 };
}
st.stereo_t -= dt;
let mode = get(input, "channel_mode", "");
if mode == "stereo" { st.stereo_t = 1.0; }
if mode != "" { st.chan = if st.stereo_t > 0.0 { "STEREO" } else { "MONO" }; }
st
}
// Labels of the lower row, from the volume stage to the output: sample rate,
// channels, output level. Short forms for narrow panels.
fn output_labels(input, st, short) {
let sr = get(input, "sample_rate", 0);
if sr <= 0 { sr = get(input, "audio_sample_rate", 0); }
let khz = if sr > 0 { "" + (sr / 1000) + "." + ((sr % 1000) / 100) } else { "--" };
let chan = if "chan" in st && st.chan != "" { st.chan } else { "--" };
let live = get(input, "playing", false) && "out_db" in st && st.out_db > -99;
let db = if live { "" + st.out_db } else { "--" };
while db.len() < 3 { db = " " + db; }
if short {
[khz + "K", if chan == "STEREO" { "ST" } else if chan == "MONO" { "MO" } else { "--" }, db + "DB"]
} else {
[khz + " KHZ", chan, "OUT " + db + " DB"]
}
}
// Signal path drawn as a schematic: boxes on a bus line that runs along their
// bottom edges, nodes between them, and a wire from the end of the upper row
// down to the lower row. The active path is lit; now and then a bright pulse
// travels along it from the source to the speakers.
// down to the lower row. Every box is a live value: source, format and
// volume above; sample rate, channels and output level below. The active path
// is lit; now and then a bright pulse travels along it to the output.
fn draw_schematic(input, st, x, y, w) {
let p = st.pal;
let playing = get(input, "playing", !input.paused && input.track_title != "");
@@ -837,17 +884,21 @@ fn draw_schematic(input, st, x, y, w) {
let low_y = ty + 2;
this.vl(xr, bus_y, low_y - bus_y, "▎", bus);
// lower row, right-aligned: tone, amplifier, speakers
let speakers = "SPEAKERS A";
let bottom = [speakers, "AMP", "TONE"];
let bw_ = sbox_width(speakers) + sbox_width("AMP") + sbox_width("TONE");
if bw_ + 4 > xr - x { speakers = "SPK A"; bottom = [speakers, "AMP", "TONE"]; bw_ = sbox_width(speakers) + sbox_width("AMP") + sbox_width("TONE"); }
// lower row, right-aligned and read right to left: sample rate, channels,
// output level (red near full scale)
// the form follows the widest values, so live readings do not switch it
let widest = sbox_width("192.0 KHZ") + sbox_width("STEREO") + sbox_width("OUT -60 DB");
let labels = output_labels(input, st, widest + 4 > xr - x);
let bw_ = 0;
for l in labels { bw_ += sbox_width(l); }
let bottom = [labels[2], labels[1], labels[0]];
let hot_out = lit && "out_db" in st && st.out_db >= -1;
let gap2 = clamp((xr - x - bw_) / 3, 2, 12);
let start = xr - 1 - bw_ - 2 * (gap2 - 1);
this.hl(start, low_y, xr - start, "▔", bus);
let cx2 = start;
for k in 0..3 {
let next = this.sbox(cx2, ty, bottom[k], on);
let next = this.sbox(cx2, ty, bottom[k], if k == 0 && hot_out { p.red } else { on });
if k < 2 { this.txt(next + (gap2 - 1) / 2, low_y, "▀", on); }
cx2 = next + gap2 - 1;
}
@@ -888,7 +939,8 @@ fn draw_transport(input, st, x, y) {
let w = transport_width();
let ly = y + 6;
let caption = whiten(p.cyan_mid, 0.25);
let stereo = get(input, "level_l", 0.0) > 0.0 && (get(input, "level_l", 0.0) - get(input, "level_r", 0.0)).abs() > 0.001;
// the same detection as the signal path (see update_output)
let stereo = "chan" in st && st.chan == "STEREO" && get(input, "playing", false);
this.txt(x, ly, "TRACK", caption);
this.txt(x + 15, ly, "STEREO", if stereo || boot { p.cyan } else { p.cyan_lamp_off });
this.txt(x + w - 7, ly, "VOLUME", caption);
@@ -962,6 +1014,7 @@ fn advance_state(input) {
st.last_pos = input.position;
let hot = mx(get(input, "peak_l", 0.0), get(input, "peak_r", 0.0));
if dbfs(input, hot) > -0.5 && hot > 0.0 { st.over = 1.0; }
st = update_output(st, input, hot, dt);
// the panel brightens while the power-on test runs
st.pal = make_palette(input, if st.boot > 0.0 { 0.1 } else { 0.0 }, if st.boot > 0.0 { 0.0 } else { st.fade });
st
@@ -1063,7 +1116,8 @@ fn draw_strip(input, st, x, y, w) {
this.txt(cx, y, ts, p.cyan_mid); cx += ts.len() + 3;
let vs = "VOL " + vol + "%";
this.txt(cx, y, vs, p.cyan_mid); cx += vs.len() + 3;
let path = src + " › " + (if fmt == "" { "DECODE" } else { fmt }) + " › VOL › TONE › AMP › A";
let out = output_labels(input, st, true);
let path = src + " › " + (if fmt == "" { "DECODE" } else { fmt }) + " › " + out[0] + " › " + out[1] + " › OUT " + out[2];
if cx + path.len() < x + w { this.txt(cx, y, path, p.cyan_mid); }
}
+12 -1
View File
@@ -58,7 +58,7 @@ const BUNDLED_SCRIPTS: &[BundledScript] = &[
id: "vfd_panel",
file_name: "vfd_panel.rhai",
display_name: "VFD panel",
version: 7,
version: 8,
source: include_str!("visualizations/vfd_panel.rhai"),
},
];
@@ -425,6 +425,13 @@ fn insert_meter(input: &mut Map, analysis: &crate::player::AudioAnalysisSnapshot
insert_float(input, "level_r", analysis.level_r);
insert_float(input, "peak_l", analysis.peak_l);
insert_float(input, "peak_r", analysis.peak_r);
insert_float(input, "level_side", analysis.level_side);
let channel_mode = match analysis.stereo {
Some(true) => "stereo",
Some(false) => "mono",
None => "",
};
input.insert("channel_mode".into(), channel_mode.into());
insert_int(input, "sample_rate", i64::from(analysis.sample_rate));
}
@@ -2226,6 +2233,8 @@ mod tests {
state.player.playing = true;
state.player.audio_analysis.spectrum = vec![0.5; crate::player::BAND_CENTERS_HZ.len()];
state.player.audio_analysis.level_l = 0.25;
state.player.audio_analysis.level_side = 0.125;
state.player.audio_analysis.stereo = Some(true);
state.player.audio_analysis.sample_rate = 44_100;
let input = input_map(Rect::new(0, 0, 80, 24), &state);
@@ -2243,6 +2252,8 @@ mod tests {
assert_eq!(text("audio_format"), "flac");
assert!(input["playing"].as_bool().unwrap());
assert_eq!(float("level_l"), 0.25);
assert_eq!(float("level_side"), 0.125);
assert_eq!(text("channel_mode"), "stereo");
assert_eq!(float("spectrum_floor_db"), -60.0);
let spectrum = input["spectrum"].clone().into_array().unwrap();
let hz = input["spectrum_hz"].clone().into_array().unwrap();