Author Topic: Playing XM sound files  (Read 934 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8449
  • Assembler is fun ;-)
    • MasmBasic
Playing XM sound files
« on: November 22, 2017, 03:23:41 PM »
I just discovered a nice sound file format: XM

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  UnzipInit 100
  FileWrite "tmp.dll", UnzipFile(1)
  Dll "tmp"
  Declare bmInit, 3 Alias "BASSMOD_Init"
  Declare bmFree, 0 Alias "BASSMOD_Free"
  Declare bmLoad, 5 Alias "BASSMOD_MusicLoad"
  Declare bmPlay, 0 Alias "BASSMOD_MusicPlay"
  void bmInit(-1, 44100, 0)
  .if bmLoad(1, Cat$(UnzipFile(0)), 0, 0, 8710)
        void bmPlay()
        Inkey "Hit any key to stop the music"
  .endif
  void bmFree()
  FreeDll 2
  Kill "tmp.dll"
EndOfCode


Plenty of sample files are at the Mod Archive. The exe includes a version of Ian Luck's BassMod.dll.

Source & exe in the first attachment, to build it you need also the second one containing the resources.
Tested on Win7-64 and Win10 - just double-click on PlayXM.exe and ignore the security warnings :biggrin:

DavidB

  • Regular Member
  • *
  • Posts: 17
Re: Playing XM sound files
« Reply #1 on: November 22, 2017, 04:07:24 PM »
I am not sure how to do this myself, but I believe using uFMOD would be an decent alternative. At the very least, you wouldn't have to drop a dll file as part of the program's execution.

http://ufmod.sourceforge.net

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8449
  • Assembler is fun ;-)
    • MasmBasic
Re: Playing XM sound files
« Reply #2 on: November 22, 2017, 06:48:08 PM »
Looks interesting but I hate COM :biggrin:
Code: [Select]
;    lpDSBuffer
;       A pointer to an IDirectSoundBuffer. uFMOD assumes
;       that it has been properly initialized to 16-bit stereo.

Siekmanski

  • Member
  • *****
  • Posts: 1495
Re: Playing XM sound files
« Reply #3 on: November 22, 2017, 07:22:38 PM »
Looks interesting but I hate COM :biggrin:
Code: [Select]
;    lpDSBuffer
;       A pointer to an IDirectSoundBuffer. uFMOD assumes
;       that it has been properly initialized to 16-bit stereo.

DirectSound COM is not that bad if you ever had to deal with the ASIO COM/C/STDCALL mixture api's :badgrin:
Creative coders use backward thinking techniques as their strategy.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8449
  • Assembler is fun ;-)
    • MasmBasic
Re: Playing XM sound files
« Reply #4 on: November 22, 2017, 10:56:20 PM »
DirectSound COM is not that bad

COM in general is a PITA :icon_redface:

But I wasted a morning and cracked its mysteries, see attachment :greensml:

Siekmanski

  • Member
  • *****
  • Posts: 1495
Re: Playing XM sound files
« Reply #5 on: November 22, 2017, 11:07:58 PM »
Use uFMOD and save 75776 - 24576 bytes = 51200 bytes.  :greensml:

http://masm32.com/board/index.php?topic=6698.msg71751#msg71751
Creative coders use backward thinking techniques as their strategy.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8449
  • Assembler is fun ;-)
    • MasmBasic
Re: Playing XM sound files
« Reply #6 on: November 22, 2017, 11:33:59 PM »
I did use uFMOD but forgot to remove the BassMod.dll - see new attachment. And mine has an icon ;-)

Siekmanski

  • Member
  • *****
  • Posts: 1495
Re: Playing XM sound files
« Reply #7 on: November 22, 2017, 11:44:32 PM »
 8)

Let's start making DEMOS.
Creative coders use backward thinking techniques as their strategy.