PLAYMID.BAS and MIDI file.
#11
(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.
Reply


Messages In This Thread
PLAYMID.BAS and MIDI file. - by Robert Claypool - 06-16-2022, 04:02 AM
RE: PLAYMID.BAS and MIDI file. - by johnno56 - 06-16-2022, 05:13 AM
RE: PLAYMID.BAS and MIDI file. - by visionmercer - 06-16-2022, 10:15 AM
RE: PLAYMID.BAS and MIDI file. - by RhoSigma - 06-16-2022, 09:06 PM
RE: PLAYMID.BAS and MIDI file. - by johnno56 - 06-18-2022, 12:14 AM
RE: PLAYMID.BAS and MIDI file. - by DSMan195276 - 06-18-2022, 02:56 AM
RE: PLAYMID.BAS and MIDI file. - by johnno56 - 06-18-2022, 07:19 PM
RE: PLAYMID.BAS and MIDI file. - by Dav - 06-19-2022, 01:34 AM
RE: PLAYMID.BAS and MIDI file. - by a740g - 06-26-2022, 06:53 AM
RE: PLAYMID.BAS and MIDI file. - by Steffan-68 - 06-28-2022, 04:06 PM
RE: PLAYMID.BAS and MIDI file. - by a740g - 06-30-2022, 09:42 PM
RE: PLAYMID.BAS and MIDI file. - by Steffan-68 - 07-01-2022, 02:23 PM
RE: PLAYMID.BAS and MIDI file. - by a740g - 07-03-2022, 09:29 AM
RE: PLAYMID.BAS and MIDI file. - by a740g - 07-03-2022, 09:39 AM
RE: PLAYMID.BAS and MIDI file. - by a740g - 07-03-2022, 09:31 AM
RE: PLAYMID.BAS and MIDI file. - by Steffan-68 - 07-03-2022, 12:31 PM
RE: PLAYMID.BAS and MIDI file. - by a740g - 07-03-2022, 03:05 PM



Users browsing this thread: 5 Guest(s)