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