AudioComponent struct in Thread
3D positional audio source backed by OpenAL Soft. Each AudioComponent owns one
AL source at runtime; the cached AudioBuffer is shared with every
other component pointing to the same file.
Supported formats: WAV (PCM 8/16, mono/stereo), OGG (stb_vorbis), MP3 (minimp3).
Properties — authored
| ClipPath | std::string | VFS path to the audio file. Drag-drop from Content Browser to set. |
| Volume | float | Linear gain 0..1. Default 1.0. |
| Pitch | float | Playback rate 0.1..3. Default 1.0. |
| Loop | bool | Restart when the buffer ends. Default false. |
| AutoPlay | bool | Start on first runtime tick. Default true. |
| Is3D | bool | When true, gain attenuates by distance (inverse model). Stereo clips are downmixed for spatialisation. |
| MinDistance | float | Full volume within this radius. Default 1.0. |
| MaxDistance | float | Attenuation clamps beyond this radius. Default 50.0. |
| OcclusionEnabled | bool | Raycast between listener and source; blocked 3D sources are muffled. Default true. |
| OcclusionStrength | float | Low-pass and direct-gain reduction from 0 (none) to 1 (full). Default 1.0. |
| ReverbSend | bool | Send this 3D source into the active Reverb Zone. Default true. |
Properties — runtime
| Clip | std::shared_ptr<AudioBuffer> | Cached buffer. Lazy-loaded on first tick. |
| SourceId | uint32_t | OpenAL source handle. 0 = not created yet. |
Volume / Pitch / Loop / distance fields are pushed to OpenAL every frame — sliders in the inspector update playback in real time.
Example
auto& ac = e.AddComponent<Thread::AudioComponent>();
ac.ClipPath = "assets/audio/footstep.wav";
ac.Volume = 0.7f;
ac.Loop = true;
ac.AutoPlay = false;
AudioComponent struct w Thread
Pozycyjne źródło dźwięku 3D oparte na OpenAL Soft. Każdy AudioComponent ma w czasie działania
jedno źródło AL; zbuforowany AudioBuffer jest współdzielony ze wszystkimi innymi
komponentami wskazującymi ten sam plik.
Obsługiwane formaty: WAV (PCM 8/16, mono/stereo), OGG (stb_vorbis), MP3 (minimp3).
Właściwości — ustawiane
| ClipPath | std::string | Ścieżka VFS pliku audio. Ustawisz ją, przeciągając plik z Content Browsera. |
| Volume | float | Liniowe wzmocnienie 0..1. Domyślnie 1.0. |
| Pitch | float | Szybkość odtwarzania 0.1..3. Domyślnie 1.0. |
| Loop | bool | Zacznij od nowa po końcu bufora. Domyślnie false. |
| AutoPlay | bool | Start przy pierwszym ticku gry. Domyślnie true. |
| Is3D | bool | Gdy true, głośność maleje z odległością (model odwrotny). Klipy stereo są miksowane do mono na potrzeby przestrzenności. |
| MinDistance | float | Pełna głośność w tym promieniu. Domyślnie 1.0. |
| MaxDistance | float | Poza tym promieniem tłumienie przestaje rosnąć. Domyślnie 50.0. |
| OcclusionEnabled | bool | Raycast między listenerem i źródłem; dźwięk 3D za przeszkodą jest przytłumiony. Domyślnie true. |
| OcclusionStrength | float | Siła filtra low-pass i tłumienia od 0 (brak) do 1 (pełna). Domyślnie 1.0. |
| ReverbSend | bool | Wysyła źródło 3D do aktywnej strefy pogłosu. Domyślnie true. |
Właściwości — w czasie działania
| Clip | std::shared_ptr<AudioBuffer> | Zbuforowany bufor. Wczytywany leniwie przy pierwszym ticku. |
| SourceId | uint32_t | Uchwyt źródła OpenAL. 0 = jeszcze nie utworzone. |
Volume / Pitch / Loop i pola odległości są co klatkę przekazywane do OpenAL — suwaki w inspektorze zmieniają odtwarzanie na żywo.
Przykład
auto& ac = e.AddComponent<Thread::AudioComponent>();
ac.ClipPath = "assets/audio/footstep.wav";
ac.Volume = 0.7f;
ac.Loop = true;
ac.AutoPlay = false;