czardas Posted May 18, 2011 Share Posted May 18, 2011 (edited) Either I'm missing something obvious, or I'm trying to do the impossible. The midi UDF contains a function called _MidiOutOpen which is intended to retrieve a MIDI handle. I am trying to create several MIDI handles to be used for playback on different instruments, but I am not having much success. I have looked at the MSDN function MidiOutOpen, but I find it quite confusing. Perhaps my approach is entirely wrong. Maybe someone can see why I am getting errors. I have also tried altering the parameters, but it didn't work. Local $instrument_A = _MidiOutOpen() Local $instrument_B = _MidiOutOpen() MsgBox(0,"Handle A",$instrument_A) MsgBox(0,"Handle B",$instrument_B) ;======================================================= ;Retrieves a MIDI handle and Opens the Device ;Parameters(Optional) - Device ID, Window Callback, ; instance, flags ;Author : Eynstyne ;Library : Microsoft winmm.dll ;======================================================= Func _MidiOutOpen($devid = 0, $callback = 0, $instance = 0, $flags = 0) $ret = DllCall("winmm.dll", "long", "midiOutOpen", "handle*", 0, "int", $devid, "dword_ptr", $callback, "dword_ptr", $instance, "long", $flags) If @error Then Return SetError(@error,0,0) If $ret[0] Then Return SetError(-1,$ret[0],0) Return $ret[1] EndFunc ;==>_MidiOutOpen Edited May 18, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted May 18, 2011 Author Share Posted May 18, 2011 (edited) It would appear I only have one midi output device, which is the reason I can't create two MIDI handles. How to solve it is still a mystery to me. My first thought was maybe I can create a virtual instrument to fool MIDI. My second thought is there has to be a lot more to this than I understand. At least I have one instrument I can use.EditLooking at this page : Processing MIDI Data from Two MIDI Sources helps to shed some light on the problem I am experiencing. If I run two scripts simultaneously, I can play two instruments at the same time using midiOutShortMsg. If I knew properly how to create a midi stream, then I may be able to solve it that way. There are several other functions, but it's a bit over my head. Examples of using midiOutShortMsg can be found in the I don't expect anyone to spend a lot of time trying to figure this out, unless it particularly interests you. I would be happy to use a work around since I only need two instruments (synchronized). Any advise is appreciated.Improvised Work AroundI have thought of a possible work around solution, although it's not perfect. Instruments can be changed during a stream using some syntax of my own invention. The only problem is that two instruments can not play the same note at the same time using midiOutShortMsg. If a note is a continuous sound, it will dissapear at the moment the second instrument plays this same note. While this is not good for musical recording, it may actually be useful for ear training purposes, because it avoids confusing the ear with superfluous information. After the second instrument has finished playing the note, I can reintroduce the previous continuous sound without it being too obvious to the listener (because only one note out of the whole chord was stopped). With this make-shift solution, the second instrument will be heard more clearly over the chord, so this is what I am going to attempt to do. Hopefully this will be successful and I can turn a disadvantage into an advantage. Edited May 18, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now