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
112unsafe impl NSObjectProtocol for AVAudioUnitEQFilterParameters {}
113
114impl AVAudioUnitEQFilterParameters {
115    extern_methods!(
116        #[unsafe(method(init))]
117        #[unsafe(method_family = init)]
118        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
119
120        /// AVAudioUnitEQFilterType
121        ///
122        /// Default:    AVAudioUnitEQFilterTypeParametric
123        #[unsafe(method(filterType))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn filterType(&self) -> AVAudioUnitEQFilterType;
126
127        /// Setter for [`filterType`][Self::filterType].
128        #[unsafe(method(setFilterType:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setFilterType(&self, filter_type: AVAudioUnitEQFilterType);
131
132        /// Frequency in Hertz.
133        ///
134        /// Range:      20 -> (SampleRate/2)
135        /// Unit:       Hertz
136        #[unsafe(method(frequency))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn frequency(&self) -> c_float;
139
140        /// Setter for [`frequency`][Self::frequency].
141        #[unsafe(method(setFrequency:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn setFrequency(&self, frequency: c_float);
144
145        /// Bandwidth in octaves.
146        ///
147        /// Range:      0.05 -> 5.0
148        /// Unit:       Octaves
149        #[unsafe(method(bandwidth))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn bandwidth(&self) -> c_float;
152
153        /// Setter for [`bandwidth`][Self::bandwidth].
154        #[unsafe(method(setBandwidth:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn setBandwidth(&self, bandwidth: c_float);
157
158        /// Gain in dB.
159        ///
160        /// Range:      -96 -> 24
161        /// Default:    0
162        /// Unit:       dB
163        #[unsafe(method(gain))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn gain(&self) -> c_float;
166
167        /// Setter for [`gain`][Self::gain].
168        #[unsafe(method(setGain:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setGain(&self, gain: c_float);
171
172        /// bypass state of band.
173        ///
174        /// Default:    YES
175        #[unsafe(method(bypass))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn bypass(&self) -> bool;
178
179        /// Setter for [`bypass`][Self::bypass].
180        #[unsafe(method(setBypass:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn setBypass(&self, bypass: bool);
183    );
184}
185
186/// Methods declared on superclass `NSObject`.
187impl AVAudioUnitEQFilterParameters {
188    extern_methods!(
189        #[unsafe(method(new))]
190        #[unsafe(method_family = new)]
191        pub unsafe fn new() -> Retained<Self>;
192    );
193}
194
195extern_class!(
196    /// An AVAudioUnitEffect that implements a Multi-Band Equalizer.
197    ///
198    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiouniteq?language=objc)
199    #[unsafe(super(AVAudioUnitEffect, AVAudioUnit, AVAudioNode, NSObject))]
200    #[derive(Debug, PartialEq, Eq, Hash)]
201    #[cfg(all(
202        feature = "AVAudioNode",
203        feature = "AVAudioUnit",
204        feature = "AVAudioUnitEffect"
205    ))]
206    pub struct AVAudioUnitEQ;
207);
208
209#[cfg(all(
210    feature = "AVAudioNode",
211    feature = "AVAudioUnit",
212    feature = "AVAudioUnitEffect"
213))]
214unsafe impl NSObjectProtocol for AVAudioUnitEQ {}
215
216#[cfg(all(
217    feature = "AVAudioNode",
218    feature = "AVAudioUnit",
219    feature = "AVAudioUnitEffect"
220))]
221impl AVAudioUnitEQ {
222    extern_methods!(
223        /// Initialize the EQ with number of bands.
224        ///
225        /// Parameter `numberOfBands`: The number of bands created by the EQ.
226        #[unsafe(method(initWithNumberOfBands:))]
227        #[unsafe(method_family = init)]
228        pub unsafe fn initWithNumberOfBands(
229            this: Allocated<Self>,
230            number_of_bands: NSUInteger,
231        ) -> Retained<Self>;
232
233        /// Array of AVAudioUnitEQFilterParameters objects.
234        ///
235        /// The number of elements in the array is equal to the number of bands.
236        #[unsafe(method(bands))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn bands(&self) -> Retained<NSArray<AVAudioUnitEQFilterParameters>>;
239
240        /// Overall gain adjustment applied to the signal.
241        ///
242        /// Range:     -96 -> 24
243        /// Default:   0
244        /// Unit:      dB
245        #[unsafe(method(globalGain))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn globalGain(&self) -> c_float;
248
249        /// Setter for [`globalGain`][Self::globalGain].
250        #[unsafe(method(setGlobalGain:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setGlobalGain(&self, global_gain: c_float);
253    );
254}
255
256/// Methods declared on superclass `AVAudioUnitEffect`.
257#[cfg(all(
258    feature = "AVAudioNode",
259    feature = "AVAudioUnit",
260    feature = "AVAudioUnitEffect"
261))]
262impl AVAudioUnitEQ {
263    extern_methods!(
264        #[cfg(feature = "objc2-audio-toolbox")]
265        #[cfg(not(target_os = "watchos"))]
266        /// Create an AVAudioUnitEffect object.
267        ///
268        ///
269        /// Parameter `audioComponentDescription`: AudioComponentDescription of the audio unit to be instantiated.
270        ///
271        /// The componentType must be one of these types
272        /// kAudioUnitType_Effect
273        /// kAudioUnitType_MusicEffect
274        /// kAudioUnitType_Panner
275        /// kAudioUnitType_RemoteEffect
276        /// kAudioUnitType_RemoteMusicEffect
277        #[unsafe(method(initWithAudioComponentDescription:))]
278        #[unsafe(method_family = init)]
279        pub unsafe fn initWithAudioComponentDescription(
280            this: Allocated<Self>,
281            audio_component_description: AudioComponentDescription,
282        ) -> Retained<Self>;
283    );
284}
285
286/// Methods declared on superclass `NSObject`.
287#[cfg(all(
288    feature = "AVAudioNode",
289    feature = "AVAudioUnit",
290    feature = "AVAudioUnitEffect"
291))]
292impl AVAudioUnitEQ {
293    extern_methods!(
294        #[unsafe(method(init))]
295        #[unsafe(method_family = init)]
296        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
297
298        #[unsafe(method(new))]
299        #[unsafe(method_family = new)]
300        pub unsafe fn new() -> Retained<Self>;
301    );
302}