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))
|
||||
}
|
||||
|
||||
@@ -191,6 +191,14 @@ test('partial files normalize, unsupported versions fail, and import does not ch
|
||||
id: 'profile_partial',
|
||||
name: 'Partial',
|
||||
scopeOrder: ['spectrogram'],
|
||||
scopeSettings: {
|
||||
waveform: {
|
||||
mode: 'stereo',
|
||||
scrollSpeed: 2,
|
||||
gainDb: 6,
|
||||
multiband: true,
|
||||
},
|
||||
},
|
||||
scopePopouts: { spectrogram: { poppedOut: true } },
|
||||
}, null, 2)}\n`, 'utf8')
|
||||
|
||||
@@ -199,6 +207,10 @@ test('partial files normalize, unsupported versions fail, and import does not ch
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.scopeSettings.spectrum.showSideLine, false)
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.scopeSettings.spectrum.heatmapSmoothing, 0.5)
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.scopeSettings.spectrogram.colorScheme, 'heat')
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.scopeSettings.waveform.mode, 'stereo')
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.scopeSettings.waveform.scrollSpeed, 2)
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.scopeSettings.waveform.multiband, true)
|
||||
assert.equal(Object.hasOwn(partialSnapshot.profiles.profile_partial.scopeSettings.waveform, 'gainDb'), false)
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.scopePopouts.spectrogram.poppedOut, true)
|
||||
assert.equal(partialSnapshot.profiles.profile_partial.widthWeights.spectrum, 1)
|
||||
|
||||
|
||||
@@ -1721,6 +1721,7 @@ test('scopeSettingsToOptions wires waveform stereo mode into analyzer options',
|
||||
assert.equal(options.backgroundColor, theme.waveform.background)
|
||||
assert.equal(options.gridMajorColor, theme.waveform.guides)
|
||||
assert.equal(options.gridMinorColor, theme.waveform.guidesSecondary)
|
||||
assert.equal(Object.hasOwn(options, 'gainDb'), false)
|
||||
})
|
||||
|
||||
test('scopeSettingsToOptions forwards shared scope background and guides to oscilloscope and vectorscope', () => {
|
||||
@@ -1934,17 +1935,16 @@ test('scopeSettingsToOptions forwards themed backgrounds and track colors to spe
|
||||
assert.equal(lufsmeter.labelColor, theme.lufsmeter.labels)
|
||||
})
|
||||
|
||||
test('scopeSummary includes Stereo for waveform only when stereo mode is enabled', () => {
|
||||
test('scopeSummary includes only waveform display modes', () => {
|
||||
const profile = createDefaultProfile('Default')
|
||||
profile.scopeSettings.waveform.gainDb = 6
|
||||
|
||||
assert.equal(scopeSummary('waveform', profile.scopeSettings.waveform), '+6 dB')
|
||||
assert.equal(scopeSummary('waveform', profile.scopeSettings.waveform), 'Mono')
|
||||
|
||||
profile.scopeSettings.waveform.mode = 'stereo'
|
||||
assert.equal(scopeSummary('waveform', profile.scopeSettings.waveform), '+6 dB · Stereo')
|
||||
assert.equal(scopeSummary('waveform', profile.scopeSettings.waveform), 'Stereo')
|
||||
|
||||
profile.scopeSettings.waveform.multiband = true
|
||||
assert.equal(scopeSummary('waveform', profile.scopeSettings.waveform), '+6 dB · Stereo · RGB')
|
||||
assert.equal(scopeSummary('waveform', profile.scopeSettings.waveform), 'Stereo · RGB')
|
||||
})
|
||||
|
||||
test('scopeSummary includes spectrum peak mode when enabled', () => {
|
||||
@@ -2000,7 +2000,6 @@ test('applying a profile snapshot does not change the machine-local frame target
|
||||
const defaultProfile = createDefaultProfile('Default')
|
||||
const alternateProfile = createDefaultProfile('Live Mix')
|
||||
alternateProfile.hiddenScopes = []
|
||||
alternateProfile.scopeSettings.waveform.gainDb = 6
|
||||
|
||||
useSettingsStore.getState().applyExternalProfileSnapshot({
|
||||
activeProfileId: 'profile_live_mix',
|
||||
@@ -2030,7 +2029,6 @@ test('applying a profile snapshot does not change the machine-local trim', () =>
|
||||
const defaultProfile = createDefaultProfile('Default')
|
||||
const alternateProfile = createDefaultProfile('Live Mix')
|
||||
alternateProfile.hiddenScopes = []
|
||||
alternateProfile.scopeSettings.waveform.gainDb = 6
|
||||
|
||||
useSettingsStore.getState().applyExternalProfileSnapshot({
|
||||
activeProfileId: 'profile_live_mix',
|
||||
@@ -2072,7 +2070,7 @@ test('profile draft comparisons return to clean after reverting a change', () =>
|
||||
...baselineProfile.scopeSettings,
|
||||
waveform: {
|
||||
...baselineProfile.scopeSettings.waveform,
|
||||
gainDb: baselineProfile.scopeSettings.waveform.gainDb + 3,
|
||||
scrollSpeed: baselineProfile.scopeSettings.waveform.scrollSpeed + 1,
|
||||
},
|
||||
},
|
||||
scopePopouts: baselineProfile.scopePopouts,
|
||||
|
||||
Reference in New Issue
Block a user