×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Here is how to play musical notes in vb6.

Here is how to play musical notes in vb6.

Here is how to play musical notes in vb6.

(OP)
Const NOTES_ON = &H90
Const MIDI_MAPPER = (-1)
Private Declare Function midiOutShortMsg Lib "winmm.dll" (ByVal hMidiOut As Long, ByVal dwMsg 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 midiOutClose Lib "winmm.dll" (ByVal hMidiOut As Long) As Long

Dim Note1Play(200) As Long, Length1_Note(200) As Single
Dim Note2Play(200) As Long, Length2_Note(200) As Single
Dim Note3Play(200) As Long, Length3_Note(200) As Single
Dim Note4Play(200) As Long, Length4_Note(200) As Single
Dim NUMBEROFNOTES As Integer
Dim NUMBEROFNOTES1 As Integer, NUMBEROFNOTES2 As Integer, NUMBEROFNOTES3 As Integer

Private Sub Form_Load()
midiOpenError = midiOutOpen(hMidiOut, MIDI_MAPPER, 0, 0, 0)
midiMessageOut = NOTES_ON
midiData2 = 127

Happy_Birthday ' This calls sub Happy_Birthday to read in notes

For y = 1 To NUMBEROFNOTES
lowint = (Note1Play(y) * 256) + &H90
GoSub PlayVoice1

lowint = (Note2Play(y) * 256) + &H94
GoSub PlayVoice1

lowint = (Note3Play(y) * 256) + &H96
GoSub PlayVoice1

lowint = (Note4Play(y) * 256) + &H98
GoSub PlayVoice1

ThisTime = Timer
Do
Loop While ThisTime + Length1_Note(y) * 0.7 > Timer
Next y

ThisTime = Timer
Do
Loop While ThisTime + 0.3 > Timer
x = midiOutClose(hMidiOut)
End

PlayVoice1:
highint = (midiData2 * 256) * 256
MidiMessage = lowint + highint
x = midiOutShortMsg(hMidiOut, MidiMessage)
Return

End Sub

Private Sub Happy_Birthday()
NUMBEROFNOTES = 26

'******************** Data for Happy Birthday VOICE ONE **************************************

For y = 1 To 12 'G G A G >C <B G G A G D C
Note1Play(y) = Choose(y, 55, 55, 57, 55, 60, 59, 55, 55, 57, 55, 62, 60)
Length1_Note(y) = Choose(y, 0.455, 0.455, 0.91, 0.91, 0.91, 1.82, 0.455, 0.455, 0.91, 0.91, 0.91, 1.82)
Next y
For y = 13 To 24 'G G >G E C C B A F F E C
Note1Play(y) = Choose(y - 12, 55, 55, 67, 64, 60, 60, 59, 57, 65, 65, 64, 60)
Length1_Note(y) = Choose(y - 12, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91)
Next y
For y = 25 To 26 ' D C
Note1Play(y) = Choose(y - 24, 62, 60)
Length1_Note(y) = Choose(y - 24, 0.91, 1.82)
Next y
'******************** Data for Happy Birthday VOICE Two **************************************

For y = 1 To 12 'F F E E E F F F F F B G
Note2Play(y) = Choose(y, 53, 53, 52, 52, 52, 53, 53, 53, 53, 53, 59, 55)
Length2_Note(y) = Choose(y, 0.455, 0.455, 0.91, 0.91, 0.91, 1.82, 0.455, 0.455, 0.91, 0.91, 0.91, 1.82)
Next y
For y = 13 To 24 'E E >C C <G <G F F >C C C <G
Note2Play(y) = Choose(y - 12, 52, 52, 60, 60, 55, 55, 53, 53, 60, 60, 60, 55)
Length2_Note(y) = Choose(y - 12, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91)
Next y
For y = 25 To 26 ' B G
Note2Play(y) = Choose(y - 24, 59, 55)
Length2_Note(y) = Choose(y - 24, 0.91, 1.82)
Next y
'******************** Data for Happy Birthday VOICE Three ************************************

For y = 1 To 12 'B B >C C E D <B B B B F E
Note3Play(y) = Choose(y, 59, 59, 60, 60, 64, 62, 59, 59, 59, 59, 65, 64)
Length3_Note(y) = Choose(y, 0.455, 0.455, 0.91, 0.91, 0.91, 1.82, 0.455, 0.455, 0.91, 0.91, 0.91, 1.82)
Next y
For y = 13 To 24 'C C E G E E C C A A G E
Note3Play(y) = Choose(y - 12, 60, 60, 64, 67, 64, 64, 60, 60, 69, 69, 67, 64)
Length3_Note(y) = Choose(y - 12, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91)
Next y
For y = 25 To 26
Note3Play(y) = Choose(y - 24, 65, 64)
Length3_Note(y) = Choose(y - 24, 0.91, 1.82)
Next y
'******************** Data for Happy Birthday VOICE Four *************************************
For y = 1 To 12 'G G G G G G G G G G G C
Note4Play(y) = Choose(y, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 60)
Length4_Note(y) = Choose(y, 0.455, 0.455, 0.91, 0.91, 0.91, 0.182, 0.455, 0.455, 0.91, 0.91, 0.91, 0.182)
Next y
For y = 13 To 24 'G G G C C C F F F F G G
Note4Play(y) = Choose(y - 12, 55, 55, 55, 60, 60, 60, 53, 53, 53, 53, 55, 55)
Length4_Note(y) = Choose(y - 12, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91, 0.455, 0.455, 0.91, 0.91)
Next y
For y = 25 To 26 ' G C
Note4Play(y) = Choose(y - 24, 55, 60)
Length4_Note(y) = Choose(y - 24, 0.91, 1.82)
Next y

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close