c++ - SDL_mixer wont play sound Raspberry Pi -
i can't sdl_mixer
play sound on raspberry. program compiles , builds ok, hear short squeak (like static) , nothing.
any ideas?
#include <sdl/sdl.h> #include <sdl/sdl_mixer.h> #include <stdio.h> #include <string> #include <iostream> int main() { mix_chunk *snd1 = null; mix_music *m = null; if(sdl_init(sdl_init_video | sdl_init_audio) < 0) { std::cout << "something went wrong"; } if(mix_openaudio(44100, mix_default_format, 2, 1024) < 0) { std::cout << "kunne ikke loade musikk"; } snd1 = mix_loadwav("bicycle_bell.wav"); if(snd1 == null) { std::cout << "fant ikke filen"; } mix_playchannel(-1, snd1, 0); mix_freechunk(snd1); mix_quit(); return 1; }
solved it. program terminated before sound playing.
when testing simple:
while(mix_playing(sound));
fixed it.
Comments
Post a Comment