msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.28k stars 1.22k forks source link

SDL_Mixer not loading MIDI files: Unrecognized audio format #8697

Closed Nrezinorn closed 3 years ago

Nrezinorn commented 3 years ago

I am not sure if this is a library/linker issue, but I am not able to load MIDI files with Mix_LoadMus() on Windows 10.

$ pacman -Q |grep mixer mingw-w64-x86_64-SDL2_mixer 2.0.4-3

.\MusTest.exe
Mix_LoadMUS("flourish.mid"): Unrecognized audio format

#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <iostream>

int main(int argc, char *args[]){
   SDL_Init(SDL_INIT_AUDIO);
   Mix_Init(MIX_INIT_MID);

   Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 16, 0);

   Mix_Music* foo;
   foo = Mix_LoadMUS("flourish.mid");
   if(!foo) {
      printf("Mix_LoadMUS(\"flourish.mid\"): %s\n", Mix_GetError());
   }

   Mix_PlayMusic(foo,-1);
   SDL_Delay(10000);

   Mix_FreeMusic(foo);
   Mix_Quit();
   SDL_Quit();

 return 0;
Nrezinorn commented 3 years ago

Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 0);

fixes. Closing