[mono-list] Is MIDI implemented with Mono

Jonathan Pryor jonpryor at vt.edu
Fri Sep 2 06:50:29 EDT 2005


On Thu, 2005-09-01 at 13:15 -0700, Michael Geis wrote:
> I expect having to either write
> spaghetti code or find a way to map 
> winmm.dll's midiStreamOut to libasound.so's
> snd_seq_schedule_note_event.

It need not be spaghetti code.  You just need to DllImport both
functions and perform a runtime check to decide which function to call:

	class MidiOutput {
		[DllImport ("winmm")]
		private static void midiStreamOut (string file);

		[DllImport ("asound")]
		private static void 
			snd_seq_schedule_note_event (string file);

		public static void Play (string file)
		{
			if (System.IO.Path.DirectorySeparatorChar == '\\')
				return midiStreamOut (file);
			return snd_seq_schedule_note_event (file);
		}
	}

Of course, actual function arguments will need to correctly match the
actual unmanaged function (I have no idea what arguments midiStreamOut
and snd_seq_schedule_note_event accept).

 - Jon




More information about the Mono-list mailing list