Archived

This topic is now archived and is closed to further replies.

Steinbein

Play single MIDI note?! Sounds easy, but wait...

Recommended Posts

Steinbein    122
My VB6 application plays a single MIDI note and currently uses midiOutShortMsg (winmm.dll)successfully, but with a noticeable delay. I''d like to use DirectX (DirectMusic/ DirectSound) to replace this in my application so that I can remove the latency and do the other cool stuff that DirectX does. However, I can''t for the life of me figure out how to get the DirectX8Performance.SendMIDIPMSG method to work (this looks like the closest analogue to sending direct MIDI messages I can find). I can get external MIDI (and wav) files to play using DirectMusic in my application, but can not get my app-generated MIDI messages to play (I''m using DirectX8.1). There is a reference to a playing a single note in the DX help, but of course it doesn''t give any example code. My old code (which works) looks roughly like this: ''// Create first DWORD midi message midimsg = &HC0 + ((Instrument) * &H100) + (volume * &H10000) + channel ''// Send First Midi message (hmidi = midi device handle) ret = midiOutShortMsg(hmidi, midimsg) '' ''// Create second DWORD midi message midimsg = &H90 + ((baseNote + Index) * &H100) + (volume * &H10000) + channel ''// Send second Midi message (hmidi = midi device handle) ret = midiOutShortMsg(hmidi, midimsg) '' This generates a tone which varies according to what you put into the variables. I''m trying to replace the above code with: Call DirectMusic8Performance.SendMIDIPMSG(0, 0, PerfChannel, midiStatusByte, midiByte1, midiByte2) [Called twice in the same way with 2 different midiStatusBytes as above] DirectMusic8Performance is the performance object that has been initialised. I can load a MIDI file into a segment and play it, but can not play a single MIDI note generated from within the application. I''ve thought about using single-note MIDI files, but that sounds very kludgy and not what GOd intended. Any suggestions? DirectX is brand new to me and this SendMIDIPMSG method is driving me nuts!! Am I correct in understanding that SendMIDIPMSG has a similar function as midiOutShortMsg (i.e.sending raw MIDI data to be played) or have I totally misunderstood? Should I be using DirectSound instead (some messages indicate that DMusic has high latency, which is not acceptable for this app). Any feedback, suggestions, help much appreciated. Thanks in advance!

Share this post


Link to post
Share on other sites
Steinbein    122
OK, so just let me know the bottom line: does anyone know how to play a single MIDI note in *any way at all* (ignore my approach in previous post) using DirectX?

Please! Someone, anyone - speak to me!

Share this post


Link to post
Share on other sites