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