10 CTypes
, SysUtils
, ogg
;
12 {$IF DEFINED(WINDOWS)}
13 {$IFDEF OPUS_WINDOZE_STATIC}
14 {$LINKLIB libopusfile.a}
17 {$DEFINE OPUS_DYNAMIC}
18 const opuslib
= 'libopus-0.dll';
19 const opusfilelib
= 'libopusfile-0.dll';
21 {$ELSEIF DEFINED(UNIX)}
22 {$DEFINE OPUS_DYNAMIC}
23 const opuslib
= 'libopus.so';
24 const opusfilelib
= 'libopusfile.so';
26 {$ERROR libopus not supported on this platform. Fix it!}
43 OP_EBADTIMESTAMP
= -139;
48 OPUS_BUFFER_TOO_SMALL
= -2;
49 OPUS_INTERNAL_ERROR
= -3;
50 OPUS_INVALID_PACKET
= -4;
51 OPUS_UNIMPLEMENTED
= -5;
52 OPUS_INVALID_STATE
= -6;
55 OPUS_APPLICATION_VOIP
= 2048;
56 OPUS_APPLICATION_AUDIO
= 2049;
57 OPUS_APPLICATION_RESTRICTED_LOWDELAY
= 2051;
59 OPUS_SIGNAL_VOICE
= 3001; // Signal being encoded is voice
60 OPUS_SIGNAL_MUSIC
= 3002; // Signal being encoded is music
62 OPUS_BANDWIDTH_NARROWBAND
= 1101; // 4 kHz bandpass @hideinitializer
63 OPUS_BANDWIDTH_MEDIUMBAND
= 1102; // 6 kHz bandpass @hideinitializer
64 OPUS_BANDWIDTH_WIDEBAND
= 1103; // 8 kHz bandpass @hideinitializer
65 OPUS_BANDWIDTH_SUPERWIDEBAND
= 1104; // 12 kHz bandpass @hideinitializer
66 OPUS_BANDWIDTH_FULLBAND
= 1105; // 20 kHz bandpass @hideinitializer
68 OPUS_FRAMESIZE_ARG
= 5000; // Select frame size from the argument (default)
69 OPUS_FRAMESIZE_2_5_MS
= 5001; // Use 2.5 ms frames
70 OPUS_FRAMESIZE_5_MS
= 5002; // Use 5 ms frames
71 OPUS_FRAMESIZE_10_MS
= 5003; // Use 10 ms frames
72 OPUS_FRAMESIZE_20_MS
= 5004; // Use 20 ms frames
73 OPUS_FRAMESIZE_40_MS
= 5005; // Use 40 ms frames
74 OPUS_FRAMESIZE_60_MS
= 5006; // Use 60 ms frames
76 OPUS_CHANNEL_COUNT_MAX
= 255;
79 OPUS_SET_APPLICATION_REQUEST
= 4000;
80 OPUS_GET_APPLICATION_REQUEST
= 4001;
81 OPUS_SET_BITRATE_REQUEST
= 4002;
82 OPUS_GET_BITRATE_REQUEST
= 4003;
83 OPUS_SET_MAX_BANDWIDTH_REQUEST
= 4004;
84 OPUS_GET_MAX_BANDWIDTH_REQUEST
= 4005;
85 OPUS_SET_VBR_REQUEST
= 4006;
86 OPUS_GET_VBR_REQUEST
= 4007;
87 OPUS_SET_BANDWIDTH_REQUEST
= 4008;
88 OPUS_GET_BANDWIDTH_REQUEST
= 4009;
89 OPUS_SET_COMPLEXITY_REQUEST
= 4010;
90 OPUS_GET_COMPLEXITY_REQUEST
= 4011;
91 OPUS_SET_INBAND_FEC_REQUEST
= 4012;
92 OPUS_GET_INBAND_FEC_REQUEST
= 4013;
93 OPUS_SET_PACKET_LOSS_PERC_REQUEST
= 4014;
94 OPUS_GET_PACKET_LOSS_PERC_REQUEST
= 4015;
95 OPUS_SET_DTX_REQUEST
= 4016;
96 OPUS_GET_DTX_REQUEST
= 4017;
97 OPUS_SET_VBR_CONSTRAINT_REQUEST
= 4020;
98 OPUS_GET_VBR_CONSTRAINT_REQUEST
= 4021;
99 OPUS_SET_FORCE_CHANNELS_REQUEST
= 4022;
100 OPUS_GET_FORCE_CHANNELS_REQUEST
= 4023;
101 OPUS_SET_SIGNAL_REQUEST
= 4024;
102 OPUS_GET_SIGNAL_REQUEST
= 4025;
103 OPUS_GET_LOOKAHEAD_REQUEST
= 4027;
104 OPUS_RESET_STATE_REQUEST
= 4028;
105 OPUS_GET_SAMPLE_RATE_REQUEST
= 4029;
106 OPUS_GET_FINAL_RANGE_REQUEST
= 4031;
107 OPUS_GET_PITCH_REQUEST
= 4033;
108 OPUS_SET_GAIN_REQUEST
= 4034;
109 OPUS_GET_GAIN_REQUEST
= 4045;
110 OPUS_SET_LSB_DEPTH_REQUEST
= 4036;
111 OPUS_GET_LSB_DEPTH_REQUEST
= 4037;
112 OPUS_GET_LAST_PACKET_DURATION_REQUEST
= 4039;
113 OPUS_SET_EXPERT_FRAME_DURATION_REQUEST
= 4040;
114 OPUS_GET_EXPERT_FRAME_DURATION_REQUEST
= 4041;
115 OPUS_SET_PREDICTION_DISABLED_REQUEST
= 4042;
116 OPUS_GET_PREDICTION_DISABLED_REQUEST
= 4043;
117 OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST
= 5120;
118 OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST
= 5122;
125 input_sample_rate
: cuint32
;
127 mapping_family
: cint
;
130 mapping
: array [0..OPUS_CHANNEL_COUNT_MAX
-1] of byte;
132 POpusHead
= ^OpusHead
;
135 OggOpusFile
= record end;
136 POggOpusFile
= ^OggOpusFile
;
139 op_read_func
= function (stream
: Pointer; buffer
: pointer; nbytes
: cint
): cint
; cdecl;
140 op_seek_func
= function (stream
: Pointer; offset
: Int64; whence
: cint
): cint
; cdecl;
141 op_tell_func
= function (stream
: Pointer): Int64; cdecl;
142 op_close_func
= function (stream
: Pointer): cint
; cdecl;
144 OpusFileCallbacks
= record
148 close
: op_close_func
;
151 function opus_get_version_string(): PAnsiChar; cdecl; external {$IFDEF OPUS_DYNAMIC}opuslib
{$ENDIF};
152 function opus_strerror(error
: cint
): PAnsiChar; cdecl; external {$IFDEF OPUS_DYNAMIC}opuslib
{$ENDIF};
154 function op_open_file(path
: pchar; err
: pcint
): POggOpusFile
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
155 function op_open_memory(data
: pointer; size
: csize_t
; err
: pcint
): POggOpusFile
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
157 function op_test_file(path
: pchar; err
: pcint
): POggOpusFile
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
158 function op_test_memory(data
: pointer; size
: csize_t
; err
: pcint
): POggOpusFile
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
160 procedure op_free(opf
: POggOpusFile
); cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
162 function op_seekable(opf
: POggOpusFile
): cint
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
163 function op_channel_count(opf
: POggOpusFile
): cuint32
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
164 function op_head(opf
: POggOpusFile
; li
: cint
): POpusHead
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
165 function op_pcm_tell(opf
: POggOpusFile
): cint64
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
166 function op_pcm_total(opf
: POggOpusFile
; li
: cint
): cint64
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
168 function op_read(opf
: POggOpusFile
; pcm
: pcint16
; bufsiz
: cint
; li
: cint
): cint
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
169 function op_read_stereo(opf
: POggOpusFile
; pcm
: pcint16
; bufsiz
: cint
): cint
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};
170 function op_pcm_seek(opf
: POggOpusFile
; pos
: cint64
): cint
; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib
{$ENDIF};