Author Topic: How do I play .MOD's and .XM's with OpenAL and LibXMP?  (Read 1546 times)

Roblomal

  • Newbie
  • *
  • Posts: 48
  • There HAS to be a way to solve it!
How do I play .MOD's and .XM's with OpenAL and LibXMP?
« on: August 15, 2015, 01:17:49 pm »
Allright, I'm sorry for not posting my previous attempt, but that would confuse you all even more, and there would be a huge case of the X/Y problem (look it up).

What do I want to do?
I want to play SongEight.mod and SongThree.xm in QB64 using LibXMP and OpenAL together (or in a way that QB64 could play soundbuffers returned by LibXMP).
If you have an alternative to LibXMP and/or OpenAL then I'm happy to use it.

Why wouldn't you use .WAV or .OGG?
Because I wan't to keep the small filesize, and I'd also like to allow people to open up the modules and see whats inside. Yep, not gonna use another format ;P

Links
LibXMP - http://xmp.sourceforge.net
OpenAL - openal.org

Notes
Files are in the attachments. (Sorry for the DLL's, I am creating this currently on Windows yes)
I use LibXMP-lite 4.3.9, the DLL in the attachment is compiled by myself.



My unfinished attempt, it returns an error (-6, which means "System Error", probably the whole thing was broken in the first place). when I try to load a module
Code: [Select]
'Dependencies: libxmp-lite-4.3.9.a
'Load Libraries
DECLARE DYNAMIC LIBRARY "libxmp"
    FUNCTION xmp_create_context%& ()
    SUB xmp_free_context (BYVAL xmp_context AS _OFFSET)

FUNCTION xmp_load_module%(BYVAL xmp_context AS _OFFSET, filename AS _OFFSET)

    SUB xmp_get_frame_info (BYVAL xmp_context AS _OFFSET, BYVAL xmp_frame_info AS _OFFSET)
END DECLARE

'Reserve some memory for the xmp_frame_info struct
DIM xmp_frame_info AS _MEM
xmp_frame_info = _MEMNEW(1608)
'Create xmp_context pointer
DIM xmp_context AS _OFFSET
xmp_context = xmp_create_context
'Open the module and write it to a file
OPEN "out.raw" FOR BINARY AS #1
DIM filename as STRING
filename$ = "SongEight.mod" + CHR$(0)
if NOT xmp_load_module(xmp_context, _OFFSET(filename$)) = 0 THEN
PRINT "ERROR: xmp_load_module:"; xmp_load_module(xmp_context, _OFFSET(filename$))
sleep
SYSTEM
END IF


CLOSE #1


xmp_get_frame_info context, frameinfo.OFFSET


'PRINT _MEMGET(frameinfo, frameinfo.OFFSET, STRING * 1608)
Appels and grapes

Clippy

  • Hero Member
  • *****
  • Posts: 19259
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: How do I play .MOD's and .XM's with OpenAL and LibXMP?
« Reply #1 on: August 16, 2015, 01:02:47 pm »
Hey ROOKIE, keep all of your subject posts TOGETHER in ONE THREAD!

Otherwise you will never be able to follow your own topic!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 SDL: QB64v0954-win15.7z