Do you know any library in C# that I can use in order to read an existing *.mid file? I want to draw the sound frequency graph for the MIDI file, but I cannot get the inner data. I tried using NAudio and Alvas.Audio, but I wans't able to read a MIDI file. Any suggestions?
Bass.net (http://www.un4seen.com) might be what you are looking for. (using the Bassmidi extension down the page)
The MIDI file format is relatively complicated (see here). Writing them is easier than reading them (as with WAV files). I don't know of any C# libraries that do this, but I should mention that since your ultimate goal is to create a spectrograph, you probably don't need a library to read the MIDI file at all.
A MIDI file does not contain any actual audio information - it merely contains instructions for a synthesizer, e.g. note on messages, volume change mesages etc. In order to create a spectrograph from a MIDI file, you need to "play" it with something so that you get actual audio data to run FFT analyses on.
You don't really need to play it with something, of course. Google midi-to-wav
for a load of options for automatically converting MIDI files into WAV files. Once you have the WAV files, Google wav file spectrum analyzer c#
to see the many options for generating spectrographs from WAV file data.
To the down-voters: suggesting Google keywords as an answer is not automatically a bad thing. In this case, I'm just trying to stear the asker in the right direction, so that they don't spend time doing something they don't need to do.
NAudio can read and write MIDI files. I'm not sure what your problem was. Have a look at MIDI file mapper as an example of a project using NAudio to map drum beats.