Link to home
Create AccountLog in
Avatar of learn
learn

asked on

VB6, play midi note

Hi,

Following is a simple code for playing a midi note and I think it is correct. However, there is no sound. Do you have any suggestion?

Private Declare Function midiOutOpen Lib "winmm.dll" (lphMidiOut As Long, ByVal uDeviceID As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Private Declare Function midiOutShortMsg Lib "winmm.dll" (ByVal hMidiOut As Long, ByVal dwMsg As Long) As Long
Private Declare Function midiOutClose Lib "winmm.dll" (ByVal hMidiOut As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private hMidi As Long
Private Sub Command1_Click()
midiOutOpen hMidi, 0, 0, 0, 0
midiOutShortMsg hMidi, &HA00000 + &H3E00 + &H90
Sleep 500
midiOutClose hMidi
End Sub
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

It works on my system.

Can you play midi with a commercial player?
Avatar of learn
learn

ASKER

Yes, I can play midi files.
Now, only thing I am not very sure is
midiOutShortMsg hMidi, parameter2
where parameter2 is a double word. Do you know or have document explaining the parameter? How it is constructed and what is each part for in the double word.

ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account