Lazarus

Programming => Graphics and Multimedia => DirectX => Topic started by: Aeternitas on October 11, 2013, 12:22:48 pm

Title: DirectMusic Problem
Post by: Aeternitas on October 11, 2013, 12:22:48 pm
Hi,

I try to use DirectX music in my application, because I need to play SGT music files. I downloaded Clootie DirectX Headers and defined:

Code: [Select]
objDX8Loader: IDirectMusicLoader8;
  objDX8Segment: IDirectMusicSegment8;
  objDX8Performance: IDirectMusicPerformance8;
  objDX8SegmentState: IDirectMusicSegmentState8;

Then I tried to init audio and load the music file:
Code: [Select]
procedure TForm30.Load(FileNamePath: string);
begin
  CoInitialize(nil); //initialize COM

  CoCreateInstance(CLSID_DirectMusicLoader,
                 nil,
                 CLSCTX_INPROC,
                 IID_IDirectMusicLoader8,
                 objDX8Loader); //create loader object

  CoCreateInstance(CLSID_DirectMusicPerformance,
                 nil,
                 CLSCTX_INPROC,
                 IID_IDirectMusicPerformance8,
                 objDX8Performance); //create performance object

  objDX8Performance.InitAudio(nil,nil,WindowHandle,DMUS_APATH_SHARED_STEREOPLUSREVERB,32,DMUS_AUDIOF_ALL,nil); //initialize DirectMusic & DirectSound

  CoCreateInstance(CLSID_DirectMusicSegment,nil,CLSCTX_INPROC,IID_IDirectMusicSegment8,objDX8Segment);

  objDX8Loader.LoadObjectFromFile(CLSID_DirectMusicSegment,IID_IDirectMusicSegment8,PWideChar(FileNamePath),objDX8Segment);

  objDX8Segment.Download(objDX8Performance);
end;

The code has been successfully compiled and ran, but then unfortunately the application crashed by the line objDX8Performance.InitAudio referring External SIGSEGV exception.

I use Win7 64bit, Lazarus 1.0.12 64bit. DirectX 9 is installed and I also put the DLLs from Clootie's page next to application exe file.

Any idea what I do wrong?

Thanks in advance.
Title: Re: DirectMusic Problem
Post by: marcov on October 11, 2013, 01:24:30 pm
Are those DLLs and headers fit for 64-bit programs?  A 64-bits programs can use a 32-bit DLL.


FPC 2.6.x 64-bit doesn't support certain forms of exception handling (in non FPC code). IF you have a problem with exceptions from external code in 64-bit mode, try the development version of FPC.
Title: Re: DirectMusic Problem
Post by: Aeternitas on October 11, 2013, 05:45:57 pm
I have also 32 bit installation of Lazarus; causing the exception as well.

Which version do you mean? Prerelease 1.1.99? If not, please give a link.
Title: Re: DirectMusic Problem
Post by: BigChimp on October 11, 2013, 06:51:03 pm
Which version do you mean? Prerelease 1.1.99? If not, please give a link.
1.1.99 is still based on 2.6.x so no.

You would need a snapshot based on FPC 2.7.1 or compile yourself using an svn copy (e.g. using fpcup).
Title: Re: DirectMusic Problem
Post by: BlueIcaro on October 11, 2013, 06:57:17 pm
do you have all need dll into folder where is your exe? or in path?

/BlueIcaro
Title: Re: DirectMusic Problem
Post by: Aeternitas on October 11, 2013, 07:18:27 pm
do you have all need dll into folder where is your exe? or in path?

/BlueIcaro

I have there d3dx9_33.dll and DXErr9ab.dll. And DirectX9.2 is installed.
TinyPortal © 2005-2018