refactor: split soundtrack chapter and drive commands
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { SectionId } from '@/content/types';
|
||||
import type {
|
||||
AudioJourneyState,
|
||||
AudioInitialState,
|
||||
ChapterIntent,
|
||||
DriveEnergySample,
|
||||
MusicMood,
|
||||
@@ -40,18 +40,7 @@ export const DEFAULT_DRIVE_ENERGY = Object.freeze({
|
||||
source: 'idle',
|
||||
} as const satisfies DriveEnergySample);
|
||||
|
||||
export function resolveJourneyMusicState(sectionId: string, intensity = 0): AudioJourneyState {
|
||||
const canonicalId = Object.hasOwn(JOURNEY_MUSIC, sectionId)
|
||||
? sectionId as SectionId
|
||||
: 'start';
|
||||
const chapter = resolveChapterIntent(canonicalId);
|
||||
const finiteIntensity = Number.isFinite(intensity) ? intensity : 0;
|
||||
return Object.freeze({
|
||||
atStart: sectionId === 'start',
|
||||
intensity: Math.min(1, Math.max(0, finiteIntensity)),
|
||||
bias: chapter.mood,
|
||||
entryPhrase: chapter.entryPhrase,
|
||||
});
|
||||
}
|
||||
|
||||
export const DEFAULT_AUDIO_JOURNEY_STATE = resolveJourneyMusicState('start');
|
||||
export const DEFAULT_AUDIO_INITIAL_STATE = Object.freeze({
|
||||
chapter: DEFAULT_CHAPTER_INTENT,
|
||||
drive: DEFAULT_DRIVE_ENERGY,
|
||||
} as const satisfies AudioInitialState);
|
||||
|
||||
Reference in New Issue
Block a user