Sunday, 30 March 2014

VB5, VB6, VB.NET - MIDI IN and MIDI OUT Source Code

Here is some code for you all to play with. I have searched the 'net for decent MIDI IN and MIDI OUT code - it is almost impossible to find - especially MIDI IN. So, here is working code to save all VB programmers from tearing what is left of their hair out ;-)

However, let me just say a few words first. My definition of MIDI IN and MIDI OUT processing is not some baby code that handles a few notes struck on a keyboard - or the odd SYSEX message. No - good MIDI IN and MIDI OUT code has to handle amazingly complex MIDI input and output. The only way to do this is to use MIDI FILES that provide a "torture test" ;-)

To test the code I use loopMIDI from Tobias Erichsen. This is rock solid code. I have tried loopBE1 - but I gave up on this as one of my MIDI files consistently broke it. I have included the file, CHANGING.MID, so you can try this code with it.

Here is the link to the source code and MIDI files:

https://onedrive.live.com/redir?resid=68C7CC233B49C4C2!576&authkey=!AKEp6IWwji2FKzg&ithint=folder%2c.txt

To test MIDI IN and MIDI OUT - use your favourite MIDI file player - you can use mine if you like:

https://onedrive.live.com/redir?resid=68C7CC233B49C4C2!342&authkey=!AFDQL1CnIX7o-Gg&ithint=folder%2c.exe

Install loopMIDI and XG-GS Utilities from the site above.

Set MIDI OUT from the player (XG/GS MIDI Jukebox) to "loopMIDI port".
Set MIDI IN in the test code below to "loopMIDI port".
Set MIDI OUT in the test code below to "Your favourite hardware or software synth"
Press play in your player - sit back - and watch.

The items I have uploaded are:

MIDIIN VB5

This is the code that started it all. MIDI IN and OUT using only VB5. This code is rock solid and never breaks. Just double click "MidiMon.exe" to run it.

MIDIIN VB6

This is exactly the same code as the VB5 code above - just compiled with VB6. It does NOT WORK! I am firmly convinced that MIDI IN is simply not possible with VB6 :-( It can play most of the MIDI files I have uploaded - as long as it is feeling happy and there is not much SYSEX input. It cannot play any of the ANO MIDI files that I have uploaded - apart from ANO5 - which has no SYSEX - and which it sometimes plays. I would be very grateful if someone can find out why this code does not work consistently! Just double click "MidiMon.exe" to run it.

XGGSMON

This is VB.NET using VS 2010. The code is rock solid - it never breaks. Converting this code from VB5 was a real pain - disabling Garbage Collection for the MIDI Headers and using GlobalAlloc had to be used. Just double click "XGGSMON.exe" in the \XGGSMON\bin\Release folder to run it.

A huge thank you to zsyncoz here:

http://codes-sources.commentcamarche.net/source/view/100174/1316105

He/she is the only person who I have seen who has got MIDI IN working properly!

MIDI Files

There are 2 folders:

ANO
- All files were written for Roland Sound Canvas in SC-55 Map mode
- They will almost certainly not play back on anything which is not Roland
- Use XG/GS Reset to set your SC-88, SC-88Pro or SC-8850 into SC-55 Map Mode (see earlier for link)
- Even though you will hear strange things using other equipment - they stress MIDI IN like nothing else

ELP
- Some of my favourite ELP files
- 5BrFugueGS.mid is solo piano - even the VB6 MIDI code plays this one sometimes ;-)
- Changing.mid will break loopBE1 - it has never broken loopMIDI

Enjoy

7 Comments:

At 27 August 2014 at 06:15 , Blogger Unknown said...

Thanks very much for posting this. Like you say, not much on the net about it.

Anyway i found that all three versions of your code work for me.

The only thing i'm trying to work out is where the midi input gets passed to the output, so i can monitor the note values.

 
At 27 August 2014 at 16:33 , Blogger Mike Le Voi said...

Dominic,

There is a Callback structure that is triggered every time MIDI IN occurs. The notes, SYSEX etc are placed in arrays in the program when this occurs. There is a timer loop that fires every 50 milliseconds which extracts data from the arrays and updates the display. Email me if you need more information.

Mike

mikelevoi at gmail dot com

 
At 30 March 2015 at 05:10 , Blogger Unknown said...

Thank you! Nice and clean code.

 
At 11 June 2015 at 23:26 , Blogger sadas said...

Really very useful post thanks for sharing...........
Website Development in India

 
At 17 June 2015 at 06:31 , Blogger Unknown said...

Much thanks to Mike Le Voi! A huge many-year work was made! I will learn it if can. Thank you very much!

 
At 26 May 2018 at 03:17 , Blogger Giuseppe said...

This comment has been removed by the author.

 
At 26 May 2018 at 03:23 , Blogger Giuseppe said...

Is possible to have code that only list all midi device and send note-controller value to them?

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home