diff options
| author | Ian C <ianc@noddybox.co.uk> | 2026-06-29 09:41:42 +0900 |
|---|---|---|
| committer | Ian C <ianc@noddybox.co.uk> | 2026-06-29 09:41:42 +0900 |
| commit | c527acfc79f3bda8cfe13a7b51b0b16a32683960 (patch) | |
| tree | e5bbd119a070848301a03b52f1232a797b35c119 /src/audio.c | |
| parent | c31b779c20638ce25f11489c445a53798a663b13 (diff) | |
First partial working attempt at sound. Producing output, but very distorted
Diffstat (limited to 'src/audio.c')
| -rw-r--r-- | src/audio.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/audio.c b/src/audio.c index b5ce1df..7eef433 100644 --- a/src/audio.c +++ b/src/audio.c @@ -27,17 +27,41 @@ #include <SDL.h> #include "audio.h" +#include "util.h" -/* ---------------------------------------- INTERFACES +/* ---------------------------------------- INTERNAL DATA */ +static SDL_AudioSpec actual; +static SDL_AudioDeviceID device; + +/* ---------------------------------------- INTERFACES +*/ int AUDIOInit(void) { - return 0; + SDL_AudioSpec spec = {0}; + + spec.freq = SAMPLE_RATE; + spec.format = AUDIO_S8; + spec.channels = 1; + spec.samples = 4096; + + device = SDL_OpenAudioDevice(NULL, 0, &spec, &actual, 0); + + if (device != 0) + { + SDL_PauseAudioDevice(device, 0); + } + + return device != 0; } -void AUDIOQueue(char *buffer, size_t len) +void AUDIOQueue(Uint8 *buffer, size_t len) { + if (device != 0) + { + SDL_QueueAudio(device, buffer, len); + } } |
