c++midisdl-mixer

Reading midi-files


I'm trying to help out a friend creating a program. And we need to read some midi-file data. I've searched for a good 2 hours now and I can't really seem to find any straight forward ways of doing it.

I've downloaded and hopefully installed SDL_mixer correctly. And managed to play a song with this:

//Initialize sound
SDL_Init(SDL_INIT_AUDIO);
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024);
Mix_VolumeMusic(100);

//Load song
string midiFile = LIB_AUDIO + "redlottery.mid";
Mix_Music *song = Mix_LoadMUS(midiFile.c_str());

//Play song
Mix_PlayMusic(song, 1);

So, what I'm wondering is... Is it possible to extract data using this? I need things like, note timings. I don't really know how they are structured, but I want to access data. How do you suggest I try doing that?

Thanks!


Solution

  • There are open-source libraries for reading MIDI files. Here are a few:

    midifile.sapp.org

    naudio.codeplex.com

    www.juce.com