Question

I'm using NAudio to play MIDI files in my .NET project.

I want to play some MIDI tracks (drum loops particularly) so each sound maps to a certain wav or mp3 file. Is that possible?

I'm new to MIDI development, I just heard of the idea of SoundFonts, is this what I'm looking for perhaps?

Has anyone tried that before?

Update
It's not that I have those wave files present, I just hate the sound of the default MIDI device on the computer.

Maybe I just need a better sound card, or maybe there is a virtual MIDI device that has professional tones.

Update
After reading about SoundFont, I am almost sure this is the solution I'm seeking. The question is how to use it with NAudio.

Was it helpful?

Solution

To do this you will need a software synthesizer, which can convert from MIDI notes into PCM audio. Some software synthesizers make use of soundfonts as you mention, others use samples, and others generate sounds using oscillators or physical modelling.

NAudio does not include a software synthesizer, and building one is not a trivial task at all (will require knowledge of filters, resampling, oscillators, DSP etc). You might find that the best approach is to use NAudio in combination with VST.net. This would allow you to load any VST software instrument (of which there are thousands, both commerical and free), pass your MIDI into that, and use NAudio to write the resulting sound to a file.

Having said that, if all you need is a simple drum sequencer, the NAudio WPF demo does include an example of playing back drum samples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top