objc2_avf_audio/generated/AVAudioEnvironmentNode.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Types of distance attenuation models
11///
12/// Distance attenuation is the natural attenuation of sound when traveling from the source to
13/// the listener. The different attenuation models listed below describe the drop-off in gain as
14/// the source moves away from the listener.
15///
16/// AVAudioEnvironmentDistanceAttenuationModelExponential
17/// distanceGain = (distance / referenceDistance) ^ (-rolloffFactor)
18///
19/// AVAudioEnvironmentDistanceAttenuationModelInverse
20/// distanceGain = referenceDistance / (referenceDistance + rolloffFactor *
21/// (distance – referenceDistance))
22///
23/// AVAudioEnvironmentDistanceAttenuationModelLinear
24/// distanceGain = (1 – rolloffFactor * (distance – referenceDistance) /
25/// (maximumDistance – referenceDistance))
26///
27/// With all the distance models, if the formula can not be evaluated then the source will not
28/// be attenuated. For example, if a linear model is being used with referenceDistance equal
29/// to maximumDistance, then the gain equation will have a divide-by-zero error in it. In this case,
30/// there is no attenuation for that source.
31///
32/// All the values for distance are specified in meters.
33///
34/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioenvironmentdistanceattenuationmodel?language=objc)
35// NS_ENUM
36#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct AVAudioEnvironmentDistanceAttenuationModel(pub NSInteger);
39impl AVAudioEnvironmentDistanceAttenuationModel {
40 #[doc(alias = "AVAudioEnvironmentDistanceAttenuationModelExponential")]
41 pub const Exponential: Self = Self(1);
42 #[doc(alias = "AVAudioEnvironmentDistanceAttenuationModelInverse")]
43 pub const Inverse: Self = Self(2);
44 #[doc(alias = "AVAudioEnvironmentDistanceAttenuationModelLinear")]
45 pub const Linear: Self = Self(3);
46}
47
48unsafe impl Encode for AVAudioEnvironmentDistanceAttenuationModel {
49 const ENCODING: Encoding = NSInteger::ENCODING;
50}
51
52unsafe impl RefEncode for AVAudioEnvironmentDistanceAttenuationModel {
53 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
54}
55
56extern_class!(
57 /// Parameters specifying the amount of distance attenuation
58 ///
59 /// A standalone instance of AVAudioEnvironmentDistanceAttenuationParameters cannot be created.
60 /// Only an instance vended out by a source object (e.g. AVAudioEnvironmentNode) can be used.
61 ///
62 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioenvironmentdistanceattenuationparameters?language=objc)
63 #[unsafe(super(NSObject))]
64 #[derive(Debug, PartialEq, Eq, Hash)]
65 pub struct AVAudioEnvironmentDistanceAttenuationParameters;
66);
67
68extern_conformance!(
69 unsafe impl NSObjectProtocol for AVAudioEnvironmentDistanceAttenuationParameters {}
70);
71
72impl AVAudioEnvironmentDistanceAttenuationParameters {
73 extern_methods!(
74 #[unsafe(method(init))]
75 #[unsafe(method_family = init)]
76 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
77
78 /// Type of distance attenuation model
79 ///
80 /// Default: AVAudioEnvironmentDistanceAttenuationModelInverse
81 #[unsafe(method(distanceAttenuationModel))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn distanceAttenuationModel(&self)
84 -> AVAudioEnvironmentDistanceAttenuationModel;
85
86 /// Setter for [`distanceAttenuationModel`][Self::distanceAttenuationModel].
87 #[unsafe(method(setDistanceAttenuationModel:))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn setDistanceAttenuationModel(
90 &self,
91 distance_attenuation_model: AVAudioEnvironmentDistanceAttenuationModel,
92 );
93
94 /// The minimum distance at which attenuation is applied
95 ///
96 /// Default: 1.0 meter
97 /// Models: AVAudioEnvironmentDistanceAttenuationModelInverse,
98 /// AVAudioEnvironmentDistanceAttenuationModelLinear
99 #[unsafe(method(referenceDistance))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn referenceDistance(&self) -> c_float;
102
103 /// Setter for [`referenceDistance`][Self::referenceDistance].
104 #[unsafe(method(setReferenceDistance:))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn setReferenceDistance(&self, reference_distance: c_float);
107
108 /// The distance beyond which no further attenuation is applied
109 ///
110 /// Default: 100000.0 meters
111 /// Models: AVAudioEnvironmentDistanceAttenuationModelLinear
112 #[unsafe(method(maximumDistance))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn maximumDistance(&self) -> c_float;
115
116 /// Setter for [`maximumDistance`][Self::maximumDistance].
117 #[unsafe(method(setMaximumDistance:))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn setMaximumDistance(&self, maximum_distance: c_float);
120
121 /// Determines the attenuation curve
122 ///
123 /// A higher value results in a steeper attenuation curve.
124 /// The rolloff factor should be a value greater than 0.
125 /// Default: 1.0
126 /// Models: AVAudioEnvironmentDistanceAttenuationModelExponential
127 /// AVAudioEnvironmentDistanceAttenuationModelInverse
128 /// AVAudioEnvironmentDistanceAttenuationModelLinear
129 #[unsafe(method(rolloffFactor))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn rolloffFactor(&self) -> c_float;
132
133 /// Setter for [`rolloffFactor`][Self::rolloffFactor].
134 #[unsafe(method(setRolloffFactor:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn setRolloffFactor(&self, rolloff_factor: c_float);
137 );
138}
139
140/// Methods declared on superclass `NSObject`.
141impl AVAudioEnvironmentDistanceAttenuationParameters {
142 extern_methods!(
143 #[unsafe(method(new))]
144 #[unsafe(method_family = new)]
145 pub unsafe fn new() -> Retained<Self>;
146 );
147}
148
149extern_class!(
150 /// Parameters used to control the reverb in AVAudioEnvironmentNode
151 ///
152 /// Reverberation can be used to simulate the acoustic characteristics of an environment.
153 /// AVAudioEnvironmentNode has a built in reverb that describes the space that the listener
154 /// is in.
155 ///
156 /// The reverb also has a single filter that sits at the end of the chain. This filter is useful
157 /// to shape the overall sound of the reverb. For instance, one of the reverb presets can be
158 /// selected to simulate the general space and then the filter can be used to brighten or darken
159 /// the overall sound.
160 ///
161 /// A standalone instance of AVAudioEnvironmentReverbParameters cannot be created.
162 /// Only an instance vended out by a source object (e.g. AVAudioEnvironmentNode) can be used.
163 ///
164 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioenvironmentreverbparameters?language=objc)
165 #[unsafe(super(NSObject))]
166 #[derive(Debug, PartialEq, Eq, Hash)]
167 pub struct AVAudioEnvironmentReverbParameters;
168);
169
170extern_conformance!(
171 unsafe impl NSObjectProtocol for AVAudioEnvironmentReverbParameters {}
172);
173
174impl AVAudioEnvironmentReverbParameters {
175 extern_methods!(
176 #[unsafe(method(init))]
177 #[unsafe(method_family = init)]
178 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
179
180 /// Turns on/off the reverb
181 ///
182 /// Default: NO
183 #[unsafe(method(enable))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn enable(&self) -> bool;
186
187 /// Setter for [`enable`][Self::enable].
188 #[unsafe(method(setEnable:))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn setEnable(&self, enable: bool);
191
192 /// Controls the master level of the reverb
193 ///
194 /// Range: -40 to 40 dB
195 /// Default: 0.0
196 #[unsafe(method(level))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn level(&self) -> c_float;
199
200 /// Setter for [`level`][Self::level].
201 #[unsafe(method(setLevel:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn setLevel(&self, level: c_float);
204
205 #[cfg(feature = "AVAudioUnitEQ")]
206 /// filter that applies to the output of the reverb
207 #[unsafe(method(filterParameters))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn filterParameters(&self) -> Retained<AVAudioUnitEQFilterParameters>;
210
211 #[cfg(feature = "AVAudioUnitReverb")]
212 /// Load one of the reverb's factory presets
213 ///
214 /// Parameter `preset`: Reverb preset to be set.
215 ///
216 /// Loading a factory reverb preset changes the sound of the reverb. This works independently
217 /// of the filter which follows the reverb in the signal chain.
218 #[unsafe(method(loadFactoryReverbPreset:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn loadFactoryReverbPreset(&self, preset: AVAudioUnitReverbPreset);
221 );
222}
223
224/// Methods declared on superclass `NSObject`.
225impl AVAudioEnvironmentReverbParameters {
226 extern_methods!(
227 #[unsafe(method(new))]
228 #[unsafe(method_family = new)]
229 pub unsafe fn new() -> Retained<Self>;
230 );
231}
232
233/// Types of output for AVAudio3DMixingRenderingAlgorithmAuto
234///
235/// The output type determines the rendering method for any input bus using
236/// AVAudio3DMixingRenderingAlgorithmAuto.
237///
238/// AVAudioEnvironmentOutputTypeAuto
239/// Automatically detect playback route and pick the correct output type when possible.
240/// Wired output defaults to AVAudioEnvironmentOutputTypeHeadphones and Manual Rendering
241/// with a two-channel output layout defaults to AVAudioEnvironmentOutputTypeExternalSpeakers.
242///
243/// AVAudioEnvironmentOutputTypeHeadphones
244/// Render for headphones.
245///
246/// AVAudioEnvironmentOutputTypeBuiltInSpeakers
247/// Render for built-in speakers on the current hardware. The output will not be suitable
248/// for playback on other hardware. On iOS devices, the rendering may be specific to
249/// device orientation. Manual Rendering modes may not provide the intended rendering if
250/// the orientation changes between rendering the audio and playing it back.
251///
252/// AVAudioEnvironmentOutputTypeExternalSpeakers
253/// Render for external speakers based on the environment node's output channel layout.
254///
255/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioenvironmentoutputtype?language=objc)
256// NS_ENUM
257#[repr(transparent)]
258#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
259pub struct AVAudioEnvironmentOutputType(pub NSInteger);
260impl AVAudioEnvironmentOutputType {
261 #[doc(alias = "AVAudioEnvironmentOutputTypeAuto")]
262 pub const Auto: Self = Self(0);
263 #[doc(alias = "AVAudioEnvironmentOutputTypeHeadphones")]
264 pub const Headphones: Self = Self(1);
265 #[doc(alias = "AVAudioEnvironmentOutputTypeBuiltInSpeakers")]
266 pub const BuiltInSpeakers: Self = Self(2);
267 #[doc(alias = "AVAudioEnvironmentOutputTypeExternalSpeakers")]
268 pub const ExternalSpeakers: Self = Self(3);
269}
270
271unsafe impl Encode for AVAudioEnvironmentOutputType {
272 const ENCODING: Encoding = NSInteger::ENCODING;
273}
274
275unsafe impl RefEncode for AVAudioEnvironmentOutputType {
276 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
277}
278
279extern_class!(
280 /// Mixer node that simulates a 3D environment
281 ///
282 /// AVAudioEnvironmentNode is a mixer node that simulates a 3D audio environment. Any node that
283 /// conforms to the AVAudioMixing protocol (e.g. AVAudioPlayerNode) can act as a source in this
284 /// environment.
285 ///
286 /// The environment has an implicit "listener". By controlling the listener's position and
287 /// orientation, the application controls the way the user experiences the virtual world.
288 /// In addition, this node also defines properties for distance attenuation and reverberation
289 /// that help characterize the environment.
290 ///
291 /// It is important to note that AVAudio3DMixingSourceMode affects how inputs with different channel
292 /// configurations are rendered. By default, only inputs with a mono channel are spatialized.
293 ///
294 /// In order to set the environment node’s output to a multichannel format, use an AVAudioFormat
295 /// with a desired AudioChannelLayout.
296 ///
297 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioenvironmentnode?language=objc)
298 #[unsafe(super(AVAudioNode, NSObject))]
299 #[derive(Debug, PartialEq, Eq, Hash)]
300 #[cfg(feature = "AVAudioNode")]
301 pub struct AVAudioEnvironmentNode;
302);
303
304#[cfg(all(feature = "AVAudioMixing", feature = "AVAudioNode"))]
305extern_conformance!(
306 unsafe impl AVAudio3DMixing for AVAudioEnvironmentNode {}
307);
308
309#[cfg(all(feature = "AVAudioMixing", feature = "AVAudioNode"))]
310extern_conformance!(
311 unsafe impl AVAudioMixing for AVAudioEnvironmentNode {}
312);
313
314#[cfg(all(feature = "AVAudioMixing", feature = "AVAudioNode"))]
315extern_conformance!(
316 unsafe impl AVAudioStereoMixing for AVAudioEnvironmentNode {}
317);
318
319#[cfg(feature = "AVAudioNode")]
320extern_conformance!(
321 unsafe impl NSObjectProtocol for AVAudioEnvironmentNode {}
322);
323
324#[cfg(feature = "AVAudioNode")]
325impl AVAudioEnvironmentNode {
326 extern_methods!(
327 #[unsafe(method(init))]
328 #[unsafe(method_family = init)]
329 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
330
331 /// Type of output hardware to be used with AVAudio3DMixingRenderingAlgorithmAuto
332 ///
333 /// Output hardware cannot be automatically determined in Manual Rendering modes or for wired
334 /// output. This property can be used to override the output type if the correct type is known.
335 ///
336 /// Selecting an output type that does not match the actual hardware can produce unexpected
337 /// results, especially with AVAudioEnvironmentOutputTypeBuiltInSpeakers. An app choosing
338 /// a value other than AVAudio3DMixingOutputTypeAuto should listen to route change
339 /// notifications and update the output type accordingly.
340 ///
341 /// Default: AVAudio3DMixingOutputTypeAuto
342 #[unsafe(method(outputType))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn outputType(&self) -> AVAudioEnvironmentOutputType;
345
346 /// Setter for [`outputType`][Self::outputType].
347 #[unsafe(method(setOutputType:))]
348 #[unsafe(method_family = none)]
349 pub unsafe fn setOutputType(&self, output_type: AVAudioEnvironmentOutputType);
350
351 /// The mixer's output volume.
352 ///
353 /// This accesses the mixer's output volume (0.0-1.0, inclusive).
354 #[unsafe(method(outputVolume))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn outputVolume(&self) -> c_float;
357
358 /// Setter for [`outputVolume`][Self::outputVolume].
359 #[unsafe(method(setOutputVolume:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn setOutputVolume(&self, output_volume: c_float);
362
363 #[cfg(feature = "AVAudioTypes")]
364 /// Find an unused input bus
365 ///
366 /// This will find and return the first input bus to which no other node is connected.
367 #[unsafe(method(nextAvailableInputBus))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn nextAvailableInputBus(&self) -> AVAudioNodeBus;
370
371 #[cfg(feature = "AVAudioTypes")]
372 /// Sets the listener's position in the 3D environment
373 ///
374 /// The coordinates are specified in meters.
375 /// Default:
376 /// The default position of the listener is at the origin.
377 /// x: 0.0
378 /// y: 0.0
379 /// z: 0.0
380 #[unsafe(method(listenerPosition))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn listenerPosition(&self) -> AVAudio3DPoint;
383
384 #[cfg(feature = "AVAudioTypes")]
385 /// Setter for [`listenerPosition`][Self::listenerPosition].
386 #[unsafe(method(setListenerPosition:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn setListenerPosition(&self, listener_position: AVAudio3DPoint);
389
390 #[cfg(feature = "AVAudioTypes")]
391 /// The listener's orientation in the environment
392 ///
393 /// Changing listenerVectorOrientation will result in a corresponding change in listenerAngularOrientation.
394 /// Default:
395 /// The default orientation is with the listener looking directly along the negative Z axis.
396 /// forward: (0, 0, -1)
397 /// up: (0, 1, 0)
398 #[unsafe(method(listenerVectorOrientation))]
399 #[unsafe(method_family = none)]
400 pub unsafe fn listenerVectorOrientation(&self) -> AVAudio3DVectorOrientation;
401
402 #[cfg(feature = "AVAudioTypes")]
403 /// Setter for [`listenerVectorOrientation`][Self::listenerVectorOrientation].
404 #[unsafe(method(setListenerVectorOrientation:))]
405 #[unsafe(method_family = none)]
406 pub unsafe fn setListenerVectorOrientation(
407 &self,
408 listener_vector_orientation: AVAudio3DVectorOrientation,
409 );
410
411 #[cfg(feature = "AVAudioTypes")]
412 /// The listener's orientation in the environment
413 ///
414 /// Changing listenerAngularOrientation will result in a corresponding change in listenerVectorOrientation.
415 /// All angles are specified in degrees.
416 /// Default:
417 /// The default orientation is with the listener looking directly along the negative Z axis.
418 /// yaw: 0.0
419 /// pitch: 0.0
420 /// roll: 0.0
421 #[unsafe(method(listenerAngularOrientation))]
422 #[unsafe(method_family = none)]
423 pub unsafe fn listenerAngularOrientation(&self) -> AVAudio3DAngularOrientation;
424
425 #[cfg(feature = "AVAudioTypes")]
426 /// Setter for [`listenerAngularOrientation`][Self::listenerAngularOrientation].
427 #[unsafe(method(setListenerAngularOrientation:))]
428 #[unsafe(method_family = none)]
429 pub unsafe fn setListenerAngularOrientation(
430 &self,
431 listener_angular_orientation: AVAudio3DAngularOrientation,
432 );
433
434 /// The distance attenuation parameters for the environment
435 #[unsafe(method(distanceAttenuationParameters))]
436 #[unsafe(method_family = none)]
437 pub unsafe fn distanceAttenuationParameters(
438 &self,
439 ) -> Retained<AVAudioEnvironmentDistanceAttenuationParameters>;
440
441 /// The reverb parameters for the environment
442 #[unsafe(method(reverbParameters))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn reverbParameters(&self) -> Retained<AVAudioEnvironmentReverbParameters>;
445
446 /// Returns an array of AVAudio3DMixingRenderingAlgorithm values based on the current output format
447 ///
448 /// AVAudioEnvironmentNode supports several rendering algorithms per input bus which are defined
449 /// in
450 /// <AVFAudio
451 /// /AVAudioMixing.h>.
452 ///
453 /// Depending on the current output format of the environment node, this method returns
454 /// an immutable array of the applicable rendering algorithms. This is important when the
455 /// environment node has been configured to a multichannel output format because only a subset
456 /// of the available rendering algorithms are designed to render to all of the channels.
457 ///
458 /// This information should be retrieved after a successful connection to the destination node
459 /// via the engine's connect method.
460 #[unsafe(method(applicableRenderingAlgorithms))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn applicableRenderingAlgorithms(&self) -> Retained<NSArray<NSNumber>>;
463
464 /// On capable devices, listener orientation will be automatically rotated based on user's head-orientation if enabled.
465 #[unsafe(method(isListenerHeadTrackingEnabled))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn isListenerHeadTrackingEnabled(&self) -> bool;
468
469 /// Setter for [`isListenerHeadTrackingEnabled`][Self::isListenerHeadTrackingEnabled].
470 #[unsafe(method(setListenerHeadTrackingEnabled:))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn setListenerHeadTrackingEnabled(&self, listener_head_tracking_enabled: bool);
473 );
474}
475
476/// Methods declared on superclass `NSObject`.
477#[cfg(feature = "AVAudioNode")]
478impl AVAudioEnvironmentNode {
479 extern_methods!(
480 #[unsafe(method(new))]
481 #[unsafe(method_family = new)]
482 pub unsafe fn new() -> Retained<Self>;
483 );
484}