mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-12 05:10:51 +02:00
get rid of seperate gain in waveform
This commit is contained in:
@@ -296,7 +296,6 @@ export function scopeSettingsToOptions(
|
||||
},
|
||||
mode: s.mode,
|
||||
scrollSpeed: s.scrollSpeed,
|
||||
gainDb: s.gainDb,
|
||||
multiband: s.multiband,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,7 @@ export function scopeSummary(kind: ScopeKind, settings: ScopeSettings[ScopeKind]
|
||||
return 'Bar Meter'
|
||||
case 'waveform': {
|
||||
const scopeSettings = settings as ScopeSettings['waveform']
|
||||
const summary = [`${scopeSettings.gainDb > 0 ? '+' : ''}${scopeSettings.gainDb} dB`]
|
||||
if (scopeSettings.mode === 'stereo') {
|
||||
summary.push('Stereo')
|
||||
}
|
||||
const summary = [scopeSettings.mode === 'stereo' ? 'Stereo' : 'Mono']
|
||||
if (scopeSettings.multiband) {
|
||||
summary.push('RGB')
|
||||
}
|
||||
@@ -523,17 +520,6 @@ export default function ScopeSettingsSection({
|
||||
/>
|
||||
</ToggleGroup>
|
||||
|
||||
<RangeControl
|
||||
label="Gain"
|
||||
value={current.gainDb}
|
||||
valueLabel={`${current.gainDb > 0 ? '+' : ''}${current.gainDb.toFixed(0)} dB`}
|
||||
min={-12}
|
||||
max={12}
|
||||
step={1}
|
||||
fullWidth={false}
|
||||
onChange={(value) => onUpdate('waveform', { gainDb: value })}
|
||||
/>
|
||||
|
||||
<RangeControl
|
||||
label="Speed"
|
||||
value={current.scrollSpeed}
|
||||
|
||||
@@ -4,10 +4,8 @@ import { defaultVisualizerSessionSource, type VisualizerSessionSource } from './
|
||||
import { FrameScheduler } from './frameScheduler'
|
||||
import { VisualizerFrameLoop } from './visualizerFrameLoop'
|
||||
import {
|
||||
DEFAULT_WAVEFORM_GAIN_DB,
|
||||
DEFAULT_WAVEFORM_MODE,
|
||||
DEFAULT_WAVEFORM_SCROLL_SPEED,
|
||||
clampWaveformGainDb,
|
||||
clampWaveformScrollSpeed,
|
||||
type WaveformMode,
|
||||
} from '../../types/waveform'
|
||||
@@ -35,7 +33,6 @@ export interface WaveformOptions {
|
||||
}
|
||||
mode?: WaveformMode
|
||||
scrollSpeed?: number
|
||||
gainDb?: number
|
||||
multiband?: boolean
|
||||
dataSource?: WaveformDataSource
|
||||
frameScheduler?: FrameScheduler
|
||||
@@ -55,7 +52,6 @@ const defaultOptions: ResolvedWaveformOptions = {
|
||||
},
|
||||
mode: DEFAULT_WAVEFORM_MODE,
|
||||
scrollSpeed: DEFAULT_WAVEFORM_SCROLL_SPEED,
|
||||
gainDb: DEFAULT_WAVEFORM_GAIN_DB,
|
||||
multiband: false,
|
||||
}
|
||||
|
||||
@@ -115,7 +111,6 @@ export class Waveform {
|
||||
...optionOverrides,
|
||||
mode: optionOverrides.mode ?? defaultOptions.mode,
|
||||
scrollSpeed: clampWaveformScrollSpeed(optionOverrides.scrollSpeed ?? defaultOptions.scrollSpeed),
|
||||
gainDb: clampWaveformGainDb(optionOverrides.gainDb ?? defaultOptions.gainDb),
|
||||
multiband: optionOverrides.multiband ?? defaultOptions.multiband,
|
||||
}
|
||||
this.dataSource = dataSource ?? defaultWaveformDataSource
|
||||
@@ -186,7 +181,6 @@ export class Waveform {
|
||||
mode: optionUpdates.mode ?? this.options.mode,
|
||||
lineColor: optionUpdates.lineColor ?? this.options.lineColor,
|
||||
scrollSpeed: clampWaveformScrollSpeed(optionUpdates.scrollSpeed ?? this.options.scrollSpeed),
|
||||
gainDb: clampWaveformGainDb(optionUpdates.gainDb ?? this.options.gainDb),
|
||||
multiband: optionUpdates.multiband ?? this.options.multiband,
|
||||
}
|
||||
const speedChanged = nextOptions.scrollSpeed !== this.options.scrollSpeed
|
||||
@@ -349,9 +343,8 @@ export class Waveform {
|
||||
laneHeight: number,
|
||||
color: [number, number, number],
|
||||
): void {
|
||||
const amplitudeGain = Math.pow(10, this.options.gainDb / 20)
|
||||
const scaledMin = Math.max(-1, Math.min(1, min * amplitudeGain))
|
||||
const scaledMax = Math.max(-1, Math.min(1, max * amplitudeGain))
|
||||
const scaledMin = Math.max(-1, Math.min(1, min))
|
||||
const scaledMax = Math.max(-1, Math.min(1, max))
|
||||
const centerY = laneTop + (laneHeight / 2)
|
||||
const displayHalfHeight = (laneHeight / 2) * DISPLAY_MARGIN
|
||||
const yTop = Math.round(centerY - scaledMax * displayHalfHeight)
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
import { AUDIO_SCOPE_KINDS, SCOPE_KINDS, normalizeScopeKind, type ScopeKind } from '../types/scope'
|
||||
import { DEFAULT_SCOPE_SETTINGS, type ScopeSettings } from '../types/settings'
|
||||
import { normalizeSpectrumPeakInfoMode } from '../types/spectrum'
|
||||
import { clampWaveformScrollSpeed } from '../types/waveform'
|
||||
|
||||
export const DEFAULT_VISIBLE: ScopeKind[] = ['spectrum', 'oscilloscope', 'vectorscope', 'vumeter']
|
||||
export const DEFAULT_SCOPE_ORDER: ScopeKind[] = [...AUDIO_SCOPE_KINDS]
|
||||
@@ -134,6 +135,9 @@ export function mergeScopeSettings(raw: unknown): ScopeSettings {
|
||||
const rawSpectrum: Partial<ScopeSettings['spectrum']> = typeof parsed.spectrum === 'object' && parsed.spectrum !== null
|
||||
? parsed.spectrum
|
||||
: {}
|
||||
const rawWaveform: Partial<ScopeSettings['waveform']> = typeof parsed.waveform === 'object' && parsed.waveform !== null
|
||||
? parsed.waveform
|
||||
: {}
|
||||
const rawNowPlaying: Partial<ScopeSettings['nowPlaying']> = typeof legacyParsed.nowPlaying === 'object' && legacyParsed.nowPlaying !== null
|
||||
? legacyParsed.nowPlaying
|
||||
: (typeof legacyParsed.astra === 'object' && legacyParsed.astra !== null ? legacyParsed.astra : {})
|
||||
@@ -149,7 +153,16 @@ export function mergeScopeSettings(raw: unknown): ScopeSettings {
|
||||
spectrogram: { ...DEFAULT_SCOPE_SETTINGS.spectrogram, ...(parsed.spectrogram ?? {}) },
|
||||
vumeter: { ...DEFAULT_SCOPE_SETTINGS.vumeter, ...(parsed.vumeter ?? {}) },
|
||||
lufsmeter: { ...DEFAULT_SCOPE_SETTINGS.lufsmeter, ...(parsed.lufsmeter ?? {}) },
|
||||
waveform: { ...DEFAULT_SCOPE_SETTINGS.waveform, ...(parsed.waveform ?? {}) },
|
||||
waveform: {
|
||||
...DEFAULT_SCOPE_SETTINGS.waveform,
|
||||
mode: rawWaveform.mode === 'stereo' || rawWaveform.mode === 'mono'
|
||||
? rawWaveform.mode
|
||||
: DEFAULT_SCOPE_SETTINGS.waveform.mode,
|
||||
scrollSpeed: clampWaveformScrollSpeed(rawWaveform.scrollSpeed ?? DEFAULT_SCOPE_SETTINGS.waveform.scrollSpeed),
|
||||
multiband: typeof rawWaveform.multiband === 'boolean'
|
||||
? rawWaveform.multiband
|
||||
: DEFAULT_SCOPE_SETTINGS.waveform.multiband,
|
||||
},
|
||||
nowPlaying: { ...DEFAULT_SCOPE_SETTINGS.nowPlaying, ...rawNowPlaying },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ export interface ScopeSettings {
|
||||
waveform: {
|
||||
mode: WaveformMode
|
||||
scrollSpeed: number
|
||||
gainDb: number
|
||||
multiband: boolean
|
||||
}
|
||||
nowPlaying: {
|
||||
@@ -68,7 +67,7 @@ export const DEFAULT_SCOPE_SETTINGS: ScopeSettings = {
|
||||
spectrogram: { fftSize: 2048, scrollSpeed: 2, clarityMode: 'sharper', scaleMode: 'log', colorScheme: 'heat' },
|
||||
vumeter: { mode: 'bar', orientation: 'horizontal' },
|
||||
lufsmeter: { mode: 'bar' },
|
||||
waveform: { mode: DEFAULT_WAVEFORM_MODE, scrollSpeed: 1, gainDb: 0, multiband: false },
|
||||
waveform: { mode: DEFAULT_WAVEFORM_MODE, scrollSpeed: 1, multiband: false },
|
||||
nowPlaying: {
|
||||
showCoverArt: true,
|
||||
showTitle: true,
|
||||
|
||||
@@ -4,10 +4,6 @@ export const MIN_WAVEFORM_SCROLL_SPEED = 0.5
|
||||
export const MAX_WAVEFORM_SCROLL_SPEED = 8
|
||||
export const WAVEFORM_SCROLL_SPEED_STEP = 0.5
|
||||
export const DEFAULT_WAVEFORM_SCROLL_SPEED = 1
|
||||
export const MIN_WAVEFORM_GAIN_DB = -12
|
||||
export const MAX_WAVEFORM_GAIN_DB = 18
|
||||
export const WAVEFORM_GAIN_DB_STEP = 0.5
|
||||
export const DEFAULT_WAVEFORM_GAIN_DB = 0
|
||||
export const DEFAULT_WAVEFORM_MODE: WaveformMode = 'mono'
|
||||
|
||||
export function clampWaveformScrollSpeed(value: unknown): number {
|
||||
@@ -19,14 +15,3 @@ export function clampWaveformScrollSpeed(value: unknown): number {
|
||||
const snapped = Math.round(numeric / WAVEFORM_SCROLL_SPEED_STEP) * WAVEFORM_SCROLL_SPEED_STEP
|
||||
return Math.min(MAX_WAVEFORM_SCROLL_SPEED, Math.max(MIN_WAVEFORM_SCROLL_SPEED, snapped))
|
||||
}
|
||||
|
||||
export function clampWaveformGainDb(value: unknown): number {
|
||||
const numeric = Number(value)
|
||||
if (!Number.isFinite(numeric)) {
|
||||
return DEFAULT_WAVEFORM_GAIN_DB
|
||||
}
|
||||
|
||||
const snapped = Math.round(numeric / WAVEFORM_GAIN_DB_STEP) * WAVEFORM_GAIN_DB_STEP
|
||||
const rounded = Math.round(snapped * 10) / 10
|
||||
return Math.min(MAX_WAVEFORM_GAIN_DB, Math.max(MIN_WAVEFORM_GAIN_DB, rounded))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user