All files / audio types.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265                  2x 2x 2x 2x 2x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
// filepath: /workspaces/blacktrigram/src/audio/types.ts
/**
 * Type definitions for audio types
 * Auto-generated by type migration script
 */
 
import { KoreanText, PlayerArchetype, TrigramStance } from "@/types";
 
// Export AudioCategory enum (only one declaration)
export enum AudioCategory {
  SFX = "sfx",
  MUSIC = "music",
  VOICE = "voice",
  UI = "ui",
  // Remove AMBIENT since it's causing errors
}
 
// Audio context for spatial audio
export interface AudioContext3D {
  readonly position: { x: number; y: number; z?: number };
  readonly velocity?: { x: number; y: number; z?: number };
  readonly orientation?: { x: number; y: number; z?: number };
  readonly maxDistance?: number;
  readonly rolloffFactor?: number;
}
 
// Combat audio mapping
// Add missing type exports
export type SoundEffectId = string;
export type MusicTrackId = string;
export type VoiceLineId = string;
 
// Audio format type (string literals only, not enum)
export type AudioFormat =
  | "audio/mp3"
  | "audio/wav"
  | "audio/ogg"
  | "audio/webm";
 
// Audio effect definitions
export interface AudioEffect {
  readonly type: "reverb" | "delay" | "distortion" | "filter" | "compressor";
  readonly parameters: Record<string, number>;
  readonly enabled: boolean;
}
 
// Audio mixer channel
export interface AudioChannel {
  readonly id: string;
  readonly category: AudioCategory;
  readonly volume: number;
  readonly muted: boolean;
  readonly effects: readonly AudioEffect[];
  readonly connectedSources: readonly string[];
}
 
// Audio platform capabilities
export interface AudioCapabilities {
  readonly supportsWebAudio: boolean;
  readonly supportsHowler: boolean;
  readonly maxSources: number;
  readonly formats: readonly string[];
  readonly spatialAudio: boolean;
  readonly realTimeEffects: boolean;
}
 
export interface IAudioManager {
  readonly isInitialized: boolean;
  readonly masterVolume: number;
  readonly sfxVolume: number;
  readonly musicVolume: number;
  readonly muted: boolean;
 
  initialize(config?: AudioConfig): Promise<void>;
  loadAsset(asset: AudioAsset): Promise<void>; // ✅ Added missing method
  setVolume(type: "master" | "sfx" | "music" | "voice", volume: number): void;
  playMusic(trackId: string): Promise<void>;
  playSoundEffect(soundId: string): Promise<void>;
  playSFX(soundId: string, volume?: number): Promise<void>; // ✅ Added missing playSFX method
  stopMusic(): void;
  mute(): void;
  unmute(): void;
  fadeIn(trackId: string, duration?: number): Promise<void>; // ✅ Added for combat audio
  fadeOut(duration?: number): Promise<void>; // ✅ Added for combat audio
  playKoreanTechniqueSound(
    techniqueId: string,
    archetype: string
  ): Promise<void>;
  playTrigramStanceSound(stance: string): Promise<void>;
  playVitalPointHitSound(severity: string): Promise<void>;
  playDojiangAmbience(): Promise<void>;
}
 
export interface AudioAsset {
  readonly id: string;
  readonly name?: string;
  readonly type: "sound" | "music" | "voice";
  readonly url: string;
  readonly formats: readonly string[];
  readonly loaded: boolean;
  readonly volume?: number;
  readonly category?: string;
}
 
export interface MusicTrack extends AudioAsset {
  readonly type: "music";
  readonly title?: KoreanText;
  readonly artist?: string;
  readonly album?: string;
  readonly bpm?: number;
  readonly loop?: boolean;
  readonly fadeInTime?: number;
  readonly fadeOutTime?: number;
  readonly variations?: readonly string[];
  readonly category: "music" | "voice";
}
 
export interface SoundEffect extends AudioAsset {
  readonly type: "sound";
  readonly pitch?: number;
  readonly variations?: readonly string[];
  readonly category: "sfx" | "ui";
}
 
export interface VoiceLine extends AudioAsset {
  readonly type: "voice";
  readonly text: KoreanText;
  readonly archetype?: PlayerArchetype;
  readonly emotion?:
    | "neutral"
    | "aggressive"
    | "defensive"
    | "victorious"
    | "defeated";
  category?: AudioCategory;
  volume?: number;
}
 
export interface AudioConfig {
  readonly enableSpatialAudio: boolean;
  readonly maxSimultaneousSounds: number;
  readonly audioFormats: readonly string[];
  readonly fadeTransitionTime: number;
  readonly defaultVolume?: number;
  masterVolume?: number;
  musicVolume?: number;
  sfxVolume?: number;
}
 
export interface AudioEvent {
  readonly type: "play" | "stop" | "pause" | "resume" | "volume" | "fade";
  readonly assetId: string;
  readonly volume?: number;
  readonly delay?: number;
  readonly fadeTime?: number;
  readonly loop?: boolean;
  readonly priority?: number;
}
 
export interface CombatAudioMap {
  readonly attacks: Record<string, SoundEffectId>;
  readonly impacts: Record<string, SoundEffectId>;
  readonly stances: Record<TrigramStance, string>;
  readonly environments: Record<string, SoundEffectId>;
  readonly ui: Record<string, SoundEffectId>;
}
 
export interface AudioState {
  readonly isPlaying: boolean;
  readonly isPaused: boolean;
  readonly currentTime: number;
  readonly duration: number;
  readonly volume: number;
  readonly loop: boolean;
  readonly masterVolume: number;
  readonly sfxVolume: number;
  readonly musicVolume: number;
  readonly muted: boolean;
  readonly currentMusicTrack: string | null;
  readonly isInitialized: boolean;
  readonly fallbackMode: boolean;
}
 
export interface AudioPlaybackOptions {
  readonly volume?: number;
  readonly loop?: boolean;
  readonly fadeIn?: number;
  readonly fadeOut?: number;
  readonly delay?: number;
  readonly startTime?: number;
  readonly endTime?: number;
  readonly rate?: number;
}
 
export interface ProceduralSoundConfig {
  readonly frequency: number;
  readonly duration: number;
  readonly type: "sine" | "square" | "sawtooth" | "triangle" | "noise";
  readonly attack?: number;
  readonly decay?: number;
  readonly sustain?: number;
  readonly release?: number;
  readonly volume?: number;
}
 
export interface CombatAudioEvent {
  readonly type: "attack" | "hit" | "block" | "dodge" | "stance_change";
  readonly technique?: string;
  readonly stance?: string;
  readonly damage?: number;
  readonly critical?: boolean;
}
 
/**
 * Audio-specific body regions for impact sound mapping
 * Maps to Korean martial arts vital point locations
 */
export type AudioBodyRegion =
  | "head" // 두부 (Head/Skull): temple, jaw, neck
  | "torso" // 몸통 (Torso): ribs, sternum, solar plexus, organs
  | "arms" // 팔 (Arms): shoulder, elbow, forearm, wrist
  | "legs" // 다리 (Legs): hip, knee, shin, ankle
  | "soft_tissue"; // 연조직 (Soft tissue): muscle, flesh, non-bone areas
 
/**
 * Impact intensity levels for bone/flesh contact
 * Determines audio selection and volume variation
 */
export type ImpactIntensity =
  | "light" // 경타 (Light): Glancing blows, minimal damage
  | "medium" // 중타 (Medium): Solid contact, moderate damage
  | "heavy" // 강타 (Heavy): Devastating strikes, severe damage
  | "critical" // 급소타 (Critical): Vital point precision strikes
  | "fracture"; // 골절 (Fracture): Bone-breaking force, <30% health
 
/**
 * Bone impact audio event with body region and intensity
 * Used for anatomically accurate combat sound feedback
 */
export interface BoneImpactEvent {
  readonly region: AudioBodyRegion;
  readonly intensity: ImpactIntensity;
  readonly vitalPoint?: boolean; // True if hitting a vital point
  readonly remainingHealth?: number; // For fracture detection (<30%)
}
 
export interface AudioLoadingState {
  readonly total: number;
  readonly loaded: number;
  readonly failed: number;
  readonly currentAsset?: string;
  readonly progress: number;
  readonly errors: readonly string[];
}
export interface AudioSystemInterface {
  playSFX: (id: SoundEffectId, options?: AudioPlaybackOptions) => void;
  playMusic: (id: MusicTrackId, options?: AudioPlaybackOptions) => void;
  stopMusic: (id?: MusicTrackId, fadeOutDuration?: number) => void;
  setVolume: (type: "master" | "sfx" | "music", volume: number) => void;
  loadAudioAsset: (asset: AudioAsset) => Promise<void>;
  isMusicPlaying: (id?: MusicTrackId) => boolean;
}
 
export interface AudioManagerInterface extends IAudioManager {}