(06-16-2022, 04:02 AM)Robert Claypool Wrote: I wrote this and compiled it on 0.8.2 but the MIDI file won't play for me.
Code: (Select All)Print "Press any key to start"
Do: Loop Until InKey$ <> ""
Filename$ = "TONOWH~2.MID"
LoadSound& = _SndOpen(Filename$)
MySound& = _SndCopy(LoadSound&)
_SndPlay MySound&
Do: Loop Until InKey$ <> ""
_SndClose MySound&
_SndClose LoadSound&
I would not recommend using older versions of QB64.
If you are writing a Windows only program, then look at https://github.com/a740g/AlienAlleyQB64
I got MIDI working using a tiny C header library that I put together.
C header: MIDIPlayer.h
Code: (Select All)
Declare Library "./MIDIPlayer"
Sub MIDIInit ' Initializes stuff - call this before using the library
Sub MIDIDone ' Frees allocated memory - this must be called once we are done with the MIDI (or else we will leak memory)
Function MIDIRegister& (mididata As String) ' Sets up and opens the WinMM MIDI stream - mididata here is string buffer!
Sub MIDIUnregister ' Closes the WinMM MIDI stream
Sub MIDIPlay (ByVal looping As Long) ' Kickstarts MIDI stream playback
Sub MIDIPause ' Pauses a MIDI stream
Sub MIDIResume ' Resumes a paused MIDI stream
Sub MIDIStop ' Stops playing the MIDI file - this does not free resources!
End Declare
See the following routine in AlienAlley.bas to see how this is used.
Code: (Select All)
Sub PlayMIDIFile (fileName As String)
Hopefully, soon we'll have native MIDI playback in QB64 using Timidity or FluidSynth.