Last active
April 15, 2018 23:44
-
-
Save araml/7191ba537e497cc1ccd7e0199c65bdc6 to your computer and use it in GitHub Desktop.
Revisions
-
araml revised this gist
Apr 15, 2018 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,8 +18,8 @@ int main(int argc, char **argv) { bool run = true; SDL_Event e; Mix_Music *m1 = Mix_LoadMUS("mp3file1"), *m2 = Mix_LoadMUS("mp3file2"); Mix_PlayMusic(m1, -1); @@ -33,11 +33,11 @@ int main(int argc, char **argv) { } auto nnew = steady_clock::now(); if (nnew - old > seconds{4} && m1_running) { Mix_PlayMusic(m2, -1); old = nnew; m1_running = false; } else if (nnew - old > seconds{4}) { Mix_PlayMusic(m1, -1); old = nnew; m1_running = true; -
araml created this gist
Apr 15, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ // g++ sdl_mixer_test.cpp -o sdl_mixer -lSDL2 -lSDL2_mixer -std=c++11 #include <SDL2/SDL.h> #include <chrono> #include <SDL2/SDL_mixer.h> using namespace std::chrono; SDL_Window *window = NULL; int main(int argc, char **argv) { SDL_Init(SDL_INIT_VIDEO); Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024); window = SDL_CreateWindow("Audio", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 400, SDL_WINDOW_SHOWN); bool run = true; SDL_Event e; Mix_Music *m1 = Mix_LoadMUS("mp3file"), *m2 = Mix_LoadMUS("mp3file"); Mix_PlayMusic(m1, -1); auto old = steady_clock::now(); bool test, m1_running = true; while (run) { while (SDL_PollEvent(&e)) { if (e.type == SDL_QUIT) run = false; } auto nnew = steady_clock::now(); if (nnew - old > seconds{7} && m1_running) { Mix_PlayMusic(m2, -1); old = nnew; m1_running = false; } else if (nnew - old > seconds{7}) { Mix_PlayMusic(m1, -1); old = nnew; m1_running = true; } } return 0; }