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
#12
The program is great.
Only as a MIDI payer alone does it work very well.
I'm very happy about that.

I also have a lot of MOD sound files, but I can't find any way to include them in my programs.
Which is actually a shame because they are very small and contain good sound.
Reply
#13
(06-28-2022, 04:06 PM)Steffan-68 Wrote: The program is great.
Only as a MIDI payer alone does it work very well.
I'm very happy about that.

I also have a lot of MOD sound files, but I can't find any way to include them in my programs.
Which is actually a shame because they are very small and contain good sound.

Thank you!  Smile

Well, you are in for a treat.

If the files are just AMIGA Protracker compatible MODs then you can try a740g/QB64-MOD-Player: A ProTracker (and compatible) MOD player & library written in QB64 (github.com)
If you've got S3M, XM & IT then try a740g/QB64-LibXMPLite: LibXMP Player and Library for QB64 (github.com)
The second one is based off a similar library by RhoSigma you can find here: https://staging.qb64phoenix.com/showthread.php?tid=29
Reply
#14
(06-30-2022, 09:42 PM)a740g Wrote:
(06-28-2022, 04:06 PM)Steffan-68 Wrote: The program is great.
Only as a MIDI payer alone does it work very well.
I'm very happy about that.

I also have a lot of MOD sound files, but I can't find any way to include them in my programs.
Which is actually a shame because they are very small and contain good sound.

Thank you!  Smile

Well, you are in for a treat.

If the files are just AMIGA Protracker compatible MODs then you can try a740g/QB64-MOD-Player: A ProTracker (and compatible) MOD player & library written in QB64 (github.com)
If you've got S3M, XM & IT then try a740g/QB64-LibXMPLite: LibXMP Player and Library for QB64 (github.com)
The second one is based off a similar library by RhoSigma you can find here: https://staging.qb64phoenix.com/showthread.php?tid=29

Thank you for your prompt reply
The first MOD Player is already very good and I like it.
I would like the second ( LIBXMP Player ) better but it causes a compiler error for me.
The attached EXE runs great.
At the moment I just can't find the error why it isn't compiled.
Tried it with QB64PE 0.8.2 and QB64 2.0.2 in 64 bit but it always crashes with an error.

   
   
Reply
#15
(07-01-2022, 02:23 PM)Steffan-68 Wrote:
(06-30-2022, 09:42 PM)a740g Wrote:
(06-28-2022, 04:06 PM)Steffan-68 Wrote: The program is great.
Only as a MIDI payer alone does it work very well.
I'm very happy about that.

I also have a lot of MOD sound files, but I can't find any way to include them in my programs.
Which is actually a shame because they are very small and contain good sound.

Thank you!  Smile

Well, you are in for a treat.

If the files are just AMIGA Protracker compatible MODs then you can try a740g/QB64-MOD-Player: A ProTracker (and compatible) MOD player & library written in QB64 (github.com)
If you've got S3M, XM & IT then try a740g/QB64-LibXMPLite: LibXMP Player and Library for QB64 (github.com)
The second one is based off a similar library by RhoSigma you can find here: https://staging.qb64phoenix.com/showthread.php?tid=29

Thank you for your prompt reply
The first MOD Player is already very good and I like it.
I would like the second ( LIBXMP Player ) better but it causes a compiler error for me.
The attached EXE runs great.
At the moment I just can't find the error why it isn't compiled.
Tried it with QB64PE 0.8.2 and QB64 2.0.2 in 64 bit but it always crashes with an error.

From the screenshots you have shared, it seems like QB64 cannot file the required files.
Assuming you have extracted the files to its own folder, open QB64 (latest x64 version) and then ensure "Run > Output EXE to Source Folder" is checked. Then load XMPlayer.bas and compiler. You can also download the files again from GitHub. I've submitted some new changes.
Reply
#16
I have also submitted a new cross-platform MIDI player. Smile

Find it here https://github.com/a740g/QB64-MIDI-Player
Reply
#17
(07-01-2022, 02:23 PM)Steffan-68 Wrote:
(06-30-2022, 09:42 PM)a740g Wrote:
(06-28-2022, 04:06 PM)Steffan-68 Wrote: The program is great.
Only as a MIDI payer alone does it work very well.
I'm very happy about that.

I also have a lot of MOD sound files, but I can't find any way to include them in my programs.
Which is actually a shame because they are very small and contain good sound.

Thank you!  Smile

Well, you are in for a treat.

If the files are just AMIGA Protracker compatible MODs then you can try a740g/QB64-MOD-Player: A ProTracker (and compatible) MOD player & library written in QB64 (github.com)
If you've got S3M, XM & IT then try a740g/QB64-LibXMPLite: LibXMP Player and Library for QB64 (github.com)
The second one is based off a similar library by RhoSigma you can find here: https://staging.qb64phoenix.com/showthread.php?tid=29

Thank you for your prompt reply
The first MOD Player is already very good and I like it.
I would like the second ( LIBXMP Player ) better but it causes a compiler error for me.
The attached EXE runs great.
At the moment I just can't find the error why it isn't compiled.
Tried it with QB64PE 0.8.2 and QB64 2.0.2 in 64 bit but it always crashes with an error.

Ah. I remember why it gives the 12555 error.  It's a bug in QB64. I submitted a bug report. However, there is a workaround.
See Linking to static libraries does not work on Windows · Issue #112 · QB64-Phoenix-Edition/QB64pe (github.com)
And this one https://discord.com/channels/97538191235...0487655454
The workaround is in the Discord thread.
You'll have to make the changes to the QB64 IDE source code and recompile it.

If you want, you can also download the one that I compiled (attachment below). This is for QBPE 0.8.2. Download, then run a virus scan (VirusTotal - Home) and then replace qb64.exe in the QB64 folder with this one.

Thank you for calling this out. I've updated the LibXMP GitHub README.md with a note on this bug.


Attached Files
.zip   qb64.zip (Size: 3.13 MB / Downloads: 67)
Reply
#18
Thanks for your answer.
It worked now with this change.
I compiled the QB64.exe again and it works great.
I have another question, my EXE still has the original size (8.39MB) yours is only smaller (7.96 MB) what else did you change there?
Reply
#19
(07-03-2022, 12:31 PM)Steffan-68 Wrote: Thanks for your answer.
It worked now with this change.
I compiled the QB64.exe again and it works great.
I have another question, my EXE still has the original size (8.39MB) yours is only smaller (7.96 MB) what else did you change there?

I compiled with Options > C++ Compiler Settings > Compile programs with C++ optimization flag - enabled.
Fair warning: Compiling with this enabled, takes a really long time. Also, this will reset some QB64 settings (recent list, stuff under run, etc.)
Reply




Users browsing this thread: 5 Guest(s)