source: trunk/Packages/uos/uos_opus.pas

Last change on this file was 664, checked in by chronos, 3 days ago
  • Added: Ability to play music in background in start screen and in-game. Used uos as audio library.
  • Property svn:executable set to *
File size: 31.5 KB
Line 
1{This unit is part of United Openlibraries of Sound (uos)}
2
3{This is the Pascal Wrapper + Dynamic loading of Opus library.
4 Load library with op_load() and release with op_unload().
5 License : modified LGPL.
6 Fred van Stappen / fiens@hotmail.com}
7
8unit uos_opus;
9
10{$mode objfpc}{$H+}
11{$PACKRECORDS C}
12
13interface
14
15uses
16 dynlibs, CTypes, SysUtils;
17
18const
19 OPUS_OK = 0;
20 OPUS_BAD_ARG = -1;
21 OPUS_BUFFER_TOO_SMALL = -2;
22 OPUS_INTERNAL_ERROR = -3;
23 OPUS_INVALID_PACKET = -4;
24 OPUS_UNIMPLEMENTED = -5;
25 OPUS_INVALID_STATE = -6;
26 OPUS_ALLOC_FAIL = -7;
27
28 OPUS_APPLICATION_VOIP = 2048;
29 OPUS_APPLICATION_AUDIO = 2049;
30 OPUS_APPLICATION_RESTRICTED_LOWDELAY = 2051;
31
32 OPUS_SIGNAL_VOICE = 3001; // Signal being encoded is voice
33 OPUS_SIGNAL_MUSIC = 3002; // Signal being encoded is music
34
35 OPUS_BANDWIDTH_NARROWBAND = 1101; // 4 kHz bandpass @hideinitializer
36 OPUS_BANDWIDTH_MEDIUMBAND = 1102; // 6 kHz bandpass @hideinitializer
37 OPUS_BANDWIDTH_WIDEBAND = 1103; // 8 kHz bandpass @hideinitializer
38 OPUS_BANDWIDTH_SUPERWIDEBAND = 1104; // 12 kHz bandpass @hideinitializer
39 OPUS_BANDWIDTH_FULLBAND = 1105; // 20 kHz bandpass @hideinitializer
40
41 OPUS_FRAMESIZE_ARG = 5000; // Select frame size from the argument (default)
42 OPUS_FRAMESIZE_2_5_MS = 5001; // Use 2.5 ms frames
43 OPUS_FRAMESIZE_5_MS = 5002; // Use 5 ms frames
44 OPUS_FRAMESIZE_10_MS = 5003; // Use 10 ms frames
45 OPUS_FRAMESIZE_20_MS = 5004; // Use 20 ms frames
46 OPUS_FRAMESIZE_40_MS = 5005; // Use 40 ms frames
47 OPUS_FRAMESIZE_60_MS = 5006; // Use 60 ms frames
48
49const
50 OPUS_SET_APPLICATION_REQUEST = 4000;
51 OPUS_GET_APPLICATION_REQUEST = 4001;
52 OPUS_SET_BITRATE_REQUEST = 4002;
53 OPUS_GET_BITRATE_REQUEST = 4003;
54 OPUS_SET_MAX_BANDWIDTH_REQUEST = 4004;
55 OPUS_GET_MAX_BANDWIDTH_REQUEST = 4005;
56 OPUS_SET_VBR_REQUEST = 4006;
57 OPUS_GET_VBR_REQUEST = 4007;
58 OPUS_SET_BANDWIDTH_REQUEST = 4008;
59 OPUS_GET_BANDWIDTH_REQUEST = 4009;
60 OPUS_SET_COMPLEXITY_REQUEST = 4010;
61 OPUS_GET_COMPLEXITY_REQUEST = 4011;
62 OPUS_SET_INBAND_FEC_REQUEST = 4012;
63 OPUS_GET_INBAND_FEC_REQUEST = 4013;
64 OPUS_SET_PACKET_LOSS_PERC_REQUEST = 4014;
65 OPUS_GET_PACKET_LOSS_PERC_REQUEST = 4015;
66 OPUS_SET_DTX_REQUEST = 4016;
67 OPUS_GET_DTX_REQUEST = 4017;
68 OPUS_SET_VBR_CONSTRAINT_REQUEST = 4020;
69 OPUS_GET_VBR_CONSTRAINT_REQUEST = 4021;
70 OPUS_SET_FORCE_CHANNELS_REQUEST = 4022;
71 OPUS_GET_FORCE_CHANNELS_REQUEST = 4023;
72 OPUS_SET_SIGNAL_REQUEST = 4024;
73 OPUS_GET_SIGNAL_REQUEST = 4025;
74 OPUS_GET_LOOKAHEAD_REQUEST = 4027;
75 OPUS_RESET_STATE_REQUEST = 4028;
76 OPUS_GET_SAMPLE_RATE_REQUEST = 4029;
77 OPUS_GET_FINAL_RANGE_REQUEST = 4031;
78 OPUS_GET_PITCH_REQUEST = 4033;
79 OPUS_SET_GAIN_REQUEST = 4034;
80 OPUS_GET_GAIN_REQUEST = 4045;
81 OPUS_SET_LSB_DEPTH_REQUEST = 4036;
82 OPUS_GET_LSB_DEPTH_REQUEST = 4037;
83 OPUS_GET_LAST_PACKET_DURATION_REQUEST = 4039;
84 OPUS_SET_EXPERT_FRAME_DURATION_REQUEST = 4040;
85 OPUS_GET_EXPERT_FRAME_DURATION_REQUEST = 4041;
86 OPUS_SET_PREDICTION_DISABLED_REQUEST = 4042;
87 OPUS_GET_PREDICTION_DISABLED_REQUEST = 4043;
88 OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST = 5120;
89 OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST = 5122;
90
91type
92 TOpusEncoder = Pointer;
93 TOpusDecoder = Pointer;
94 TOpusRepacketizer = Pointer;
95 TOpusMSDecoder = pointer;
96 TOpusMSEncoder = pointer;
97
98 TOpusFrames = array [0..47] of Pointer;
99 TOpusFrameSizes = array [0..47] of cint;
100
101type
102 TRequestValueType = (orPointer, orInteger, orXY, orNoValue);
103 TOpusCTLRequestRecord = record
104 Request: Word;
105 case ReqType: TRequestValueType of
106 orPointer: (PtrValue: Pointer);
107 orInteger: (IntValue: cint);
108 orXY: (XValue: cint; YValue: pointer);
109 end;
110
111 var
112 opus_get_version_string: function(): PAnsiChar; cdecl; opus_strerror: function(error: cint): PAnsiChar; cdecl;
113 opus_encode: function(st: TOpusEncoder; pcm : pcfloat; frame_size: cint;
114 var data; max_data_bytes: cint): cint; cdecl;
115 opus_encode_float: function(st: TOpusEncoder; pcm : pcfloat; frame_size: cint; var data; max_data_bytes: cint): cint; cdecl;
116 opus_encoder_create: function(Fs: cint; channels, application: cint; out error: cint): TOpusEncoder; cdecl;
117
118 opus_encoder_ctli: function(st: TOpusEncoder; const reqrequest: word ; reqval : cint ): cint; cdecl;
119 opus_encoder_ctlp: function(st: TOpusEncoder; const reqrequest: word ; reqval : pointer ): cint; cdecl;
120 opus_encoder_ctlxy: function(st: TOpusEncoder; const reqrequest: word ; reqx : cint ; reqy : pointer ): cint; cdecl;
121 opus_encoder_ctln: function(st: TOpusEncoder; const reqrequest: word): cint; cdecl;
122
123 opus_encoder_destroy: procedure(st: TOpusEncoder); cdecl;
124 opus_encoder_get_size: function(channels: cint): cint; cdecl;
125 opus_encoder_init: function(st: TOpusEncoder; Fs: cint; channels, application: cint): cint; cdecl;
126
127 opus_decode: function(st: TOpusDecoder; const data; len: cint; pcm : pcfloat; frame_size, decode_fec: cint): cint; cdecl;
128 opus_decode_float: function(st: TOpusDecoder; const data; len: cint; pcm : pcfloat; frame_size, decode_fec: cint): cint; cdecl;
129 opus_decoder_create: function(fs: cint; channels: cint; out error: cint): TOpusDecoder; cdecl;
130
131 opus_decoder_ctli: function(st: TOpusDecoder; const reqrequest: word ; reqval : cint ): cint; cdecl;
132 opus_decoder_ctlp: function(st: TOpusDecoder; const reqrequest: word ; reqval : pointer ): cint; cdecl;
133 opus_decoder_ctlxy: function(st: TOpusDecoder; const reqrequest: word ; reqx : cint ; reqy : pointer ): cint; cdecl;
134 opus_decoder_ctln: function(st: TOpusDecoder; const reqrequest: word): cint; cdecl;
135
136 opus_decoder_destroy: procedure(st: TOpusDecoder); cdecl;
137 opus_decoder_get_nb_samples: function(st: TOpusDecoder; const packet; len: cint): cint; cdecl;
138 opus_decoder_get_size: function(channels: cint): cint; cdecl;
139 opus_decoder_init: function(st: TOpusDecoder; Fs: cint; channels: cint): cint; cdecl;
140 opus_packet_get_bandwidth: function(const packet): cint; cdecl;
141 opus_packet_get_nb_channels: function(const packet): cint; cdecl;
142 opus_packet_get_nb_frames: function(const packet; len: cint): cint; cdecl;
143 opus_packet_get_nb_samples: function(const packet; len, fs: cint): cint; cdecl;
144 opus_packet_get_samples_per_frame: function(const packet; fs: cint): cint; cdecl;
145 opus_packet_parse: function(const packet; var out_toc: Pointer; var frames: TOpusFrames; var size: TOpusFrameSizes; var payload_offset: cint): cint; cdecl;
146 opus_pcm_soft_clip: procedure(pcm : pcfloat; frame_size, channels: cint; var softclip_mem: Double); cdecl;
147
148 opus_multistream_packet_pad: function(var data; len, new_len, nb_streams: cint): cint; cdecl;
149 opus_multistream_packet_unpad: function(var data; len, nb_streams: cint): cint; cdecl;
150 opus_packet_pad: function(var data; len, new_len: cint): cint; cdecl;
151 opus_packet_unpad: function(var data; len: cint): cint; cdecl;
152 opus_repacketizer_cat: function(rp: TOpusRepacketizer; const data; len: cint): cint; cdecl;
153 opus_repacketizer_create: function: TOpusRepacketizer; cdecl;
154 opus_repacketizer_destroy: procedure(rp: TOpusRepacketizer); cdecl;
155 opus_repacketizer_get_nb_frames: function(rp: TOpusRepacketizer): cint; cdecl;
156 opus_repacketizer_get_size: function: cint; cdecl;
157 opus_repacketizer_init: function(rp: TOpusRepacketizer): TOpusRepacketizer; cdecl;
158 opus_repacketizer_out: function(rp: TOpusRepacketizer; var data; maxlen: cint): cint; cdecl;
159 opus_repacketizer_out_range: function(rp: TOpusRepacketizer; var data; maxlen: cint): cint; cdecl;
160
161 opus_multistream_decode: function(st: TOpusMSDecoder; const data; len: cint; pcm : pcfloat; frame_size, decode_fec: cint): cint; cdecl;
162 opus_multistream_decode_float: function(st: TOpusMSDecoder; const data; len: cint; pcm : pcfloat; frame_size, decode_fec: cint): cint; cdecl;
163 opus_multistream_decoder_create: function(fs: cint; channels, streams, coupled_streams: cint; const mapping: array of Byte; out error: cint): TOpusMSDecoder; cdecl;
164
165 opus_multistream_decoder_ctli: function(st: TOpusMSDecoder; const reqrequest: word ; reqval : cint ): cint; cdecl;
166 opus_multistream_decoder_ctlp: function(st: TOpusMSDecoder; const reqrequest: word ; reqval : pointer ): cint; cdecl;
167 opus_multistream_decoder_ctlxy: function(st: TOpusMSDecoder; const reqrequest: word ; reqx : cint ; reqy : pointer ): cint; cdecl;
168 opus_multistream_decoder_ctln: function(st: TOpusMSDecoder; const reqrequest: word): cint; cdecl;
169
170 opus_multistream_decoder_destroy: procedure(st: TOpusMSDecoder); cdecl;
171 opus_multistream_decoder_get_size: function(streams, coupled_streams: cint): cint; cdecl;
172 opus_multistream_decoder_init: function(st: TOpusMSDecoder; fs: cint; channels, streams, coupled_streams: cint; const mapping: array of Byte): cint; cdecl;
173
174 opus_multistream_encode: function(st: TOpusMSEncoder; pcm : pcfloat; frame_size: cint; var data; max_data_bytes: cint): cint; cdecl;
175 opus_multistream_encode_float: function(st: TOpusMSEncoder; pcm : pcfloat; frame_size: cint; var data; max_data_bytes: cint): cint; cdecl;
176 opus_multistream_encoder_create: function(Fs: cint; channels, streams, coupled_streams: cint; const mapping: array of Byte; application: cint; out error: cint): TOpusMSEncoder; cdecl;
177
178 opus_multistream_encoder_ctli: function(st: TOpusMSEncoder; const reqrequest: word ; reqval : cint ): cint; cdecl;
179 opus_multistream_encoder_ctlp: function(st: TOpusMSEncoder; const reqrequest: word ; reqval : pointer ): cint; cdecl;
180 opus_multistream_encoder_ctlxy: function(st: TOpusMSEncoder; const reqrequest: word ; reqx : cint ; reqy : pointer ): cint; cdecl;
181 opus_multistream_encoder_ctln: function(st: TOpusMSEncoder; const reqrequest: word ): cint; cdecl;
182
183 opus_multistream_encoder_destroy: procedure(st: TOpusMSEncoder); cdecl;
184 opus_multistream_encoder_get_size: function(streams, coupled_streams: cint): cint; cdecl;
185 opus_multistream_encoder_init: function(st: TOpusMSEncoder; fs: cint; channels, streams, coupled_streams: cint; const mapping: array of Byte; application: cint): cint; cdecl;
186
187 opus_multistream_surround_encoder_create: function(Fs: cint; channels, mapping_family, streams, coupled_streams: cint; const mapping: array of Byte; application: cint; out error: cint): TOpusMSEncoder; cdecl;
188 opus_multistream_surround_encoder_get_size: function(channels, mapping_family: cint): cint; cdecl;
189 opus_multistream_surround_encoder_init: function(st: TOpusMSEncoder; fs: cint; channels, mapping_family, streams, coupled_streams: cint; const mapping: array of Byte; application: cint): cint; cdecl;
190
191function opus_encoder_ctl(st: TOpusEncoder; const req: TOpusCTLRequestRecord): Integer; inline;
192function opus_decoder_ctl(st: TOpusdecoder; const req: TOpusCTLRequestRecord): Integer; inline;
193
194function opus_multistream_encoder_ctl(st: TOpusMSEncoder; const req: TOpusCTLRequestRecord): cint; inline;
195function opus_multistream_decoder_ctl(st: TOpusMSdecoder; const req: TOpusCTLRequestRecord): cint; inline;
196
197// Macros for opus_encode_ctl.
198function OPUS_GET_APPLICATION(var x: cint): TOpusCTLRequestRecord; inline;
199function OPUS_GET_BITRATE(var x: cint): TOpusCTLRequestRecord; inline;
200function OPUS_GET_COMPLEXITY(var x: cint): TOpusCTLRequestRecord; inline;
201function OPUS_GET_DTX(var x: cint): TOpusCTLRequestRecord; inline;
202function OPUS_GET_EXPERT_FRAME_DURATION(var x: cint): TOpusCTLRequestRecord; inline;
203function OPUS_GET_FORCE_CHANNELS(var x: cint): TOpusCTLRequestRecord; inline;
204function OPUS_GET_LOOKAHEAD(var x: cint): TOpusCTLRequestRecord; inline;
205function OPUS_GET_LSB_DEPTH(var x: cint): TOpusCTLRequestRecord; inline;
206function OPUS_GET_MAX_BANDWIDTH(var x: cint): TOpusCTLRequestRecord; inline;
207function OPUS_GET_PACKET_LOSS_PERC(var x: cint): TOpusCTLRequestRecord; inline;
208function OPUS_GET_PREDICTION_DISABLED(var x: cint): TOpusCTLRequestRecord; inline;
209function OPUS_GET_SIGNAL(var x: cint): TOpusCTLRequestRecord; inline;
210function OPUS_GET_VBR(var x: cint): TOpusCTLRequestRecord; inline;
211function OPUS_GET_VBR_CONSTRAINT(var x: cint): TOpusCTLRequestRecord; inline;
212
213function OPUS_SET_APPLICATION(x: cint): TOpusCTLRequestRecord; inline;
214function OPUS_SET_BANDWIDTH(x: cint): TOpusCTLRequestRecord; inline;
215function OPUS_SET_BITRATE(x: cint): TOpusCTLRequestRecord; inline;
216function OPUS_SET_COMPLEXITY(x: cint): TOpusCTLRequestRecord; inline;
217function OPUS_SET_DTX(x: cint): TOpusCTLRequestRecord; inline;
218function OPUS_SET_EXPERT_FRAME_DURATION(x: cint): TOpusCTLRequestRecord; inline;
219function OPUS_SET_FORCE_CHANNELS(x: cint): TOpusCTLRequestRecord; inline;
220function OPUS_SET_INBAND_FEC(x: cint): TOpusCTLRequestRecord; inline;
221function OPUS_SET_LSB_DEPTH(x: cint): TOpusCTLRequestRecord; inline;
222function OPUS_SET_MAX_BANDWIDTH(x: cint): TOpusCTLRequestRecord; inline;
223function OPUS_SET_PACKET_LOSS_PERC(x: cint): TOpusCTLRequestRecord; inline;
224function OPUS_SET_PREDICTION_DISABLED(x: cint): TOpusCTLRequestRecord; inline;
225function OPUS_SET_SIGNAL(x: cint): TOpusCTLRequestRecord; inline;
226function OPUS_SET_VBR(x: cint): TOpusCTLRequestRecord; inline;
227function OPUS_SET_VBR_CONSTRAINT(x: cint): TOpusCTLRequestRecord; inline;
228
229// For opus_decoder_ctl and opus_encoder_ctl.
230function OPUS_GET_BANDWIDTH(var x: cint): TOpusCTLRequestRecord; inline;
231function OPUS_GET_FINAL_RANGE(var x: Cardinal): TOpusCTLRequestRecord; inline;
232function OPUS_GET_SAMPLE_RATE(var x: cint): TOpusCTLRequestRecord; inline;
233function OPUS_RESET_STATE: TOpusCTLRequestRecord; inline;
234
235// For the opus_decode_ctl.
236function OPUS_GET_GAIN(var x: cint): TOpusCTLRequestRecord; inline;
237function OPUS_GET_LAST_PACKET_DURATION(var x: cint): TOpusCTLRequestRecord; inline;
238function OPUS_GET_PITCH(var x: cint): TOpusCTLRequestRecord; inline;
239function OPUS_SET_GAIN(x: cint): TOpusCTLRequestRecord; inline;
240
241function OPUS_MULTISTREAM_GET_DECODER_STATE(x: cint; var y: cint): TOpusCTLRequestRecord; inline;
242function OPUS_MULTISTREAM_GET_ENCODER_STATE(x: cint; var y: cint): TOpusCTLRequestRecord; inline;
243
244 var op_Handle:TLibHandle=dynlibs.NilHandle;
245
246 var ReferenceCounter : cardinal = 0;
247
248function op_IsLoaded : boolean; inline;
249
250Function op_Load(const libfilename:string) :boolean;
251
252Procedure op_Unload;
253
254implementation
255
256function op_IsLoaded: boolean;
257begin
258 Result := (op_Handle <> dynlibs.NilHandle);
259end;
260
261Procedure op_Unload;
262begin
263// < Reference counting
264 if ReferenceCounter > 0 then
265 dec(ReferenceCounter);
266 if ReferenceCounter > 0 then
267 exit;
268 // >
269 if op_IsLoaded then
270 begin
271 DynLibs.UnloadLibrary(op_Handle);
272 op_Handle:=DynLibs.NilHandle;
273 end;
274end;
275
276Function op_Load (const libfilename:string) :boolean;
277begin
278 Result := False;
279 if op_Handle<>0 then
280begin
281 Inc(ReferenceCounter);
282 result:=true {is it already there ?}
283end else
284begin {go & load the library}
285 if Length(libfilename) = 0 then exit;
286 op_Handle:=DynLibs.SafeLoadLibrary(libfilename); // obtain the handle we want
287 if op_Handle <> DynLibs.NilHandle then
288begin {now we tie the functions to the VARs from above}
289Pointer(opus_get_version_string):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_get_version_string'));
290Pointer(opus_strerror):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_strerror'));
291Pointer(opus_encode):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encode'));
292Pointer(opus_encode_float):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encode_float'));
293Pointer(opus_encoder_create):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_create'));
294
295Pointer(opus_encoder_ctli):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_ctl'));
296Pointer(opus_encoder_ctlp):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_ctl'));
297Pointer(opus_encoder_ctlxy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_ctl'));
298Pointer(opus_encoder_ctln):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_ctl'));
299
300Pointer(opus_encoder_destroy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_destroy'));
301Pointer(opus_encoder_get_size):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_get_size'));
302Pointer(opus_encoder_init):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_encoder_init'));
303Pointer(opus_decode):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decode'));
304Pointer(opus_decode_float):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decode_float'));
305Pointer(opus_decoder_create):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_create'));
306
307Pointer(opus_decoder_ctli):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_ctl'));
308Pointer(opus_decoder_ctlp):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_ctl'));
309Pointer(opus_decoder_ctlxy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_ctl'));
310Pointer(opus_decoder_ctln):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_ctl'));
311
312Pointer(opus_decoder_destroy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_destroy'));
313Pointer(opus_decoder_get_nb_samples):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_get_nb_samples'));
314Pointer(opus_decoder_get_size):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_get_size'));
315Pointer(opus_decoder_init):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_decoder_init'));
316Pointer(opus_packet_get_bandwidth):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_packet_get_bandwidth'));
317Pointer(opus_packet_get_nb_channels):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_packet_get_nb_channels'));
318Pointer(opus_packet_get_nb_frames):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_packet_get_nb_frames'));
319Pointer(opus_packet_get_nb_samples):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_packet_get_nb_samples'));
320Pointer(opus_packet_get_samples_per_frame):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_packet_get_samples_per_frame'));
321Pointer( opus_packet_parse):=DynLibs.GetProcedureAddress(OP_Handle,PChar(' opus_packet_parse'));
322Pointer(opus_pcm_soft_clip):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_pcm_soft_clip'));
323Pointer(opus_multistream_packet_pad):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_packet_pad'));
324Pointer(opus_multistream_packet_unpad):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_packet_unpad'));
325Pointer(opus_packet_pad):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_packet_pad'));
326Pointer(opus_packet_unpad):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_packet_unpad'));
327Pointer(opus_repacketizer_cat):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_repacketizer_cat'));
328Pointer(opus_repacketizer_create):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_repacketizer_create'));
329Pointer(opus_repacketizer_destroy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('oopus_repacketizer_destroy'));
330Pointer(opus_repacketizer_get_nb_frames):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_repacketizer_get_nb_frames'));
331Pointer(opus_repacketizer_get_size):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_repacketizer_get_size'));
332Pointer(opus_repacketizer_init):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_repacketizer_init'));
333Pointer(opus_repacketizer_out):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_repacketizer_out'));
334Pointer(opus_repacketizer_out_range):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_repacketizer_out_range'));
335Pointer(opus_multistream_decode):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decode'));
336Pointer(opus_multistream_decode_float):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decode_float'));
337Pointer(opus_multistream_decoder_create):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_create'));
338
339Pointer(opus_multistream_decoder_ctli):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_ctl'));
340Pointer(opus_multistream_decoder_ctlp):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_ctl'));
341Pointer(opus_multistream_decoder_ctlxy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_ctl'));
342Pointer(opus_multistream_decoder_ctln):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_ctl'));
343
344Pointer(opus_multistream_decoder_destroy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_destroy'));
345Pointer(opus_multistream_decoder_get_size):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_get_size'));
346Pointer(opus_multistream_decoder_init):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_decoder_init'));
347Pointer(opus_multistream_encode):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encode'));
348Pointer(opus_multistream_encode_float):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encode_float'));
349Pointer(opus_multistream_encoder_create):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_create'));
350
351Pointer(opus_multistream_encoder_ctli):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_ctl'));
352Pointer(opus_multistream_encoder_ctlp):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_ctl'));
353Pointer(opus_multistream_encoder_ctlxy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_ctl'));
354Pointer(opus_multistream_encoder_ctln):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_ctl'));
355
356Pointer(opus_multistream_encoder_destroy):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_destroy'));
357Pointer(opus_multistream_encoder_get_size):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_get_size'));
358Pointer(opus_multistream_encoder_init):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_encoder_init'));
359Pointer(opus_multistream_surround_encoder_create):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_surround_encoder_create'));
360Pointer(opus_multistream_surround_encoder_get_size):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_surround_encoder_get_size'));
361Pointer(opus_multistream_surround_encoder_init):=DynLibs.GetProcedureAddress(OP_Handle,PChar('opus_multistream_surround_encoder_init'));
362
363end;
364 Result := op_IsLoaded;
365 ReferenceCounter:=1;
366end;
367
368end;
369
370
371function OPUS_GET_APPLICATION(var x: cint): TOpusCTLRequestRecord; inline;
372begin
373 Result.Request := OPUS_GET_APPLICATION_REQUEST;
374 Result.ReqType := orPointer;
375 Result.PtrValue := @x;
376end;
377
378function OPUS_GET_BITRATE(var x: cint): TOpusCTLRequestRecord; inline;
379begin
380 Result.Request := OPUS_GET_BITRATE_REQUEST;
381 Result.ReqType := orPointer;
382 Result.PtrValue := @x;
383end;
384
385function OPUS_GET_COMPLEXITY(var x: cint): TOpusCTLRequestRecord; inline;
386begin
387 Result.Request := OPUS_GET_COMPLEXITY_REQUEST;
388 Result.ReqType := orPointer;
389 Result.PtrValue := @x;
390end;
391
392function OPUS_GET_DTX(var x: cint): TOpusCTLRequestRecord; inline;
393begin
394 Result.Request := OPUS_GET_DTX_REQUEST;
395 Result.ReqType := orPointer;
396 Result.PtrValue := @x;
397end;
398
399function OPUS_GET_EXPERT_FRAME_DURATION(var x: cint): TOpusCTLRequestRecord; inline;
400begin
401 Result.Request := OPUS_GET_EXPERT_FRAME_DURATION_REQUEST;
402 Result.ReqType := orPointer;
403 Result.PtrValue := @x;
404end;
405
406function OPUS_GET_FORCE_CHANNELS(var x: cint): TOpusCTLRequestRecord; inline;
407begin
408 Result.Request := OPUS_GET_FORCE_CHANNELS_REQUEST;
409 Result.ReqType := orPointer;
410 Result.PtrValue := @x;
411end;
412
413function OPUS_GET_LOOKAHEAD(var x: cint): TOpusCTLRequestRecord; inline;
414begin
415 Result.Request := OPUS_GET_LOOKAHEAD_REQUEST;
416 Result.ReqType := orPointer;
417 Result.PtrValue := @x;
418end;
419
420function OPUS_GET_LSB_DEPTH(var x: cint): TOpusCTLRequestRecord; inline;
421begin
422 Result.Request := OPUS_GET_LSB_DEPTH_REQUEST;
423 Result.ReqType := orPointer;
424 Result.PtrValue := @x;
425end;
426
427function OPUS_GET_MAX_BANDWIDTH(var x: cint): TOpusCTLRequestRecord; inline;
428begin
429 Result.Request := OPUS_GET_MAX_BANDWIDTH_REQUEST;
430 Result.ReqType := orPointer;
431 Result.PtrValue := @x;
432end;
433
434function OPUS_GET_PACKET_LOSS_PERC(var x: cint): TOpusCTLRequestRecord; inline;
435begin
436 Result.Request := OPUS_GET_PACKET_LOSS_PERC_REQUEST;
437 Result.ReqType := orPointer;
438 Result.PtrValue := @x;
439end;
440
441function OPUS_GET_PREDICTION_DISABLED(var x: cint): TOpusCTLRequestRecord; inline;
442begin
443 Result.Request := OPUS_GET_PREDICTION_DISABLED_REQUEST;
444 Result.ReqType := orPointer;
445 Result.PtrValue := @x;
446end;
447
448function OPUS_GET_SIGNAL(var x: cint): TOpusCTLRequestRecord; inline;
449begin
450 Result.Request := OPUS_GET_SIGNAL_REQUEST;
451 Result.ReqType := orPointer;
452 Result.PtrValue := @x;
453end;
454
455function OPUS_GET_VBR(var x: cint): TOpusCTLRequestRecord; inline;
456begin
457 Result.Request := OPUS_GET_VBR_REQUEST;
458 Result.ReqType := orPointer;
459 Result.PtrValue := @x;
460end;
461
462function OPUS_GET_VBR_CONSTRAINT(var x: cint): TOpusCTLRequestRecord; inline;
463begin
464 Result.Request := OPUS_GET_VBR_CONSTRAINT_REQUEST;
465 Result.ReqType := orPointer;
466 Result.PtrValue := @x;
467end;
468
469function OPUS_SET_APPLICATION(x: cint): TOpusCTLRequestRecord; inline;
470begin
471 Result.Request := OPUS_SET_APPLICATION_REQUEST;
472 Result.ReqType := orInteger;
473 Result.IntValue := x;
474end;
475
476function OPUS_SET_BANDWIDTH(x: cint): TOpusCTLRequestRecord; inline;
477begin
478 Result.Request := OPUS_SET_BANDWIDTH_REQUEST;
479 Result.ReqType := orInteger;
480 Result.IntValue := x;
481end;
482
483function OPUS_SET_BITRATE(x: cint): TOpusCTLRequestRecord; inline;
484begin
485 Result.Request := OPUS_SET_BITRATE_REQUEST;
486 Result.ReqType := orInteger;
487 Result.IntValue := x;
488end;
489
490function OPUS_SET_COMPLEXITY(x: cint): TOpusCTLRequestRecord; inline;
491begin
492 Result.Request := OPUS_SET_COMPLEXITY_REQUEST;
493 Result.ReqType := orInteger;
494 Result.IntValue := x;
495end;
496
497function OPUS_SET_DTX(x: cint): TOpusCTLRequestRecord; inline;
498begin
499 Result.Request := OPUS_SET_DTX_REQUEST;
500 Result.ReqType := orInteger;
501 Result.IntValue := x;
502end;
503
504function OPUS_SET_EXPERT_FRAME_DURATION(x: cint): TOpusCTLRequestRecord; inline;
505begin
506 Result.Request := OPUS_SET_EXPERT_FRAME_DURATION_REQUEST;
507 Result.ReqType := orInteger;
508 Result.IntValue := x;
509end;
510
511function OPUS_SET_FORCE_CHANNELS(x: cint): TOpusCTLRequestRecord; inline;
512begin
513 Result.Request := OPUS_SET_FORCE_CHANNELS_REQUEST;
514 Result.ReqType := orInteger;
515 Result.IntValue := x;
516end;
517
518function OPUS_SET_INBAND_FEC(x: cint): TOpusCTLRequestRecord; inline;
519begin
520 Result.Request := OPUS_SET_INBAND_FEC_REQUEST;
521 Result.ReqType := orInteger;
522 Result.IntValue := x;
523end;
524
525function OPUS_SET_LSB_DEPTH(x: cint): TOpusCTLRequestRecord; inline;
526begin
527 Result.Request := OPUS_SET_LSB_DEPTH_REQUEST;
528 Result.ReqType := orInteger;
529 Result.IntValue := x;
530end;
531
532function OPUS_SET_MAX_BANDWIDTH(x: cint): TOpusCTLRequestRecord; inline;
533begin
534 Result.Request := OPUS_SET_MAX_BANDWIDTH_REQUEST;
535 Result.ReqType := orInteger;
536 Result.IntValue := x;
537end;
538
539function OPUS_SET_PACKET_LOSS_PERC(x: cint): TOpusCTLRequestRecord; inline;
540begin
541 Result.Request := OPUS_SET_PACKET_LOSS_PERC_REQUEST;
542 Result.ReqType := orInteger;
543 Result.IntValue := x;
544end;
545
546function OPUS_SET_PREDICTION_DISABLED(x: cint): TOpusCTLRequestRecord; inline;
547begin
548 Result.Request := OPUS_SET_PREDICTION_DISABLED_REQUEST;
549 Result.ReqType := orInteger;
550 Result.IntValue := x;
551end;
552
553function OPUS_SET_SIGNAL(x: cint): TOpusCTLRequestRecord; inline;
554begin
555 Result.Request := OPUS_SET_SIGNAL_REQUEST;
556 Result.ReqType := orInteger;
557 Result.IntValue := x;
558end;
559
560function OPUS_SET_VBR(x: cint): TOpusCTLRequestRecord; inline;
561begin
562 Result.Request := OPUS_SET_VBR_REQUEST;
563 Result.ReqType := orInteger;
564 Result.IntValue := x;
565end;
566
567function OPUS_SET_VBR_CONSTRAINT(x: cint): TOpusCTLRequestRecord; inline;
568begin
569 Result.Request := OPUS_SET_VBR_CONSTRAINT_REQUEST;
570 Result.ReqType := orInteger;
571 Result.IntValue := x;
572end;
573
574function OPUS_GET_BANDWIDTH(var x: cint): TOpusCTLRequestRecord; inline;
575begin
576 Result.Request := OPUS_GET_BANDWIDTH_REQUEST;
577 Result.ReqType := orPointer;
578 Result.PtrValue := @x;
579end;
580
581function OPUS_GET_FINAL_RANGE(var x: Cardinal): TOpusCTLRequestRecord; inline;
582begin
583 Result.Request := OPUS_GET_BANDWIDTH_REQUEST;
584 Result.ReqType := orPointer;
585 Result.PtrValue := @x;
586end;
587
588function OPUS_GET_SAMPLE_RATE(var x: cint): TOpusCTLRequestRecord; inline;
589begin
590 Result.Request := OPUS_GET_BANDWIDTH_REQUEST;
591 Result.ReqType := orPointer;
592 Result.PtrValue := @x;
593end;
594
595function OPUS_RESET_STATE: TOpusCTLRequestRecord; inline;
596begin
597 Result.Request := OPUS_RESET_STATE_REQUEST;
598 Result.ReqType := orNoValue;
599end;
600
601function OPUS_GET_GAIN(var x: cint): TOpusCTLRequestRecord; inline;
602begin
603 Result.Request := OPUS_GET_GAIN_REQUEST;
604 Result.ReqType := orPointer;
605 Result.PtrValue := @x;
606end;
607
608function OPUS_GET_LAST_PACKET_DURATION(var x: cint): TOpusCTLRequestRecord; inline;
609begin
610 Result.Request := OPUS_GET_LAST_PACKET_DURATION_REQUEST;
611 Result.ReqType := orPointer;
612 Result.PtrValue := @x;
613end;
614
615function OPUS_GET_PITCH(var x: cint): TOpusCTLRequestRecord; inline;
616begin
617 Result.Request := OPUS_GET_PITCH_REQUEST;
618 Result.ReqType := orPointer;
619 Result.PtrValue := @x;
620end;
621
622function OPUS_SET_GAIN(x: cint): TOpusCTLRequestRecord; inline;
623begin
624 Result.Request := OPUS_SET_GAIN_REQUEST;
625 Result.ReqType := orInteger;
626 Result.IntValue := x;
627end;
628
629function OPUS_MULTISTREAM_GET_DECODER_STATE(x: cint; var y: cint): TOpusCTLRequestRecord; inline;
630begin
631 Result.Request := OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST;
632 Result.ReqType := orXY;
633 Result.XValue := x;
634 Result.YValue := @y;
635end;
636
637function OPUS_MULTISTREAM_GET_ENCODER_STATE(x: cint; var y: cint): TOpusCTLRequestRecord; inline;
638begin
639 Result.Request := OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST;
640 Result.ReqType := orXY;
641 Result.XValue := x;
642 Result.YValue := @y;
643end;
644
645function opus_encoder_ctl(st: TOpusEncoder; const req: TOpusCTLRequestRecord): Integer; inline;
646begin
647 case req.ReqType of
648 orPointer: Result := opus_encoder_ctlp(st, req.Request, req.PtrValue);
649 orInteger: Result := opus_encoder_ctli(st, req.Request, req.IntValue);
650 orXY: Result := opus_encoder_ctlxy(st, req.Request, req.XValue, req.YValue);
651 orNoValue: Result := opus_encoder_ctln(st, req.Request);
652 else
653 Result := OPUS_BAD_ARG;
654 end;
655end;
656
657function opus_decoder_ctl(st: TOpusDecoder; const req: TOpusCTLRequestRecord): Integer; inline;
658begin
659 case req.ReqType of
660 orPointer: Result := opus_decoder_ctlp(st, req.Request, req.PtrValue);
661 orInteger: Result := opus_decoder_ctli(st, req.Request, req.IntValue);
662 orXY: Result := opus_decoder_ctlxy(st, req.Request, req.XValue, req.YValue);
663 orNoValue: Result := opus_decoder_ctln(st, req.Request);
664 else
665 Result := OPUS_BAD_ARG;
666 end;
667end;
668
669function opus_multistream_encoder_ctl(st: TOpusMSEncoder; const req: TOpusCTLRequestRecord): Integer; inline;
670begin
671 case req.ReqType of
672 orPointer: Result := opus_multistream_encoder_ctlp(st, req.Request, req.PtrValue);
673 orInteger: Result := opus_multistream_encoder_ctli(st, req.Request, req.IntValue);
674 orXY: Result := opus_multistream_encoder_ctlxy(st, req.Request, req.XValue, req.YValue);
675 orNoValue: Result := opus_multistream_encoder_ctln(st, req.Request);
676 else
677 Result := OPUS_BAD_ARG;
678 end;
679end;
680
681function opus_multistream_decoder_ctl(st: TOpusMSDecoder; const req: TOpusCTLRequestRecord): Integer; inline;
682begin
683 case req.ReqType of
684 orPointer: Result := opus_multistream_decoder_ctlp(st, req.Request, req.PtrValue);
685 orInteger: Result := opus_multistream_decoder_ctli(st, req.Request, req.IntValue);
686 orXY: Result := opus_multistream_decoder_ctlxy(st, req.Request, req.XValue, req.YValue);
687 orNoValue: Result := opus_multistream_decoder_ctln(st, req.Request);
688 else
689 Result := OPUS_BAD_ARG;
690 end;
691end;
692
693end.
Note: See TracBrowser for help on using the repository browser.