#define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h" #include static ma_device device; static float phase = 0.0f; static void audio_callback(ma_device*, void* output, const void*, ma_uint32 frames) { int16_t* out = (int16_t*)output; const float freq = 440.0f; const float sr = 32000.0f; for (ma_uint32 i = 0; i < frames; i++) { float s = sinf(phase) * 0.2f; phase += 2.0f * 3.14159265f * freq / sr; if (phase > 2.0f * 3.14159265f) phase -= 2.0f * 3.14159265f; out[i] = (int16_t)(s * 32767.0f); } } void audio_init() { ma_device_config cfg = ma_device_config_init(ma_device_type_playback); cfg.playback.format = ma_format_s16; cfg.playback.channels = 1; cfg.sampleRate = 32000; cfg.dataCallback = audio_callback; ma_device_init(nullptr, &cfg, &device); ma_device_start(&device); } void audio_update() {} void audio_shutdown() { ma_device_uninit(&device); }