-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathmain_di.pas
More file actions
277 lines (227 loc) · 7.89 KB
/
Copy pathmain_di.pas
File metadata and controls
277 lines (227 loc) · 7.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/////////////////// Demo how to use United Openlib of Sound ////////////////////
unit main_di;
{$mode objfpc}{$H+}
interface
uses
uos_flat,
Forms,
Dialogs,
SysUtils,
Graphics,
StdCtrls,
ExtCtrls,
Grids,
Classes;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
PaintBox1: TPaintBox;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
procedure CheckInfos();
private
{ private declarations }
public
{ public declarations }
end;
procedure uos_logo();
var
Form1: TForm1;
BufferBMP: TBitmap;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormActivate(Sender: TObject);
{$IFDEF Darwin}
var
opath: string;
{$ENDIF}
begin
uos_logo();
{$IFDEF Windows}
{$if defined(cpu64)}
edit1.Text := application.Location + 'lib\Windows\64bit\LibPortaudio-64.dll';
{$else}
edit1.Text := application.Location + 'lib\Windows\32bit\LibPortaudio-32.dll';
{$endif}
{$ENDIF}
{$IFDEF Darwin}
{$IFDEF CPU32}
opath := application.Location;
opath := copy(opath, 1, Pos('/uos', opath) - 1);
edit1.Text := opath + '/lib/Mac/32bit/LibPortaudio-32.dylib';
{$ENDIF}
{$IFDEF CPU64}
opath := application.Location;
opath := copy(opath, 1, Pos('/uos', opath) - 1);
Edit1.Text := opath + '/lib/Mac/64bit/LibPortaudio-64.dylib';
{$ENDIF}
{$ENDIF}
{$if defined(CPUAMD64) and defined(openbsd) }
edit1.Text := application.Location + 'lib/OpenBSD/64bit/LibPortaudio-64.so';
{$ENDIF}
{$if defined(CPUAMD64) and defined(linux) }
edit1.Text := application.Location + 'lib/Linux/64bit/LibPortaudio-64.so';
{$endif}
{$if defined(cpu86) and defined(linux)}
edit1.Text := application.Location + 'lib/Linux/32bit/LibPortaudio-32.so';
{$endif}
{$if defined(linux) and defined(cpuarm)}
edit1.Text := application.Location + 'lib/Linux/arm_raspberrypi/libportaudio-arm.so';
{$endif}
{$if defined(linux) and defined(cpuaarch64)}
edit1.Text := ordir + 'lib/Linux/aarch64_raspberrypi/libportaudio_aarch64.so';
{$ENDIF}
{$IFDEF freebsd}
{$if defined(cpu64)}
edit1.Text := application.Location + 'lib/FreeBSD/64bit/libportaudio-64.so';
{$else}
edit1.Text := application.Location + 'lib/FreeBSD/32bit/libportaudio-32.so';
{$endif}
{$ENDIF}
//////////////////////////////////////////////////////////////////////////
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.Draw(0, 0, BufferBMP);
end;
procedure TForm1.CheckInfos();
var
x: integer;
begin
uos_GetInfoDevice();
label2.Caption := 'Devices Count = ' + IntToStr(uosDeviceCount);
label3.Caption := 'Default Device IN = ' + IntToStr(uosDefaultDeviceIN);
label4.Caption := 'Default Device OUT = ' + IntToStr(uosDefaultDeviceOUT);
stringgrid1.rowcount := uosDeviceCount + 1;
x := 1;
while x < uosDeviceCount + 1 do
begin
stringgrid1.Cells[0, x] := IntToStr(uosDeviceInfos[x - 1].DeviceNum);
stringgrid1.Cells[1, x] := uosDeviceInfos[x - 1].DeviceName;
if uosDeviceInfos[x - 1].DefaultDevIn = True then
stringgrid1.Cells[2, x] := 'Yes'
else
stringgrid1.Cells[2, x] := 'No';
if uosDeviceInfos[x - 1].DefaultDevOut = True then
stringgrid1.Cells[3, x] := 'Yes'
else
stringgrid1.Cells[3, x] := 'No';
stringgrid1.Cells[4, x] := IntToStr(uosDeviceInfos[x - 1].ChannelsIn);
stringgrid1.Cells[5, x] := IntToStr(uosDeviceInfos[x - 1].ChannelsOut);
stringgrid1.Cells[6, x] := floattostrf(uosDeviceInfos[x - 1].SampleRate, ffFixed, 15, 0);
stringgrid1.Cells[7, x] := floattostrf(uosDeviceInfos[x - 1].LatencyHighIn, ffFixed, 15, 8);
stringgrid1.Cells[8, x] := floattostrf(uosDeviceInfos[x - 1].LatencyHighOut,
ffFixed, 15, 8);
stringgrid1.Cells[9, x] := floattostrf(uosDeviceInfos[x - 1].LatencyLowIn, ffFixed, 15, 8);
stringgrid1.Cells[10, x] :=
floattostrf(uosDeviceInfos[x - 1].LatencyLowOut, ffFixed, 15, 8);
stringgrid1.Cells[11, x] := uosDeviceInfos[x - 1].HostAPIName;
stringgrid1.Cells[12, x] := uosDeviceInfos[x - 1].DeviceType;
Inc(x);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// Load the library
// function uos_loadlib(PortAudioFileName, SndFileFileName, Mpg123FileName, Mp4ffFileName, FaadFileName, opusfilefilename, libxmpfilename: PChar) : LongInt;
if uos_LoadLib(PChar(edit1.Text), nil, nil, nil, nil, nil, nil) = 0 then
begin
form1.hide;
button1.Caption := 'PortAudio is loaded...';
button1.Enabled := False;
edit1.ReadOnly := True;
CheckInfos();
form1.Height := 688;
form1.Position := poScreenCenter;
form1.Show;
end
else
begin
if uosLoadResult.PAloaderror = 1 then
MessageDlg(edit1.Text + ' do not exist...', mtWarning, [mbYes], 0);
if uosLoadResult.PAloaderror = 2 then
MessageDlg(edit1.Text + ' do not load...', mtWarning, [mbYes], 0);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
CheckInfos();
end;
procedure uos_logo();
var
xpos, ypos: integer;
ratio: double;
begin
xpos := 0;
ypos := 0;
ratio := 1;
BufferBMP := TBitmap.Create;
with form1 do
begin
form1.PaintBox1.Parent.DoubleBuffered := True;
PaintBox1.Height := round(ratio * 116);
PaintBox1.Width := round(ratio * 100);
BufferBMP.Height := PaintBox1.Height;
BufferBMP.Width := PaintBox1.Width;
BufferBMP.Canvas.AntialiasingMode := amOn;
BufferBMP.Canvas.Pen.Width := round(ratio * 6);
BufferBMP.Canvas.brush.Color := clmoneygreen;
BufferBMP.Canvas.FillRect(0, 0, PaintBox1.Width, PaintBox1.Height);
BufferBMP.Canvas.Pen.Color := clblack;
BufferBMP.Canvas.brush.Color := $70FF70;
BufferBMP.Canvas.Ellipse(round(ratio * (22) + xpos),
round(ratio * (30) + ypos), round(ratio * (72) + xpos),
round(ratio * (80) + ypos));
BufferBMP.Canvas.brush.Color := clmoneygreen;
BufferBMP.Canvas.Arc(round(ratio * (34) + xpos), round(ratio * (8) + ypos),
round(ratio * (58) + xpos), round(ratio * (32) + ypos), round(ratio * (58) + xpos),
round(ratio * (20) + ypos), round(ratio * (46) + xpos),
round(ratio * (32) + xpos));
BufferBMP.Canvas.Arc(round(ratio * (34) + xpos), round(ratio * (32) + ypos),
round(ratio * (58) + xpos), round(ratio * (60) + ypos), round(ratio * (34) + xpos),
round(ratio * (48) + ypos), round(ratio * (46) + xpos),
round(ratio * (32) + ypos));
BufferBMP.Canvas.Arc(round(ratio * (-28) + xpos), round(ratio * (18) + ypos),
round(ratio * (23) + xpos), round(ratio * (80) + ypos), round(ratio * (20) + xpos),
round(ratio * (50) + ypos), round(ratio * (3) + xpos), round(ratio * (38) + ypos));
BufferBMP.Canvas.Arc(round(ratio * (70) + xpos), round(ratio * (18) + ypos),
round(ratio * (122) + xpos), round(ratio * (80) + ypos),
round(ratio * (90 - xpos)),
round(ratio * (38) + ypos), round(ratio * (72) + xpos),
round(ratio * (50) + ypos));
BufferBMP.Canvas.Font.Name := 'Arial';
BufferBMP.Canvas.Font.Size := round(ratio * 10);
BufferBMP.Canvas.TextOut(round(ratio * (4) + xpos),
round(ratio * (83) + ypos), 'United Openlib');
BufferBMP.Canvas.Font.Size := round(ratio * 7);
BufferBMP.Canvas.TextOut(round(ratio * (20) + xpos),
round(ratio * (101) + ypos), 'of');
BufferBMP.Canvas.Font.Size := round(ratio * 10);
BufferBMP.Canvas.TextOut(round(ratio * (32) + xpos),
round(ratio * (98) + ypos), 'Sound');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Height := 126;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if button1.Enabled = False then
uos_free;
BufferBMP.free;
end;
end.