feat: add narrative page turn audio cue
This commit is contained in:
@@ -57,7 +57,7 @@ export type MusicDuckOptions = {
|
||||
releaseMs?: number;
|
||||
};
|
||||
|
||||
type SemanticCueGroup = 'turn' | 'operation' | 'objective';
|
||||
type SemanticCueGroup = 'turn' | 'operation' | 'objective' | 'narrative';
|
||||
|
||||
type MusicDuckState = {
|
||||
multiplier: number;
|
||||
@@ -102,7 +102,8 @@ export class SoundDirector {
|
||||
private readonly semanticCueCooldownMs: Record<SemanticCueGroup, number> = {
|
||||
turn: 900,
|
||||
operation: 650,
|
||||
objective: 1200
|
||||
objective: 1200,
|
||||
narrative: 220
|
||||
};
|
||||
private readonly semanticCuePlayedAt = new Map<SemanticCueGroup, number>();
|
||||
private lastPlayedSemanticCue?: { group: SemanticCueGroup; key: string; at: number };
|
||||
@@ -434,6 +435,13 @@ export class SoundDirector {
|
||||
});
|
||||
}
|
||||
|
||||
playStoryAdvanceCue() {
|
||||
return this.playSemanticCue('narrative', 'story-page-turn', {
|
||||
volume: 0.15,
|
||||
stopAfterMs: 1100
|
||||
});
|
||||
}
|
||||
|
||||
playStrategyPulse() {
|
||||
this.playEffect('strategy-cast', { volume: 0.44, rate: 0.96, stopAfterMs: 960 });
|
||||
this.playTone(460, 0.08, 0.012, 'sine');
|
||||
@@ -500,7 +508,7 @@ export class SoundDirector {
|
||||
private playSemanticCue(
|
||||
group: SemanticCueGroup,
|
||||
key: string,
|
||||
options: PlayEffectOptions & { duck: MusicDuckOptions }
|
||||
options: PlayEffectOptions & { duck?: MusicDuckOptions }
|
||||
) {
|
||||
if (!this.started || this.muted || !this.effectTracks[key]) {
|
||||
return false;
|
||||
@@ -519,7 +527,9 @@ export class SoundDirector {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.duckMusic(options.duck);
|
||||
if (options.duck) {
|
||||
this.duckMusic(options.duck);
|
||||
}
|
||||
const played = this.playEffect(key, options);
|
||||
if (played) {
|
||||
this.semanticCuePlayedAt.set(group, now);
|
||||
|
||||
Reference in New Issue
Block a user