/** * Mouth System Module * Handles mouth animation based on audio volume, visemes, or manual control * * Note: This module does NOT handle rendering - it only manages state. * The renderRig module handles actual rendering of mouth images. */ import type { RigData } from '../types.js'; /** * Mouth shape types - THE SINGLE SOURCE OF TRUTH * Based on actual character rig mouth images */ export type MouthShape = 'f' | 'l' | 'ds' | 'ee' | 'eh' | 'open' | 'closed' | 'half-open' | 'wide-open' | 'slightly-open'; /** * Audio analysis data structure */ export interface AudioAnalysisData { analyser: AnalyserNode; dataArray: Uint8Array; audioElement: HTMLAudioElement; } /** * Viseme mapping data (phoneme to mouth shape) */ export interface VisemeData { viseme: string; timestamp: number; } /** * Mouth animation mode */ export type MouthAnimationMode = 'manual' | 'audio' | 'viseme'; /** * Mouth state */ export interface MouthState { currentMouthKey: MouthShape; lastMouthChangeTime: number; currentVolume: number; mode: MouthAnimationMode; } /** * Mouth configuration */ export interface MouthConfig { volumeThreshold?: number; mouthChangeInterval?: number; talkingMouths?: MouthShape[]; visemeMapping?: Record; } /** * MouthSystem class - Manages mouth animation state */ export declare class MouthSystem { private state; private config; private characterId; private availableMouths; /** * Default viseme to mouth shape mapping * Maps phonemes to actual available mouth shapes */ private static readonly DEFAULT_VISEME_MAPPING; /** * Default talking mouths (used for random audio-based animation) */ private static readonly DEFAULT_TALKING_MOUTHS; /** * Creates a new MouthSystem instance * @param characterId - Unique identifier for the character * @param availableMouths - Set of available mouth shapes for this character * @param config - Optional mouth configuration */ constructor(characterId: string, availableMouths?: Set, config?: MouthConfig); /** * Get current mouth state */ getState(): MouthState; /** * Get current mouth shape */ getCurrentMouth(): MouthShape; /** * Manually set mouth shape */ setMouthShape(shape: MouthShape): void; /** * Set available mouth shapes */ setAvailableMouths(mouths: MouthShape[]): void; /** * Update mouth animation based on audio volume * @param currentTime - Current time in milliseconds * @param audioData - Audio analysis data */ updateFromAudio(currentTime: number, audioData: AudioAnalysisData): void; /** * Update mouth animation based on viseme data * @param viseme - Viseme identifier (e.g., 'A', 'E', 'O') */ updateFromViseme(viseme: string): void; /** * Reset mouth to closed state */ reset(): void; /** * Get the image key for the current mouth shape * Mouth shapes are named absolutely (no variations) * * @returns The image key for the current mouth (e.g., 'open', 'closed', 'f') */ getCurrentMouthImageKey(): string; /** * Get configuration */ getConfig(): MouthConfig; /** * Update configuration */ updateConfig(config: Partial): void; /** * Get debug information */ getDebugInfo(): string; } /** * Factory function to create mouth system */ export declare function createMouthSystem(characterId: string, availableMouths?: MouthShape[], config?: MouthConfig): MouthSystem; /** * Helper: Extract available mouth shapes from rig data * Only looks for the specific mouth shapes defined in MouthShape type */ export declare function extractMouthShapesFromRigData(rigData: RigData): MouthShape[]; /** * Helper: Extract mouth image hashes from rig data * Returns only the valid mouth shape MD5 hashes, excluding positioning data * @param rigData - Character rig data * @returns Object with mouth shape names as keys and MD5 hashes as values */ export declare function extractMouthImagesFromRigData(rigData: RigData): Record; //# sourceMappingURL=mouthSystem.d.ts.map