Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Midi DLL (winmm.dll)

Author
Message
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 12th Apr 2005 03:40
We have the windows winmm dll working in Liberty basic for short midi message output. Can someone please post the Darkbasic method of doing the following dll calls?

Liberty Basic example to open dll

struct m, a# as ptr
CallDll #winmm, "midiOutOpen", m as struct, -1 as long, 0 as long, 0 as long, 0 as long, ret as long

hMidiOut=m.a$.struct 'handle to midi device

-1 above controls the port that opens. you should look at one of your midi programs, and see what list of ports it opens, and then pick a number here that matchs that port in the list positon.

-1 is midi mapper. It is not present in windows xp, so just try -1, 1, 2, etc. and eventually you will figure out what number will match what ports you have on your midi interface, and card, etc.


To set what instrument you will use

Pick a number from 1-128 or 0-127 if your keyboard or midi device starts numbering from 0.

voice=15 ' we will set instrument 15
event=192 'command to do instrument change on channel 1, add 1 for
'instrument change on channel 2 etc.

velocity=127 'set to a good value for your midi device. this is
'setting to max velocity, so you will hear it first
'time around

low=(voice*256)+event
hi=velocity*256*256
dwmsg=low+hi
CallDll #winmm, "midiOutShortMsg", hMidiOut as ulong, dwMsg as ulong, ret as ulong.

Ulong means unsigned long number.


To play a note:

event=144 'midi channel 1 , 145 = channel 2 etc.
low=(note*256)+event
velocity=127 'set to max to hear it first time. adjust to desired
'level of velocity

hi=velocity*256*256
dwMsg=low+hi
CallDll #winmm, "midiOutShortMsg",hMidiOut as ulong, dwmsg as ulong, ret as ulong


Then you wait the length of the note.

And then you repeat the above, but set velocity to 0, which will cause the note to turn off. This is an alternate method to use of the midi off command for a note. Either will work and midi files often use either method for shut off of a note. Almost any sequencer around will recognize either method in a midi file, and work ok.

This midi dll also can do sysex messages, but for that you will need to use the MidiOutLongMsg command.

You can find documentation for much of the commands this dll uses at microsoft developers web site.

Do a search on midi, midi sdk, winmm.dll etc, will get you into the right areas.
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 12th Apr 2005 13:05
Where to get more info on windows dll for midi

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_about_midi.asp

documentation of midiShortMsg

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_using_midioutshortmsg_to_send_individual_midi_messages.asp

Documentation on the winmm.dll What commands does it allow, how do you make the calls etc. (not in darkbasic format)
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 16th Apr 2005 08:21
Typo Alert: sorry I got a typo in the first part. It should be A$ instead of A#
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 26th Apr 2005 14:27
Thanks to some one named user, I got a midi program together, Its not the greatest, but it will help you get midi output for no media working.
Scrol down and to right, click button to view code for midi windchimes in dark basic pro.
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 28th Apr 2005 13:04
This was not quite the correct way to make the dll call, each and every varible in the position of 0,0,0 should of been defined as type and or a mem block made for them,plus there should be a return varible following the 0,0,0 to pick up the statud of success or failure in making the calls..

Also I learned that midi ports start numbering with 0, so the remark for ports should be changed. Luckly it workes anyway, but I was making use of port 2.


Anyway, this should not be used as an example on how to make a dll call correctly.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 28th Apr 2005 18:26
Quote: "This was not quite the correct way to make the dll call, each and every varible in the position of 0,0,0 should of been defined as type and or a mem block made for them,plus there should be a return varible following the 0,0,0 to pick up the statud of success or failure in making the calls.."

Sorry, but that is BS.
Do you - at least sometimes - read what other people post?


Play Nice! Play Basic! Version 1.06
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 29th Apr 2005 04:31
Yes Empty,
I just read your message of what you posted and came here to put a note here saying my bull shoud be ignored.

Go to code snippits topic, and read Emptys fine explanation of why what I said is bull. I did not know some of the parameters in the call were optional, and also some can not be used with dbp.

Sorry Empty, wish I could of got here a bit faster than you.

What happend Empty, is I looked at the code, and then looked at how it was done in another language, and thought boy, I just do not have all those data types for each optional varible declared, so I blew it, I should of asked you first about it.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 29th Apr 2005 04:34
No worries.


Play Nice! Play Basic! Version 1.06
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 7th May 2005 15:11
hmmm not to crash u
but i have a midi plugin with stringtables

X-Patch x-patch.exe(gui):75% make.exe:5% x-patch.dll(runtime dll):0% developed on win xp home sp2
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 9th May 2005 13:11
Thats Cool Offset! Always glad someone is doing something to add things to dbp. Now why do you just tantalize us with it, instead of showing us the way by posting a link or sample code here on how to use it, and where to get it?
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 21st May 2005 13:23
sorry wasnt thinking in the zip file is keywords file and dll

midi qsound i beleive is it might be mid qsound
look at the keywords file for more commands

documentation will be out soon

formerly shadows of emptiness

Attachments

Login to view attachments
Zaine
18
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 30th May 2005 07:26
how would i creat a midi dll using DB?

Login to post a reply

Server time is: 2024-04-26 10:16:18
Your offset time is: 2024-04-26 10:16:18