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::*;
#[cfg(feature = "objc2-core-midi")]
use objc2_core_midi::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// Base class for MIDI instruments.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounitmidiinstrument?language=objc)
    #[unsafe(super(AVAudioUnit, AVAudioNode, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "AVAudioNode", feature = "AVAudioUnit"))]
    pub struct AVAudioUnitMIDIInstrument;
);

#[cfg(all(
    feature = "AVAudioMixing",
    feature = "AVAudioNode",
    feature = "AVAudioUnit"
))]
extern_conformance!(
    unsafe impl AVAudio3DMixing for AVAudioUnitMIDIInstrument {}
);

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

#[cfg(all(
    feature = "AVAudioMixing",
    feature = "AVAudioNode",
    feature = "AVAudioUnit"
))]
extern_conformance!(
    unsafe impl AVAudioStereoMixing for AVAudioUnitMIDIInstrument {}
);

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

#[cfg(all(feature = "AVAudioNode", feature = "AVAudioUnit"))]
impl AVAudioUnitMIDIInstrument {
    extern_methods!(
        #[cfg(feature = "objc2-audio-toolbox")]
        #[cfg(not(target_os = "watchos"))]
        /// Initialize the node with the component description for an AUv2 Audio Unit.
        ///
        /// - Parameter description: audio component description structure that describes the audio component of type kAudioUnitType_MusicDevice
        /// or kAudioUnitType_RemoteInstrument.
        ///
        /// - note: To load AUv3 audio units (or any audio unit asynchronously), use the class
        /// method ``AVAudioUnit/instantiateWithComponentDescription:options:completionHandler:`` instead.
        #[unsafe(method(initWithAudioComponentDescription:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAudioComponentDescription(
            this: Allocated<Self>,
            description: AudioComponentDescription,
        ) -> Retained<Self>;

        /// Sends a MIDI Note On event to the instrument
        ///
        /// - Parameters:
        /// - note: the note number (key) to play. Range: 0 -> 127
        /// - velocity: specifies the volume with which the note is played. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15
        #[unsafe(method(startNote:withVelocity:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startNote_withVelocity_onChannel(&self, note: u8, velocity: u8, channel: u8);

        /// Sends a MIDI Note Off event to the instrument
        ///
        /// - Parameters:
        /// - note: the note number (key) to stop. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15
        #[unsafe(method(stopNote:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopNote_onChannel(&self, note: u8, channel: u8);

        /// Sends a MIDI controller event to the instrument.
        ///
        /// - Parameters:
        /// - controller: a standard MIDI controller number. Range: 0 -> 127
        /// - value: value for the controller. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15
        #[unsafe(method(sendController:withValue:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendController_withValue_onChannel(
            &self,
            controller: u8,
            value: u8,
            channel: u8,
        );

        /// Sends a MIDI controller event to the instrument.
        ///
        /// - Parameters:
        /// - controller: a standard MIDI controller number. Range: 0 -> 127
        /// - value: value for the controller. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15
        #[unsafe(method(sendPitchBend:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendPitchBend_onChannel(&self, pitchbend: u16, channel: u8);

        /// Sends MIDI channel pressure event to the instrument.
        ///
        /// - Parameters:
        /// - pressure: value of the pressure. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15
        #[unsafe(method(sendPressure:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendPressure_onChannel(&self, pressure: u8, channel: u8);

        /// Sends MIDI Polyphonic key pressure event to the instrument
        ///
        /// - Parameters:
        /// - key: the key (note) number to which the pressure event applies. Range: 0 -> 127
        /// - value: value of the pressure. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15so
        #[unsafe(method(sendPressureForKey:withValue:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendPressureForKey_withValue_onChannel(
            &self,
            key: u8,
            value: u8,
            channel: u8,
        );

        /// Sends MIDI Program Change event to the instrument
        ///
        /// The instrument will be loaded from the bank that has been previous set by MIDI Bank Select
        /// controller messages (0 and 31). If none has been set, bank 0 will be used.
        /// - Parameters:
        /// - program: the program number. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15
        #[unsafe(method(sendProgramChange:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendProgramChange_onChannel(&self, program: u8, channel: u8);

        /// Sends a MIDI Program Change and Bank Select events to the instrument
        ///
        /// - Parameters:
        /// - program: specifies the program (preset) number within the bank to load. Range: 0 -> 127
        /// - bankMSB: specifies the most significant byte value for the bank to select. Range: 0 -> 127
        /// - bankLSB: specifies the least significant byte value for the bank to select. Range: 0 -> 127
        /// - channel: the channel number to which the event is sent. Range: 0 -> 15
        #[unsafe(method(sendProgramChange:bankMSB:bankLSB:onChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendProgramChange_bankMSB_bankLSB_onChannel(
            &self,
            program: u8,
            bank_msb: u8,
            bank_lsb: u8,
            channel: u8,
        );

        /// Sends a MIDI event which contains two data bytes to the instrument.
        ///
        /// - Parameters:
        /// - midiStatus: the STATUS value of the MIDI event
        /// - data1: the first data byte of the MIDI event
        /// - data2: the second data byte of the MIDI event.
        #[unsafe(method(sendMIDIEvent:data1:data2:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendMIDIEvent_data1_data2(&self, midi_status: u8, data1: u8, data2: u8);

        /// Sends a MIDI event which contains one data byte to the instrument.
        ///
        /// - Parameters:
        /// - midiStatus: the STATUS value of the MIDI event
        /// - data1: the first data byte of the MIDI event
        #[unsafe(method(sendMIDIEvent:data1:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendMIDIEvent_data1(&self, midi_status: u8, data1: u8);

        /// Sends a MIDI System Exclusive event to the instrument.
        ///
        /// - Parameters:
        /// - midiData: a NSData object containing the complete SysEx data including start(F0) and termination(F7) bytes.
        #[unsafe(method(sendMIDISysExEvent:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendMIDISysExEvent(&self, midi_data: &NSData);

        #[cfg(feature = "objc2-core-midi")]
        /// Sends a MIDI event list to the instrument.
        ///
        /// - Parameters:
        /// - eventList: the MIDIEventList
        ///
        /// # Safety
        ///
        /// `event_list` must be a valid pointer.
        #[unsafe(method(sendMIDIEventList:))]
        #[unsafe(method_family = none)]
        pub unsafe fn sendMIDIEventList(&self, event_list: NonNull<MIDIEventList>);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "AVAudioNode", feature = "AVAudioUnit"))]
impl AVAudioUnitMIDIInstrument {
    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>;
    );
}