[fpc-pascal] Re: Playing sounds with standard components

Ludo Brands ludo.brands at free.fr
Mon Jun 11 20:22:14 CEST 2012


> I took a look in Openal examples. I need to confess that I 
> expected something easier. Perhaps, something like:
> 
> PlaySound('file.wav', 0)
> 
> In MMSystem, we have something like that, but it's not cross platform.
> 
> The examples present hundreds of lines. It's something frightful!
> 
> Regarding the complexity, probably is's possible to do much 
> more than simply play a sound. In spite of that, it would be 
> intersting to have something easier.
> 
> The examples work with complex and for me, abstract 
> structures. Which kind of content, do I need to study to 
> understand Openal or SDL?
> 

On the lazarus forum, kpjcomp made a wrapper for Openal. Haven't tested it
but his example code is as simple as:

  openAl := TLazOpenAL.Create;

  wav1 := TLazOpenALWavFileSource.Create('drumloop.wav');
  wav1.looping := true;
  openal.SourceList.Add(wav1);

  wav2 := TLazOpenALWavFileSource.Create('chimes.wav');
  openal.SourceList.Add(wav2); 

  wav1.play;
  wav2.play;

Perhaps worth looking at.

Ludo




More information about the fpc-pascal mailing list