Creating applications with audio in Lazarus is a task for few, even the most trivial operation like playing a .wav file has several different methods, the most common and simple involving the 'MMSystem' unit only works for Windows. However it looks like we have a winning package that is cross-platform, ACS.
The only difficulty with ACS is that depending on what you are going to do it may be necessary to load a DLL along with the .exe. So to play .wav in my programs I have to use a mixed form, if I compile for Windows then I use 'MMSystem' and if I compile for Linux then I use ACS. In practice my code looks like this, in uses:
uses
(…)
{$IFDEF WINDOWS} MMSystem,{$ENDIF} {$IFDEF LINUX} acs_misc, acs_audio, acs_cdrom, {$ENDIF} (…)
And to play a simple wav file I have to do it like this:
if FileExists(sSoundFile) then
begin
{$IFDEF WINDOWS}
sndPlaySound(pchar(sSoundFile), snd_Async or snd_NoDefault); // unit MMSystem
{$ENDIF}
{$IFDEF LINUX}
AcsAudioOut1:=TAcsAudioOut.Create(nil);
AcsCDIn1:=TAcsCDIn.Create(nil);
try
AcsCDIn1.FileName:=sSoundFile;
AcsAudioOut1.Input:=AcsCDIn1;
AcsAudioOut1.DriverName:=Wavemapper;
AcsAudioOut1.Run;
finally
AcsAudioOut1.Free;
AcsCDIn1:Free;
end;
{$ENDIF}
end;
And then I can play files in both environments with less complexity when the environment is Windows. Of course, at first glance it seems to be complicated to play .wav files on Linux, the reason for this is that ACS is a cannon shot to kill a mosquito, it was made for more advanced things than playing a .wav, but there is no Linux something simpler for mundane things like playing a .wav file.