0
0

Hi, I’ve got a bit of a problem:

I decided to use fmod to put some sound in my game developed in delphi, so I tried to just play a music and it doesn’t work.
I don’t know what is the problem, the initialisation is good, the location of the file is also good but I don’t hear anything at all. Any idea?

[code:3h22qush]unit son;

interface
uses
fmod, fmodtypes, fmoderrors, Windows, SysUtils;

procedure music(test:PWideChar);

implementation

procedure music(test:PWideChar);
var
musique: PFMusicModule;
begin

if FSOUND_Init(44100, 2, 0) then
  writeln('Init Ok')
else
  writeln('Init Faux');
if FileExists(test) then
  writeln('Link Ok')
else
  write('Link False');
musique := FSOUND_Stream_Open(test, 0, 0, 0);

// if FSOUND_SetVolume(1 , 200) then
// writeln(’Volume Ok’)
// else
// write(’Volume False’);
FSOUND_Stream_Play(FSOUND_FREE, musique);
// FSOUND_Stream_Close(musique);
// FSOUND_Close();
end;

end.[/code:3h22qush]

And in the call of the function:

[code:3h22qush]begin
try
{ TODO -oUtilisateur -cCode du point d’entrée : Placez le code ici }
music(’Son/menu.mp3’);

readln;[/code:3h22qush]

  • You must to post comments
0
0

The problem come from delphi 2009. I don’t understand why but with older delphi it works.

  • You must to post comments
0
0

Delphi 2009 uses unicode strings by default. If you tell Delphi 2009 to use PChar (like it’s defined in fmod headers) it will use PWidechar but the FMod dll expects an PAnsichar.

try this
[code:34umhwg0]procedure music(test: AnsiString);
...
FSOUND_Stream_Open(PAnsiChar(test), FSOUND_NORMAL, 0, 0);
[/code:34umhwg0]

  • You must to post comments
0
0

To fix, use: PChar(AnsiString(‘filename’))

Sample using FSOUND_Sample_Load function with Delphi 2009.

[code:3ngw3uic] Sample := FSOUND_Sample_Load(FSOUND_FREE, PChar(AnSiString(filename)), Flags, 0, 0);[/code:3ngw3uic]

José Castillo (Lima-Perú) 😆

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.