objc2-avf-audio 0.3.2

Bindings to the AVFAudio framework
Documentation
//! 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::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypeoutput?language=objc)
    pub static AVAudioUnitTypeOutput: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypemusicdevice?language=objc)
    pub static AVAudioUnitTypeMusicDevice: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypemusiceffect?language=objc)
    pub static AVAudioUnitTypeMusicEffect: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypeformatconverter?language=objc)
    pub static AVAudioUnitTypeFormatConverter: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypeeffect?language=objc)
    pub static AVAudioUnitTypeEffect: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypemixer?language=objc)
    pub static AVAudioUnitTypeMixer: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypepanner?language=objc)
    pub static AVAudioUnitTypePanner: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypegenerator?language=objc)
    pub static AVAudioUnitTypeGenerator: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypeofflineeffect?language=objc)
    pub static AVAudioUnitTypeOfflineEffect: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounittypemidiprocessor?language=objc)
    pub static AVAudioUnitTypeMIDIProcessor: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounitmanufacturernameapple?language=objc)
    pub static AVAudioUnitManufacturerNameApple: &'static NSString;
}

extern_class!(
    /// Provides details about an audio unit such as type, subtype, manufacturer, location etc. User
    /// tags can be added to the AVAudioUnitComponent which can be queried later for display.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounitcomponent?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVAudioUnitComponent;
);

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

impl AVAudioUnitComponent {
    extern_methods!(
        /// the name of an audio component
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub unsafe fn name(&self) -> Retained<NSString>;

        /// standard audio component types returned as strings
        #[unsafe(method(typeName))]
        #[unsafe(method_family = none)]
        pub unsafe fn typeName(&self) -> Retained<NSString>;

        /// localized string of typeName for display
        #[unsafe(method(localizedTypeName))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedTypeName(&self) -> Retained<NSString>;

        /// the manufacturer name, extracted from the manufacturer key defined in Info.plist dictionary
        #[unsafe(method(manufacturerName))]
        #[unsafe(method_family = none)]
        pub unsafe fn manufacturerName(&self) -> Retained<NSString>;

        /// version number comprised of a hexadecimal number with major, minor, dot-release format: 0xMMMMmmDD
        #[unsafe(method(version))]
        #[unsafe(method_family = none)]
        pub unsafe fn version(&self) -> NSUInteger;

        /// version number as string
        #[unsafe(method(versionString))]
        #[unsafe(method_family = none)]
        pub unsafe fn versionString(&self) -> Retained<NSString>;

        /// URL representing location of component
        #[deprecated]
        #[unsafe(method(componentURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn componentURL(&self) -> Option<Retained<NSURL>>;

        /// NSArray of NSNumbers each of which corresponds to one of the constants in Mach-O Architecture in NSBundle Class Reference
        #[unsafe(method(availableArchitectures))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableArchitectures(&self) -> Retained<NSArray<NSNumber>>;

        /// On OSX, YES if the AudioComponent can be loaded into a sandboxed process otherwise NO.
        /// On iOS, this is always YES.
        #[unsafe(method(isSandboxSafe))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSandboxSafe(&self) -> bool;

        /// YES if AudioComponent has midi input, otherwise NO
        #[unsafe(method(hasMIDIInput))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasMIDIInput(&self) -> bool;

        /// YES if AudioComponent has midi output, otherwise NO
        #[unsafe(method(hasMIDIOutput))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasMIDIOutput(&self) -> bool;

        #[cfg(feature = "objc2-audio-toolbox")]
        #[cfg(not(target_os = "watchos"))]
        /// the audioComponent that can be used in AudioComponent APIs.
        #[unsafe(method(audioComponent))]
        #[unsafe(method_family = none)]
        pub unsafe fn audioComponent(&self) -> AudioComponent;

        /// User tags represent the tags from the current user.
        #[unsafe(method(userTagNames))]
        #[unsafe(method_family = none)]
        pub unsafe fn userTagNames(&self) -> Retained<NSArray<NSString>>;

        /// Setter for [`userTagNames`][Self::userTagNames].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setUserTagNames:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setUserTagNames(&self, user_tag_names: &NSArray<NSString>);

        /// represent the tags from the current user and the system tags defined by AudioComponent.
        #[unsafe(method(allTagNames))]
        #[unsafe(method_family = none)]
        pub unsafe fn allTagNames(&self) -> Retained<NSArray<NSString>>;

        #[cfg(feature = "objc2-audio-toolbox")]
        #[cfg(not(target_os = "watchos"))]
        /// description of the audio component that can be used in AudioComponent APIs.
        #[unsafe(method(audioComponentDescription))]
        #[unsafe(method_family = none)]
        pub unsafe fn audioComponentDescription(&self) -> AudioComponentDescription;

        /// A URL that will specify the location of an icon file that can be used when presenting UI
        /// for this audio component.
        #[unsafe(method(iconURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn iconURL(&self) -> Option<Retained<NSURL>>;

        /// YES if the AudioComponent has passed the AU validation tests, otherwise NO
        #[unsafe(method(passesAUVal))]
        #[unsafe(method_family = none)]
        pub unsafe fn passesAUVal(&self) -> bool;

        /// YES if the AudioComponent provides custom view, otherwise NO
        #[unsafe(method(hasCustomView))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasCustomView(&self) -> bool;

        /// A NSDictionary that contains information describing the capabilities of the AudioComponent.
        /// The specific information depends on the type and the keys are defined in AudioUnitProperties.h
        #[unsafe(method(configurationDictionary))]
        #[unsafe(method_family = none)]
        pub unsafe fn configurationDictionary(&self)
            -> Retained<NSDictionary<NSString, AnyObject>>;

        /// returns YES if the AudioComponent supports the input/output channel configuration
        #[unsafe(method(supportsNumberInputChannels:outputChannels:))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportsNumberInputChannels_outputChannels(
            &self,
            num_input_channels: NSInteger,
            num_output_channels: NSInteger,
        ) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl AVAudioUnitComponent {
    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>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounitcomponenttagsdidchangenotification?language=objc)
    pub static AVAudioUnitComponentTagsDidChangeNotification: &'static NSString;
}

extern_class!(
    /// A singleton object that provides an easy way to find audio components that are
    /// registered with the system.
    ///
    /// AVAudioUnitComponentManager provides methods to search and query various information about the
    /// audio components without opening them.
    ///
    /// Currently audio components that are audio units can only be searched.
    ///
    /// The class also supports predefined system tags and arbitrary user tags. Each audio unit can be
    /// tagged as part of its definition. Refer to AudioComponent.h for more details. AudioUnit Hosts
    /// such as Logic or GarageBand can present groupings of audio units based on the tags.
    ///
    /// Searching for audio units can be done in various ways
    /// - using a NSPredicate that contains search strings for tags or descriptions
    /// - using a block to match on custom criteria
    /// - using an AudioComponentDescription
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounitcomponentmanager?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVAudioUnitComponentManager;
);

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

impl AVAudioUnitComponentManager {
    extern_methods!(
        /// returns all tags associated with the current user as well as all system tags defined by
        /// the audio unit(s).
        #[unsafe(method(tagNames))]
        #[unsafe(method_family = none)]
        pub unsafe fn tagNames(&self) -> Retained<NSArray<NSString>>;

        /// returns the localized standard system tags defined by the audio unit(s).
        #[unsafe(method(standardLocalizedTagNames))]
        #[unsafe(method_family = none)]
        pub unsafe fn standardLocalizedTagNames(&self) -> Retained<NSArray<NSString>>;

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

        /// returns an array of AVAudioUnitComponent objects that match the search predicate.
        ///
        /// AudioComponent's information or tags can be used to build a search criteria.
        /// For example, "typeName CONTAINS 'Effect'" or tags IN {'Sampler', 'MIDI'}"
        #[unsafe(method(componentsMatchingPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn componentsMatchingPredicate(
            &self,
            predicate: &NSPredicate,
        ) -> Retained<NSArray<AVAudioUnitComponent>>;

        #[cfg(feature = "block2")]
        /// returns an array of AVAudioUnitComponent objects that pass the user provided block method.
        ///
        /// For each AudioComponent found by the manager, the block method will be called. If the return
        /// value is YES then the AudioComponent is added to the resulting array else it will excluded.
        /// This gives more control to the block provider to filter out the components returned.
        #[unsafe(method(componentsPassingTest:))]
        #[unsafe(method_family = none)]
        pub unsafe fn componentsPassingTest(
            &self,
            test_handler: &block2::DynBlock<
                dyn Fn(NonNull<AVAudioUnitComponent>, NonNull<Bool>) -> Bool,
            >,
        ) -> Retained<NSArray<AVAudioUnitComponent>>;

        #[cfg(feature = "objc2-audio-toolbox")]
        #[cfg(not(target_os = "watchos"))]
        /// returns an array of AVAudioUnitComponent objects that match the description.
        ///
        /// This method provides a mechanism to search for AudioComponents using AudioComponentDescription
        /// structure. The type, subtype and manufacturer fields are used to search for audio units. A
        /// value of 0 for any of these fields is a wildcard and returns the first match found.
        #[unsafe(method(componentsMatchingDescription:))]
        #[unsafe(method_family = none)]
        pub unsafe fn componentsMatchingDescription(
            &self,
            desc: AudioComponentDescription,
        ) -> Retained<NSArray<AVAudioUnitComponent>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl AVAudioUnitComponentManager {
    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>;
    );
}

extern "C" {
    /// A notification generated when AVAudioUnitComponentManager updates its list of components.
    ///
    /// Register for this notification on the shared AVAudioUnitComponentManager instance,
    /// as follows:
    ///
    /// ```text
    /// [[NSNotificationCenter defaultCenter] addObserver: myObject
    /// selector:
    /// sel!(registrationsChanged:)
    /// name:        AVAudioUnitComponentManagerRegistrationsChangedNotification
    /// object:      [AVAudioUnitComponentManager sharedAudioUnitComponentManager]];
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounitcomponentmanagerregistrationschangednotification?language=objc)
    pub static AVAudioUnitComponentManagerRegistrationsChangedNotification:
        &'static NSNotificationName;
}