2

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!

Aleksander Fimreite
  • 1,439
  • 2
  • 18
  • 31
  • Search "midi file format" on google. This seems to yield a lot of interesting information. Also this [SO question](http://stackoverflow.com/questions/3087277/what-is-the-structure-of-a-midi-file) deals with the midi file format. – Jabberwocky Mar 18 '14 at 18:31

1 Answers1

2

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

midifile.sapp.org

naudio.codeplex.com

www.juce.com

SSteve
  • 10,550
  • 5
  • 46
  • 72