23 lines
717 B
C
23 lines
717 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <assert.h>
|
|
#include <SDL2/SDL.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
assert(argc == 2);
|
|
if(SDL_Init(SDL_INIT_AUDIO)) {fprintf(stderr, "cannot initialize audio");exit(1);}
|
|
SDL_AudioSpec wavSpec;
|
|
Uint32 wavLength;
|
|
Uint8 *wavBuffer;
|
|
SDL_LoadWAV(argv[1], &wavSpec, &wavBuffer, &wavLength);
|
|
SDL_AudioDeviceID deviceId = SDL_OpenAudioDevice(NULL, 0, &wavSpec, NULL, 0);
|
|
int success = SDL_QueueAudio(deviceId, wavBuffer, wavLength);
|
|
SDL_PauseAudioDevice(deviceId, 0);
|
|
usleep((int)((wavLength)/88200.0*100000.0));
|
|
SDL_CloseAudioDevice(deviceId);
|
|
SDL_FreeWAV(wavBuffer);
|
|
SDL_Quit();
|
|
return 0;
|
|
}
|
|
// yummy
|