Settings has one choice, kept on the device, in place of the spectrogram switch: Spectrogram, Bars, Oscilloscope, Milkdrop or None. Whoever had turned the spectrogram off stays on None. - Bars: the classic spectrum, with a cap on each bar that waits and falls. - Oscilloscope: the wave of the sound as it plays. - Milkdrop: butterchurn and its presets fill the background of the full-screen player behind a veil. They are loaded only when chosen, change by themselves every 25 seconds or with a button, and give way to the spectrogram where WebGL is missing or the system asks for less motion. - The bar of the player keeps a small picture; for Milkdrop it is the spectrogram. - The analyser also hands over the wave and the audio node.
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { useVisualizerPref } from '@/player/prefs'
|
|
import Bars from './Bars'
|
|
import Scope from './Scope'
|
|
import Spectrogram from './Spectrogram'
|
|
|
|
interface VisualizerProps {
|
|
/** `bar` is the small place in the bar of the player, `full` the big one in the full-screen player. */
|
|
size: 'bar' | 'full'
|
|
/** The track is a friend's: the colour is the friend's. */
|
|
friend?: boolean
|
|
className?: string
|
|
}
|
|
|
|
/** The picture of the sound this device chose in Settings, or nothing when it chose None. */
|
|
export default function Visualizer({ size, friend = false, className }: VisualizerProps) {
|
|
const mode = useVisualizerPref((s) => s.mode)
|
|
const big = size === 'full'
|
|
const spectrogram = <Spectrogram columns={big ? 72 : 28} rows={big ? 16 : 6} friend={friend} className={className} />
|
|
switch (mode) {
|
|
case 'off':
|
|
return null
|
|
case 'bars':
|
|
return <Bars bars={big ? 48 : 20} friend={friend} className={className} />
|
|
case 'scope':
|
|
return <Scope friend={friend} className={className} />
|
|
// Milkdrop is drawn behind the whole full-screen player (see NowPlaying): in the place of the picture, as in the bar,
|
|
// the spectrogram stays.
|
|
default:
|
|
return spectrogram
|
|
}
|
|
}
|