{"id":342,"date":"2022-01-07T18:24:24","date_gmt":"2022-01-07T21:24:24","guid":{"rendered":"https:\/\/gladiston.net.br\/?page_id=342"},"modified":"2022-07-13T16:04:57","modified_gmt":"2022-07-13T19:04:57","slug":"acs-audio-components","status":"publish","type":"page","link":"https:\/\/gladiston.net.br\/en\/programacao\/lazarus-ide\/acs-audio-components\/","title":{"rendered":"ACS \u2013 Audio Components"},"content":{"rendered":"<p>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 &#039;MMSystem&#039; unit only works for Windows. However it looks like we have a winning package that is cross-platform, ACS.<\/p>\n\n\n\n<p>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 &#039;MMSystem&#039; and if I compile for Linux then I use ACS. In practice my code looks like this, in uses:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>uses\n(\u2026)<\/code>\n<code>{$IFDEF WINDOWS} MMSystem,{$ENDIF} {$IFDEF LINUX} acs_misc, acs_audio, acs_cdrom, {$ENDIF} (\u2026)<\/code><\/code><\/pre>\n\n\n\n<p>And to play a simple wav file I have to do it like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>if FileExists(sSoundFile) then\nbegin\n  {$IFDEF WINDOWS}\n    sndPlaySound(pchar(sSoundFile), snd_Async or snd_NoDefault); \/\/ unit MMSystem\n  {$ENDIF}\n  {$IFDEF LINUX}\n    AcsAudioOut1:=TAcsAudioOut.Create(nil);\n    AcsCDIn1:=TAcsCDIn.Create(nil);\n    try\n      AcsCDIn1.FileName:=sSoundFile;\n      AcsAudioOut1.Input:=AcsCDIn1;\n      AcsAudioOut1.DriverName:=Wavemapper;\n      AcsAudioOut1.Run;\n    finally\n      AcsAudioOut1.Free;\n      AcsCDIn1:Free;\n    end;\n  {$ENDIF}<\/code>\n<code>end;<\/code><\/code><\/pre>\n\n\n\n<p>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.<\/p>","protected":false},"excerpt":{"rendered":"<p>Criar aplica\u00e7\u00f5es com \u00e1udio no Lazarus \u00e9 tarefa para poucos, mesmo a opera\u00e7\u00e3o mais banal como tocar um arquivo .wav tem v\u00e1rios m\u00e9todos diferentes, o mais comum e simples que envolve a unit \u2018MMSystem\u2019 s\u00f3 funciona para Windows. Contudo parece que temos um pacote vencedor que \u00e9 multiplataforma, o ACS. A \u00fanica dificuldade com o [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":159,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"templates\/template-full-width.php","meta":{"footnotes":""},"class_list":["post-342","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/comments?post=342"}],"version-history":[{"count":8,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/342\/revisions"}],"predecessor-version":[{"id":717,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/342\/revisions\/717"}],"up":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/159"}],"wp:attachment":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/media?parent=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}