Jump to content
Tuts 4 You



Recommended Posts

XM (file format)

XM, standing for "extended module", is an audio file type introduced by Triton's FastTracker 2. XM introduced multisampling-capable instruments with volume and panning envelopes, and basic pattern compression. It also expanded the available effect commands and channels, added 16-bit sample support, and offered an alternative frequency table for portamentos. www.modarchive.org uses this format.

XM is a common format for many chiptunes.


I would like some help on how to emmbed a XM file in my delphi code, so when it is run the music is played, i have searched the net and found codes but they font wot=rk at all, i use DELPHI 7 so i woild be grateful to anyone who can help me with this problem, i know i ask alot but any sample projects i can learn from i am truly grateful to you guys.


thank you in advance my brothers and sisters.

Link to comment

Serach dosent work, i have over 2GB of XM files and have already made a project with everything else but for some reason i cant find the code for XM and only found V2M but thats no good at all, if any one can help thank you if not then i still thank you

Link to comment

Search works just fine, and Delphi code for XM player can be found there. And it can be compiled using Delphi 7. And it works.


If you are too lazy to use it, why should we waste our time on your problems?

Link to comment

im not lazy bro, i asked for help cause i need it but thank yu for your attitude towards me. not a player i need but when my exe loads it plsys the music file

Link to comment

@omar911: Playing XM in Delphi is very easy, this is what you need to do:


Download "ufmod-1.25.2a-win32.7z" from http://sourceforge.net/projects/ufmod/ and unpack it to get "uFMOD.pas" and "ufmod.obj" files found in "Examples\Delphi\WinMM".To convert your xm file into a .pas file, there are few tools around but one of them is called "Xtractor" by Serial Killer (pretty sure our friend DREAMER here has a copy :prop:), this tool will allow you to play and convert any xm file into "Music.pas".Once you converted your xm file, place all three files "uFMOD.pas", "ufmod.obj" and "Music.pas" inside your project folder. Now add the following to your Delphi project:

uses ... uFMOD, Music;// OnCreate Event uFMOD.uFMOD_PlaySong(@Data,Length(Data),XM_MEMORY);// OnClose Event uFMOD.uFMOD_StopSong;


Another way of doing this is by using the "eff.exe" tool included in "ufmod-1.25.2a-win32.7z" file, this is how:


1- Run the eff tool

2- Load your XM file i.e "XmTrack.xm"

3- Tick "Generate a hex dump file ..." and select "Pascal (Delphi)" then click "Go!", now you should have a "XmTrack.pas" file in the same folder.

4- Place "uFMOD.pas" and "ufmod.obj" files inside your project folder and add the following to your Delphi project:

uses ... , uFMOD;implementation{$R *.dfm}// Here you can paste what you have inside "XmTrack.pas" fileconst   xm : array[1..500] of Byte = (....etc); // note: your xm size might differ// OnCreate Event uFMOD.uFMOD_PlaySong(@xm,Length(xm),XM_MEMORY);// OnClose Event uFMOD.uFMOD_StopSong;

Once again you are done!


Cheers :peace:

Edited by ChOoKi
  • Like 1
Link to comment

@Kurapica I totally disagree with you here my friend, in fact, it would be very disappointing to find it in the trash because chances are this problem will happen again sometime in the future, therefore I believe best would be is to address it objectively rather than dismiss it or worse, to pretend it wont come back.


@omar911: A lot of people think coding is a simple thing, simple enough to learn in a day or two, but what they fail to understand is one would have to spend countless hours learning the basics and implementing them in a real project and sometimes things don't run so smoothly and you end up facing a situations where something is just not working as it should, well, this is where all that learning starts to pay off for without it you will end up with frustration and despair and that is understandable because most of us been there!
Now, do I and others here feel insulted for trying to help? I fear not, you feel that we failed you and for that I apologize because our short-range telepathic powers were unable to know for sure where you went wrong with your project, but the good news are coming, in a week, a month or even a year you will find and correct that error and start to look back and regret your words here, how do I know all this? have a guess!

Edited by ChOoKi
  • Like 2
Link to comment

@omar911: Playing XM in Delphi is very easy, this is what you need to do:

To convert your xm file into a .pas file, there are few tools around but one of them is called "Xtractor" by Serial Killer (pretty sure our friend DREAMER here has a copy :prop:), this tool will allow you to play and convert any xm file into "Music.pas".



Cheers :peace:


here is  tool from serial  killer



© Xtractor_by_Serial_Killer.rar

Edited by DREAMER
  • Like 2
Link to comment

I'm sure he will edit out many offensive posts in this topic, he doesn't allow this level of behavior here.


Yes, I have.


An extension to the PureBasic source code I posted here in the other topic now with MiniFmod playing an XM chiptune, its not Delphi but hopefully it gives you the idea. Attachment is included with working source code, lib and chiptune...

Import "libminifmod170.lib"

  MiniFmod_SetVolume(Volume) As "_MiniFmod_SetVolume@4"

  MiniFmod_Free() As "_MiniFmod_Free@0"

  MiniFmod_GetChannels() As "_MiniFmod_GetChannels@4"

  MiniFmod_GetOrder() As "_MiniFmod_GetOrder@0"

  MiniFmod_GetRow() As "_MiniFmod_GetRow@0"

  MiniFmod_GetSynch(channel) As "_MiniFmod_GetSynch@4"

  MiniFmod_GetTime() As "_MiniFmod_GetTime@0"

  MiniFmod_Init(*File,Size) As "_MiniFmod_Init@8"

  MiniFmod_Play() As "_MiniFmod_Play@0"

  MiniFmod_Stop() As "_MiniFmod_Stop@0"


Declare Fade(void)

If OpenWindow(0, 0, 0, 350, 160, "PureBasic Example Keygen Template", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)


  CreateThread(@Fade(), 0) ; Fade in from a thread to avoid gadgets not showing up whilst waiting for the next window event...


  StringGadget(2, 10, 30, 330, 20, "teddyrogers@tuts4you.com", #PB_Text_Center)

  StringGadget(4, 10, 75, 330, 20, "Teddy Rogers", #PB_Text_Center | #PB_String_ReadOnly)


  ; Change the following gadgets to use bold font...


  If LoadFont(1,"Arial",8, #PB_Font_Bold)

    SetGadgetFont(#PB_Default, FontID(1))



  TextGadget(1, 10,  10, 330, 20, "Email Address:")

  TextGadget(3, 10, 55, 330, 20, "Registration Code:")

  ButtonGadget(5, 10,100, 330, 50, "GENERATE!", #PB_Button_MultiLine)


  ; Setup MiniFmod and start playing the music...


  If MiniFmod_Init(?ModStart,?ModEnd-?ModStart)

    If MiniFmod_Play()

      #Playing = #True




  ; Wait for a window or gadget event, then do stuff...



    Event = WaitWindowEvent()


    Select Event


      Case #PB_Event_Gadget


        Select EventGadget()

          Case 2 ; Checks email length, detects "@" and any duplicate(s), looks for "." and minimum characters proceeding it...


            Email.s = GetGadgetText(2)

            Length = Len(Email.s)


            If Length >= 5

              Check = FindString(Email.s, "@")

              If Check

                If Not FindString(Email.s, "@", (Check+1))

                  DotPos = FindString(Email.s, ".", (Check+1))

                  If DotPos

                    DotStr.s = Right(Email.s, (Len(Email.s)-DotPos))

                    DotLen = Len(DotStr.s)


                    ; Random numbers between 0 to 9


                    If DotLen >= 2

                      Code.s = Str(Random(99999,000000))+"-"+Str(Random(99999,000000))+"-"+Str(Random(99999,000000))+"-"+Str(Random(99999,000000))+"-"+Str(Random(99999,000000))

                      SetGadgetText(4, Code.s)







        Case 5 ; "Generate!" gadget button ID

          Code.s = Str(Random(99999,000000))+"-"+Str(Random(99999,000000))+"-"+Str(Random(99999,000000))+"-"+Str(Random(99999,000000))+"-"+Str(Random(99999,000000))

          SetGadgetText(4, Code.s)





  Until Event = #PB_Event_CloseWindow


  ; Fade out effect...


  For Opacity = 255 To 0 Step -1

    SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, #WS_EX_LAYERED)

    SetLayeredWindowAttributes_(WindowID(0), 0, Opacity, #LWA_ALPHA)




  ; Stop music from playing and free up any used memory...


  If #Playing





; Fade window in effect...

Procedure Fade(void)


  For Opacity = 0 To 255

    SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, #WS_EX_LAYERED)

    SetLayeredWindowAttributes_(WindowID(0), 0, Opacity, #LWA_ALPHA)







  IncludeBinary "Modules/zabutom.xm"




Keygen Template.rar

  • Like 1
Link to comment

Here is a basic Delphi project of what was discussed earlier using eff tool to convert a given XM file into a hex dump to be played via uFMOD. The XM track used in this project was posted earlier by omar911, therefore to choose a different track changes should only be made inside unit "Music.pas", anyone new to Delphi should know how by now :prop:


An external link to whom are not members at this forum https://www.sendspace.com/file/1kphap


Hopefully we can put this whole matter to rest once and for all :peace:

Basic XM Playing Delphi Project.7z

  • Like 3
Link to comment
  • 2 weeks later...

I'm using uFMOD afor a long time. First i started with Delphi 2009, now i'm on Delphi XE7.

And it works like a charm. But keep in mind that its only for x86 executables.

Formerly i used it also with a so called "Music.pas" but now... I'm using it directly with a given xm file.

The xm file must be imported/integrated to your project like this...



And now you need a little bit coding skills...

Define the uFMOD.pas into the "Uses" section...

Uses uFMOD;

And then you play your xm file like this...

uFMOD_PlaySong(pchar(5),0 ,XM_RESOURCE);

To stop playing the file simply use this code...


  • Like 1
Link to comment

sorry I just can reply to your message, and maybe I reply herehope this helps.


Include Example.exe, UFMod, MiniMod, Bero XM, 2 chiptune

Play From File, Memory, Resource


for converter * .XM to * .Pas I use [this My Old Files], which I modif of Benjamin Roseaux, there may be a slight problem on the foreign character (Non Alphabet) and forgot to mark the name in Table arrangement of data, so it must name manually, if the play XM more from one in a Form. hehe: D

X88 - Source Code X-tended Module Player (Delphi only).zip

Edited by X-88
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...