unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
(* uos, uos_flat NOT WORK error not find unit*)
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
var uos_lib_OK : Boolean;
implementation
{$R *.lfm}
{ TForm1 }
(* CLICK BUTTON LOAD LIBRARY AND SOUND *)
procedure TForm1.Button1Click(Sender: TObject);
var PlayerIndex1: cardinal;
In1Index : integer;
res: integer;
ordir, opath, PA_FileName, SF_FileName, MPG_FileName: string;
begin
(********************************************************************)
(********************* START LOAD LIBRARY LINUX *********************)
(********************************************************************)
ordir := application.Location;
{$IFDEF linux}
{$if defined(cpu64)}
PA_FileName := ordir + 'uos_lib/Linux/64bit/LibPortaudio-64.so';
SF_FileName := ordir + 'uos_lib/Linux/64bit/LibSndFile-64.so';
MPG_FileName := ordir + 'uos_lib/Linux/64bit/LibMpg123-64.so';
{$else}
PA_FileName := ordir + 'uos_lib/Linux/32bit/LibPortaudio-32.so';
SF_FileName := ordir + 'uos_lib/Linux/32bit/LibSndFile-32.so';
MPG_FileName := ordir + 'uos_lib/Linux/32bit/LibMpg123-32.so';
{$endif}
{$ENDIF}
// Load the libraries
// function uos_LoadLib(PortAudioFileName: Pchar; SndFileFileName: Pchar; Mpg123FileName: Pchar; SoundTouchFileName: Pchar) : integer;
res := uos_LoadLib(Pchar(PA_FileName), Pchar(SF_FileName), Pchar(MPG_FileName), nil) ;
// writeln('Result of loading (if 0 => ok ) : ' + IntToStr(res));
if res = 0 then uos_lib_OK := True else
begin
uos_lib_OK := False;
ShowMessage('uos LoadLib Error');
end;
(********************************************************************)
(************************* END LOAD LIBRARY LINUX********************)
(********************************************************************)
(********************************************************************)
(************************ START SOUND ******************************)
(********************************************************************)
if uos_lib_OK then
begin
PlayerIndex1 := 0;
uos_CreatePlayer(PlayerIndex1); //// Create the player
In1Index := uos_AddFromFile(PlayerIndex1,(pchar('test.wav')));
uos_AddIntoDevOut(PlayerIndex1, -1, -1, uos_InputGetSampleRate(PlayerIndex1, In1Index), -1, -1, -1);
// play File
uos_Play(PlayerIndex1);
end;
end;
end.