1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4
5use std::os::raw::{c_char, c_int, c_long, c_short, c_uint, c_ulong, c_void};
6
7pub const MYSOFA_DEFAULT_NEIGH_STEP_ANGLE: f64 = 0.5;
8pub const MYSOFA_DEFAULT_NEIGH_STEP_RADIUS: f64 = 0.01;
9
10pub type size_t = c_ulong;
11pub type wchar_t = c_int;
12
13#[repr(C)]
14#[derive(Debug, Copy, Clone)]
15pub struct MYSOFA_ATTRIBUTE {
16 pub next: *mut MYSOFA_ATTRIBUTE,
17 pub name: *mut c_char,
18 pub value: *mut c_char,
19}
20
21#[repr(C)]
22#[derive(Debug, Copy, Clone)]
23pub struct MYSOFA_ARRAY {
24 pub values: *mut f32,
25 pub elements: c_uint,
26 pub attributes: *mut MYSOFA_ATTRIBUTE,
27}
28
29#[repr(C)]
30#[derive(Debug, Copy, Clone)]
31pub struct MYSOFA_VARIABLE {
32 pub next: *mut MYSOFA_VARIABLE,
33 pub name: *mut c_char,
34 pub value: *mut MYSOFA_ARRAY,
35}
36
37#[repr(C)]
38#[derive(Debug, Copy, Clone)]
39pub struct MYSOFA_HRTF {
40 pub I: c_uint,
41 pub C: c_uint,
42 pub R: c_uint,
43 pub E: c_uint,
44 pub N: c_uint,
45 pub M: c_uint,
46
47 pub ListenerPosition: MYSOFA_ARRAY,
48 pub ReceiverPosition: MYSOFA_ARRAY,
49 pub SourcePosition: MYSOFA_ARRAY,
50 pub EmitterPosition: MYSOFA_ARRAY,
51 pub ListenerUp: MYSOFA_ARRAY,
52 pub ListenerView: MYSOFA_ARRAY,
53 pub DataIR: MYSOFA_ARRAY,
54 pub DataSamplingRate: MYSOFA_ARRAY,
55 pub DataDelay: MYSOFA_ARRAY,
56 pub attributes: *mut MYSOFA_ATTRIBUTE,
57 pub variables: *mut MYSOFA_VARIABLE,
58}
59
60#[repr(C)]
61#[derive(Debug, Copy, Clone)]
62pub struct MYSOFA_LOOKUP {
63 pub kdtree: *mut c_void,
64 pub radius_min: f32,
65 pub radius_max: f32,
66 pub theta_min: f32,
67 pub theta_max: f32,
68 pub phi_min: f32,
69 pub phi_max: f32,
70}
71
72#[repr(C)]
73#[derive(Debug, Copy, Clone)]
74pub struct MYSOFA_NEIGHBORHOOD {
75 pub elements: c_int,
76 pub index: *mut c_int,
77}
78
79pub const MYSOFA_OK: c_int = 0;
80pub const MYSOFA_INTERNAL_ERROR: c_int = -1;
81pub const MYSOFA_INVALID_FORMAT: c_int = 10000;
82pub const MYSOFA_UNSUPPORTED_FORMAT: c_int = 10001;
83pub const MYSOFA_NO_MEMORY: c_int = 10002;
84pub const MYSOFA_READ_ERROR: c_int = 10003;
85pub const MYSOFA_INVALID_ATTRIBUTES: c_int = 10004;
86pub const MYSOFA_INVALID_DIMENSIONS: c_int = 10005;
87pub const MYSOFA_INVALID_DIMENSION_LIST: c_int = 10006;
88pub const MYSOFA_INVALID_COORDINATE_TYPE: c_int = 10007;
89pub const MYSOFA_ONLY_EMITTER_WITH_ECI_SUPPORTED: c_int = 10008;
90pub const MYSOFA_ONLY_DELAYS_WITH_IR_OR_MR_SUPPORTED: c_int = 10009;
91pub const MYSOFA_ONLY_THE_SAME_SAMPLING_RATE_SUPPORTED: c_int = 10010;
92pub const MYSOFA_RECEIVERS_WITH_RCI_SUPPORTED: c_int = 10011;
93pub const MYSOFA_RECEIVERS_WITH_CARTESIAN_SUPPORTED: c_int = 10012;
94pub const MYSOFA_INVALID_RECEIVER_POSITIONS: c_int = 10013;
95pub const MYSOFA_ONLY_SOURCES_WITH_MC_SUPPORTED: c_int = 10014;
96
97extern "C" {
98 pub fn mysofa_load(filename: *const c_char, err: *mut c_int) -> *mut MYSOFA_HRTF;
99 pub fn mysofa_check(hrtf: *mut MYSOFA_HRTF) -> c_int;
100 pub fn mysofa_getAttribute(attr: *mut MYSOFA_ATTRIBUTE, name: *mut c_char) -> *mut c_char;
101 pub fn mysofa_tospherical(hrtf: *mut MYSOFA_HRTF);
102 pub fn mysofa_tocartesian(hrtf: *mut MYSOFA_HRTF);
103 pub fn mysofa_free(hrtf: *mut MYSOFA_HRTF);
104 pub fn mysofa_lookup_init(hrtf: *mut MYSOFA_HRTF) -> *mut MYSOFA_LOOKUP;
105 pub fn mysofa_lookup(lookup: *mut MYSOFA_LOOKUP, coordinate: *mut f32) -> c_int;
106 pub fn mysofa_lookup_free(lookup: *mut MYSOFA_LOOKUP);
107 pub fn mysofa_neighborhood_init(
108 hrtf: *mut MYSOFA_HRTF,
109 lookup: *mut MYSOFA_LOOKUP,
110 ) -> *mut MYSOFA_NEIGHBORHOOD;
111 pub fn mysofa_neighborhood_init_withstepdefine(
112 hrtf: *mut MYSOFA_HRTF,
113 lookup: *mut MYSOFA_LOOKUP,
114 neighbor_angle_step: f32,
115 neighbor_radius_step: f32,
116 ) -> *mut MYSOFA_NEIGHBORHOOD;
117 pub fn mysofa_neighborhood(neighborhood: *mut MYSOFA_NEIGHBORHOOD, pos: c_int) -> *mut c_int;
118 pub fn mysofa_neighborhood_free(neighborhood: *mut MYSOFA_NEIGHBORHOOD);
119 pub fn mysofa_interpolate(
120 hrtf: *mut MYSOFA_HRTF,
121 cordinate: *mut f32,
122 nearest: c_int,
123 neighborhood: *mut c_int,
124 fir: *mut f32,
125 delays: *mut f32,
126 ) -> *mut f32;
127 pub fn mysofa_resample(hrtf: *mut MYSOFA_HRTF, samplerate: f32) -> c_int;
128 pub fn mysofa_loudness(hrtf: *mut MYSOFA_HRTF) -> f32;
129 pub fn mysofa_minphase(hrtf: *mut MYSOFA_HRTF, threshold: f32) -> c_int;
130 pub fn mysofa_cache_lookup(filename: *const c_char, samplerate: f32) -> *mut MYSOFA_EASY;
131 pub fn mysofa_cache_store(
132 arg1: *mut MYSOFA_EASY,
133 filename: *const c_char,
134 samplerate: f32,
135 ) -> *mut MYSOFA_EASY;
136 pub fn mysofa_cache_release(arg1: *mut MYSOFA_EASY);
137 pub fn mysofa_cache_release_all();
138 pub fn mysofa_c2s(values: *mut f32);
139 pub fn mysofa_s2c(values: *mut f32);
140}
141
142#[repr(C)]
143#[derive(Debug, Copy, Clone)]
144pub struct MYSOFA_EASY {
145 pub hrtf: *mut MYSOFA_HRTF,
146 pub lookup: *mut MYSOFA_LOOKUP,
147 pub neighborhood: *mut MYSOFA_NEIGHBORHOOD,
148 pub fir: *mut f32,
149}
150
151extern "C" {
152 pub fn mysofa_open(
153 filename: *const c_char,
154 samplerate: f32,
155 filterlength: *mut c_int,
156 err: *mut c_int,
157 ) -> *mut MYSOFA_EASY;
158
159 pub fn mysofa_open_no_norm(
160 filename: *const c_char,
161 samplerate: f32,
162 filterlength: *mut c_int,
163 err: *mut c_int,
164 ) -> *mut MYSOFA_EASY;
165
166 pub fn mysofa_open_advanced(
167 filename: *const c_char,
168 samplerate: f32,
169 filterlength: *mut c_int,
170 err: *mut c_int,
171 norm: bool,
172 neighbor_angle_step: f32,
173 neighbor_radius_step: f32,
174 ) -> *mut MYSOFA_EASY;
175
176 pub fn mysofa_open_data(
177 data: *const c_char,
178 size: c_long,
179 samplerate: f32,
180 filterlength: *mut c_int,
181 err: *mut c_int,
182 ) -> *mut MYSOFA_EASY;
183
184 pub fn mysofa_open_data_no_norm(
185 data: *const c_char,
186 size: c_long,
187 samplerate: f32,
188 filterlength: *mut c_int,
189 err: *mut c_int,
190 ) -> *mut MYSOFA_EASY;
191
192 pub fn mysofa_open_data_advanced(
193 data: *const c_char,
194 size: c_long,
195 samplerate: f32,
196 filterlength: *mut c_int,
197 err: *mut c_int,
198 norm: bool,
199 neighbor_angle_step: f32,
200 neighbor_radius_step: f32,
201 ) -> *mut MYSOFA_EASY;
202
203 pub fn mysofa_open_cached(
204 filename: *const c_char,
205 samplerate: f32,
206 filterlength: *mut c_int,
207 err: *mut c_int,
208 ) -> *mut MYSOFA_EASY;
209
210 pub fn mysofa_getfilter_short(
211 easy: *mut MYSOFA_EASY,
212 x: f32,
213 y: f32,
214 z: f32,
215 IRleft: *mut c_short,
216 IRright: *mut c_short,
217 delayLeft: *mut c_int,
218 delayRight: *mut c_int,
219 );
220
221 pub fn mysofa_getfilter_float(
222 easy: *mut MYSOFA_EASY,
223 x: f32,
224 y: f32,
225 z: f32,
226 IRleft: *mut f32,
227 IRright: *mut f32,
228 delayLeft: *mut f32,
229 delayRight: *mut f32,
230 );
231
232 pub fn mysofa_getfilter_float_nointerp(
233 easy: *mut MYSOFA_EASY,
234 x: f32,
235 y: f32,
236 z: f32,
237 IRleft: *mut f32,
238 IRright: *mut f32,
239 delayLeft: *mut f32,
240 delayRight: *mut f32,
241 );
242
243 pub fn mysofa_close(easy: *mut MYSOFA_EASY);
244 pub fn mysofa_close_cached(easy: *mut MYSOFA_EASY);
245 pub fn mysofa_getversion(major: *mut c_int, minor: *mut c_int, patch: *mut c_int);
246}