midiTone

In this category you can exchange your programming questions and solutions.
Post Reply
klasinus
Posts: 1
Joined: Tue Nov 08, 2005 3:00 pm

midiTone

Post: # 387Post klasinus
Thu Jan 08, 2009 3:22 pm

Hello,

I am writing a program for practicing rythm in music. For that i need a subroutine that can play individual sounds.
On the internet I found for VB:

Private Declare Function midiOutClose Lib "winmm.dll" (ByVal hMidiOut As Long) As Long
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

Dim hMidiOut As Long

Private Sub Form_Load()
Dim T As Long
midiOutOpen hMidiOut, 0, 0, 0, 0
midiOutShortMsg hMidiOut, 6567325
T = Timer
Do: DoEvents: Loop Until Timer > T + 4
midiOutClose hMidiOut
End Sub

and translated this into:

dim myform as form
declare mOC as "midiOutClose" of "winmm.dll"
 hMidiOut as long
 result as integer
end declare

declare mOO as "midiOutOpen" of "winmm.dll"
 lphMidiOut as long
 uDeviceID as long
 dwCallback as long
 dwInstance as long
 dwFlags as long
 result as integer
end declare

declare mOSM as "midiOutShortMsg" of "winmm.dll"
 hMidiOut as long
 dwMsg as long
 result as integer
end declare

dim hMidiOut As long

mOO.uDeviceID=-1
mOO.dwCallback=0
mOO.dwInstance=0
mOO.dwFlags=0
mOO

mOSM.hMidiOut=6567325
moSM

sleep 1000

mOC

myform.showmodal

I cannot findout why this is not working.

Hans

Post Reply