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
Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Dim hMidiOut As Long
Public notes
Public instrument
Public temps
Sub jouer_la_note()
midiOutClose hMidiOut
midiOutOpen hMidiOut, 0, 0, 0, 0
midiOutShortMsg hMidiOut, RGB(192, instrument - 1, 127)
lanote = 12 + CInt(notes)
note = RGB(144, lanote, 127)
midiOutShortMsg hMidiOut, note
Sleep (temps)
fin:
End Sub
Sub danse_du_sabre()
Numéro = 0
notes_a_jouer = "6262626262626262626262626262" & _
"616262626162626261626262616262626161" & _
"606059595858006158006158"
For Notess = 0 To Len(notes_a_jouer) Step 2
noteG = Mid(notes_a_jouer, (Numéro * 2) + 1, 2)
Application.EnableCancelKey = xlErrorHandler
On Error GoTo fin
TEMP = "150150150150150150150150150150150" & _
"150150150150150150150150150150150150150150" & _
"150150150150150150150150150200150" & _
"150150100200300100200300"
temps = Mid(TEMP, (Numéro * 3) + 1, 3)
lanote = 12 + CInt(noteG)
note = RGB(144, lanote, 127)
notes = lanote
instrument = 87 'Int(Rnd * 128)
jouer_la_note
Numéro = Numéro + 1
Next
fin:
midiOutClose hMidiOut
End Sub