objc2-core-midi 0.3.2

Bindings to the CoreMIDI framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-foundation")]
use objc2_foundation::*;

use crate::*;

#[cfg(feature = "objc2")]
extern_class!(
    /// An object representing Capability Inquiry Profile on a MIDICIDevice.
    ///
    ///
    /// MIDI-CI profiles describe a mapping of MIDI messages to specific sounds and synthesis
    /// behaviors, e.g. General MIDI, a drawbar organ, etc. A MIDI-CI Profile may be a standard
    /// registered Profile or vendor-specific.
    ///
    /// A MIDI-CI Profile ID consists of 5 bytes.
    /// ===============================================================
    /// Standard Profile            Vendor-Specific Profile
    /// Profile ID Byte 1:    0x7E Standard Profile        Manufacturer SysEx ID 1 Profile
    /// Profile ID Byte 2:    Profile Bank            Manufacturer SysEx ID 2 Profile
    /// Profile ID Byte 3:    Profile Number            Manufacturer SysEx ID 3 Profile
    /// Profile ID Byte 4:    Profile Version            Manufacturer-specific Info
    /// Profile ID Byte 5:    Profile Level            Manufacturer-specific Info
    ///
    /// MIDI-CI Profiles have the following generalized types:
    ///
    /// Profile Type        Source        Channels        Channel Range
    /// ============        ==========    ===========    ========================
    /// Single-channel         0x00~0x0F     1            1 channel (1 to 16) of a Group
    /// Group            0x7E            16            All channels of a Group
    /// Function Block        0x7F            16 per Group     All channels of a Function Block
    /// Multi-channel        0x00~0x0F    2 or more        Profile-specific
    ///
    /// MIDIUMPCIProfile objects may only be registered to a single CI device, and any number
    /// of MIDIUMPCIProfile objects containg the same profile ID may be registered to CI
    /// devices in the MIDI 2.0 subsystem.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midiumpciprofile?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct MIDIUMPCIProfile;
);

#[cfg(feature = "objc2")]
extern_conformance!(
    unsafe impl NSObjectProtocol for MIDIUMPCIProfile {}
);

#[cfg(feature = "objc2")]
impl MIDIUMPCIProfile {
    extern_methods!(
        #[cfg(feature = "objc2-foundation")]
        /// The name of the MIDI-CI proifle.
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub unsafe fn name(&self) -> Retained<NSString>;

        #[cfg(all(feature = "MIDIMessages", feature = "MIDIUMPCI"))]
        /// C struct representation of MIDI-CI Profile ID.
        ///
        /// # Safety
        ///
        /// The returned must be correctly initialized.
        #[unsafe(method(profileID))]
        #[unsafe(method_family = none)]
        pub unsafe fn profileID(&self) -> MIDICIProfileID;

        #[cfg(feature = "MIDIUMPCI")]
        /// The type of MIDI-CI Profile, i.e., single-channel, multichannel, Group, or Function Block.
        #[unsafe(method(profileType))]
        #[unsafe(method_family = none)]
        pub unsafe fn profileType(&self) -> MIDICIProfileType;

        #[cfg(feature = "MIDIMessages")]
        /// For Group profiles defined on Function Blocks, the value to be added to the lowest
        /// Function Block UMP Group for messaging (e.g., a Group Profile defined on the second
        /// Group of a Function Block has a groupOffset of 1).
        #[unsafe(method(groupOffset))]
        #[unsafe(method_family = none)]
        pub unsafe fn groupOffset(&self) -> MIDIUMPGroupNumber;

        #[cfg(feature = "MIDIMessages")]
        /// The first channel number supported on the Profile.
        #[unsafe(method(firstChannel))]
        #[unsafe(method_family = none)]
        pub unsafe fn firstChannel(&self) -> MIDIChannelNumber;

        #[cfg(feature = "MIDIMessages")]
        /// The number of channels currently enabled on the Profile. When the profile is disabled,
        /// this value is set to 0.
        #[unsafe(method(enabledChannelCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn enabledChannelCount(&self) -> MIDIUInteger14;

        #[cfg(feature = "MIDIMessages")]
        /// The total number of channels supported by the Profile.
        #[unsafe(method(totalChannelCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn totalChannelCount(&self) -> MIDIUInteger14;

        /// The enable state of the Profile.
        #[unsafe(method(isEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isEnabled(&self) -> bool;

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

        #[cfg(all(feature = "MIDIMessages", feature = "objc2-foundation"))]
        /// Issue a Set Profile On or Set Profile Off request on this profile using the MIDI server's
        /// MUID.
        ///
        ///
        /// Parameter `isEnabled`: YES if setting the Profile to on.
        ///
        /// Parameter `enabledChannelCount`: The requsted number of channels to be enabled when
        /// the Profile is enabled. This field is only used when isOn
        /// is set to YES and the profile can enable a variable number
        /// of channels. Otherwise, it is ignored.
        ///
        /// Parameter `error`: The out-error used if an error occurred.
        ///
        ///
        /// The result of this operation, if any, is received via the profile notification
        /// posted by the MIDICIDeviceManager.
        /// Returns YES if the request is valid and the request was dispatched.
        #[unsafe(method(setProfileState:enabledChannelCount:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn setProfileState_enabledChannelCount_error(
            &self,
            is_enabled: bool,
            enabled_channel_count: MIDIUInteger14,
        ) -> Result<(), Retained<NSError>>;
    );
}

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