Hello all,
I've start a small project which includes working with Midi files. I've been wondering, does any of you know of a c# \vb.net code that peforms that cast between midi and wav files?
Hello all,
I've start a small project which includes working with Midi files. I've been wondering, does any of you know of a c# \vb.net code that peforms that cast between midi and wav files?
MIDI files contain only note and controller information, not sounds. In order to get sounds from a MIDI file, you have to pass the file through a music synthesizer or sampler, which will convert the note and controller information into actual sounds.
In practice this means that any given MIDI file doesn't have a specific sound to it. The sound that results from converting a MIDI file to audio will vary depending on the quality of the synthesizer or sample library, and the sounds that are selected to perform the conversion.
Many sound cards have the capability of producing sound from MIDI files. They can do this because many MIDI files follow a standard called the General MIDI specification. The General MIDI Specification provides a standardized way to map specific instrument assignments. If your MIDI file conforms to this standard, you can play it through a General MIDI sound generator and expect a snare drum to sound like a snare drum, and not like a trumpet.
If you have a sophisticated music production package like Cakewalk, you can load a MIDI file into it, and it will use its on-board sound libraries to render a sound file for you, and this can actually be done faster than real-time (i.e. it doesn't have to play the sound through the sound card and capture the output).
I guess what I'm trying to say is there's a lot of moving parts to this. There isn't a single piece of code or a class module that will do this for you.
There are a number of programs you can purchase that will do this (google "convert midi to WAV"), but I've never come across publically-available .Net code that does this (I think some of these programs are written in .Net, but the source code is not available).
I have an online friend who is working on a commercial MIDI-to-WAV converter, but it isn't in .Net and it won't be open source. As Robert Harvey mentioned, this is not a simple task at all, as it basically involves writing your own software synthesizer (a task after my own heart).
You could try to somehow interface with Timidity, which is Open Source:
TiMidity++ is a software synthesizer. It can play MIDI files by converting them into PCM waveform data; give it a MIDI data along with digital instrument data files, then it synthesizes them in real-time, and plays. It can not only play sounds, but also can save the generated waveforms into hard disks as various audio file formats.
FluidSynth is a more recently updated Open Source project in a similar vein:
FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications.
You can download some free SoundFonts (the actual PCM data used by these synthesizers to "render" the MIDI files) from the sites on this list.