//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-audio-toolbox")]
#[cfg(not(target_os = "watchos"))]
use objc2_audio_toolbox::*;
use objc2_foundation::*;

use crate::*;

/// Filter types available to use with AVAudioUnitEQ.
///
/// Depending on the filter type, a combination of one or all of the filter parameters defined
/// in AVAudioUnitEQFilterParameters are used to set the filter.
///
/// AVAudioUnitEQFilterTypeParametric
/// Parametric filter based on Butterworth analog prototype.
/// Required parameters: frequency (center), bandwidth, gain
///
/// AVAudioUnitEQFilterTypeLowPass
/// Simple Butterworth 2nd order low pass filter
/// Required parameters: frequency (-3 dB cutoff at specified frequency)
///
/// AVAudioUnitEQFilterTypeHighPass
/// Simple Butterworth 2nd order high pass filter
/// Required parameters: frequency (-3 dB cutoff at specified frequency)
///
/// AVAudioUnitEQFilterTypeResonantLowPass
/// Low pass filter with resonance support (via bandwidth parameter)
/// Required parameters: frequency (-3 dB cutoff at specified frequency), bandwidth
///
/// AVAudioUnitEQFilterTypeResonantHighPass
/// High pass filter with resonance support (via bandwidth parameter)
/// Required parameters: frequency (-3 dB cutoff at specified frequency), bandwidth
///
/// AVAudioUnitEQFilterTypeBandPass
/// Band pass filter
/// Required parameters: frequency (center), bandwidth
///
/// AVAudioUnitEQFilterTypeBandStop
/// Band stop filter (aka "notch filter")
/// Required parameters: frequency (center), bandwidth
///
/// AVAudioUnitEQFilterTypeLowShelf
/// Low shelf filter
/// Required parameters: frequency (center), gain
///
/// AVAudioUnitEQFilterTypeHighShelf
/// High shelf filter
/// Required parameters: frequency (center), gain
///
/// AVAudioUnitEQFilterTypeResonantLowShelf
/// Low shelf filter with resonance support (via bandwidth parameter)
/// Required parameters: frequency (center), bandwidth, gain
///
/// AVAudioUnitEQFilterTypeResonantHighShelf
/// High shelf filter with resonance support (via bandwidth parameter)
/// Required parameters: frequency (center), bandwidth, gain
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiouniteqfiltertype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVAudioUnitEQFilterType(pub NSInteger);
impl AVAudioUnitEQFilterType {
    #[doc(alias = "AVAudioUnitEQFilterTypeParametric")]
    pub const Parametric: Self = Self(0);
    #[doc(alias = "AVAudioUnitEQFilterTypeLowPass")]
    pub const LowPass: Self = Self(1);
    #[doc(alias = "AVAudioUnitEQFilterTypeHighPass")]
    pub const HighPass: Self = Self(2);
    #[doc(alias = "AVAudioUnitEQFilterTypeResonantLowPass")]
    pub const ResonantLowPass: Self = Self(3);
    #[doc(alias = "AVAudioUnitEQFilterTypeResonantHighPass")]
    pub const ResonantHighPass: Self = Self(4);
    #[doc(alias = "AVAudioUnitEQFilterTypeBandPass")]
    pub const BandPass: Self = Self(5);
    #[doc(alias = "AVAudioUnitEQFilterTypeBandStop")]
    pub const BandStop: Self = Self(6);
    #[doc(alias = "AVAudioUnitEQFilterTypeLowShelf")]
    pub const LowShelf: Self = Self(7);
    #[doc(alias = "AVAudioUnitEQFilterTypeHighShelf")]
    pub const HighShelf: Self = Self(8);
    #[doc(alias = "AVAudioUnitEQFilterTypeResonantLowShelf")]
    pub const ResonantLowShelf: Self = Self(9);
    #[doc(alias = "AVAudioUnitEQFilterTypeResonantHighShelf")]
    pub const ResonantHighShelf: Self = Self(10);
}

unsafe impl Encode for AVAudioUnitEQFilterType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for AVAudioUnitEQFilterType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Filter parameters used by AVAudioUnitEQ.
    ///
    /// A standalone instance of AVAudioUnitEQFilterParameters cannot be created. Only an instance
    /// vended out by a source object (e.g. AVAudioUnitEQ) can be used.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiouniteqfilterparameters?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVAudioUnitEQFilterParameters;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for AVAudioUnitEQFilterParameters {}
);

impl AVAudioUnitEQFilterParameters {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// AVAudioUnitEQFilterType
        ///
        /// Default:    AVAudioUnitEQFilterTypeParametric
        #[unsafe(method(filterType))]
        #[unsafe(method_family = none)]
        pub unsafe fn filterType(&self) -> AVAudioUnitEQFilterType;

        /// Setter for [`filterType`][Self::filterType].
        #[unsafe(method(setFilterType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFilterType(&self, filter_type: AVAudioUnitEQFilterType);

        /// Frequency in Hertz.
        ///
        /// Range:      20 -> (SampleRate/2)
        /// Unit:       Hertz
        #[unsafe(method(frequency))]
        #[unsafe(method_family = none)]
        pub unsafe fn frequency(&self) -> c_float;

        /// Setter for [`frequency`][Self::frequency].
        #[unsafe(method(setFrequency:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFrequency(&self, frequency: c_float);

        /// Bandwidth in octaves.
        ///
        /// Range:      0.05 -> 5.0
        /// Unit:       Octaves
        #[unsafe(method(bandwidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn bandwidth(&self) -> c_float;

        /// Setter for [`bandwidth`][Self::bandwidth].
        #[unsafe(method(setBandwidth:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBandwidth(&self, bandwidth: c_float);

        /// Gain in dB.
        ///
        /// Range:      -96 -> 24
        /// Default:    0
        /// Unit:       dB
        #[unsafe(method(gain))]
        #[unsafe(method_family = none)]
        pub unsafe fn gain(&self) -> c_float;

        /// Setter for [`gain`][Self::gain].
        #[unsafe(method(setGain:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGain(&self, gain: c_float);

        /// bypass state of band.
        ///
        /// Default:    YES
        #[unsafe(method(bypass))]
        #[unsafe(method_family = none)]
        pub unsafe fn bypass(&self) -> bool;

        /// Setter for [`bypass`][Self::bypass].
        #[unsafe(method(setBypass:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBypass(&self, bypass: bool);
    );
}

/// Methods declared on superclass `NSObject`.
impl AVAudioUnitEQFilterParameters {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// An AVAudioUnitEffect that implements a Multi-Band Equalizer.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiouniteq?language=objc)
    #[unsafe(super(AVAudioUnitEffect, AVAudioUnit, AVAudioNode, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(
        feature = "AVAudioNode",
        feature = "AVAudioUnit",
        feature = "AVAudioUnitEffect"
    ))]
    pub struct AVAudioUnitEQ;
);

#[cfg(all(
    feature = "AVAudioNode",
    feature = "AVAudioUnit",
    feature = "AVAudioUnitEffect"
))]
extern_conformance!(
    unsafe impl NSObjectProtocol for AVAudioUnitEQ {}
);

#[cfg(all(
    feature = "AVAudioNode",
    feature = "AVAudioUnit",
    feature = "AVAudioUnitEffect"
))]
impl AVAudioUnitEQ {
    extern_methods!(
        /// Initialize the EQ with number of bands.
        ///
        /// Parameter `numberOfBands`: The number of bands created by the EQ.
        #[unsafe(method(initWithNumberOfBands:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithNumberOfBands(
            this: Allocated<Self>,
            number_of_bands: NSUInteger,
        ) -> Retained<Self>;

        /// Array of AVAudioUnitEQFilterParameters objects.
        ///
        /// The number of elements in the array is equal to the number of bands.
        #[unsafe(method(bands))]
        #[unsafe(method_family = none)]
        pub unsafe fn bands(&self) -> Retained<NSArray<AVAudioUnitEQFilterParameters>>;

        /// Overall gain adjustment applied to the signal.
        ///
        /// Range:     -96 -> 24
        /// Default:   0
        /// Unit:      dB
        #[unsafe(method(globalGain))]
        #[unsafe(method_family = none)]
        pub unsafe fn globalGain(&self) -> c_float;

        /// Setter for [`globalGain`][Self::globalGain].
        #[unsafe(method(setGlobalGain:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGlobalGain(&self, global_gain: c_float);
    );
}

/// Methods declared on superclass `AVAudioUnitEffect`.
#[cfg(all(
    feature = "AVAudioNode",
    feature = "AVAudioUnit",
    feature = "AVAudioUnitEffect"
))]
impl AVAudioUnitEQ {
    extern_methods!(
        #[cfg(feature = "objc2-audio-toolbox")]
        #[cfg(not(target_os = "watchos"))]
        /// Create an AVAudioUnitEffect object.
        ///
        ///
        /// Parameter `audioComponentDescription`: AudioComponentDescription of the audio unit to be instantiated.
        ///
        /// The componentType must be one of these types
        /// kAudioUnitType_Effect
        /// kAudioUnitType_MusicEffect
        /// kAudioUnitType_Panner
        /// kAudioUnitType_RemoteEffect
        /// kAudioUnitType_RemoteMusicEffect
        #[unsafe(method(initWithAudioComponentDescription:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAudioComponentDescription(
            this: Allocated<Self>,
            audio_component_description: AudioComponentDescription,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(
    feature = "AVAudioNode",
    feature = "AVAudioUnit",
    feature = "AVAudioUnitEffect"
))]
impl AVAudioUnitEQ {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}
