VB6: Using MIDI

I have a program that lets me make MIDI files. I was wondering if
there's anyway 2 use MIDI in a VB6 game. I tried the "PLAYWAVE(file)"
thing but that didn't work.

Thanks!
[red]Dragon[/red][purple]storM[/purple]

Comments

  • : I have a program that lets me make MIDI files. I was wondering if
    : there's anyway 2 use MIDI in a VB6 game. I tried the "PLAYWAVE(file)"
    : thing but that didn't work.
    :
    : Thanks!
    : [red]Dragon[/red][purple]storM[/purple]
    :


    'This project needs a Common Dialog box, named 'CDBox'
    ' (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
    ' and select Microsoft Common Dialog control)
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    Dim Alias As String
    Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    Const PlayTime = 10
    'Set the common dialog box' title
    CDBox.DialogTitle = "Choose your midi-file"
    'Set the filter
    CDBox.Filter = "Midi-files (*.mid)|*.mid"
    'Show the 'Open File'-dialog
    CDBox.ShowOpen
    'Extract an alias from the file
    Alias = Left$(CDBox.FileTitle, Len(CDBox.FileTitle) - 4)

    'play midi
    R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
    R% = mciSendString("PLAY " + Alias + " FROM 0", 0&, 0, 0)
    R% = mciSendString("CLOSE ANIMATION", 0&, 0, 0)

    'play midi for 10 secs
    t = Timer
    Do: DoEvents: Loop Until Timer > t + PlayTime

    'stop midi and close it
    R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
    R% = mciSendString&("STOP " + Alias, 0&, 0, 0)
    R% = mciSendString&("CLOSE ANIMATION", 0&, 0, 0)
    End Sub

    where is the full code on a working example.Just for the record, I could had coded it but (because as you can see, it's simple) but I went and got it from www.allapi.net (great, related api, site) Hope this helps...

    [b]Hard[/b][grey][italic]Coded[/italic][/grey]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion