cb6d9e61d1
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
2.2 KiB
Markdown
48 lines
2.2 KiB
Markdown
---
|
|
name: audio_engine
|
|
kind: function
|
|
lang: cpp
|
|
domain: gamedev
|
|
version: "0.1.0"
|
|
purity: impure
|
|
signature: "engine_init() -> Engine; engine_shutdown(Engine&); engine_set_volume(Engine&, float)"
|
|
description: "Lifecycle del engine de audio basado en miniaudio (single-header, public domain). Inicializa device default, expone master volume, y libera recursos. Cross-platform: Windows/Linux/macOS via WASAPI/ALSA/CoreAudio y WebAudio bajo emscripten. Issue 0072b — runtime gamedev nucleo. Esta TU es la unica del proyecto que define MINIAUDIO_IMPLEMENTATION."
|
|
tags: [gamedev, audio, miniaudio]
|
|
uses_functions: []
|
|
uses_types: []
|
|
returns: []
|
|
returns_optional: false
|
|
error_type: "error_go_core"
|
|
imports: []
|
|
example: |
|
|
fn::audio::Engine eng = fn::audio::engine_init();
|
|
if (!eng.ok) { /* fallback silencioso */ }
|
|
fn::audio::engine_set_volume(eng, 0.8f);
|
|
// ... loop principal ...
|
|
fn::audio::engine_shutdown(eng);
|
|
tested: false
|
|
tests: []
|
|
test_file_path: ""
|
|
file_path: "cpp/functions/gamedev/audio_engine.cpp"
|
|
params:
|
|
- name: e
|
|
desc: "Engine handle. ok=true tras engine_init exitoso. Estructura opaca: impl apunta a ma_engine internamente."
|
|
- name: v
|
|
desc: "Volumen master 0..1 (lineal). Valores >1 amplifican (riesgo de clipping)."
|
|
output: "Engine con impl=ma_engine* y ok=true si MA_SUCCESS, ok=false en cualquier fallo (malloc o init de miniaudio). engine_shutdown deja ok=false e impl=nullptr — llamadas posteriores son no-op seguros."
|
|
---
|
|
|
|
# audio_engine
|
|
|
|
Wrapper minimo del engine de [miniaudio](https://miniaud.io/) (v0.11.25, single-header, public domain / MIT-0). Vendored en `cpp/vendor/miniaudio/`.
|
|
|
|
## Por que
|
|
|
|
Audio cross-platform sin depender de SDL_mixer / OpenAL / FMOD. Compila en Windows/Linux/macOS y WASM (emscripten) desde el mismo source. Sin excepciones, sin RTTI, sin std::string.
|
|
|
|
## Notas
|
|
|
|
- Estado de fallo se reporta via `Engine.ok=false`. No hay `error_type` porque no devolvemos `error_go_core`-style; el consumidor revisa `ok` antes de operar.
|
|
- `MINIAUDIO_IMPLEMENTATION` se define UNICAMENTE en `audio_engine.cpp`. Otras TU que usen miniaudio deben hacer solo `#include "miniaudio.h"`.
|
|
- Memoria via `malloc`/`free` (no `new`) para mantener compat con `-fno-exceptions`.
|