mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-20 20:39:59 +02:00
Improve spectrogram
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { VectorscopeMode } from '../renderer/visualizers/Vectorscope'
|
||||
import type { SpectrogramClarityMode, SpectrogramScaleMode } from './spectrogram'
|
||||
import { DEFAULT_SPECTROGRAM_CONTRAST, type SpectrogramClarityMode, type SpectrogramScaleMode } from './spectrogram'
|
||||
import { DEFAULT_VU_REFERENCE_DBFS, type VUMeterMode, type VUMeterNeedleChannels, type VUMeterOrientation } from './vumeter'
|
||||
import { DEFAULT_LUFS_METER_READOUT, type LUFSMeterMode, type LUFSMeterReadout } from './lufsmeter'
|
||||
import { DEFAULT_WAVEFORM_MODE, type WaveformMode } from './waveform'
|
||||
@@ -34,6 +34,7 @@ export interface ScopeSettings {
|
||||
spectrogram: {
|
||||
fftSize: number
|
||||
scrollSpeed: number
|
||||
contrast: number
|
||||
clarityMode: SpectrogramClarityMode
|
||||
scaleMode: SpectrogramScaleMode
|
||||
colorScheme: 'heat' | 'mono'
|
||||
@@ -67,7 +68,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, clarityMode: 'sharper', scaleMode: 'log', colorScheme: 'heat' },
|
||||
spectrogram: { fftSize: 2048, scrollSpeed: 2, contrast: DEFAULT_SPECTROGRAM_CONTRAST, clarityMode: 'sharper', scaleMode: 'log', 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,6 +19,11 @@ export const MAX_SPECTROGRAM_SCROLL_SPEED = 4
|
||||
export const SPECTROGRAM_SCROLL_SPEED_STEP = 0.5
|
||||
export const DEFAULT_SPECTROGRAM_SCROLL_SPEED = 2
|
||||
|
||||
export const MIN_SPECTROGRAM_CONTRAST = 0.5
|
||||
export const MAX_SPECTROGRAM_CONTRAST = 2.0
|
||||
export const SPECTROGRAM_CONTRAST_STEP = 0.1
|
||||
export const DEFAULT_SPECTROGRAM_CONTRAST = 1.0
|
||||
|
||||
export function isSpectrogramClarityMode(value: unknown): value is SpectrogramClarityMode {
|
||||
return typeof value === 'string' && SPECTROGRAM_CLARITY_MODES.includes(value as SpectrogramClarityMode)
|
||||
}
|
||||
@@ -36,3 +41,13 @@ export function clampSpectrogramScrollSpeed(value: unknown): number {
|
||||
const snapped = Math.round(numeric / SPECTROGRAM_SCROLL_SPEED_STEP) * SPECTROGRAM_SCROLL_SPEED_STEP
|
||||
return Math.min(MAX_SPECTROGRAM_SCROLL_SPEED, Math.max(MIN_SPECTROGRAM_SCROLL_SPEED, snapped))
|
||||
}
|
||||
|
||||
export function clampSpectrogramContrast(value: unknown): number {
|
||||
const numeric = Number(value)
|
||||
if (!Number.isFinite(numeric)) {
|
||||
return DEFAULT_SPECTROGRAM_CONTRAST
|
||||
}
|
||||
|
||||
const snapped = Math.round(numeric / SPECTROGRAM_CONTRAST_STEP) * SPECTROGRAM_CONTRAST_STEP
|
||||
return Math.min(MAX_SPECTROGRAM_CONTRAST, Math.max(MIN_SPECTROGRAM_CONTRAST, snapped))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user