objc2_avf_audio/generated/AVAudioMixing.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::*;
6
7use crate::*;
8
9extern_protocol!(
10 /// Protocol that defines properties applicable to the input bus of a mixer
11 /// node
12 ///
13 /// Nodes that conform to the AVAudioMixing protocol can talk to a mixer node downstream,
14 /// specifically of type AVAudioMixerNode or AVAudioEnvironmentNode. The properties defined
15 /// by this protocol apply to the respective input bus of the mixer node that the source node is
16 /// connected to. Note that effect nodes cannot talk to their downstream mixer.
17 ///
18 /// Properties can be set either on the source node, or directly on individual mixer connections.
19 /// Source node properties are:
20 /// - applied to all existing mixer connections when set
21 /// - applied to new mixer connections
22 /// - preserved upon disconnection from mixers
23 /// - not affected by connections/disconnections to/from mixers
24 /// - not affected by any direct changes to properties on individual mixer connections
25 ///
26 /// Individual mixer connection properties, when set, will override any values previously derived
27 /// from the corresponding source node properties. However, if a source node property is
28 /// subsequently set, it will override the corresponding property value of all individual mixer
29 /// connections.
30 /// Unlike source node properties, individual mixer connection properties are not preserved upon
31 /// disconnection (see `AVAudioMixing(destinationForMixer:bus:)` and `AVAudioMixingDestination`).
32 ///
33 /// Source nodes that are connected to a mixer downstream can be disconnected from
34 /// one mixer and connected to another mixer with source node's mixing settings intact.
35 /// For example, an AVAudioPlayerNode that is being used in a gaming scenario can set up its
36 /// 3D mixing settings and then move from one environment to another.
37 ///
38 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiomixing?language=objc)
39 pub unsafe trait AVAudioMixing: AVAudioStereoMixing + AVAudio3DMixing {
40 #[cfg(all(feature = "AVAudioNode", feature = "AVAudioTypes"))]
41 /// Returns the AVAudioMixingDestination object corresponding to specified mixer node and
42 /// its input bus
43 ///
44 /// When a source node is connected to multiple mixers downstream, setting AVAudioMixing
45 /// properties directly on the source node will apply the change to all the mixers downstream.
46 /// If you want to set/get properties on a specific mixer, use this method to get the
47 /// corresponding AVAudioMixingDestination and set/get properties on it.
48 ///
49 /// Note:
50 /// - Properties set on individual AVAudioMixingDestination instances will not reflect at the
51 /// source node level.
52 ///
53 /// - AVAudioMixingDestination reference returned by this method could become invalid when
54 /// there is any disconnection between the source and the mixer node. Hence this reference
55 /// should not be retained and should be fetched every time you want to set/get properties
56 /// on a specific mixer.
57 ///
58 /// If the source node is not connected to the specified mixer/input bus, this method
59 /// returns nil.
60 ///
61 /// Calling this on an AVAudioMixingDestination instance returns self if the specified
62 /// mixer/input bus matches its connection point, otherwise, it returns nil.
63 #[unsafe(method(destinationForMixer:bus:))]
64 #[unsafe(method_family = none)]
65 unsafe fn destinationForMixer_bus(
66 &self,
67 mixer: &AVAudioNode,
68 bus: AVAudioNodeBus,
69 ) -> Option<Retained<AVAudioMixingDestination>>;
70
71 /// Set a bus's input volume
72 ///
73 /// Range: 0.0 -> 1.0
74 /// Default: 1.0
75 /// Mixers: AVAudioMixerNode, AVAudioEnvironmentNode
76 #[unsafe(method(volume))]
77 #[unsafe(method_family = none)]
78 unsafe fn volume(&self) -> c_float;
79
80 /// Setter for [`volume`][Self::volume].
81 #[unsafe(method(setVolume:))]
82 #[unsafe(method_family = none)]
83 unsafe fn setVolume(&self, volume: c_float);
84 }
85);
86
87extern_protocol!(
88 /// Protocol that defines stereo mixing properties
89 ///
90 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiostereomixing?language=objc)
91 pub unsafe trait AVAudioStereoMixing: NSObjectProtocol {
92 /// Set a bus's stereo pan
93 ///
94 /// Range: -1.0 -> 1.0
95 /// Default: 0.0
96 /// Mixer: AVAudioMixerNode
97 #[unsafe(method(pan))]
98 #[unsafe(method_family = none)]
99 unsafe fn pan(&self) -> c_float;
100
101 /// Setter for [`pan`][Self::pan].
102 #[unsafe(method(setPan:))]
103 #[unsafe(method_family = none)]
104 unsafe fn setPan(&self, pan: c_float);
105 }
106);
107
108/// Types of rendering algorithms available per input bus of the environment node
109///
110/// The rendering algorithms differ in terms of quality and cpu cost.
111/// AVAudio3DMixingRenderingAlgorithmEqualPowerPanning is the simplest panning algorithm and also
112/// the least expensive computationally.
113///
114/// When rendering to multi-channel hardware, audio data will only be rendered to channels 1
115/// &
116/// 2
117/// with all rendering algorithms except AVAudio3DMixingRenderingAlgorithmSoundField and
118/// AVAudio3DMixingRenderingAlgorithmAuto.
119///
120/// AVAudio3DMixingRenderingAlgorithmEqualPowerPanning
121/// EqualPowerPanning merely pans the data of the mixer bus into a stereo field. This
122/// algorithm is analogous to the pan knob found on a mixing board channel strip.
123///
124/// AVAudio3DMixingRenderingAlgorithmSphericalHead
125/// SphericalHead is designed to emulate 3 dimensional space in headphones by simulating
126/// inter-aural time delays and other spatial cues. SphericalHead is slightly less CPU
127/// intensive than the HRTF algorithm.
128///
129/// AVAudio3DMixingRenderingAlgorithmHRTF
130/// HRTF (Head Related Transfer Function) is a high quality algorithm using filtering to
131/// emulate 3 dimensional space in headphones. HRTF is a cpu intensive algorithm.
132///
133/// AVAudio3DMixingRenderingAlgorithmHRTFHQ
134/// Higher quality HRTF rendering algorithm compared to AVAudio3DMixingRenderingAlgorithmHRTF.
135/// Improvements have been made to the overall frequency response and localization of
136/// sources in a 3D space.
137///
138/// AVAudio3DMixingRenderingAlgorithmSoundField
139/// SoundField is designed for rendering to multi channel hardware. The mixer takes data
140/// being rendered with SoundField and distributes it amongst all the output channels with
141/// a weighting toward the location in which the sound derives. It is very effective for
142/// ambient sounds, which may derive from a specific location in space, yet should be heard
143/// through the listener's entire space.
144///
145/// AVAudio3DMixingRenderingAlgorithmStereoPassThrough
146/// StereoPassThrough should be used when no localization is desired for the source data.
147/// Setting this algorithm tells the mixer to pass the input channels to output without
148/// localization. If the input and output AudioChannelLayouts differ, mixing is done
149/// according to the kAudioFormatProperty_MatrixMixMap property of the layouts.
150///
151/// AVAudio3DMixingRenderingAlgorithmAuto
152/// Automatically pick the highest-quality rendering algorithm available for current playback
153/// hardware. The algorithm may not be identical to other existing algorithms and may change
154/// in the future as new algorithms are developed. When using Manual Rendering modes or
155/// wired output, it may be necessary to manually set the AVAudioEnvironmentNode's output
156/// type. Multi-channel rendering requires setting a channel layout on the
157/// AVAudioEnvironmentNode's output.
158///
159/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudio3dmixingrenderingalgorithm?language=objc)
160// NS_ENUM
161#[repr(transparent)]
162#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
163pub struct AVAudio3DMixingRenderingAlgorithm(pub NSInteger);
164impl AVAudio3DMixingRenderingAlgorithm {
165 #[doc(alias = "AVAudio3DMixingRenderingAlgorithmEqualPowerPanning")]
166 pub const EqualPowerPanning: Self = Self(0);
167 #[doc(alias = "AVAudio3DMixingRenderingAlgorithmSphericalHead")]
168 pub const SphericalHead: Self = Self(1);
169 #[doc(alias = "AVAudio3DMixingRenderingAlgorithmHRTF")]
170 pub const HRTF: Self = Self(2);
171 #[doc(alias = "AVAudio3DMixingRenderingAlgorithmSoundField")]
172 pub const SoundField: Self = Self(3);
173 #[doc(alias = "AVAudio3DMixingRenderingAlgorithmStereoPassThrough")]
174 pub const StereoPassThrough: Self = Self(5);
175 #[doc(alias = "AVAudio3DMixingRenderingAlgorithmHRTFHQ")]
176 pub const HRTFHQ: Self = Self(6);
177 #[doc(alias = "AVAudio3DMixingRenderingAlgorithmAuto")]
178 pub const Auto: Self = Self(7);
179}
180
181unsafe impl Encode for AVAudio3DMixingRenderingAlgorithm {
182 const ENCODING: Encoding = NSInteger::ENCODING;
183}
184
185unsafe impl RefEncode for AVAudio3DMixingRenderingAlgorithm {
186 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
187}
188
189/// Source types available per input bus of the environment node
190///
191/// The source types differ in how the individual channels of an input bus are distributed
192/// in space.
193///
194/// AVAudio3DMixingSourceModeSpatializeIfMono
195/// A mono input bus is rendered as a point source at the location of the source node.
196/// An input bus with more than one channel is bypassed. This corresponds to legacy
197/// behavior and is equivalent to AVAudio3DMixingSourceModePointSource for a mono bus
198/// and AVAudio3DMixingSourceModeBypass for a bus with more than one channel.
199///
200/// AVAudio3DMixingSourceModeBypass
201/// No spatial rendering. If input and output AudioChannelLayouts are equivalent, all
202/// input channels are directly copied to corresponding output channels. If the input and
203/// output AudioChannelLayouts differ, mixing is done according to the
204/// kAudioFormatProperty_MatrixMixMap property of the layouts. No occlusion, obstruction,
205/// or reverb is applied in this mode.
206///
207/// AVAudio3DMixingSourceModePointSource
208/// All channels of the bus are rendered as a single source at the location of the source
209/// node.
210///
211/// AVAudio3DMixingSourceModeAmbienceBed
212/// The input channels are spatialized around the listener as far-field sources anchored to
213/// global space. This means that the rendering depends on listener orientation but not on
214/// listener position. The directions of the input channels are specified by the
215/// AudioChannelLayout of the bus. The rotation of the whole bed in the global space is
216/// controlled by the direction of the source node.
217///
218/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudio3dmixingsourcemode?language=objc)
219// NS_ENUM
220#[repr(transparent)]
221#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
222pub struct AVAudio3DMixingSourceMode(pub NSInteger);
223impl AVAudio3DMixingSourceMode {
224 #[doc(alias = "AVAudio3DMixingSourceModeSpatializeIfMono")]
225 pub const SpatializeIfMono: Self = Self(0);
226 #[doc(alias = "AVAudio3DMixingSourceModeBypass")]
227 pub const Bypass: Self = Self(1);
228 #[doc(alias = "AVAudio3DMixingSourceModePointSource")]
229 pub const PointSource: Self = Self(2);
230 #[doc(alias = "AVAudio3DMixingSourceModeAmbienceBed")]
231 pub const AmbienceBed: Self = Self(3);
232}
233
234unsafe impl Encode for AVAudio3DMixingSourceMode {
235 const ENCODING: Encoding = NSInteger::ENCODING;
236}
237
238unsafe impl RefEncode for AVAudio3DMixingSourceMode {
239 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
240}
241
242/// In-head modes available for AVAudio3DMixingSourceModePointSource in AVAudio3DMixingRenderingAlgorithmAuto
243///
244/// The in-head modes differ in what happens when a point source moves inside the
245/// listener's head while using AVAudio3DMixingRenderingAlgorithmAuto.
246///
247/// AVAudio3DMixingPointSourceInHeadModeMono
248/// A point source remains a single mono source inside the listener's head regardless
249/// of the channels it consists of.
250///
251/// AVAudio3DMixingPointSourceInHeadModeBypass
252/// A point source splits into bypass inside the listener's head. This enables transitions
253/// between traditional, non-spatialized rendering and spatialized sources outside the
254/// listener's head.
255///
256/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudio3dmixingpointsourceinheadmode?language=objc)
257// NS_ENUM
258#[repr(transparent)]
259#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
260pub struct AVAudio3DMixingPointSourceInHeadMode(pub NSInteger);
261impl AVAudio3DMixingPointSourceInHeadMode {
262 #[doc(alias = "AVAudio3DMixingPointSourceInHeadModeMono")]
263 pub const Mono: Self = Self(0);
264 #[doc(alias = "AVAudio3DMixingPointSourceInHeadModeBypass")]
265 pub const Bypass: Self = Self(1);
266}
267
268unsafe impl Encode for AVAudio3DMixingPointSourceInHeadMode {
269 const ENCODING: Encoding = NSInteger::ENCODING;
270}
271
272unsafe impl RefEncode for AVAudio3DMixingPointSourceInHeadMode {
273 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
274}
275
276extern_protocol!(
277 /// Protocol that defines 3D mixing properties
278 ///
279 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudio3dmixing?language=objc)
280 pub unsafe trait AVAudio3DMixing: NSObjectProtocol {
281 /// Type of rendering algorithm used
282 ///
283 /// Depending on the current output format of the AVAudioEnvironmentNode, only a subset of the
284 /// rendering algorithms may be supported. An array of valid rendering algorithms can be
285 /// retrieved by calling applicableRenderingAlgorithms on AVAudioEnvironmentNode.
286 ///
287 /// Default: AVAudio3DMixingRenderingAlgorithmEqualPowerPanning
288 /// Mixer: AVAudioEnvironmentNode
289 #[unsafe(method(renderingAlgorithm))]
290 #[unsafe(method_family = none)]
291 unsafe fn renderingAlgorithm(&self) -> AVAudio3DMixingRenderingAlgorithm;
292
293 /// Setter for [`renderingAlgorithm`][Self::renderingAlgorithm].
294 #[unsafe(method(setRenderingAlgorithm:))]
295 #[unsafe(method_family = none)]
296 unsafe fn setRenderingAlgorithm(
297 &self,
298 rendering_algorithm: AVAudio3DMixingRenderingAlgorithm,
299 );
300
301 /// Controls how individual channels of an input bus are rendered
302 ///
303 /// Default: AVAudio3DMixingSourceModeSpatializeIfMono
304 /// Mixer: AVAudioEnvironmentNode
305 #[unsafe(method(sourceMode))]
306 #[unsafe(method_family = none)]
307 unsafe fn sourceMode(&self) -> AVAudio3DMixingSourceMode;
308
309 /// Setter for [`sourceMode`][Self::sourceMode].
310 #[unsafe(method(setSourceMode:))]
311 #[unsafe(method_family = none)]
312 unsafe fn setSourceMode(&self, source_mode: AVAudio3DMixingSourceMode);
313
314 /// In-head rendering choice for AVAudio3DMixingSourceModePointSource in AVAudio3DMixingRenderingAlgorithmAuto
315 ///
316 /// Default: AVAudio3DMixingPointSourceInHeadModeMono
317 /// Mixer: AVAudioEnvironmentNode
318 #[unsafe(method(pointSourceInHeadMode))]
319 #[unsafe(method_family = none)]
320 unsafe fn pointSourceInHeadMode(&self) -> AVAudio3DMixingPointSourceInHeadMode;
321
322 /// Setter for [`pointSourceInHeadMode`][Self::pointSourceInHeadMode].
323 #[unsafe(method(setPointSourceInHeadMode:))]
324 #[unsafe(method_family = none)]
325 unsafe fn setPointSourceInHeadMode(
326 &self,
327 point_source_in_head_mode: AVAudio3DMixingPointSourceInHeadMode,
328 );
329
330 /// Changes the playback rate of the input signal
331 ///
332 /// A value of 2.0 results in the output audio playing one octave higher.
333 /// A value of 0.5, results in the output audio playing one octave lower.
334 ///
335 /// Range: 0.5 -> 2.0
336 /// Default: 1.0
337 /// Mixer: AVAudioEnvironmentNode
338 #[unsafe(method(rate))]
339 #[unsafe(method_family = none)]
340 unsafe fn rate(&self) -> c_float;
341
342 /// Setter for [`rate`][Self::rate].
343 #[unsafe(method(setRate:))]
344 #[unsafe(method_family = none)]
345 unsafe fn setRate(&self, rate: c_float);
346
347 /// Controls the blend of dry and reverb processed audio
348 ///
349 /// This property controls the amount of the source's audio that will be processed by the reverb
350 /// in AVAudioEnvironmentNode. A value of 0.5 will result in an equal blend of dry and processed
351 /// (wet) audio.
352 ///
353 /// Range: 0.0 (completely dry) -> 1.0 (completely wet)
354 /// Default: 0.0
355 /// Mixer: AVAudioEnvironmentNode
356 #[unsafe(method(reverbBlend))]
357 #[unsafe(method_family = none)]
358 unsafe fn reverbBlend(&self) -> c_float;
359
360 /// Setter for [`reverbBlend`][Self::reverbBlend].
361 #[unsafe(method(setReverbBlend:))]
362 #[unsafe(method_family = none)]
363 unsafe fn setReverbBlend(&self, reverb_blend: c_float);
364
365 /// Simulates filtering of the direct path of sound due to an obstacle
366 ///
367 /// Only the direct path of sound between the source and listener is blocked.
368 ///
369 /// Range: -100.0 -> 0.0 dB
370 /// Default: 0.0
371 /// Mixer: AVAudioEnvironmentNode
372 #[unsafe(method(obstruction))]
373 #[unsafe(method_family = none)]
374 unsafe fn obstruction(&self) -> c_float;
375
376 /// Setter for [`obstruction`][Self::obstruction].
377 #[unsafe(method(setObstruction:))]
378 #[unsafe(method_family = none)]
379 unsafe fn setObstruction(&self, obstruction: c_float);
380
381 /// Simulates filtering of the direct and reverb paths of sound due to an obstacle
382 ///
383 /// Both the direct and reverb paths of sound between the source and listener are blocked.
384 ///
385 /// Range: -100.0 -> 0.0 dB
386 /// Default: 0.0
387 /// Mixer: AVAudioEnvironmentNode
388 #[unsafe(method(occlusion))]
389 #[unsafe(method_family = none)]
390 unsafe fn occlusion(&self) -> c_float;
391
392 /// Setter for [`occlusion`][Self::occlusion].
393 #[unsafe(method(setOcclusion:))]
394 #[unsafe(method_family = none)]
395 unsafe fn setOcclusion(&self, occlusion: c_float);
396
397 #[cfg(feature = "AVAudioTypes")]
398 /// The location of the source in the 3D environment
399 ///
400 /// The coordinates are specified in meters.
401 ///
402 /// Mixer: AVAudioEnvironmentNode
403 #[unsafe(method(position))]
404 #[unsafe(method_family = none)]
405 unsafe fn position(&self) -> AVAudio3DPoint;
406
407 #[cfg(feature = "AVAudioTypes")]
408 /// Setter for [`position`][Self::position].
409 #[unsafe(method(setPosition:))]
410 #[unsafe(method_family = none)]
411 unsafe fn setPosition(&self, position: AVAudio3DPoint);
412 }
413);
414
415extern_class!(
416 /// An object representing a connection to a mixer node from a node that
417 /// conforms to AVAudioMixing protocol
418 ///
419 /// A standalone instance of AVAudioMixingDestination cannot be created.
420 /// Only an instance vended by a source node (e.g. AVAudioPlayerNode) can be used
421 /// (see `AVAudioMixing`).
422 ///
423 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiomixingdestination?language=objc)
424 #[unsafe(super(NSObject))]
425 #[derive(Debug, PartialEq, Eq, Hash)]
426 pub struct AVAudioMixingDestination;
427);
428
429extern_conformance!(
430 unsafe impl AVAudio3DMixing for AVAudioMixingDestination {}
431);
432
433extern_conformance!(
434 unsafe impl AVAudioMixing for AVAudioMixingDestination {}
435);
436
437extern_conformance!(
438 unsafe impl AVAudioStereoMixing for AVAudioMixingDestination {}
439);
440
441extern_conformance!(
442 unsafe impl NSObjectProtocol for AVAudioMixingDestination {}
443);
444
445impl AVAudioMixingDestination {
446 extern_methods!(
447 #[unsafe(method(init))]
448 #[unsafe(method_family = init)]
449 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
450
451 #[cfg(feature = "AVAudioConnectionPoint")]
452 /// Returns the underlying mixer connection point
453 #[unsafe(method(connectionPoint))]
454 #[unsafe(method_family = none)]
455 pub unsafe fn connectionPoint(&self) -> Retained<AVAudioConnectionPoint>;
456 );
457}
458
459/// Methods declared on superclass `NSObject`.
460impl AVAudioMixingDestination {
461 extern_methods!(
462 #[unsafe(method(new))]
463 #[unsafe(method_family = new)]
464 pub unsafe fn new() -> Retained<Self>;
465 );
466}