Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to play a Midi file
#1
This a short snippet on how to play a Midi file:

Code: (Select All)
Dim SoundHandle As Long
$Unstable:Midi
$MidiSoundFont:Default
Print "Enter midi file";
Input Midi$
Midi$ = UCase$(Midi$)
If Right$(Midi$, 4) = ".MID" Then
   If _FileExists(Midi$) Then
      Print "Playing.."
      Print "  Enter <space>=pause/+plus 10/-minus 10."
      Print "  Press <escape> to exit."
      '_SndPlayFile Midi$
      SoundHandle = _SndOpen(Midi$)
      If SoundHandle Then
         _SndPlay SoundHandle
         Do
            _Limit 50
            x$ = InKey$
            If Len(x$) Then
               If x$ = Chr$(27) Then Exit Do
               If x$ = "+" Then
                  z! = _SndGetPos(SoundHandle)
                  z! = z! + 10!
                  _SndSetPos SoundHandle, z!
               End If
               If x$ = "-" Then
                  z! = _SndGetPos(SoundHandle)
                  z! = z! - 10!
                  If z! < 0! Then z! = 0!
                  _SndSetPos SoundHandle, z!
               End If
               If x$ = " " Then
                  If _SndPaused(SoundHandle) Then
                     _SndPlay SoundHandle
                  Else
                     _SndPause (SoundHandle)
                  End If
               End If
            End If
         Loop
      End If
   End If
End If
End
note the included $metacommands..

attached is midiplay.zip which contains the midi player and midi.zip with some .mid files.


Attached Files
.zip   MIDIPLAY.ZIP (Size: 121.53 KB / Downloads: 31)
Reply


Messages In This Thread
How to play a Midi file - by eoredson - 05-02-2024, 05:17 AM
RE: How to play a Midi file - by eoredson - 05-03-2024, 04:32 AM
RE: How to play a Midi file - by Steffan-68 - 05-03-2024, 03:24 PM
RE: How to play a Midi file - by eoredson - 05-03-2024, 11:19 PM
RE: How to play a Midi file - by eoredson - 05-04-2024, 03:13 AM



Users browsing this thread: 1 Guest(s)