0
0

I used to use FMOD 3.8, when I try to test Fmod Ex, I met such a problem below.

A simple console program which I translated from c, cannot run.

[code:3drt07jx]
Program Project1;

{$APPTYPE CONSOLE}

Uses
SysUtils, Classes, Windows,
fmod, fmodtypes, fmoderrors;

Var
pSound: pChar;
pFMod_ExInfo: FMOD_CREATESOUNDEXINFO;
pFMod_System, pFModSound_Intro, pFMod_Channel: Pointer;
fWavFile: TMemoryStream;

Procedure ErrCheck(return: FMOD_RESULT);
Begin
If return <> FMOD_OK Then
Begin
WriteLn(’FMOD error:’ + FMOD_ErrorString(return));
Halt;
End;
End;

Begin

// 1. start FMOD system

ErrCheck(FMOD_System_Create(pFMod_System));
ErrCheck(FMOD_system_init(pFMod_System, 32, FMOD_INIT_NORMAL, Nil));

// 2. load data to memory

ZeroMemory(@pFMod_ExInfo, SizeOf(FMOD_CREATESOUNDEXINFO));
pFMod_ExInfo.cbsize := SizeOf(FMOD_CREATESOUNDEXINFO);
fWavFile := TMemoryStream.Create;
fWavFile.LoadFromFile(’Se001.wav’);
pFMod_ExInfo.length := fWavFile.Size;
GetMem(pSound, fWavFile.size);
fWavFile.ReadBuffer(pSound^, fWavFile.size);
fWavFile.Free;

// 3. play sound

FMOD_System_CreateSound(pFMod_System, pSound, FMOD_SOFTWARE or FMOD_OPENMEMORY, @pFMod_ExInfo, pFModSound_Intro);
// ^ Error occured at this line.
// –> Exception EAccessViolation in module fmodex.dll at 0006E505.
// –> Access violation at address 1006E505 in module ‘fmodex.dll’. Read of address 00000000.

FMOD_System_PlaySound(pFMod_System, FMOD_CHANNEL_FREE, pFModSound_Intro, False, pFMod_Channel);

// 4. holding, for listen the sound.
ReadLn;

End.

[/code:3drt07jx]

Any ideas? 😥 help me! Thank you very much!

  • You must to post comments
0
0

FMOD Ex needs a call to update every few ms. Try that to see if it helps.

  • You must to post comments
0
0

It doesnt need an update to play a sound.

The user is most likely not waiting for the sound to finish. Put a sleep or while loop in there to wait for the sound to play. It looks like you are exiting your program as soon as you call play.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.