objc2_avf_audio/generated/
AVAudioUnitSampler.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
13extern_class!(
14    /// Apple's sampler audio unit.
15    ///
16    /// An AVAudioUnit for Apple's Sampler Audio Unit. The sampler can be configured by loading
17    /// instruments from different types of files such as an aupreset, a DLS or SF2 sound bank,
18    /// an EXS24 instrument, a single audio file, or an array of audio files.
19    ///
20    /// The output is a single stereo bus.
21    ///
22    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudiounitsampler?language=objc)
23    #[unsafe(super(AVAudioUnitMIDIInstrument, AVAudioUnit, AVAudioNode, NSObject))]
24    #[derive(Debug, PartialEq, Eq, Hash)]
25    #[cfg(all(
26        feature = "AVAudioNode",
27        feature = "AVAudioUnit",
28        feature = "AVAudioUnitMIDIInstrument"
29    ))]
30    pub struct AVAudioUnitSampler;
31);
32
33#[cfg(all(
34    feature = "AVAudioMixing",
35    feature = "AVAudioNode",
36    feature = "AVAudioUnit",
37    feature = "AVAudioUnitMIDIInstrument"
38))]
39extern_conformance!(
40    unsafe impl AVAudio3DMixing for AVAudioUnitSampler {}
41);
42
43#[cfg(all(
44    feature = "AVAudioMixing",
45    feature = "AVAudioNode",
46    feature = "AVAudioUnit",
47    feature = "AVAudioUnitMIDIInstrument"
48))]
49extern_conformance!(
50    unsafe impl AVAudioMixing for AVAudioUnitSampler {}
51);
52
53#[cfg(all(
54    feature = "AVAudioMixing",
55    feature = "AVAudioNode",
56    feature = "AVAudioUnit",
57    feature = "AVAudioUnitMIDIInstrument"
58))]
59extern_conformance!(
60    unsafe impl AVAudioStereoMixing for AVAudioUnitSampler {}
61);
62
63#[cfg(all(
64    feature = "AVAudioNode",
65    feature = "AVAudioUnit",
66    feature = "AVAudioUnitMIDIInstrument"
67))]
68extern_conformance!(
69    unsafe impl NSObjectProtocol for AVAudioUnitSampler {}
70);
71
72#[cfg(all(
73    feature = "AVAudioNode",
74    feature = "AVAudioUnit",
75    feature = "AVAudioUnitMIDIInstrument"
76))]
77impl AVAudioUnitSampler {
78    extern_methods!(
79        /// loads a specific instrument from the specified sound bank
80        ///
81        /// Parameter `bankURL`: URL for a Soundbank file. The file can be either a DLS bank (.dls) or a SoundFont bank (.sf2).
82        ///
83        /// Parameter `program`: program number for the instrument to load
84        ///
85        /// Parameter `bankMSB`: MSB for the bank number for the instrument to load.  This is usually 0x79 for melodic
86        /// instruments and 0x78 for percussion instruments.
87        ///
88        /// Parameter `bankLSB`: LSB for the bank number for the instrument to load.  This is often 0, and represents the "bank variation".
89        ///
90        /// Parameter `outError`: the status of the operation
91        ///
92        /// This method reads from file and allocates memory, so it should not be called on a real time thread.
93        #[unsafe(method(loadSoundBankInstrumentAtURL:program:bankMSB:bankLSB:error:_))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn loadSoundBankInstrumentAtURL_program_bankMSB_bankLSB_error(
96            &self,
97            bank_url: &NSURL,
98            program: u8,
99            bank_msb: u8,
100            bank_lsb: u8,
101        ) -> Result<(), Retained<NSError>>;
102
103        /// configures the sampler by loading the specified preset file.
104        ///
105        /// Parameter `instrumentURL`: URL to the preset file or audio file
106        ///
107        /// Parameter `outError`: the status of the operation
108        ///
109        /// The file can be of one of the following types: Logic/GarageBand EXS24 instrument,
110        /// the Sampler AU's native aupreset, or an audio file (eg. .caf, .aiff, .wav, .mp3).
111        ///
112        /// If an audio file URL is loaded, it will become the sole sample in a new default instrument.
113        /// Any information contained in the file regarding its keyboard placement (e.g. root key,
114        /// key range) will be used.
115        /// This method reads from file and allocates memory, so it should not be called on a real time thread.
116        #[unsafe(method(loadInstrumentAtURL:error:_))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn loadInstrumentAtURL_error(
119            &self,
120            instrument_url: &NSURL,
121        ) -> Result<(), Retained<NSError>>;
122
123        /// configures the sampler by loading a set of audio files.
124        ///
125        /// Parameter `audioFiles`: array of URLs for audio files to be loaded
126        ///
127        /// Parameter `outError`: the status of the operation
128        ///
129        /// The audio files are loaded into a new default instrument with each audio file placed
130        /// into its own sampler zone. Any information contained in the audio file regarding
131        /// their placement on the keyboard (e.g. root key, key range) will be used.
132        /// This method reads from file and allocates memory, so it should not be called on a real time thread.
133        #[unsafe(method(loadAudioFilesAtURLs:error:_))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn loadAudioFilesAtURLs_error(
136            &self,
137            audio_files: &NSArray<NSURL>,
138        ) -> Result<(), Retained<NSError>>;
139
140        /// adjusts the pan for all the notes played.
141        /// Range:     -100 -> +100
142        /// Default:   0
143        #[unsafe(method(stereoPan))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn stereoPan(&self) -> c_float;
146
147        /// Setter for [`stereoPan`][Self::stereoPan].
148        #[unsafe(method(setStereoPan:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setStereoPan(&self, stereo_pan: c_float);
151
152        /// adjusts the gain of all the notes played
153        /// Range:     -90.0 -> +12 db
154        /// Default: 0 db
155        #[unsafe(method(overallGain))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn overallGain(&self) -> c_float;
158
159        /// Setter for [`overallGain`][Self::overallGain].
160        #[unsafe(method(setOverallGain:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setOverallGain(&self, overall_gain: c_float);
163
164        /// adjusts the gain of all the notes played
165        /// Range:     -90.0 -> +12 db
166        /// Default: 0 db
167        #[deprecated]
168        #[unsafe(method(masterGain))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn masterGain(&self) -> c_float;
171
172        /// Setter for [`masterGain`][Self::masterGain].
173        #[deprecated]
174        #[unsafe(method(setMasterGain:))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn setMasterGain(&self, master_gain: c_float);
177
178        /// adjusts the tuning of all the notes played.
179        /// Range:     -2400 -> +2400 cents
180        /// Default:   0
181        #[unsafe(method(globalTuning))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn globalTuning(&self) -> c_float;
184
185        /// Setter for [`globalTuning`][Self::globalTuning].
186        #[unsafe(method(setGlobalTuning:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn setGlobalTuning(&self, global_tuning: c_float);
189    );
190}
191
192/// Methods declared on superclass `AVAudioUnitMIDIInstrument`.
193#[cfg(all(
194    feature = "AVAudioNode",
195    feature = "AVAudioUnit",
196    feature = "AVAudioUnitMIDIInstrument"
197))]
198impl AVAudioUnitSampler {
199    extern_methods!(
200        #[cfg(feature = "objc2-audio-toolbox")]
201        #[cfg(not(target_os = "watchos"))]
202        /// Initialize the node with the component description for an AUv2 Audio Unit.
203        ///
204        /// - Parameter description: audio component description structure that describes the audio component of type kAudioUnitType_MusicDevice
205        /// or kAudioUnitType_RemoteInstrument.
206        ///
207        /// - note: To load AUv3 audio units (or any audio unit asynchronously), use the class
208        /// method ``AVAudioUnit/instantiateWithComponentDescription:options:completionHandler:`` instead.
209        #[unsafe(method(initWithAudioComponentDescription:))]
210        #[unsafe(method_family = init)]
211        pub unsafe fn initWithAudioComponentDescription(
212            this: Allocated<Self>,
213            description: AudioComponentDescription,
214        ) -> Retained<Self>;
215    );
216}
217
218/// Methods declared on superclass `NSObject`.
219#[cfg(all(
220    feature = "AVAudioNode",
221    feature = "AVAudioUnit",
222    feature = "AVAudioUnitMIDIInstrument"
223))]
224impl AVAudioUnitSampler {
225    extern_methods!(
226        #[unsafe(method(init))]
227        #[unsafe(method_family = init)]
228        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
229
230        #[unsafe(method(new))]
231        #[unsafe(method_family = new)]
232        pub unsafe fn new() -> Retained<Self>;
233    );
234}