complete overhaul of spectrogram

This commit is contained in:
Boof2015
2026-05-19 13:13:24 -04:00
parent c8a33ba647
commit e4c82c0a64
14 changed files with 1079 additions and 541 deletions
+3 -1
View File
@@ -2,6 +2,7 @@ import type { VectorscopeMode } from '../renderer/visualizers/Vectorscope'
import {
DEFAULT_SPECTROGRAM_CONTRAST,
DEFAULT_SPECTROGRAM_ORIENTATION,
DEFAULT_SPECTROGRAM_TILT_DB_PER_OCTAVE,
type SpectrogramClarityMode,
type SpectrogramOrientation,
type SpectrogramScaleMode,
@@ -39,6 +40,7 @@ export interface ScopeSettings {
}
spectrogram: {
fftSize: number
tiltDbPerOctave: number
scrollSpeed: number
contrast: number
clarityMode: SpectrogramClarityMode
@@ -75,7 +77,7 @@ export const DEFAULT_SCOPE_SETTINGS: ScopeSettings = {
spectrum: { fftSize: 2048, tiltDbPerOctave: 2.0, heatmap: false, heatmapTiltDbPerOctave: 2.0, heatmapSmoothing: 0.5, showGrid: true, smoothing: 0.9, fillGradient: true, showSideLine: false, peakInfoMode: DEFAULT_SPECTRUM_PEAK_INFO_MODE },
oscilloscope: { pitchLock: true, underfillEnabled: false, showGrid: true, lineWidth: 2 },
vectorscope: { mode: 'lissajous', multiband: false, showGrid: true, persistence: 0.10, lineWidth: 1.5 },
spectrogram: { fftSize: 2048, scrollSpeed: 2, contrast: DEFAULT_SPECTROGRAM_CONTRAST, clarityMode: 'sharper', scaleMode: 'log', orientation: DEFAULT_SPECTROGRAM_ORIENTATION, colorScheme: 'heat' },
spectrogram: { fftSize: 4096, tiltDbPerOctave: DEFAULT_SPECTROGRAM_TILT_DB_PER_OCTAVE, scrollSpeed: 2, contrast: DEFAULT_SPECTROGRAM_CONTRAST, clarityMode: 'sharper', scaleMode: 'log', orientation: DEFAULT_SPECTROGRAM_ORIENTATION, colorScheme: 'heat' },
vumeter: { mode: 'bar', orientation: 'horizontal', needleChannels: 'stereo', referenceDb: DEFAULT_VU_REFERENCE_DBFS },
lufsmeter: { mode: 'bar', readout: DEFAULT_LUFS_METER_READOUT },
waveform: { mode: DEFAULT_WAVEFORM_MODE, scrollSpeed: 1, multiband: false },
+19
View File
@@ -30,6 +30,11 @@ export const MAX_SPECTROGRAM_CONTRAST = 2.0
export const SPECTROGRAM_CONTRAST_STEP = 0.1
export const DEFAULT_SPECTROGRAM_CONTRAST = 1.0
export const DEFAULT_SPECTROGRAM_TILT_DB_PER_OCTAVE = 4.0
export const MIN_SPECTROGRAM_TILT_DB_PER_OCTAVE = -2.0
export const MAX_SPECTROGRAM_TILT_DB_PER_OCTAVE = 8.0
export const SPECTROGRAM_TILT_STEP = 0.1
export function isSpectrogramClarityMode(value: unknown): value is SpectrogramClarityMode {
return typeof value === 'string' && SPECTROGRAM_CLARITY_MODES.includes(value as SpectrogramClarityMode)
}
@@ -61,3 +66,17 @@ export function clampSpectrogramContrast(value: unknown): number {
const snapped = Math.round(numeric / SPECTROGRAM_CONTRAST_STEP) * SPECTROGRAM_CONTRAST_STEP
return Math.min(MAX_SPECTROGRAM_CONTRAST, Math.max(MIN_SPECTROGRAM_CONTRAST, snapped))
}
export function clampSpectrogramTiltDbPerOctave(value: unknown): number {
const numeric = Number(value)
if (!Number.isFinite(numeric)) {
return DEFAULT_SPECTROGRAM_TILT_DB_PER_OCTAVE
}
const snapped = Math.round(numeric / SPECTROGRAM_TILT_STEP) * SPECTROGRAM_TILT_STEP
const rounded = Math.round(snapped * 10) / 10
return Math.min(
MAX_SPECTROGRAM_TILT_DB_PER_OCTAVE,
Math.max(MIN_SPECTROGRAM_TILT_DB_PER_OCTAVE, rounded),
)
}