Skip to content

Instantly share code, notes, and snippets.

@LaughingSun
Forked from armornick/playwav.c
Last active April 12, 2022 06:34
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LaughingSun/e3450d28012a44182ebc to your computer and use it in GitHub Desktop.
Save LaughingSun/e3450d28012a44182ebc to your computer and use it in GitHub Desktop.
Play a sound with SDL2 added lots of print information and the ability to specify the wav file as first argument. Woohoo.
SRCS = $(wildcard *.c)
.PHONY: all
all: $(patsubst %.c,%,$(SRCS))
@echo found rules for: $^
%: %.c
gcc -I/usr/local/include -L/usr/local/lib $< -Wl,-rpath,/usr/local/lib -lSDL2 -lm -o $@
@echo built: $@
clean: $(patsubst %.c,%,$(SRCS))
rm $(patsubst %.c,%,$(SRCS))
@echo cleaned: $^
# gcc -I/usr/local/include -L/usr/local/lib $< -Wl,-rpath,/usr/local/lib -lSDL2 -lm -o $@
View raw

(Sorry about that, but we can’t show files that are this big right now.)

@Ragbot
Copy link

Ragbot commented Apr 25, 2021

It just spits out a bunch of things when I start it with one of the audio files and just doesn't play any help?

@Randrianasulu
Copy link

I modified this a bit, so now it shows type of error at init and list devices.


int i;

for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
printf("Audio driver %d: %s\n", i, SDL_GetAudioDriver(i));
}
..
// Initialize SDL.
int err = SDL_Init(SDL_INIT_AUDIO);
if ( err < 0) {
printf("SDL_Init(SDL_INIT_AUDIO) < 0, err = %s \n", SDL_GetError());
return 1;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment