old sdl audio test that worked... idk how to use this tho
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
static unsigned int wav_length; /* length of our sample */
|
||||||
|
static unsigned char* wav_buffer; /* buffer containing our audio file */
|
||||||
|
static SDL_AudioSpec wav_spec;
|
||||||
|
static SDL_AudioDeviceID device_id = 0;
|
||||||
|
|
||||||
|
void queue(char* file)
|
||||||
|
{
|
||||||
|
if (SDL_LoadWAV(file, &wav_spec, &wav_buffer, &wav_length) == NULL) {
|
||||||
|
printf("file is null!!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
device_id = SDL_OpenAudioDevice(NULL, 0, &wav_spec, NULL, 0);
|
||||||
|
SDL_QueueAudio(device_id, wav_buffer, wav_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void close_audio(void) {
|
||||||
|
SDL_CloseAudioDevice(device_id);
|
||||||
|
SDL_FreeWAV(wav_buffer);
|
||||||
|
SDL_Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
SDL_Init(SDL_INIT_EVERYTHING);
|
||||||
|
queue("example.wav");
|
||||||
|
SDL_PauseAudioDevice(device_id, 0);
|
||||||
|
SDL_Delay(3000);
|
||||||
|
close_audio();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BIN
Binary file not shown.
Reference in New Issue
Block a user