The MASM Forum

Projects => MasmBasic & the RichMasm IDE => Topic started by: jj2007 on November 22, 2017, 03:23:41 PM

Title: Playing XM sound files
Post by: jj2007 on November 22, 2017, 03:23:41 PM
I just discovered a nice sound file format: XM

include \masm32\MasmBasic\MasmBasic.inc         ; download (http://masm32.com/board/index.php?topic=94.0)
  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 (https://modarchive.org/index.php?request=view_by_rating_comments&query=10&page=6#mods). The exe includes a version of Ian Luck's BassMod.dll (https://www.un4seen.com/).

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:
Title: Re: Playing XM sound files
Post by: DavidB 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 (http://ufmod.sourceforge.net)
Title: Re: Playing XM sound files
Post by: jj2007 on November 22, 2017, 06:48:08 PM
Looks interesting but I hate COM :biggrin:
;    lpDSBuffer
;       A pointer to an IDirectSoundBuffer. uFMOD assumes
;       that it has been properly initialized to 16-bit stereo.
Title: Re: Playing XM sound files
Post by: Siekmanski on November 22, 2017, 07:22:38 PM
Quote from: jj2007 on November 22, 2017, 06:48:08 PM
Looks interesting but I hate COM :biggrin:
;    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:
Title: Re: Playing XM sound files
Post by: jj2007 on November 22, 2017, 10:56:20 PM
Quote from: Siekmanski on November 22, 2017, 07:22:38 PMDirectSound 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:
Title: Re: Playing XM sound files
Post by: Siekmanski 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
Title: Re: Playing XM sound files
Post by: jj2007 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 ;-)
Title: Re: Playing XM sound files
Post by: Siekmanski on November 22, 2017, 11:44:32 PM
 8)

Let's start making DEMOS.