Authoritative reference for music-driven color processing in the live codebase. Supersedes legacy "consciousness" terminology and documents only the modules currently shipped.
- Entry module:
src-js/audio/MusicSyncService.ts - Responsibilities: subscribe to Spicetify player events, fetch audio features, compute enhanced BPM/beat phases, broadcast
music:*events via unified event bus, coordinate withColorHarmonyEngineand visual systems.
- Progressive initialization: waits for Spicetify availability, supports degraded mode.
- Beat scheduling: predictive beat tracking, exposes
startBeatScheduler,stopBeatScheduler,getCurrentBeatPhase. - Metrics: maintains processing metrics, cache stats, exposed via
getMetrics. - Event publishing: emits
music:beat,music:energy,music:dramatic-peak, etc. - Integration: registers with lifecycle coordinator; used by visual managers (
Card3DManager,DepthLayerController, etc.).
- Core module:
src-js/audio/ColorHarmonyEngine.tsorchestrates OKLAB color processing for album art palettes and music tone. - Utilities:
src-js/utils/color/OKLABColorProcessor.ts(RGB <-> OKLAB conversions, perceptual blending) andEmotionalTemperatureMapper.ts(maps musical/emotional data to temperature ranges). - Outputs:
SpicetifyColorBridgeandCSSVariableWriter/CSSVariableBatcherapply colors to CSS vars (-sn-oklab-*,-sn-dynamic-*).
blendColors()converts RGB to OKLAB, interpolates in OKLAB space, and converts back-ensuring perceptually uniform gradients.updatePaletteFromAlbumArt()extracts dominant colors, caches by album art hash, and harmonizes them with Catppuccin tokens.publishColorState()emitscolors:extracted/colors:harmonizedevents and queues CSS variable updates via batcher.
- SCSS modules import
core/_design_tokensand useoklab-color('token', opacity)helper (seetoken-usage-guideguidance). - Tokens available:
accent,primary,secondary,shadow,highlight(mapped from OKLAB outputs). - Migration tips: replace
rgba(var(--sn-accent-rgb), x)withoklab-color('accent', x); see legacy OKLAB migration notes for path adjustments.
ColorEventCoordinatorlistens for color events and synchronizesColorStateManager.- Settings toggles (via
settings) can adjust vibrancy, warmth bias, and fallback behavior.
MusicSyncServicefetches audio features; emits beat/color events.ColorHarmonyEnginereceives music payloads, processes OKLAB colors.SpicetifyColorBridgeandCSSVariableWriterupdate CSS vars (-sn-dynamic-*).VisualEffectsCoordinatorand participants react to color/mood changes via event bus.
- Reviewed
src-js/audio/MusicSyncService.ts,src-js/audio/ColorHarmonyEngine.ts,src-js/utils/color/OKLABColorProcessor.ts,src-js/utils/color/EmotionalTemperatureMapper.ts, andsrc-js/utils/spicetify/SpicetifyColorBridge.ts.
- Document genre profile behavior (
GenreProfileManager). - Add diagrams for beat/color flow once verified with runtime logs.
- Consolidate OKLAB naming/migration notes into this doc when rewriting token guides.