objc2_avf_audio/generated/
AVAudioUnitEQ.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#[cfg(feature = "objc2-audio-toolbox")]
7#[cfg(not(target_os = "watchos"))]
8use objc2_audio_toolbox::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13/// Filter types available to use with AVAudioUnitEQ.
14///
15/// Depending on the filter type, a combination of one or all of the filter parameters defined
16/// in AVAudioUnitEQFilterParameters are used to set the filter.
17///
18/// AVAudioUnitEQFilterTypeParametric
19/// Parametric filter based on Butterworth analog prototype.
20/// Required parameters: frequency (center), bandwidth, gain
21///
22/// AVAudioUnitEQFilterTypeLowPass
23/// Simple Butterworth 2nd order low pass filter
24/// Required parameters: frequency (-3 dB cutoff at specified frequency)
25///
26/// AVAudioUnitEQFilterTypeHighPass
27/// Simple Butterworth 2nd order high pass filter
28/// Required parameters: frequency (-3 dB cutoff at specified frequency)
29///
30/// AVAudioUnitEQFilterTypeResonantLowPass
31/// Low pass filter with resonance support (via bandwidth parameter)
32/// Required parameters: frequency (-3 dB cutoff at specified frequency), bandwidth
33///
34/// AVAudioUnitEQFilterTypeResonantHighPass
35/// High pass filter with resonance support (via bandwidth parameter)
36/// Required parameters: frequency (-3 dB cutoff at specified frequency), bandwidth
37///
38/// AVAudioUnitEQFilterTypeBandPass
39/// Band pass filter
40/// Required parameters: frequency (center), bandwidth
41///
42/// AVAudioUnitEQFilterTypeBandStop
43/// Band stop filter (aka "notch filter")
44/// Required parameters: frequency (center), bandwidth
45///
46/// AVAudioUnitEQFilterTypeLowShelf
47/// Low shelf filter
48/// Required parameters: frequency (center), gain
49///
50/// AVAudioUnitEQFilterTypeHighShelf
51/// High shelf filter
52/// Required parameters: frequency (center), gain
53///
54/// AVAudioUnitEQFilterTypeResonantLowShelf
55/// Low shelf filter with resonance support (via bandwidth parameter)
56/// Required parameters: frequency (center), bandwidth, gain
57///
58/// AVAudioUnitEQFilterTypeResonantHighShelf
59/// High shelf filter with resonance support (via bandwidth parameter)
60/// Required parameters: frequency (center), bandwidth, gain
61///
62/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiouniteqfiltertype?language=objc)
63// NS_ENUM
64#[repr(transparent)]
65#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
66pub struct AVAudioUnitEQFilterType(pub NSInteger);
67impl AVAudioUnitEQFilterType {
68    #[doc(alias = "AVAudioUnitEQFilterTypeParametric")]
69    pub const Parametric: Self = Self(0);
70    #[doc(alias = "AVAudioUnitEQFilterTypeLowPass")]
71    pub const LowPass: Self = Self(1);
72    #[doc(alias = "AVAudioUnitEQFilterTypeHighPass")]
73    pub const HighPass: Self = Self(2);
74    #[doc(alias = "AVAudioUnitEQFilterTypeResonantLowPass")]
75    pub const ResonantLowPass: Self = Self(3);
76    #[doc(alias = "AVAudioUnitEQFilterTypeResonantHighPass")]
77    pub const ResonantHighPass: Self = Self(4);
78    #[doc(alias = "AVAudioUnitEQFilterTypeBandPass")]
79    pub const BandPass: Self = Self(5);
80    #[doc(alias = "AVAudioUnitEQFilterTypeBandStop")]
81    pub const BandStop: Self = Self(6);
82    #[doc(alias = "AVAudioUnitEQFilterTypeLowShelf")]
83    pub const LowShelf: Self = Self(7);
84    #[doc(alias = "AVAudioUnitEQFilterTypeHighShelf")]
85    pub const HighShelf: Self = Self(8);
86    #[doc(alias = "AVAudioUnitEQFilterTypeResonantLowShelf")]
87    pub const ResonantLowShelf: Self = Self(9);
88    #[doc(alias = "AVAudioUnitEQFilterTypeResonantHighShelf")]
89    pub const ResonantHighShelf: Self = Self(10);
90}
91
92unsafe impl Encode for AVAudioUnitEQFilterType {
93    const ENCODING: Encoding = NSInteger::ENCODING;
94}
95
96unsafe impl RefEncode for AVAudioUnitEQFilterType {
97    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
98}
99
100extern_class!(
101    /// Filter parameters used by AVAudioUnitEQ.
102    ///
103    /// A standalone instance of AVAudioUnitEQFilterParameters cannot be created. Only an instance
104    /// vended out by a source object (e.g. AVAudioUnitEQ) can be used.
105    ///
106    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiouniteqfilterparameters?language=objc)
107    #[unsafe(super(NSObject))]
108    #[derive(Debug, PartialEq, Eq, Hash)]
109    pub struct AVAudioUnitEQFilterParameters;
110);
111
112extern_conformance!(
113    unsafe impl NSObjectProtocol for AVAudioUnitEQFilterParameters {}
114);
115
116impl AVAudioUnitEQFilterParameters {
117    extern_methods!(
118        #[unsafe(method(init))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
121
122        /// AVAudioUnitEQFilterType
123        ///
124        /// Default:    AVAudioUnitEQFilterTypeParametric
125        #[unsafe(method(filterType))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn filterType(&self) -> AVAudioUnitEQFilterType;
128
129        /// Setter for [`filterType`][Self::filterType].
130        #[unsafe(method(setFilterType:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn setFilterType(&self, filter_type: AVAudioUnitEQFilterType);
133
134        /// Frequency in Hertz.
135        ///
136        /// Range:      20 -> (SampleRate/2)
137        /// Unit:       Hertz
138        #[unsafe(method(frequency))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn frequency(&self) -> c_float;
141
142        /// Setter for [`frequency`][Self::frequency].
143        #[unsafe(method(setFrequency:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setFrequency(&self, frequency: c_float);
146
147        /// Bandwidth in octaves.
148        ///
149        /// Range:      0.05 -> 5.0
150        /// Unit:       Octaves
151        #[unsafe(method(bandwidth))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn bandwidth(&self) -> c_float;
154
155        /// Setter for [`bandwidth`][Self::bandwidth].
156        #[unsafe(method(setBandwidth:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setBandwidth(&self, bandwidth: c_float);
159
160        /// Gain in dB.
161        ///
162        /// Range:      -96 -> 24
163        /// Default:    0
164        /// Unit:       dB
165        #[unsafe(method(gain))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn gain(&self) -> c_float;
168
169        /// Setter for [`gain`][Self::gain].
170        #[unsafe(method(setGain:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn setGain(&self, gain: c_float);
173
174        /// bypass state of band.
175        ///
176        /// Default:    YES
177        #[unsafe(method(bypass))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn bypass(&self) -> bool;
180
181        /// Setter for [`bypass`][Self::bypass].
182        #[unsafe(method(setBypass:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn setBypass(&self, bypass: bool);
185    );
186}
187
188/// Methods declared on superclass `NSObject`.
189impl AVAudioUnitEQFilterParameters {
190    extern_methods!(
191        #[unsafe(method(new))]
192        #[unsafe(method_family = new)]
193        pub unsafe fn new() -> Retained<Self>;
194    );
195}
196
197extern_class!(
198    /// An AVAudioUnitEffect that implements a Multi-Band Equalizer.
199    ///
200    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiouniteq?language=objc)
201    #[unsafe(super(AVAudioUnitEffect, AVAudioUnit, AVAudioNode, NSObject))]
202    #[derive(Debug, PartialEq, Eq, Hash)]
203    #[cfg(all(
204        feature = "AVAudioNode",
205        feature = "AVAudioUnit",
206        feature = "AVAudioUnitEffect"
207    ))]
208    pub struct AVAudioUnitEQ;
209);
210
211#[cfg(all(
212    feature = "AVAudioNode",
213    feature = "AVAudioUnit",
214    feature = "AVAudioUnitEffect"
215))]
216extern_conformance!(
217    unsafe impl NSObjectProtocol for AVAudioUnitEQ {}
218);
219
220#[cfg(all(
221    feature = "AVAudioNode",
222    feature = "AVAudioUnit",
223    feature = "AVAudioUnitEffect"
224))]
225impl AVAudioUnitEQ {
226    extern_methods!(
227        /// Initialize the EQ with number of bands.
228        ///
229        /// Parameter `numberOfBands`: The number of bands created by the EQ.
230        #[unsafe(method(initWithNumberOfBands:))]
231        #[unsafe(method_family = init)]
232        pub unsafe fn initWithNumberOfBands(
233            this: Allocated<Self>,
234            number_of_bands: NSUInteger,
235        ) -> Retained<Self>;
236
237        /// Array of AVAudioUnitEQFilterParameters objects.
238        ///
239        /// The number of elements in the array is equal to the number of bands.
240        #[unsafe(method(bands))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn bands(&self) -> Retained<NSArray<AVAudioUnitEQFilterParameters>>;
243
244        /// Overall gain adjustment applied to the signal.
245        ///
246        /// Range:     -96 -> 24
247        /// Default:   0
248        /// Unit:      dB
249        #[unsafe(method(globalGain))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn globalGain(&self) -> c_float;
252
253        /// Setter for [`globalGain`][Self::globalGain].
254        #[unsafe(method(setGlobalGain:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn setGlobalGain(&self, global_gain: c_float);
257    );
258}
259
260/// Methods declared on superclass `AVAudioUnitEffect`.
261#[cfg(all(
262    feature = "AVAudioNode",
263    feature = "AVAudioUnit",
264    feature = "AVAudioUnitEffect"
265))]
266impl AVAudioUnitEQ {
267    extern_methods!(
268        #[cfg(feature = "objc2-audio-toolbox")]
269        #[cfg(not(target_os = "watchos"))]
270        /// Create an AVAudioUnitEffect object.
271        ///
272        ///
273        /// Parameter `audioComponentDescription`: AudioComponentDescription of the audio unit to be instantiated.
274        ///
275        /// The componentType must be one of these types
276        /// kAudioUnitType_Effect
277        /// kAudioUnitType_MusicEffect
278        /// kAudioUnitType_Panner
279        /// kAudioUnitType_RemoteEffect
280        /// kAudioUnitType_RemoteMusicEffect
281        #[unsafe(method(initWithAudioComponentDescription:))]
282        #[unsafe(method_family = init)]
283        pub unsafe fn initWithAudioComponentDescription(
284            this: Allocated<Self>,
285            audio_component_description: AudioComponentDescription,
286        ) -> Retained<Self>;
287    );
288}
289
290/// Methods declared on superclass `NSObject`.
291#[cfg(all(
292    feature = "AVAudioNode",
293    feature = "AVAudioUnit",
294    feature = "AVAudioUnitEffect"
295))]
296impl AVAudioUnitEQ {
297    extern_methods!(
298        #[unsafe(method(init))]
299        #[unsafe(method_family = init)]
300        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
301
302        #[unsafe(method(new))]
303        #[unsafe(method_family = new)]
304        pub unsafe fn new() -> Retained<Self>;
305    );
306}