musializer.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <complex.h>
  5. #include <raylib.h>
  6. #ifndef _WIN32
  7. #include <signal.h> // needed for sigaction()
  8. #endif // _WIN32
  9. #include "./hotreload.h"
  10. int main(void)
  11. {
  12. #ifndef _WIN32
  13. // NOTE: This is needed because if the pipe between Musializer and FFmpeg breaks
  14. // Musializer will receive SIGPIPE on trying to write into it. While such behavior
  15. // makes sense for command line utilities, Musializer is a relatively friendly GUI
  16. // application that is trying to recover from such situations.
  17. struct sigaction act = {0};
  18. act.sa_handler = SIG_IGN;
  19. sigaction(SIGPIPE, &act, NULL);
  20. #endif // _WIN32
  21. if (!reload_libplug()) return 1;
  22. Image logo = LoadImage("./resources/logo/logo-256.png");
  23. SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_ALWAYS_RUN);
  24. size_t factor = 80;
  25. InitWindow(factor*16, factor*9, "Musializer");
  26. SetWindowIcon(logo);
  27. SetTargetFPS(60);
  28. SetExitKey(KEY_NULL);
  29. InitAudioDevice();
  30. plug_init();
  31. while (!WindowShouldClose()) {
  32. if (IsKeyPressed(KEY_H)) {
  33. void *state = plug_pre_reload();
  34. if (!reload_libplug()) return 1;
  35. plug_post_reload(state);
  36. }
  37. plug_update();
  38. }
  39. CloseAudioDevice();
  40. CloseWindow();
  41. UnloadImage(logo);
  42. return 0;
  43. }