News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Playing XM sound files

Started by jj2007, November 22, 2017, 03:23:41 PM

Previous topic - Next topic

jj2007

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

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

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.

Siekmanski

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:
Creative coders use backward thinking techniques as a strategy.

jj2007

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:

Siekmanski

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 a strategy.

jj2007

I did use uFMOD but forgot to remove the BassMod.dll - see new attachment. And mine has an icon ;-)

Siekmanski

Creative coders use backward thinking techniques as a strategy.