1 //! Core Audio's various const audio unit types identifiers represented as typesafe enums. 2 //! 3 //! Oirginal documentation [here](https://developer.apple.com/library/prerelease/mac/documentation/AudioUnit/Reference/AUComponentServicesReference/index.html#//apple_ref/doc/constant_group/Audio_Unit_Types). 4 5 6 /// Represents the different kinds of Audio Units that are available. 7 /// 8 /// Original documentation [here](https://developer.apple.com/library/prerelease/mac/documentation/AudioUnit/Reference/AUComponentServicesReference/index.html#//apple_ref/doc/constant_group/Audio_Unit_Types). 9 #[derive(Copy, Clone, Debug)] 10 pub enum Type { 11 /// Provides input, output, or both input and output simultaneously. 12 /// 13 /// It can be used as the head of an audio unit processing graph. 14 /// 15 /// **Available** in OS X v10.2 and later. 16 IO(IOType), 17 /// An instrument unit can be used as a software musical instrument, such as a sampler or 18 /// synthesizer. 19 /// 20 /// It responds to MIDI (Musical Instrument Digital Interface) control signals and can create 21 /// notes. 22 /// 23 /// **Available** in OS X v10.2 and later. 24 MusicDevice(MusicDeviceType), 25 /// An effect unit that can respond to MIDI control messages, typically through a mapping of 26 /// MIDI messages to parameters of the audio unit's DSP algorithm. 27 /// 28 /// **Available** in OS X v10.2 and later. 29 MusicEffect, 30 /// A format converter unit can transform audio formats, such as performing sample rate 31 /// conversion. 32 /// 33 /// A format converter is also appropriate for dferred rendering and for effects such as 34 /// varispeed. 35 /// 36 /// A format converter unit can ask for as much or as little audio input as it needs to produce 37 /// a given output, while still completing its rendering within the time represented by the 38 /// output buffer. 39 /// 40 /// For effect-like format converters, such as pitch shifters, it is common to provide both a 41 /// real-time and an offline version. OS X, for example, includes Time-Pitch and Varispeed 42 /// audio units in both real-time and offline versions. 43 /// 44 /// **Available** in OS X v10.2 and later. 45 FormatConverter(FormatConverterType), 46 /// An effect unit repeatedly processes a number of audio input samples to produce the same 47 /// number of audio output samples. 48 /// 49 /// Most commonly, an effect unit has a single input and a single output. 50 /// 51 /// Some effects take side-chain inputs as well. 52 /// 53 /// Effect units can be run offline, such as to process a file without playing it, but are 54 /// expected to run in real-time. 55 /// 56 /// **Available** in OS X v10.2 and later. 57 Effect(EffectType), 58 /// A mixer unit takes a number of input channels and mixes them to provide one or more output 59 /// channels. 60 /// 61 /// For example, the **StereoMixer** **SubType** in OS X takes multiple mono or stereo inputs 62 /// and produces a single stereo output. 63 /// 64 /// **Available** in OS X v10.2 and later. 65 Mixer(MixerType), 66 /// A panner unit is a specialised effect unit that distributes one or more channels in a 67 /// single input to one or more channels in a single output. 68 /// 69 /// Panner units must support a set of standard audio unit parameters that specify panning 70 /// coordinates. 71 /// 72 /// **Available** in OS X v10.3 and later. 73 Panner, 74 /// A generator unit provides audio output that has no audio input. 75 /// 76 /// This audio unit type is appropriate for a tone generator. 77 /// 78 /// Unlike an instrument unit, a generator unit does not have a control input. 79 /// 80 /// **Available** in OS X v10.3 and later. 81 Generator(GeneratorType), 82 /// An offline effect unit provides digital signal processing of a sort that cannot proceed in 83 /// real-time. 84 /// 85 /// For example, level normalisation requires examination of an entire sound, beginning to end, 86 /// before the normalisation factor can be calculated. 87 /// 88 /// As such, offline effect units also have a notion of a priming stage that can be performed 89 /// before the actual rendering/processing phase is executed. 90 /// 91 /// **Available** in OS X v10.3 and later. 92 OfflineEffect, 93 /// FIXME: Could not find any documenation for this type - it seems it was added very recently 94 /// (around 2013) and Apple's documentation doesn't seem to have updated to include it. 95 MidiProcessor, 96 } 97 98 99 impl Type { 100 101 /// Convert the `Type` to its associated `u32` for compatibility with original API. to_u32(&self) -> u32102 pub fn to_u32(&self) -> u32 { 103 match *self { 104 Type::IO(_) => 1635086197, 105 Type::MusicDevice(_) => 1635085685, 106 Type::MusicEffect => 1635085670, 107 Type::FormatConverter(_) => 1635083875, 108 Type::Effect(_) => 1635083896, 109 Type::Mixer(_) => 1635085688, 110 Type::Panner => 1635086446, 111 Type::Generator(_) => 1635084142, 112 Type::OfflineEffect => 1635086188, 113 Type::MidiProcessor => 1635085673, 114 } 115 } 116 117 /// Convert the `Type` to the const `u32` that is associated with its subtype. to_subtype_u32(&self) -> Option<u32>118 pub fn to_subtype_u32(&self) -> Option<u32> { 119 match *self { 120 Type::IO(ty) => Some(ty as u32), 121 Type::MusicDevice(ty) => Some(ty as u32), 122 Type::FormatConverter(ty) => Some(ty as u32), 123 Type::Effect(ty) => Some(ty as u32), 124 Type::Mixer(ty) => Some(ty as u32), 125 Type::Generator(ty) => Some(ty as u32), 126 _ => None, 127 } 128 } 129 130 } 131 132 133 impl From<EffectType> for Type { from(ty: EffectType) -> Self134 fn from(ty: EffectType) -> Self { 135 Type::Effect(ty) 136 } 137 } 138 139 impl From<FormatConverterType> for Type { from(ty: FormatConverterType) -> Self140 fn from(ty: FormatConverterType) -> Self { 141 Type::FormatConverter(ty) 142 } 143 } 144 145 impl From<MixerType> for Type { from(ty: MixerType) -> Self146 fn from(ty: MixerType) -> Self { 147 Type::Mixer(ty) 148 } 149 } 150 151 impl From<GeneratorType> for Type { from(ty: GeneratorType) -> Self152 fn from(ty: GeneratorType) -> Self { 153 Type::Generator(ty) 154 } 155 } 156 157 impl From<MusicDeviceType> for Type { from(ty: MusicDeviceType) -> Self158 fn from(ty: MusicDeviceType) -> Self { 159 Type::MusicDevice(ty) 160 } 161 } 162 163 impl From<IOType> for Type { from(ty: IOType) -> Self164 fn from(ty: IOType) -> Self { 165 Type::IO(ty) 166 } 167 } 168 169 170 /// Effect (digital signal processing) audio unit subtypes for audio units provided by Apple. 171 #[derive(Copy, Clone, Debug, PartialEq)] 172 pub enum EffectType { 173 /// An audio unit that enforces an upper dynamic limit on an audio signal. 174 /// 175 /// **Available** in OS X v10.2 and later. 176 PeakLimiter = 1819112562, 177 /// An audio unit that provides dynamic compression or expansion. 178 /// 179 /// **Available** in OS X v10.3 and later. 180 DynamicsProcessor = 1684237680, 181 /// An audio unit that passes frequencies below a specified cutoff frequency and blocks 182 /// frequencies above that cutoff frequency. 183 /// 184 /// **Available** in OS X v10.2 and later. 185 LowPassFilter = 1819304307, 186 /// An audio unit that passes frequencies above a specified cutoff frequency and blocks 187 /// frequencies below that cutoff frequency. 188 /// 189 /// **Available** in OS X v10.2 and later. 190 HighPassFilter = 1752195443, 191 /// An audio unit that passes frequencies between specified upper and lower cutoff frequencies, 192 /// and blocks frequencies outside that band. 193 /// 194 /// **Available** in OS X v10.2 and later. 195 BandPassFilter = 1651532147, 196 /// An audio unit suitable for implementing a treble control in an audio playback or recording 197 /// system. 198 /// 199 /// **Available** in OS X v10.2 and later. 200 HighShelfFilter = 1752393830, 201 /// An audio unit suitable for implementing a bass control in an audio playback or recording 202 /// system. 203 /// 204 /// **Available** in OS X v10.2 and later. 205 LowShelfFilter = 1819502694, 206 /// An audio unit that provides a filter whose center frequency, boost/cut level, and Q can be 207 /// adjusted. 208 /// 209 /// **Available** in OS X v10.2 and later. 210 ParametricEQ = 1886217585, 211 /// An audio unit that provides a distortion effect. 212 /// 213 /// **Available** in OS X v10.5 and later. 214 Distortion = 1684632436, 215 /// An audio unit that introduces a time delay to a signal. 216 /// 217 /// **Available** in OS X v10.2 and later. 218 Delay = 1684368505, 219 /// An audio unit that provides a time delay for a specified number of samples. 220 /// 221 /// **Available** in OS X v10.4 and later. 222 SampleDelay = 1935961209, 223 /// An audio unit that provides a 10- or 31-band graphic equalizer. 224 /// 225 /// Available in OS X v10.2 and later. 226 GraphicEQ = 1735550321, 227 /// An audio unit that provides four-bands of dynamic compression or expansion. 228 /// 229 /// **Available** in OS X v10.3 and later. 230 MultiBandCompressor = 1835232624, 231 /// An audio unit that provides a reverberation effect that can be used to simulate a variety 232 /// of acoustic spaces. 233 /// 234 /// **Available** in OS X v10.2 and later. 235 MatrixReverb = 1836213622, 236 /// An audio unit for modifying the pitch of a signal. 237 /// 238 /// **Available** in OS X v10.4 and later. 239 Pitch = 1953329268, 240 /// An audio unit that provides a combination of five filters: low-frequency, three 241 /// mid-frequencies, and high-frequency. 242 /// 243 /// **Available** in OS X v10.4 and later. 244 AUFilter = 1718185076, 245 /// An audio unit for use in conjunction with a kAudioUnitSubType_NetReceive audio unit for 246 /// sending audio across a network or from one application to another. 247 /// 248 /// **Available** in OS X v10.4 and later. 249 NetSend = 1853058660, 250 /// An audio unit that detects gaps between segments of speech and fills the gaps with a short 251 /// tone, simulating the sound of a walkie-talkie communication device. 252 /// 253 /// **Available** in OS X v10.5 and later. 254 RogerBeep = 1919903602, 255 /// A multi-band equalizer with specifiable filter type for each band. 256 /// 257 /// **Available** in OS X v10.9 and later. 258 NBandEQ = 1851942257, 259 } 260 261 262 /// Audio data format converter audio unit subtypes for **AudioUnit**s provided by Apple. 263 #[derive(Copy, Clone, Debug, PartialEq)] 264 pub enum FormatConverterType { 265 /// An audio unit that uses an audio converter to do linear PCM conversions, such as changes to 266 /// sample rate, bit depth, or interleaving. 267 /// 268 /// **Available** in OS X v10.2 and later. 269 AUConverter = 1668247158, 270 /// An audio unit that can be used to have independent control of both playback rate and pitch. 271 /// 272 /// In OS X it provides a generic view, so it can be used in both a UI and programmatic 273 /// context. 274 /// 275 /// It also comes in an offline version for processing audio files. 276 /// 277 /// **Available** in OS X v10.7 and later. 278 NewTimePitch = 1853191280, 279 /// An audio unit that can provide independent control of playback rate and pitch. This subtype 280 /// provides a generic view, making it suitable for UI and programmatic context. OS X provides 281 /// realtime and offline audio units of this subtype. 282 /// 283 /// **Available** in OS X v10.3 and later. 284 TimePitch = 1953329268, 285 /// An audio unit that acquires audio input from a separate thread than the thread on which its 286 /// render method is called. 287 /// 288 /// You can use this subtype to introduce multiple threads into an audio unit processing graph. 289 /// 290 /// There is a delay, equal to the buffer size, introduced between the audio input and output. 291 /// 292 /// **Available** in OS X v10.4 and later. 293 DeferredRenderer = 1684366962, 294 /// An audio unit with one input bus and two output buses. The audio unit duplicates the input 295 /// signal to each of its two output buses. 296 /// 297 /// **Available** in OS X v10.4 and later. 298 Splitter = 1936747636, 299 /// An audio unit with two input buses and one output bus. The audio unit merges the two input 300 /// signals to the single output. 301 /// 302 /// **Available** in OS X v10.4 and later. 303 Merger = 1835364967, 304 /// An audio unit that can control playback rate. As the playback rate increases, so does 305 /// pitch. 306 /// 307 /// This subtype provides a generic view, making it suitable for UI and programmatic context. 308 /// 309 /// OS X provides realtime and offline audio units of this subtype. 310 /// 311 /// **Available** in OS X v10.3 and later. 312 Varispeed = 1986097769, 313 /// **Available** in OS X v10.9 and later. 314 AUiPodTimeOther = 1768977519, 315 } 316 317 318 /// Audio mixing **AudioUnit** subtypes for **AudioUnit**s provided by Apple. 319 #[derive(Copy, Clone, Debug, PartialEq)] 320 pub enum MixerType { 321 /// An audio unit that can have any number of input buses, with any number of channels on each 322 /// input bus, and one output bus. 323 /// 324 /// In OS X, the output bus can have any number of channels. 325 /// 326 /// In iPhone OS, the output bus always has two channels. 327 /// 328 /// **Available** in OS X v10.5 and later. 329 MultiChannelMixer = 1835232632, 330 /// An audio unit that can have any number of input buses, each of which is mono or stereo, and 331 /// one stereo output bus. 332 /// 333 /// **Available** in OS X v10.2 and later. 334 StereoMixer = 1936554098, 335 /// An audio unit that can have any number of input buses and one output bus. 336 /// 337 /// Each input bus can be mono, in which case it can be panned using 3D coordinates and 338 /// parameters. 339 /// 340 /// Stereo input buses pass directly through to the output. 341 /// 342 /// Four-channel ambisonic inputs are rendered to the output configuration. 343 /// 344 /// The single output bus can be configured with 2, 4, 5, 6, 7 or 8 channels. 345 /// 346 /// **Available** in OS X v10.3 and later. 347 /// 348 /// **Deprecated** in OS X v10.10. 349 Mixer3D = 862219640, 350 /// An audio unit that can have any number of input and output buses with any number of 351 /// channels on each bus. 352 /// 353 /// You configure the mix using a matrix of channels with a separate input level control for 354 /// each channel. 355 /// 356 /// The audio unit also provides individual level control for each 357 /// input-channel-to-output-channel combination, as well as level control for each output 358 /// channel. 359 /// 360 /// Finally, the audio unit provides a global level control for the matrix as a whole. 361 /// 362 /// **Available** in OS X v10.3 and later. 363 MatrixMixer = 1836608888, 364 } 365 366 367 /// Audio units that serve as sound sources. 368 #[derive(Copy, Clone, Debug, PartialEq)] 369 pub enum GeneratorType { 370 /// A generator unit that can be used to schedule slices of audio to be played at specified 371 /// times. 372 /// 373 /// The audio is scheduled using the time stamps for the render operation and can be scheduled 374 /// from any thread. 375 /// 376 /// **Available** in OS X v10.4 and later. 377 ScheduledSoundPlayer = 1936945260, 378 /// A generator unit that is used to play a file. In OS X it presents a custom UI so can be 379 /// used in a UI context as well as in a programmatic context. 380 /// 381 /// **Available** in OS X v10.4 and later. 382 AudioFilePlayer = 1634103404, 383 } 384 385 386 /// Audio units that can be played as musical instruments via MIDI control. 387 #[derive(Copy, Clone, Debug, PartialEq)] 388 pub enum MusicDeviceType { 389 /// A multitimbral instrument unit that can use sample banks in either DLS or SoundFont 390 /// formats. 391 /// 392 /// It fully supports GM-MIDI and the basic extensions of GS-MIDI 393 /// 394 /// **Available** in OS X v10.2 and later. 395 DLSSynth = 1684828960, 396 /// A monotimbral instrument unit that functions a a sampler-synthesizer and supports full 397 /// interactive editing of its state. 398 /// 399 /// **Available** in OS X v10.7 and later. 400 Sampler = 1935764848, 401 } 402 403 404 /// Input/output **AudioUnit** subtypes for **AudioUnit**s provided by Apple. 405 #[derive(Copy, Clone, Debug, PartialEq)] 406 pub enum IOType { 407 /// An audio unit that responds to start/stop calls and provides basic services for converting 408 /// to and from linear PCM formats. 409 /// 410 /// Use this audio unit when sending the output of an audio processing graph to your 411 /// application rather than to the output audio hardware. You would typically use the Generic 412 /// Output unit for offline audio processing. Just like the other I/O units, the Generic Output 413 /// unit incorporates a Format Converter unit. This lets the Generic Output unit perform format 414 /// conversion between the stream format used in an audio processing graph and the format you 415 /// want. 416 /// 417 /// You can also use a Generic Output unit as the final node in a subgraph that you place into 418 /// a parent audio processing graph. 419 /// 420 /// **Available** in OS X v10.2 and later. 421 GenericOutput = 1734700658, 422 /// An audio unit that can provides input/output connection to an a specified audio device. 423 /// 424 /// Bus 0 provides output to the audio device and bus 1 accepts input from the audio device. 425 /// 426 /// **Available** in OS X v10.2 and later. 427 HalOutput = 1634230636, 428 /// A specialized **HalOutput** audio unit that connects to the user’s selected default device 429 /// in Sound Preferences. 430 /// 431 /// **Available** in OS X v10.2 and later. 432 DefaultOutput = 1684366880, 433 /// A specialized **HalOutput** audio unit that connects to the user’s selected device for 434 /// sound effects, alerts, and other user-interface sounds. 435 /// 436 /// **Available** in OS X v10.2 and later. 437 SystemOutput = 1937339168, 438 /// An audio unit that interfaces to the audio inputs and outputs of iPhone OS devices and 439 /// provides voice processing features. 440 /// 441 /// Bus 0 provides output to hardware and bus 1 accepts input from hardware. 442 /// 443 /// See the [Voice-Processing I/O Audio Unit 444 /// Properties](https://developer.apple.com/library/prerelease/mac/documentation/AudioUnit/Reference/AudioUnitPropertiesReference/index.html#//apple_ref/doc/constant_group/Voice_Processing_I_O_Audio_Unit_Properties) 445 /// enumeration for the identifiers for this audio unit’s properties. 446 /// 447 /// **Available** in OS X v10.7 and later. 448 VoiceProcessingIO = 1987078511, 449 /// Connects to device hardware for input, output, or simultaneous input and output. 450 /// Use it for playback, recording, or low-latency simultaneous input and output where echo 451 /// cancelation is not needed. 452 /// 453 /// See https://developer.apple.com/library/content/documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/UsingSpecificAudioUnits/UsingSpecificAudioUnits.html 454 /// **Available** in iOS. 455 RemoteIO = 1919512419, 456 } 457 458