twn_audio.c: .wav support and scratch channels

This commit is contained in:
veclavtalica
2025-01-13 19:56:20 +03:00
parent 87ae1a7312
commit eefd53a630
3 changed files with 166 additions and 18 deletions

View File

@ -13,9 +13,12 @@
#define AUDIO_FREQUENCY 48000
/* TODO: specify which PCM formats are usable with WAV */
/* TODO: specify limitations of libxm */
/* TODO: specify limitations of stb_vorbis */
typedef enum AudioFileType {
AUDIO_FILE_TYPE_OGG,
AUDIO_FILE_TYPE_WAV,
AUDIO_FILE_TYPE_XM,
AUDIO_FILE_TYPE_COUNT,
AUDIO_FILE_TYPE_UNKNOWN,
@ -30,6 +33,12 @@ union AudioContext {
uint8_t channel_count;
} vorbis;
struct {
void *samples;
SDL_AudioSpec spec;
size_t position;
} wav;
struct {
xm_context_t *handle;
} xm;
@ -44,6 +53,7 @@ typedef struct AudioChannel {
bool repeat;
float volume;
float panning;
bool finished;
} AudioChannel;