jxharding
asked on
play musical notes in vb, e.g. A, B, B#
someone i knew had qbasic long ago and he was able to do it
he assigned a key to a tone e.g.
COMPUTER KEY A = (musical)"A"
COMPUTER KEY B = (musical)"B"
etc.
is something like this possible in vb?
he assigned a key to a tone e.g.
COMPUTER KEY A = (musical)"A"
COMPUTER KEY B = (musical)"B"
etc.
is something like this possible in vb?
ok here is some code.
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_KeyPress(KeyAscii As Integer)
SendMidiOut 144, KeyAscii, 100
End Sub
Private Sub Form_Load()
midiOutOpen hMidiOut, 0, 0, 0, 0
End Sub
Private Sub SendMidiOut(MidiEventOut, MidiNoteOut, MidiVelOut)
lowint = (MidiNoteOut * 256) + MidiEventOut
VelOut = MidiVelOut * 256
highint = VelOut * 256
MidiMessage = lowint + highint
midiOutShortMsg hMidiOut, MidiMessage
End Sub
Private Sub Form_Unload(Cancel As Integer)
midiOutClose hMidiOut
End Sub
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_KeyPress(KeyAscii As Integer)
SendMidiOut 144, KeyAscii, 100
End Sub
Private Sub Form_Load()
midiOutOpen hMidiOut, 0, 0, 0, 0
End Sub
Private Sub SendMidiOut(MidiEventOut, MidiNoteOut, MidiVelOut)
lowint = (MidiNoteOut * 256) + MidiEventOut
VelOut = MidiVelOut * 256
highint = VelOut * 256
MidiMessage = lowint + highint
midiOutShortMsg hMidiOut, MidiMessage
End Sub
Private Sub Form_Unload(Cancel As Integer)
midiOutClose hMidiOut
End Sub
ASKER
thanks for the input!
modlor , i just cant figure out how your sub
sendmidiout works. when do i call it?
i forgot to mention the qbasic version worked on pc speaker, but who wants that these days?
thanks!
modlor , i just cant figure out how your sub
sendmidiout works. when do i call it?
i forgot to mention the qbasic version worked on pc speaker, but who wants that these days?
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think Moglor's comments are worth preserving.
ASKER
thanks for the input
i cant get it to work, but im accepting it
i cant get it to work, but im accepting it
Programmatic sound synthesis is not as fashionable (or easy) as it once was (e.g. on the Amstrad CPC464 built-in Basic). It's mostly done with sampling which gives a better sound, but of course requires the samples. DirectX would probably be necesssary, but it's an horrendous learning curve.