KAOS Audio System
Relevant source files
The following files were used as context for generating this wiki page:
The KAOS Audio System is an advanced 3D/4D spatial audio engine designed for the TAMV MD-X4 ecosystem. It provides immersive soundscapes, binaural beats, and reactive audio generation to enhance user experience within environments like Dream Spaces and the Metaverse. The system integrates both client-side Web Audio API processing and server-side edge functions for atmospheric generation.
Sources: src/systems/KAOSAudioSystem.ts:1-5, README_TAMV_COMPLETO.md:46-50, supabase/functions/kaos-audio-system/index.ts:1-2
Core Architecture
The KAOS architecture is split between a high-performance client-side engine and a cloud-based generation core. The client engine handles real-time spatialization, binaural synthesis, and haptic feedback, while the Edge Functions manage complex configurations for atmospheres and reactive music logic.
Client-Side Engine (KAOSAudioSystem)
The main engine utilizes the AudioContext to manage a complex graph of nodes including GainNodes, PannerNodes, and OscillatorNodes. It supports spatial 3D audio using HRTF (Head-Related Transfer Function) models to position sound in a 360-degree space.
The diagram illustrates the internal Web Audio node routing for the KAOS Client Engine.
Sources: src/systems/KAOSAudioSystem.ts:60-95, src/systems/KAOSAudioSystem.ts:251-269
Functional Components
1. Binaural Beats and Presets
The system includes scientifically-backed binaural frequency presets designed to alter cognitive states such as focus (Gamma waves) or sleep (Delta waves). These are generated by creating a frequency offset between left and right audio channels.
| Preset | Base Freq (Hz) | Beat Freq (Hz) | Waveform | Purpose |
|---|---|---|---|---|
| Focus | 200 | 40 | Sine | Gamma waves for concentration |
| Relax | 180 | 10 | Sine | Alpha waves for relaxation |
| Meditate | 150 | 7 | Sine | Theta waves for deep meditation |
| Energy | 250 | 14 | Triangle | Beta waves for high alertness |
| Sleep | 140 | 4 | Sine | Delta waves for deep sleep |
| Creative | 160 | 7.83 | Sine | Schumann resonance |
Sources: src/systems/KAOSAudioSystem.ts:31-40
2. Spatial 3D/4D Audio
KAOS supports 3D positioning of sound sources. The engine calculates listener orientation and source positions using coordinates to provide a "Quantum" spatial depth.
Sequence of initializing and triggering spatial audio events.
Sources: src/systems/KAOSAudioSystem.ts:114-142, supabase/functions/kaos-audio-system/index.ts:91-103
3. Atmospheric Generation
Through the tamv-kaos-audio-system edge function, the system generates complex soundscape configurations based on environmental parameters.
| Action | Parameters | Description |
|---|---|---|
generate_atmosphere | space_type, mood, intensity | Configures base frequencies and reverb for specific spaces (e.g., concert, gallery). |
create_soundscape | elements, duration, evolution_rate | Creates multi-layered organic soundscapes with randomized spatial positions. |
spatial_audio | listener_position, room_size | Configures room reflection, absorption, and HRTF settings. |
reactive_music | emotion, energy_level | Generates AI-driven reactive music scales and BPM based on user state. |
Sources: supabase/functions/kaos-audio-system/index.ts:15-35, supabase/functions/kaos-audio-system/index.ts:50-70
Implementation Details
Environmental Soundscapes
Environments utilize specific noise types (Pink, Brown, White) and harmonic frequencies to simulate various settings.
const ENVIRONMENT_SOUNDS: Record<AudioEnvironment, { frequencies: number[]; amplitudes: number[]; noiseType?: 'pink' | 'brown' | 'white' }> = {
quantum: { frequencies: [432, 528, 639], amplitudes: [0.3, 0.2, 0.15], noiseType: 'pink' },
forest: { frequencies: [220, 330, 440], amplitudes: [0.2, 0.15, 0.1], noiseType: 'pink' },
cosmic: { frequencies: [136.1, 172.0, 246.0], amplitudes: [0.25, 0.2, 0.15], noiseType: 'brown' },
};
Sources: src/systems/KAOSAudioSystem.ts:43-50
Audio Configuration (Master Settings)
The system state is managed through an AudioConfig object, allowing for dynamic updates to volume and quality levels.
| Field | Type | Default | Description |
|---|---|---|---|
masterVolume | number | 0.8 | Global volume gain (0.0 to 1.0) |
spatialEnabled | boolean | true | Toggles 3D HRTF processing |
binauralEnabled | boolean | true | Toggles binaural beat synthesis |
hapticFeedback | boolean | false | Toggles mobile vibration on notifications |
quality | string | 'high' | Quality tier (low, medium, high, ultra) |
Sources: src/systems/KAOSAudioSystem.ts:68-74
Summary of Integration
KAOS is a critical component for the "DreamSpaces" and "HyperReal" modules, ensuring that visual immersion is matched by high-fidelity audio. It employs a singleton pattern via getKAOSInstance() to ensure a consistent audio context across the application while providing hooks like useAudio for easy component integration.
Sources: src/systems/KAOSAudioSystem.ts:378-385, src/systems/AudioSystem.ts:315-330, PLAN-TAMV-MODULAR.md:86-90