Sky
Sky

Reputation: 4370

Play .XM .MOD audio files in Delphi without DLLs

I want to play .XM or .MOD files in Delphi without using DLLs. I searched here and similar websites. Finally I found a good library (BeRoXM.pas) for doing this and it can do exactly what I want to do. (You can download it here)

But as I'm using Delphi XE5, I cannot compile the unit. The code is too old.

So how can I play those files?

Thank you.

Upvotes: 1

Views: 772

Answers (4)

BeRo
BeRo

Reputation: 148

I'm the author of BeRoXM. BeRoXM is since few months compatible with newer Delphi and FPC Versions.

But may I just ask, why did not you contact me directly by email? My email address can be found right at the beginning of the BeRoXM.pas file in a code comment.

Upvotes: 2

Danny Rancher
Danny Rancher

Reputation: 2005

uFMOD enables you to play .xm soundtracks [chiptunes] from within your application easily. By specifying parameters, you can play .xm files from disk, memory or resource.

http://www.delphibasics.info/home/delphibasicssnippets/ufmodexample-playxmfilesfromdiskmemoryorresource

Upvotes: 2

Arioch 'The
Arioch 'The

Reputation: 16045

without using DLLs

Without using, or without deploying ? You can have the DLL inside the application, unpack it to the temporary folder and load from it.

And the debugger says:

The debugger only works when the program is already running. Since you could not compile, that is the compiler saying.

Types of actual and formal var parameters must be identical

So could you please tell me how I can fix this error?

  1. You should understand when the function been used. There may be several functions named "BeginThread". You have to nail the one that compiler really wants to use. Usually Ctrl+Click is enough to find it, though sometimes IDE goes nuts.

  2. You should copy the declaration of that function here for us.

  3. You should find and copy the declarations of all the parameters you try to feed into the function. Here they are BeRoXMThreadProc, self, ThreadID.

  4. You would have to compare data types that declared for the parameters inside "BeginThread" declaration (those are called formal ones) and used in the place you try to call the function (those are called actual ones). And make them match each other.

This may be the declaration of the function you try to call

But maybe it is not - as said above, There may be several functions named "BeginThread".

PS: though I put those links above, you'd better copy into your question the actual functions and types declarations from your sources. StackOverflow tries to be self-dependent site, where all required data is already present in question without external links, that can go offline or 404 in future.

Upvotes: 0

David Heffernan
David Heffernan

Reputation: 612993

Types of actual and formal var parameters must be identical

This is error E2033, described by the documentation as follows:

For a variable parameter, the actual argument must be of the exact type of the formal parameter.

So the error is with a var parameter, and BeginThread only has one: the final parameter. The library code is passing ThreadID for that var parameter and ThreadID which is declared as:

ThreadID: THandle;

But the BeginThread function expects a TThreadID (which is an alias for LongWord) for that parameter. The library code is completely bogus. A thread ID is categorically not a THandle.

In older versions of Delphi THandle was incorrectly declared as LongWord. Thankfully recent versions of Delphi fix that travesty by declaring it as NativeUInt, although I personally would prefer it to be declared as an untyped pointer as it is in the Windows header files.

Fix the BeRoXM library code by changing the type of ThreadID to TThreadID. Expect there to be more problems as you port this code to XE5.

Upvotes: 2

Related Questions