Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert between midi to wav/mp3 in c#?

Tags:

c#

midi

wav

I started a small project which includes working with MIDI files. I've been wondering, is there any C# or VB.Net code that peforms that cast between MIDI and WAV files?

like image 503
vondip Avatar asked Jul 26 '09 19:07

vondip


People also ask

How do I convert a MIDI file to WAV?

How to convert a MIDI to a WAV file? Choose the MIDI file that you want to convert. Select WAV as the the format you want to convert your MIDI file to. Click "Convert" to convert your MIDI file.

Can you convert MIDI to audio?

To resample a single MIDI track, simply solo the instrument track you want to transfer to the audio track and record enable the audio track. Then, start recording! There are a few things to keep in mind when it comes to Resampling.

How do I save a MIDI file as an MP3?

Select the midi file you want to convert in the iTunes window. Select "Advanced" in the menu bar and select "Convert Selection to MP3".


2 Answers

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.

like image 177
Jacob Avatar answered Oct 01 '22 06:10

Jacob


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.

like image 45
Robert Harvey Avatar answered Oct 01 '22 06:10

Robert Harvey