summaryrefslogtreecommitdiff
path: root/src/audio/audio.h
blob: aaa5d455dcf2f2b22144aef0ac541edddb3b695b (plain)
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
// This file is part of the 64k demo project.
// It defines the public interface for the audio system.
// Includes initialization, shutdown, and frame updates.

#pragma once
#include "generated/assets.h"
#include <cstdint>

// Forward declarations
class AudioBackend;
class AudioRingBuffer;

// Expose ring buffer for backends
AudioRingBuffer* audio_get_ring_buffer();

struct SpecHeader {
  char magic[4];
  int32_t version;
  int32_t dct_size;
  int32_t num_frames;
};

void audio_init();
void audio_start(); // Starts the audio device callback

// Ring buffer audio rendering (main thread fills buffer)
void audio_render_ahead(float music_time, float dt);

// Get current playback time (in seconds) based on samples consumed
float audio_get_playback_time();

#if !defined(STRIP_ALL)
void audio_render_silent(float duration_sec); // Fast-forwards audio state
// Backend injection for testing
void audio_set_backend(AudioBackend* backend);
AudioBackend* audio_get_backend();
#endif /* !defined(STRIP_ALL) */
void audio_update();
void audio_shutdown();

int register_spec_asset(AssetId id);