Results 1 to 4 of 4

Thread: MIDIs

  1. #1
    Guest

    Post

    Few short questions about MIDIs in VB:

    1) How to play/stop/pause a MIDI? (an example or link to one would be nice if possible)

    2) How to play more than one MIDI at the same time?

    3) How to detect if a MIDI has stopped playing? (to start it again so it goes on repeating)

    Any help is appreciated and, of cource, welcome!

  2. #2
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    After 3 and half years, here is the reply

    VB Code:
    1. 'This project needs a Common Dialog box, named 'CDBox'
    2. '  (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
    3. '   and select Microsoft Common Dialog control)
    4. 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
    5. Dim Alias As String
    6. Private Sub Form_Load()
    7.     'KPD-Team 1998
    8.     'URL: [url]http://www.allapi.net/[/url]
    9.     'E-Mail: [email][email protected][/email]
    10.     Const PlayTime = 10
    11.     'Set the common dialog box' title
    12.     CDBox.DialogTitle = "Choose your midi-file"
    13.     'Set the filter
    14.     CDBox.Filter = "Midi-files (*.mid)|*.mid"
    15.     'Show the 'Open File'-dialog
    16.     CDBox.ShowOpen
    17.     'Extract an alias from the file
    18.     Alias = Left$(CDBox.FileTitle, Len(CDBox.FileTitle) - 4)
    19.  
    20.     'play midi
    21.     R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
    22.     R% = mciSendString("PLAY " + Alias + " FROM 0", 0&, 0, 0)
    23.     R% = mciSendString("CLOSE ANIMATION", 0&, 0, 0)
    24.  
    25.     'play midi for 10 secs
    26.     t = Timer
    27.     Do: DoEvents: Loop Until Timer > t + PlayTime
    28.  
    29.     'stop midi and close it
    30.     R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
    31.     R% = mciSendString&("STOP " + Alias, 0&, 0, 0)
    32.     R% = mciSendString&("CLOSE ANIMATION", 0&, 0, 0)
    33. End Sub
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  3. #3
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    haha, you know, he could be dead by now

  4. #4
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    I just click on the 'Go to last page link' on the General VB Question Topics. This was the last thread with 0 replies

    There were 6500+ threads. (since 1999)
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width