objc2_audio_toolbox/generated/MusicPlayer.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-core-foundation")]
9use objc2_core_foundation::*;
10#[cfg(feature = "objc2-core-midi")]
11use objc2_core_midi::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_null?language=objc)
16pub const kMusicEventType_NULL: u32 = 0;
17/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_extendednote?language=objc)
18pub const kMusicEventType_ExtendedNote: u32 = 1;
19/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_extendedtempo?language=objc)
20pub const kMusicEventType_ExtendedTempo: u32 = 3;
21/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_user?language=objc)
22pub const kMusicEventType_User: u32 = 4;
23/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_meta?language=objc)
24pub const kMusicEventType_Meta: u32 = 5;
25/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_midinotemessage?language=objc)
26pub const kMusicEventType_MIDINoteMessage: u32 = 6;
27/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_midichannelmessage?language=objc)
28pub const kMusicEventType_MIDIChannelMessage: u32 = 7;
29/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_midirawdata?language=objc)
30pub const kMusicEventType_MIDIRawData: u32 = 8;
31/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_parameter?language=objc)
32pub const kMusicEventType_Parameter: u32 = 9;
33/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_aupreset?language=objc)
34pub const kMusicEventType_AUPreset: u32 = 10;
35
36/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musiceventtype?language=objc)
37pub type MusicEventType = u32;
38
39/// Flags used to customise loading behaviour
40///
41/// If this flag is set the resultant Sequence will contain:
42/// a tempo track
43/// a track for each track found in the SMF
44/// This is the default behavior
45///
46/// If this flag is set the resultant Sequence will contain:
47/// a tempo track
48/// 1 track for each MIDI Channel that is found in the SMF
49/// 1 track for SysEx or MetaEvents - this will be the last track
50/// in the sequence after the LoadSMFWithFlags calls
51///
52/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musicsequenceloadflags?language=objc)
53// NS_OPTIONS
54#[repr(transparent)]
55#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
56pub struct MusicSequenceLoadFlags(pub u32);
57bitflags::bitflags! {
58 impl MusicSequenceLoadFlags: u32 {
59 #[doc(alias = "kMusicSequenceLoadSMF_PreserveTracks")]
60 const SMF_PreserveTracks = 0;
61 #[doc(alias = "kMusicSequenceLoadSMF_ChannelsToTracks")]
62 const SMF_ChannelsToTracks = 1<<0;
63 }
64}
65
66unsafe impl Encode for MusicSequenceLoadFlags {
67 const ENCODING: Encoding = u32::ENCODING;
68}
69
70unsafe impl RefEncode for MusicSequenceLoadFlags {
71 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74/// A sequence type
75///
76/// Different sequence types to describe the basic mode of operation of a sequence's time line
77/// You cannot change a music sequence's type to samples/seconds if there are tempo events
78/// The type will also define how the sequence is saved to a MIDI file:
79/// Beats - normal midi file
80/// Seconds - midi file with SMPTE time
81/// Samples - cannot be saved to a midi file
82///
83/// The default/normal type of a sequence.
84/// Tempo track defines the number of beats per second and can have multiple tempo events
85///
86/// A music sequence with a single 60bpm tempo event
87///
88/// A music sequence with a single tempo event that represents the audio sample rate
89///
90/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musicsequencetype?language=objc)
91// NS_ENUM
92#[repr(transparent)]
93#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
94pub struct MusicSequenceType(pub u32);
95impl MusicSequenceType {
96 #[doc(alias = "kMusicSequenceType_Beats")]
97 pub const Beats: Self = Self(0x62656174);
98 #[doc(alias = "kMusicSequenceType_Seconds")]
99 pub const Seconds: Self = Self(0x73656373);
100 #[doc(alias = "kMusicSequenceType_Samples")]
101 pub const Samples: Self = Self(0x73616d70);
102}
103
104unsafe impl Encode for MusicSequenceType {
105 const ENCODING: Encoding = u32::ENCODING;
106}
107
108unsafe impl RefEncode for MusicSequenceType {
109 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
110}
111
112/// describes different types of files that can be parsed by a music sequence
113///
114/// let the system read iMelody files and read and write MIDI files (and any future types)
115///
116/// read and write MIDI files
117///
118/// read iMelody files
119///
120/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musicsequencefiletypeid?language=objc)
121// NS_ENUM
122#[repr(transparent)]
123#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
124pub struct MusicSequenceFileTypeID(pub u32);
125impl MusicSequenceFileTypeID {
126 #[doc(alias = "kMusicSequenceFile_AnyType")]
127 pub const AnyType: Self = Self(0);
128 #[doc(alias = "kMusicSequenceFile_MIDIType")]
129 pub const MIDIType: Self = Self(0x6d696469);
130 #[doc(alias = "kMusicSequenceFile_iMelodyType")]
131 pub const iMelodyType: Self = Self(0x696d656c);
132}
133
134unsafe impl Encode for MusicSequenceFileTypeID {
135 const ENCODING: Encoding = u32::ENCODING;
136}
137
138unsafe impl RefEncode for MusicSequenceFileTypeID {
139 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
140}
141
142/// controls the behaviour of the create file calls
143///
144/// Does not overwrite existing files. Attempts to save over an existing file
145/// will return kAudio_FilePermissionError
146///
147/// Erase an existing file when creating a new file
148///
149/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musicsequencefileflags?language=objc)
150// NS_OPTIONS
151#[repr(transparent)]
152#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
153pub struct MusicSequenceFileFlags(pub u32);
154bitflags::bitflags! {
155 impl MusicSequenceFileFlags: u32 {
156 #[doc(alias = "kMusicSequenceFileFlags_Default")]
157 const Default = 0;
158 #[doc(alias = "kMusicSequenceFileFlags_EraseFile")]
159 const EraseFile = 1;
160 }
161}
162
163unsafe impl Encode for MusicSequenceFileFlags {
164 const ENCODING: Encoding = u32::ENCODING;
165}
166
167unsafe impl RefEncode for MusicSequenceFileFlags {
168 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
169}
170
171/// The type used to refer to time values in a music sequence
172///
173/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musictimestamp?language=objc)
174pub type MusicTimeStamp = f64;
175
176/// The parameters to specify a MIDI note
177///
178/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/midinotemessage?language=objc)
179#[repr(C)]
180#[derive(Clone, Copy, Debug, PartialEq)]
181pub struct MIDINoteMessage {
182 pub channel: u8,
183 pub note: u8,
184 pub velocity: u8,
185 pub releaseVelocity: u8,
186 pub duration: f32,
187}
188
189unsafe impl Encode for MIDINoteMessage {
190 const ENCODING: Encoding = Encoding::Struct(
191 "MIDINoteMessage",
192 &[
193 <u8>::ENCODING,
194 <u8>::ENCODING,
195 <u8>::ENCODING,
196 <u8>::ENCODING,
197 <f32>::ENCODING,
198 ],
199 );
200}
201
202unsafe impl RefEncode for MIDINoteMessage {
203 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
204}
205
206/// The parameters to specify a MIDI channel message
207///
208/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/midichannelmessage?language=objc)
209#[repr(C)]
210#[derive(Clone, Copy, Debug, PartialEq)]
211pub struct MIDIChannelMessage {
212 pub status: u8,
213 pub data1: u8,
214 pub data2: u8,
215 pub reserved: u8,
216}
217
218unsafe impl Encode for MIDIChannelMessage {
219 const ENCODING: Encoding = Encoding::Struct(
220 "MIDIChannelMessage",
221 &[
222 <u8>::ENCODING,
223 <u8>::ENCODING,
224 <u8>::ENCODING,
225 <u8>::ENCODING,
226 ],
227 );
228}
229
230unsafe impl RefEncode for MIDIChannelMessage {
231 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
232}
233
234/// Generally used to represent a MIDI SysEx message
235///
236/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/midirawdata?language=objc)
237#[repr(C)]
238#[derive(Clone, Copy, Debug, PartialEq)]
239pub struct MIDIRawData {
240 pub length: u32,
241 pub data: [u8; 1],
242}
243
244unsafe impl Encode for MIDIRawData {
245 const ENCODING: Encoding =
246 Encoding::Struct("MIDIRawData", &[<u32>::ENCODING, <[u8; 1]>::ENCODING]);
247}
248
249unsafe impl RefEncode for MIDIRawData {
250 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
251}
252
253/// The parameters to specify a MIDI meta event
254///
255/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/midimetaevent?language=objc)
256#[repr(C)]
257#[derive(Clone, Copy, Debug, PartialEq)]
258pub struct MIDIMetaEvent {
259 pub metaEventType: u8,
260 pub unused1: u8,
261 pub unused2: u8,
262 pub unused3: u8,
263 pub dataLength: u32,
264 pub data: [u8; 1],
265}
266
267unsafe impl Encode for MIDIMetaEvent {
268 const ENCODING: Encoding = Encoding::Struct(
269 "MIDIMetaEvent",
270 &[
271 <u8>::ENCODING,
272 <u8>::ENCODING,
273 <u8>::ENCODING,
274 <u8>::ENCODING,
275 <u32>::ENCODING,
276 <[u8; 1]>::ENCODING,
277 ],
278 );
279}
280
281unsafe impl RefEncode for MIDIMetaEvent {
282 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
283}
284
285/// Provides a general struct for specifying a user defined event.
286///
287/// the size in bytes of the data
288///
289/// size bytes of user defined event data
290///
291/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musiceventuserdata?language=objc)
292#[repr(C)]
293#[derive(Clone, Copy, Debug, PartialEq)]
294pub struct MusicEventUserData {
295 pub length: u32,
296 pub data: [u8; 1],
297}
298
299unsafe impl Encode for MusicEventUserData {
300 const ENCODING: Encoding = Encoding::Struct(
301 "MusicEventUserData",
302 &[<u32>::ENCODING, <[u8; 1]>::ENCODING],
303 );
304}
305
306unsafe impl RefEncode for MusicEventUserData {
307 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
308}
309
310/// The parameters to specify an extended note on event
311///
312/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/extendednoteonevent?language=objc)
313#[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
314#[repr(C)]
315#[derive(Clone, Copy, Debug, PartialEq)]
316pub struct ExtendedNoteOnEvent {
317 pub instrumentID: MusicDeviceInstrumentID,
318 pub groupID: MusicDeviceGroupID,
319 pub duration: f32,
320 pub extendedParams: MusicDeviceNoteParams,
321}
322
323#[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
324unsafe impl Encode for ExtendedNoteOnEvent {
325 const ENCODING: Encoding = Encoding::Struct(
326 "ExtendedNoteOnEvent",
327 &[
328 <MusicDeviceInstrumentID>::ENCODING,
329 <MusicDeviceGroupID>::ENCODING,
330 <f32>::ENCODING,
331 <MusicDeviceNoteParams>::ENCODING,
332 ],
333 );
334}
335
336#[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
337unsafe impl RefEncode for ExtendedNoteOnEvent {
338 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
339}
340
341/// The parameters to specify a parameter event to an audio unit.
342///
343/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/parameterevent?language=objc)
344#[cfg(feature = "AUComponent")]
345#[repr(C)]
346#[derive(Clone, Copy, Debug, PartialEq)]
347pub struct ParameterEvent {
348 pub parameterID: AudioUnitParameterID,
349 pub scope: AudioUnitScope,
350 pub element: AudioUnitElement,
351 pub value: AudioUnitParameterValue,
352}
353
354#[cfg(feature = "AUComponent")]
355unsafe impl Encode for ParameterEvent {
356 const ENCODING: Encoding = Encoding::Struct(
357 "ParameterEvent",
358 &[
359 <AudioUnitParameterID>::ENCODING,
360 <AudioUnitScope>::ENCODING,
361 <AudioUnitElement>::ENCODING,
362 <AudioUnitParameterValue>::ENCODING,
363 ],
364 );
365}
366
367#[cfg(feature = "AUComponent")]
368unsafe impl RefEncode for ParameterEvent {
369 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
370}
371
372/// specifies the value for a tempo in beats per minute
373///
374/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/extendedtempoevent?language=objc)
375#[repr(C)]
376#[derive(Clone, Copy, Debug, PartialEq)]
377pub struct ExtendedTempoEvent {
378 pub bpm: f64,
379}
380
381unsafe impl Encode for ExtendedTempoEvent {
382 const ENCODING: Encoding = Encoding::Struct("ExtendedTempoEvent", &[<f64>::ENCODING]);
383}
384
385unsafe impl RefEncode for ExtendedTempoEvent {
386 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
387}
388
389/// The parameters to specify a preset for an audio unit.
390///
391/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/aupresetevent?language=objc)
392#[cfg(all(feature = "AUComponent", feature = "objc2-core-foundation"))]
393#[repr(C)]
394#[derive(Clone, Copy, Debug, PartialEq)]
395pub struct AUPresetEvent {
396 pub scope: AudioUnitScope,
397 pub element: AudioUnitElement,
398 pub preset: NonNull<CFPropertyList>,
399}
400
401#[cfg(all(feature = "AUComponent", feature = "objc2-core-foundation"))]
402unsafe impl Encode for AUPresetEvent {
403 const ENCODING: Encoding = Encoding::Struct(
404 "AUPresetEvent",
405 &[
406 <AudioUnitScope>::ENCODING,
407 <AudioUnitElement>::ENCODING,
408 <NonNull<CFPropertyList>>::ENCODING,
409 ],
410 );
411}
412
413#[cfg(all(feature = "AUComponent", feature = "objc2-core-foundation"))]
414unsafe impl RefEncode for AUPresetEvent {
415 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
416}
417
418/// A display representation of a musical time in beats.
419///
420/// A clock's internal representation of musical time is in beats based on the
421/// beginning of the timeline. Normally, such times should be displayed to the user
422/// in terms of bars, beats, and subbeats (sometimes called "units" or "parts per
423/// quarter" [PPQ]). This data structure is such a display representation.
424///
425/// By convention, bar 1 is the beginning of the sequence. Beat 1 is the first beat
426/// of the measure. In 4/4 time, beat will have a value from 1 to 4. Music
427/// applications often use beat divisions such as 480 and 960.
428///
429///
430/// A measure number.
431///
432/// A beat number (1..n).
433///
434/// The numerator of the fractional number of beats.
435///
436/// The denominator of the fractional number of beats.
437///
438/// Must be 0.
439///
440/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/cabarbeattime?language=objc)
441#[repr(C)]
442#[derive(Clone, Copy, Debug, PartialEq)]
443pub struct CABarBeatTime {
444 pub bar: i32,
445 pub beat: u16,
446 pub subbeat: u16,
447 pub subbeatDivisor: u16,
448 pub reserved: u16,
449}
450
451unsafe impl Encode for CABarBeatTime {
452 const ENCODING: Encoding = Encoding::Struct(
453 "CABarBeatTime",
454 &[
455 <i32>::ENCODING,
456 <u16>::ENCODING,
457 <u16>::ENCODING,
458 <u16>::ENCODING,
459 <u16>::ENCODING,
460 ],
461 );
462}
463
464unsafe impl RefEncode for CABarBeatTime {
465 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
466}
467
468/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaquemusicplayer?language=objc)
469#[repr(C)]
470#[derive(Debug)]
471pub struct OpaqueMusicPlayer {
472 inner: [u8; 0],
473 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
474}
475
476unsafe impl RefEncode for OpaqueMusicPlayer {
477 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueMusicPlayer", &[]));
478}
479
480/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musicplayer?language=objc)
481pub type MusicPlayer = *mut OpaqueMusicPlayer;
482
483/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaquemusicsequence?language=objc)
484#[repr(C)]
485#[derive(Debug)]
486pub struct OpaqueMusicSequence {
487 inner: [u8; 0],
488 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
489}
490
491unsafe impl RefEncode for OpaqueMusicSequence {
492 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueMusicSequence", &[]));
493}
494
495/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musicsequence?language=objc)
496pub type MusicSequence = *mut OpaqueMusicSequence;
497
498/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaquemusictrack?language=objc)
499#[repr(C)]
500#[derive(Debug)]
501pub struct OpaqueMusicTrack {
502 inner: [u8; 0],
503 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
504}
505
506unsafe impl RefEncode for OpaqueMusicTrack {
507 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("OpaqueMusicTrack", &[]));
508}
509
510/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musictrack?language=objc)
511pub type MusicTrack = *mut OpaqueMusicTrack;
512
513/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/opaquemusiceventiterator?language=objc)
514#[repr(C)]
515#[derive(Debug)]
516pub struct OpaqueMusicEventIterator {
517 inner: [u8; 0],
518 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
519}
520
521unsafe impl RefEncode for OpaqueMusicEventIterator {
522 const ENCODING_REF: Encoding =
523 Encoding::Pointer(&Encoding::Struct("OpaqueMusicEventIterator", &[]));
524}
525
526/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musiceventiterator?language=objc)
527pub type MusicEventIterator = *mut OpaqueMusicEventIterator;
528
529/// See MusicSequenceSetUserCallback
530///
531/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musicsequenceusercallback?language=objc)
532pub type MusicSequenceUserCallback = Option<
533 unsafe extern "C-unwind" fn(
534 *mut c_void,
535 MusicSequence,
536 MusicTrack,
537 MusicTimeStamp,
538 NonNull<MusicEventUserData>,
539 MusicTimeStamp,
540 MusicTimeStamp,
541 ),
542>;
543
544/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_invalidsequencetype?language=objc)
545pub const kAudioToolboxErr_InvalidSequenceType: OSStatus = -10846;
546/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_trackindexerror?language=objc)
547pub const kAudioToolboxErr_TrackIndexError: OSStatus = -10859;
548/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_tracknotfound?language=objc)
549pub const kAudioToolboxErr_TrackNotFound: OSStatus = -10858;
550/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_endoftrack?language=objc)
551pub const kAudioToolboxErr_EndOfTrack: OSStatus = -10857;
552/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_startoftrack?language=objc)
553pub const kAudioToolboxErr_StartOfTrack: OSStatus = -10856;
554/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_illegaltrackdestination?language=objc)
555pub const kAudioToolboxErr_IllegalTrackDestination: OSStatus = -10855;
556/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_nosequence?language=objc)
557pub const kAudioToolboxErr_NoSequence: OSStatus = -10854;
558/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_invalideventtype?language=objc)
559pub const kAudioToolboxErr_InvalidEventType: OSStatus = -10853;
560/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_invalidplayerstate?language=objc)
561pub const kAudioToolboxErr_InvalidPlayerState: OSStatus = -10852;
562/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerr_cannotdoincurrentcontext?language=objc)
563pub const kAudioToolboxErr_CannotDoInCurrentContext: OSStatus = -10863;
564/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kaudiotoolboxerror_notrackdestination?language=objc)
565pub const kAudioToolboxError_NoTrackDestination: OSStatus = -66720;
566
567/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksequencetrackproperty_loopinfo?language=objc)
568pub const kSequenceTrackProperty_LoopInfo: u32 = 0;
569/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksequencetrackproperty_offsettime?language=objc)
570pub const kSequenceTrackProperty_OffsetTime: u32 = 1;
571/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksequencetrackproperty_mutestatus?language=objc)
572pub const kSequenceTrackProperty_MuteStatus: u32 = 2;
573/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksequencetrackproperty_solostatus?language=objc)
574pub const kSequenceTrackProperty_SoloStatus: u32 = 3;
575/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksequencetrackproperty_automatedparameters?language=objc)
576pub const kSequenceTrackProperty_AutomatedParameters: u32 = 4;
577/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksequencetrackproperty_tracklength?language=objc)
578pub const kSequenceTrackProperty_TrackLength: u32 = 5;
579/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/ksequencetrackproperty_timeresolution?language=objc)
580pub const kSequenceTrackProperty_TimeResolution: u32 = 6;
581
582/// Used to control the looping behaviour of a track
583///
584/// See also [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/musictrackloopinfo?language=objc)
585#[repr(C)]
586#[derive(Clone, Copy, Debug, PartialEq)]
587pub struct MusicTrackLoopInfo {
588 pub loopDuration: MusicTimeStamp,
589 pub numberOfLoops: i32,
590}
591
592unsafe impl Encode for MusicTrackLoopInfo {
593 const ENCODING: Encoding = Encoding::Struct(
594 "MusicTrackLoopInfo",
595 &[<MusicTimeStamp>::ENCODING, <i32>::ENCODING],
596 );
597}
598
599unsafe impl RefEncode for MusicTrackLoopInfo {
600 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
601}
602
603extern "C-unwind" {
604 /// Create a new music player
605 ///
606 /// A music player is used to play a sequence back. This call is used to create a player
607 /// When a sequence is to be played by a player, it can play to either an AUGraph, a MIDI Destination or a
608 /// mixture/combination of both.
609 ///
610 /// Parameter `outPlayer`: the newly created player
611 ///
612 /// # Safety
613 ///
614 /// `out_player` must be a valid pointer.
615 pub fn NewMusicPlayer(out_player: NonNull<MusicPlayer>) -> OSStatus;
616}
617
618extern "C-unwind" {
619 /// Dispose a music player
620 ///
621 /// Parameter `inPlayer`: the player to dispose
622 ///
623 /// # Safety
624 ///
625 /// `in_player` must be a valid pointer.
626 pub fn DisposeMusicPlayer(in_player: MusicPlayer) -> OSStatus;
627}
628
629extern "C-unwind" {
630 /// Set the sequence for the player to play
631 ///
632 /// A Sequence cannot be set on a player while it is playing. Setting a sequence
633 /// will overide the currently set sequence.
634 ///
635 /// Parameter `inPlayer`: the player
636 ///
637 /// Parameter `inSequence`: the sequence for the player to play
638 ///
639 /// # Safety
640 ///
641 /// - `in_player` must be a valid pointer.
642 /// - `in_sequence` must be a valid pointer or null.
643 pub fn MusicPlayerSetSequence(in_player: MusicPlayer, in_sequence: MusicSequence) -> OSStatus;
644}
645
646extern "C-unwind" {
647 /// Get the sequence attached to a player
648 ///
649 /// If the player does not have a sequence set, this will return the _NoSequence error
650 ///
651 /// Parameter `inPlayer`: the player
652 ///
653 /// Parameter `outSequence`: the sequence currently set on the player
654 ///
655 /// # Safety
656 ///
657 /// - `in_player` must be a valid pointer.
658 /// - `out_sequence` must be a valid pointer.
659 pub fn MusicPlayerGetSequence(
660 in_player: MusicPlayer,
661 out_sequence: NonNull<MusicSequence>,
662 ) -> OSStatus;
663}
664
665extern "C-unwind" {
666 /// Set the current time on the player
667 ///
668 /// The Get and Set Time calls take a specification of time as beats. This positions the player
669 /// to the specified time based on the currently set sequence. No range checking on the time value
670 /// is done. This can be set on a playing player (in which case playing will be resumed from the
671 /// new time).
672 ///
673 /// Parameter `inPlayer`: the player
674 ///
675 /// Parameter `inTime`: the new time value
676 ///
677 /// # Safety
678 ///
679 /// `in_player` must be a valid pointer.
680 pub fn MusicPlayerSetTime(in_player: MusicPlayer, in_time: MusicTimeStamp) -> OSStatus;
681}
682
683extern "C-unwind" {
684 /// Get the current time of the player
685 ///
686 /// The Get and Set Time calls take a specification of time as beats. This retrieves the player's
687 /// current time. If it is playing this time is the time of the player at the time the call was made.
688 ///
689 /// Parameter `inPlayer`: the player
690 ///
691 /// Parameter `outTime`: the current time value
692 ///
693 /// # Safety
694 ///
695 /// - `in_player` must be a valid pointer.
696 /// - `out_time` must be a valid pointer.
697 pub fn MusicPlayerGetTime(
698 in_player: MusicPlayer,
699 out_time: NonNull<MusicTimeStamp>,
700 ) -> OSStatus;
701}
702
703extern "C-unwind" {
704 /// Returns the host time that will be (or was) played at the specified beat.
705 ///
706 /// This call is only valid if the player is playing and will return an error if the player is not playing
707 /// or if the starting position of the player (its "starting beat") was after the specified beat.
708 /// For general translation of beats to time in a sequence, see the MusicSequence calls for beat
709 /// <
710 /// ->seconds.
711 ///
712 /// The call uses the player's sequence's tempo map to translate a beat time from the starting time and beat
713 /// of the player.
714 ///
715 /// Parameter `inPlayer`: the player
716 ///
717 /// Parameter `inBeats`: the specified beat-time value
718 ///
719 /// Parameter `outHostTime`: the corresponding host time
720 ///
721 /// # Safety
722 ///
723 /// - `in_player` must be a valid pointer.
724 /// - `out_host_time` must be a valid pointer.
725 pub fn MusicPlayerGetHostTimeForBeats(
726 in_player: MusicPlayer,
727 in_beats: MusicTimeStamp,
728 out_host_time: NonNull<u64>,
729 ) -> OSStatus;
730}
731
732extern "C-unwind" {
733 /// Returns the beat that will be (or was) played at the specified host time.
734 ///
735 /// This call is only valid if the player is playing and will return an error if the player is not playing
736 /// or if the starting time of the player was after the specified host time.
737 /// For general translation of beats to time in a sequence, see the MusicSequence calls for beat
738 /// <
739 /// ->seconds.
740 ///
741 /// The call uses the player's sequence's tempo map to retrieve a beat time from the starting and specified host time.
742 ///
743 ///
744 /// Parameter `inPlayer`: the player
745 ///
746 /// Parameter `inHostTime`: the specified host time value
747 ///
748 /// Parameter `outBeats`: the corresponding beat time
749 ///
750 /// # Safety
751 ///
752 /// - `in_player` must be a valid pointer.
753 /// - `out_beats` must be a valid pointer.
754 pub fn MusicPlayerGetBeatsForHostTime(
755 in_player: MusicPlayer,
756 in_host_time: u64,
757 out_beats: NonNull<MusicTimeStamp>,
758 ) -> OSStatus;
759}
760
761extern "C-unwind" {
762 /// Prepare the player for playing
763 ///
764 /// Allows the player to prepare its state so that starting is has a lower latency. If a player is started without
765 /// being prerolled, the player will pre-roll itself and then start.
766 ///
767 /// Parameter `inPlayer`: the player
768 ///
769 /// # Safety
770 ///
771 /// `in_player` must be a valid pointer.
772 pub fn MusicPlayerPreroll(in_player: MusicPlayer) -> OSStatus;
773}
774
775extern "C-unwind" {
776 /// Start the player
777 ///
778 /// If the player has not been prerolled, it will pre-roll itself and then start.
779 ///
780 /// Parameter `inPlayer`: the player
781 ///
782 /// # Safety
783 ///
784 /// `in_player` must be a valid pointer.
785 pub fn MusicPlayerStart(in_player: MusicPlayer) -> OSStatus;
786}
787
788extern "C-unwind" {
789 /// Stop the player
790 ///
791 /// Parameter `inPlayer`: the player
792 ///
793 /// # Safety
794 ///
795 /// `in_player` must be a valid pointer.
796 pub fn MusicPlayerStop(in_player: MusicPlayer) -> OSStatus;
797}
798
799extern "C-unwind" {
800 /// Returns the playing state of the player. "Is it playing?"
801 ///
802 /// This call returns a non-zero value in outIsPlaying if the player has been
803 /// started and not stopped. It may have "played" past the events of the attached
804 /// MusicSequence, but it is still considered to be playing (and its time value increasing)
805 /// until it is explicitly stopped
806 ///
807 /// Parameter `inPlayer`: the player
808 ///
809 /// Parameter `outIsPlaying`: false if not, true (non-zero) if is playing
810 ///
811 /// # Safety
812 ///
813 /// - `in_player` must be a valid pointer.
814 /// - `out_is_playing` must be a valid pointer.
815 pub fn MusicPlayerIsPlaying(
816 in_player: MusicPlayer,
817 out_is_playing: NonNull<Boolean>,
818 ) -> OSStatus;
819}
820
821extern "C-unwind" {
822 /// Scale the playback rate of the player
823 ///
824 /// Parameter `inPlayer`: the player
825 ///
826 /// Parameter `inScaleRate`: a scalar that will be applied to the playback rate. If 2, playback is twice as fast, if
827 /// 0.5 it is half as fast. As a scalar, the value must be greater than zero.
828 ///
829 /// # Safety
830 ///
831 /// `in_player` must be a valid pointer.
832 pub fn MusicPlayerSetPlayRateScalar(in_player: MusicPlayer, in_scale_rate: f64) -> OSStatus;
833}
834
835extern "C-unwind" {
836 /// Get the playback rate scalar of the player
837 ///
838 /// Parameter `inPlayer`: the player
839 ///
840 /// Parameter `outScaleRate`: the current scalar being applied to the player. Default value is 1.0
841 ///
842 /// # Safety
843 ///
844 /// - `in_player` must be a valid pointer.
845 /// - `out_scale_rate` must be a valid pointer.
846 pub fn MusicPlayerGetPlayRateScalar(
847 in_player: MusicPlayer,
848 out_scale_rate: NonNull<f64>,
849 ) -> OSStatus;
850}
851
852extern "C-unwind" {
853 /// Create a new empty sequence
854 ///
855 /// A new music sequence will only have a tempo track (with a default tempo of 120 bpm),
856 /// and the default type is beat based.
857 ///
858 /// When a sequence is to be played by a player, it can play to either an AUGraph, a MIDI Destination or a
859 /// mixture/combination of both. See MusicSequenceSetAUGraph and MusicSequenceSetMIDIEndpoint for the generic
860 /// destination assignments. Specific tracks can also be assigned nodes of a graph or a MIDI endpoint as targets
861 /// for the events that they contain; see MusicTrackSetDestNode and MusicTrackSetDestMIDIEndpoint.
862 ///
863 ///
864 /// Parameter `outSequence`: the new sequence
865 ///
866 /// # Safety
867 ///
868 /// `out_sequence` must be a valid pointer.
869 pub fn NewMusicSequence(out_sequence: NonNull<MusicSequence>) -> OSStatus;
870}
871
872extern "C-unwind" {
873 /// Dispose the sequence
874 ///
875 /// A sequence cannot be disposed while a MusicPlayer has it.
876 ///
877 /// Parameter `inSequence`: the sequence
878 ///
879 /// # Safety
880 ///
881 /// `in_sequence` must be a valid pointer.
882 pub fn DisposeMusicSequence(in_sequence: MusicSequence) -> OSStatus;
883}
884
885extern "C-unwind" {
886 /// Add a new (empty) track to the sequence
887 ///
888 /// Parameter `inSequence`: the sequence
889 ///
890 /// Parameter `outTrack`: the new track (it is always appended to any existing tracks)
891 ///
892 /// # Safety
893 ///
894 /// - `in_sequence` must be a valid pointer.
895 /// - `out_track` must be a valid pointer.
896 pub fn MusicSequenceNewTrack(
897 in_sequence: MusicSequence,
898 out_track: NonNull<MusicTrack>,
899 ) -> OSStatus;
900}
901
902extern "C-unwind" {
903 /// Remove and dispose a track from a sequence
904 ///
905 /// Parameter `inSequence`: the sequence
906 ///
907 /// Parameter `inTrack`: the track to remove and dispose
908 ///
909 /// # Safety
910 ///
911 /// - `in_sequence` must be a valid pointer.
912 /// - `in_track` must be a valid pointer.
913 pub fn MusicSequenceDisposeTrack(in_sequence: MusicSequence, in_track: MusicTrack) -> OSStatus;
914}
915
916extern "C-unwind" {
917 /// The number of tracks in a sequence.
918 /// The track count and accessors exclude the tempo track (which is treated as a special case)
919 ///
920 /// Parameter `inSequence`: the sequence
921 ///
922 /// Parameter `outNumberOfTracks`: the number of tracks
923 ///
924 /// # Safety
925 ///
926 /// - `in_sequence` must be a valid pointer.
927 /// - `out_number_of_tracks` must be a valid pointer.
928 pub fn MusicSequenceGetTrackCount(
929 in_sequence: MusicSequence,
930 out_number_of_tracks: NonNull<u32>,
931 ) -> OSStatus;
932}
933
934extern "C-unwind" {
935 /// Get a track at the specified index
936 ///
937 /// Index is zero based. It will return kAudio_ParamError if index is not in the range: 0
938 /// <
939 /// TrackCount
940 /// The track count and accessors exclude the tempo track (which is treated as a special case)
941 ///
942 /// Parameter `inSequence`: the sequence
943 ///
944 /// Parameter `inTrackIndex`: the index
945 ///
946 /// Parameter `outTrack`: the track at that index
947 ///
948 /// # Safety
949 ///
950 /// - `in_sequence` must be a valid pointer.
951 /// - `out_track` must be a valid pointer.
952 pub fn MusicSequenceGetIndTrack(
953 in_sequence: MusicSequence,
954 in_track_index: u32,
955 out_track: NonNull<MusicTrack>,
956 ) -> OSStatus;
957}
958
959extern "C-unwind" {
960 /// Get the index for a specific track
961 ///
962 /// Index is zero based. It will return an error if the track is not a member of the sequence.
963 /// The track count and accessors exclude the tempo track (which is treated as a special case)
964 ///
965 /// Parameter `inSequence`: the sequence
966 ///
967 /// Parameter `inTrack`: the track
968 ///
969 /// Parameter `outTrackIndex`: the index of the track
970 ///
971 /// # Safety
972 ///
973 /// - `in_sequence` must be a valid pointer.
974 /// - `in_track` must be a valid pointer.
975 /// - `out_track_index` must be a valid pointer.
976 pub fn MusicSequenceGetTrackIndex(
977 in_sequence: MusicSequence,
978 in_track: MusicTrack,
979 out_track_index: NonNull<u32>,
980 ) -> OSStatus;
981}
982
983extern "C-unwind" {
984 /// Get the tempo track of the sequence
985 ///
986 /// Each sequence has a single tempo track. All tempo events are placed into this tempo track (as well
987 /// as other appropriate events (time sig for instance from a MIDI file). The tempo track, once retrieved
988 /// can be edited and iterated upon as any other track. Non-tempo events in a tempo track are ignored.
989 ///
990 /// Parameter `inSequence`: the sequence
991 ///
992 /// Parameter `outTrack`: the tempo track of the sequence
993 ///
994 /// # Safety
995 ///
996 /// - `in_sequence` must be a valid pointer.
997 /// - `out_track` must be a valid pointer.
998 pub fn MusicSequenceGetTempoTrack(
999 in_sequence: MusicSequence,
1000 out_track: NonNull<MusicTrack>,
1001 ) -> OSStatus;
1002}
1003
1004extern "C-unwind" {
1005 /// Set the graph to be associated with the sequence
1006 ///
1007 /// A sequence can be associated with an AUGraph and this graph will be used to render the events as
1008 /// controlled by the sequence when it is played. By default, all of the tracks of a sequence will
1009 /// find the first AUNode that is an instance of an Apple MusicDevice audio unit (see MusicSequenceGetAUGraph).
1010 /// Specific nodes of the graph can be targeted for different tracks (see MusicTrackSetDestNode). To render a
1011 /// multi-track GM MIDI sequence on iOS, create a custom graph with a MIDISynth audio unit as the MusicDevice.
1012 /// If inGraph is set to NULL, the sequence will reset to use the default graph.
1013 ///
1014 /// Parameter `inSequence`: the sequence
1015 ///
1016 /// Parameter `inGraph`: the graph
1017 ///
1018 /// # Safety
1019 ///
1020 /// - `in_sequence` must be a valid pointer.
1021 /// - `in_graph` must be a valid pointer or null.
1022 #[cfg(feature = "AUGraph")]
1023 pub fn MusicSequenceSetAUGraph(in_sequence: MusicSequence, in_graph: AUGraph) -> OSStatus;
1024}
1025
1026extern "C-unwind" {
1027 /// Gets the graph currently associated with a sequence
1028 ///
1029 /// By default if no graph is assigned to a sequence then the sequence will create a default graph.
1030 /// This default graph contains a MusicDevice and a DynamicsProcessor and all tracks will be targeted
1031 /// to the MusicDevice. On macOS, this MusicDevice is an instance of a software synthesizer that is
1032 /// compatible with the GM and GS MIDI standards. On iOS, it is an instance of a monotimbral software
1033 /// synthesizer designed to render events from a single MIDI channel. To render multi-track GM MIDI
1034 /// sequences on iOS, create a custom graph with a MIDISynth audio unit as the MusicDevice.
1035 ///
1036 /// This call will thus either return the graph as set by the user, or this default graph.
1037 ///
1038 /// Parameter `inSequence`: the sequence
1039 ///
1040 /// Parameter `outGraph`: the graph
1041 ///
1042 /// # Safety
1043 ///
1044 /// - `in_sequence` must be a valid pointer.
1045 /// - `out_graph` must be a valid pointer.
1046 #[cfg(feature = "AUGraph")]
1047 pub fn MusicSequenceGetAUGraph(
1048 in_sequence: MusicSequence,
1049 out_graph: NonNull<AUGraph>,
1050 ) -> OSStatus;
1051}
1052
1053extern "C-unwind" {
1054 /// Makes the target of all of the tracks in the sequence a MIDI endpoint
1055 ///
1056 /// This is a convenience function, and is equivalent to iterating through all of the tracks in a sequence
1057 /// and targeting each track to the MIDI endpoint
1058 ///
1059 ///
1060 /// Parameter `inSequence`: the sequence
1061 ///
1062 /// Parameter `inEndpoint`: the MIDI endpoint
1063 ///
1064 /// # Safety
1065 ///
1066 /// `in_sequence` must be a valid pointer.
1067 #[cfg(feature = "objc2-core-midi")]
1068 pub fn MusicSequenceSetMIDIEndpoint(
1069 in_sequence: MusicSequence,
1070 in_endpoint: MIDIEndpointRef,
1071 ) -> OSStatus;
1072}
1073
1074extern "C-unwind" {
1075 /// Set the sequence type (the default is beats)
1076 ///
1077 /// These two calls allow you to get and set a MusicSequence type; specifying
1078 /// kMusicSequenceType_Beats = 'beat',
1079 /// kMusicSequenceType_Seconds = 'secs',
1080 /// kMusicSequenceType_Samples = 'samp'
1081 ///
1082 /// The sequence type can be set to beats at any time. The sequence type can only be set to
1083 /// seconds or samples if there are NO tempo events already in the sequence.
1084 ///
1085 /// For beats - it can have as many tempo events as you want
1086 /// For Samples and Seconds - you should add a single tempo event after setting the type
1087 /// Samples - the tempo is the desired sample rate - e.g. 44100 and each "beat" in the sequence will be
1088 /// interpreted as a sample count at that sample rate (so beat == 44100 is a second)
1089 /// Seconds - the tempo should be set to 60 - a beat is a second.
1090 ///
1091 /// Beats is the default (and is the behaviour on pre 10.5 systems)
1092 ///
1093 /// A meta event of interest for Seconds based MIDI files is the SMPTE Offset meta event - stored in the tempo track.
1094 /// The sequence doesn't do anything with this event (except store/write it)
1095 ///
1096 /// Parameter `inSequence`: the sequence
1097 ///
1098 /// Parameter `inType`: the sequence type
1099 ///
1100 /// # Safety
1101 ///
1102 /// `in_sequence` must be a valid pointer.
1103 pub fn MusicSequenceSetSequenceType(
1104 in_sequence: MusicSequence,
1105 in_type: MusicSequenceType,
1106 ) -> OSStatus;
1107}
1108
1109extern "C-unwind" {
1110 /// Get the sequence type
1111 ///
1112 /// See SetSequence for a full description
1113 ///
1114 /// Parameter `inSequence`: the sequence
1115 ///
1116 /// Parameter `outType`: the type
1117 ///
1118 /// # Safety
1119 ///
1120 /// - `in_sequence` must be a valid pointer.
1121 /// - `out_type` must be a valid pointer.
1122 pub fn MusicSequenceGetSequenceType(
1123 in_sequence: MusicSequence,
1124 out_type: NonNull<MusicSequenceType>,
1125 ) -> OSStatus;
1126}
1127
1128extern "C-unwind" {
1129 /// Load the data contained within the referenced file to the sequence
1130 ///
1131 /// This function will parse the file referenced by the URL and add the events to the sequence.
1132 ///
1133 /// Parameter `inSequence`: the sequence
1134 ///
1135 /// Parameter `inFileRef`: a file:// URL that references a file
1136 ///
1137 /// Parameter `inFileTypeHint`: provides a hint to the sequence on the file type being imported. Can be zero in many cases.
1138 ///
1139 /// Parameter `inFlags`: flags that can control how the data is parsed in the file and laid out in the tracks
1140 /// that will be created and added to the sequence in this operation
1141 ///
1142 /// # Safety
1143 ///
1144 /// `in_sequence` must be a valid pointer.
1145 #[cfg(feature = "objc2-core-foundation")]
1146 pub fn MusicSequenceFileLoad(
1147 in_sequence: MusicSequence,
1148 in_file_ref: &CFURL,
1149 in_file_type_hint: MusicSequenceFileTypeID,
1150 in_flags: MusicSequenceLoadFlags,
1151 ) -> OSStatus;
1152}
1153
1154extern "C-unwind" {
1155 /// Load the data to the sequence
1156 ///
1157 /// This function will parse the data and add the events to the sequence. The data provided needs to
1158 /// be of a particular file type as specified by the fileTypeHint.
1159 ///
1160 /// Parameter `inSequence`: the sequence
1161 ///
1162 /// Parameter `inData`: the contents of a valid file loaded into a CFData object
1163 ///
1164 /// Parameter `inFileTypeHint`: provides a hint to the sequence on the file type being imported. Can be zero in many cases.
1165 ///
1166 /// Parameter `inFlags`: flags that can control how the data is parsed in the file and laid out in the tracks
1167 /// that will be created and added to the sequence in this operation
1168 ///
1169 /// # Safety
1170 ///
1171 /// `in_sequence` must be a valid pointer.
1172 #[cfg(feature = "objc2-core-foundation")]
1173 pub fn MusicSequenceFileLoadData(
1174 in_sequence: MusicSequence,
1175 in_data: &CFData,
1176 in_file_type_hint: MusicSequenceFileTypeID,
1177 in_flags: MusicSequenceLoadFlags,
1178 ) -> OSStatus;
1179}
1180
1181// TODO: pub fn MusicSequenceSetSMPTEResolution(fps: SignedByte,ticks: Byte,) -> i16;
1182
1183// TODO: pub fn MusicSequenceGetSMPTEResolution(in_res: i16,fps: NonNull<SignedByte>,ticks: NonNull<Byte>,);
1184
1185extern "C-unwind" {
1186 /// Create a file from a sequence
1187 ///
1188 /// This function can be (and is most commonly) used to create a MIDI file from the events in a sequence.
1189 /// Only MIDI based events are used when creating the MIDI file. MIDI files are normally beat based, but
1190 /// can also have a SMPTE (or real-time rather than beat time) representation.
1191 ///
1192 /// inResolution is relationship between "tick" and quarter note for saving to Standard MIDI File
1193 /// - pass in zero to use default - this will be the value that is currently set on the tempo track
1194 /// - see the comments for the set track property's time resolution
1195 ///
1196 /// The different Sequence types determine the kinds of files that can be created:
1197 ///
1198 /// Beats
1199 /// When saving a MIDI file, it saves a beats (PPQ) based axis
1200 ///
1201 /// Seconds
1202 /// When saving a MIDI file, it will save it as a SMPTE resolution - so you should specify this resolution
1203 /// when creating the MIDI file.
1204 /// If zero is specified, 25 fps and 40 ticks/frame is used (a time scale of a millisecond)
1205 ///
1206 /// Samples
1207 /// You cannot save to a MIDI file with this sequence type
1208 ///
1209 /// The complete meaning of the 16-bit "division" field in a MIDI File's MThd chunk.
1210 ///
1211 /// If it is positive, then a tick represents 1/D quarter notes.
1212 ///
1213 /// If it negative:
1214 ///
1215 /// bits 14-8 are a signed 7-bit number representing the SMPTE format:
1216 /// -24, -25, -29 (drop), -30
1217 /// bits 7-0 represents the number of ticks per SMPTE frame
1218 /// typical values: 4, 10, 80, 100
1219 ///
1220 /// You can obtain millisecond resolution by specifying 25 frames/sec and 40 divisions/frame.
1221 ///
1222 /// 30 fps with 80 bits (ticks) per frame: 0xE250 ((char)0xE2 == -30)
1223 ///
1224 ///
1225 /// Parameter `inSequence`: the sequence
1226 ///
1227 /// Parameter `inFileRef`: the location of the file to create
1228 ///
1229 /// Parameter `inFileType`: the type of file to create
1230 ///
1231 /// Parameter `inFlags`: flags to control the file creation
1232 ///
1233 /// Parameter `inResolution`: the resolution (depending on file type and sequence type)
1234 ///
1235 /// # Safety
1236 ///
1237 /// `in_sequence` must be a valid pointer.
1238 #[cfg(feature = "objc2-core-foundation")]
1239 pub fn MusicSequenceFileCreate(
1240 in_sequence: MusicSequence,
1241 in_file_ref: &CFURL,
1242 in_file_type: MusicSequenceFileTypeID,
1243 in_flags: MusicSequenceFileFlags,
1244 in_resolution: i16,
1245 ) -> OSStatus;
1246}
1247
1248extern "C-unwind" {
1249 /// Create a data object from a sequence
1250 ///
1251 /// The same basic parameters apply to this as with the MusicSequenceFileCreate function. The difference
1252 /// being that that function will create a file on disk, whereas this one will create a CFData object
1253 /// that is a file in memory. The CFData object should be released by the caller.
1254 ///
1255 /// Parameter `inSequence`: the sequence
1256 ///
1257 /// Parameter `inFileType`: the type of file to create
1258 ///
1259 /// Parameter `inFlags`: flags to control the file creation
1260 ///
1261 /// Parameter `inResolution`: the resolution (depending on file type and sequence type)
1262 ///
1263 /// Parameter `outData`: the resulting data object
1264 ///
1265 /// # Safety
1266 ///
1267 /// - `in_sequence` must be a valid pointer.
1268 /// - `out_data` must be a valid pointer.
1269 #[cfg(feature = "objc2-core-foundation")]
1270 pub fn MusicSequenceFileCreateData(
1271 in_sequence: MusicSequence,
1272 in_file_type: MusicSequenceFileTypeID,
1273 in_flags: MusicSequenceFileFlags,
1274 in_resolution: i16,
1275 out_data: NonNull<*const CFData>,
1276 ) -> OSStatus;
1277}
1278
1279extern "C-unwind" {
1280 /// Reverse in time all events in a sequence, including the tempo events
1281 ///
1282 /// Parameter `inSequence`: the sequence
1283 ///
1284 /// # Safety
1285 ///
1286 /// `in_sequence` must be a valid pointer.
1287 pub fn MusicSequenceReverse(in_sequence: MusicSequence) -> OSStatus;
1288}
1289
1290extern "C-unwind" {
1291 /// Returns a seconds value that would correspond to the supplied beats
1292 ///
1293 /// Uses the sequence's tempo events
1294 ///
1295 /// Parameter `inSequence`: the sequence
1296 ///
1297 /// Parameter `inBeats`: the beats
1298 ///
1299 /// Parameter `outSeconds`: the seconds (time from 0 beat)
1300 ///
1301 /// # Safety
1302 ///
1303 /// - `in_sequence` must be a valid pointer.
1304 /// - `out_seconds` must be a valid pointer.
1305 pub fn MusicSequenceGetSecondsForBeats(
1306 in_sequence: MusicSequence,
1307 in_beats: MusicTimeStamp,
1308 out_seconds: NonNull<f64>,
1309 ) -> OSStatus;
1310}
1311
1312extern "C-unwind" {
1313 /// Returns a beat value that would correspond to the supplied seconds from zero.
1314 ///
1315 /// Uses the sequence's tempo events
1316 ///
1317 /// Parameter `inSequence`: the sequence
1318 ///
1319 /// Parameter `inSeconds`: the seconds
1320 ///
1321 /// Parameter `outBeats`: the corresponding beat
1322 ///
1323 /// # Safety
1324 ///
1325 /// - `in_sequence` must be a valid pointer.
1326 /// - `out_beats` must be a valid pointer.
1327 pub fn MusicSequenceGetBeatsForSeconds(
1328 in_sequence: MusicSequence,
1329 in_seconds: f64,
1330 out_beats: NonNull<MusicTimeStamp>,
1331 ) -> OSStatus;
1332}
1333
1334extern "C-unwind" {
1335 /// Establish a user callback for a sequence
1336 ///
1337 /// This call is used to register (or remove if inCallback is NULL) a callback
1338 /// that the MusicSequence will call for ANY UserEvents that are added to any of the
1339 /// tracks of the sequence.
1340 ///
1341 /// If there is a callback registered, then UserEvents will be chased when
1342 /// MusicPlayerSetTime is called. In that case the inStartSliceBeat and inEndSliceBeat
1343 /// will both be the same value and will be the beat that the player is chasing too.
1344 ///
1345 /// In normal cases, where the sequence data is being scheduled for playback, the
1346 /// following will apply:
1347 /// inStartSliceBeat
1348 /// <
1349 /// = inEventTime
1350 /// <
1351 /// inEndSliceBeat
1352 ///
1353 /// The only exception to this is if the track that owns the MusicEvent is looping.
1354 /// In this case the start beat will still be less than the end beat (so your callback
1355 /// can still determine that it is playing, and what beats are currently being scheduled),
1356 /// however, the inEventTime will be the original time-stamped time of the user event.
1357 ///
1358 /// Parameter `inSequence`: the sequence
1359 ///
1360 /// Parameter `inCallback`: the callback
1361 ///
1362 /// Parameter `inClientData`: client (user supplied) data provided back to the callback when it is called by the sequence
1363 ///
1364 /// # Safety
1365 ///
1366 /// - `in_sequence` must be a valid pointer.
1367 /// - `in_callback` must be implemented correctly.
1368 /// - `in_client_data` must be a valid pointer or null.
1369 pub fn MusicSequenceSetUserCallback(
1370 in_sequence: MusicSequence,
1371 in_callback: MusicSequenceUserCallback,
1372 in_client_data: *mut c_void,
1373 ) -> OSStatus;
1374}
1375
1376extern "C-unwind" {
1377 /// Convenience function to format a sequence's beat time to its bar-beat time
1378 ///
1379 /// The sequence's tempo track Time Sig events are used to
1380 /// to calculate the bar-beat representation. If there are no Time Sig events added to the sequence
1381 /// 4/4 is assumed. A Time Sig event is a MIDI Meta Event as specified for MIDI files.
1382 ///
1383 /// Parameter `inSequence`: the sequence
1384 ///
1385 /// Parameter `inBeats`: the beat which should be represented by the bar-beat
1386 ///
1387 /// Parameter `inSubbeatDivisor`: The denominator of the fractional number of beats.
1388 ///
1389 /// Parameter `outBarBeatTime`: the formatted bar/beat time
1390 ///
1391 /// # Safety
1392 ///
1393 /// - `in_sequence` must be a valid pointer.
1394 /// - `out_bar_beat_time` must be a valid pointer.
1395 pub fn MusicSequenceBeatsToBarBeatTime(
1396 in_sequence: MusicSequence,
1397 in_beats: MusicTimeStamp,
1398 in_subbeat_divisor: u32,
1399 out_bar_beat_time: NonNull<CABarBeatTime>,
1400 ) -> OSStatus;
1401}
1402
1403extern "C-unwind" {
1404 /// Convenience function to format a bar-beat time to a sequence's beat time
1405 ///
1406 /// The sequence's tempo track Time Sig events are used to
1407 /// to calculate the bar-beat representation. If there are no Time Sig events added to the sequence
1408 /// 4/4 is assumed. A Time Sig event is a MIDI Meta Event as specified for MIDI files.
1409 ///
1410 /// Parameter `inSequence`: the sequence
1411 ///
1412 /// Parameter `inBarBeatTime`: the bar-beat time
1413 ///
1414 /// Parameter `outBeats`: the sequence's beat time for that bar-beat time
1415 ///
1416 /// # Safety
1417 ///
1418 /// - `in_sequence` must be a valid pointer.
1419 /// - `in_bar_beat_time` must be a valid pointer.
1420 /// - `out_beats` must be a valid pointer.
1421 pub fn MusicSequenceBarBeatTimeToBeats(
1422 in_sequence: MusicSequence,
1423 in_bar_beat_time: NonNull<CABarBeatTime>,
1424 out_beats: NonNull<MusicTimeStamp>,
1425 ) -> OSStatus;
1426}
1427
1428/// Returns a dictionary containing meta-data derived from a sequence
1429///
1430/// The dictionary can contain one or more of the kAFInfoDictionary_*
1431/// keys specified in
1432/// <AudioToolbox
1433/// /AudioFile.h>
1434///
1435/// The caller should release the returned dictionary. If the call fails it will return NULL
1436///
1437///
1438/// Parameter `inSequence`: the sequence
1439///
1440/// Returns: a CFDictionary or NULL if the call fails.
1441///
1442/// # Safety
1443///
1444/// `in_sequence` must be a valid pointer.
1445#[cfg(feature = "objc2-core-foundation")]
1446#[inline]
1447pub unsafe extern "C-unwind" fn MusicSequenceGetInfoDictionary(
1448 in_sequence: MusicSequence,
1449) -> CFRetained<CFDictionary> {
1450 extern "C-unwind" {
1451 fn MusicSequenceGetInfoDictionary(
1452 in_sequence: MusicSequence,
1453 ) -> Option<NonNull<CFDictionary>>;
1454 }
1455 let ret = unsafe { MusicSequenceGetInfoDictionary(in_sequence) };
1456 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1457 unsafe { CFRetained::retain(ret) }
1458}
1459
1460extern "C-unwind" {
1461 /// Gets the sequence which the track is a member of
1462 ///
1463 /// Parameter `inTrack`: the track
1464 ///
1465 /// Parameter `outSequence`: the track's sequence
1466 ///
1467 /// # Safety
1468 ///
1469 /// - `in_track` must be a valid pointer.
1470 /// - `out_sequence` must be a valid pointer.
1471 pub fn MusicTrackGetSequence(
1472 in_track: MusicTrack,
1473 out_sequence: NonNull<MusicSequence>,
1474 ) -> OSStatus;
1475}
1476
1477extern "C-unwind" {
1478 /// Sets the track's target to the specified AUNode
1479 ///
1480 /// The node must be a member of the graph that the track's sequence is using. When played, the track
1481 /// will send all of its events to that node.
1482 ///
1483 /// Parameter `inTrack`: the track
1484 ///
1485 /// Parameter `inNode`: the new node
1486 ///
1487 /// # Safety
1488 ///
1489 /// `in_track` must be a valid pointer.
1490 #[cfg(feature = "AUGraph")]
1491 pub fn MusicTrackSetDestNode(in_track: MusicTrack, in_node: AUNode) -> OSStatus;
1492}
1493
1494extern "C-unwind" {
1495 /// Sets the track's target to the specified MIDI endpoint
1496 ///
1497 /// When played, the track will send all of its events to the specified MIDI Endpoint.
1498 ///
1499 /// Parameter `inTrack`: the track
1500 ///
1501 /// Parameter `inEndpoint`: the new MIDI endpoint
1502 ///
1503 /// # Safety
1504 ///
1505 /// `in_track` must be a valid pointer.
1506 #[cfg(feature = "objc2-core-midi")]
1507 pub fn MusicTrackSetDestMIDIEndpoint(
1508 in_track: MusicTrack,
1509 in_endpoint: MIDIEndpointRef,
1510 ) -> OSStatus;
1511}
1512
1513extern "C-unwind" {
1514 /// Gets the track's target if it is an AUNode
1515 ///
1516 /// Returns kAudioToolboxErr_IllegalTrackDestination if the track's target is a MIDIEndpointRef
1517 /// and NOT an AUNode
1518 ///
1519 /// Parameter `inTrack`: the track
1520 ///
1521 /// Parameter `outNode`: the node target for the track
1522 ///
1523 /// # Safety
1524 ///
1525 /// - `in_track` must be a valid pointer.
1526 /// - `out_node` must be a valid pointer.
1527 #[cfg(feature = "AUGraph")]
1528 pub fn MusicTrackGetDestNode(in_track: MusicTrack, out_node: NonNull<AUNode>) -> OSStatus;
1529}
1530
1531extern "C-unwind" {
1532 /// Gets the track's target if it is a MIDI Endpoint
1533 ///
1534 /// Returns kAudioToolboxErr_IllegalTrackDestination if the track's target is an AUNode
1535 /// and NOT a MIDI Endpoint
1536 ///
1537 /// Parameter `inTrack`: the track
1538 ///
1539 /// Parameter `outEndpoint`: the MIDI Endpoint target for the track
1540 ///
1541 /// # Safety
1542 ///
1543 /// - `in_track` must be a valid pointer.
1544 /// - `out_endpoint` must be a valid pointer.
1545 #[cfg(feature = "objc2-core-midi")]
1546 pub fn MusicTrackGetDestMIDIEndpoint(
1547 in_track: MusicTrack,
1548 out_endpoint: NonNull<MIDIEndpointRef>,
1549 ) -> OSStatus;
1550}
1551
1552extern "C-unwind" {
1553 /// Sets the specified property value
1554 ///
1555 /// Property values are always get and set by reference
1556 ///
1557 /// Parameter `inTrack`: the track
1558 ///
1559 /// Parameter `inPropertyID`: the property ID
1560 ///
1561 /// Parameter `inData`: the new property value
1562 ///
1563 /// Parameter `inLength`: the size of the property value being set
1564 ///
1565 /// # Safety
1566 ///
1567 /// - `in_track` must be a valid pointer.
1568 /// - `in_data` must be a valid pointer.
1569 pub fn MusicTrackSetProperty(
1570 in_track: MusicTrack,
1571 in_property_id: u32,
1572 in_data: NonNull<c_void>,
1573 in_length: u32,
1574 ) -> OSStatus;
1575}
1576
1577extern "C-unwind" {
1578 /// Gets the specified property value
1579 ///
1580 /// If outData is NULL, then the size of the data will be passed back in ioLength
1581 /// This allows the client to allocate a buffer of the correct size (useful for variable
1582 /// length properties -- currently all properties have fixed size)
1583 /// Property values are always get and set by reference
1584 ///
1585 /// Parameter `inTrack`: the track
1586 ///
1587 /// Parameter `inPropertyID`: the property ID
1588 ///
1589 /// Parameter `outData`: if not NULL, points to data of size ioLength
1590 ///
1591 /// Parameter `ioLength`: on input the available size of outData, on output the size of the valid data that outData
1592 /// will then point too.
1593 ///
1594 /// # Safety
1595 ///
1596 /// - `in_track` must be a valid pointer.
1597 /// - `out_data` must be a valid pointer.
1598 /// - `io_length` must be a valid pointer.
1599 pub fn MusicTrackGetProperty(
1600 in_track: MusicTrack,
1601 in_property_id: u32,
1602 out_data: NonNull<c_void>,
1603 io_length: NonNull<u32>,
1604 ) -> OSStatus;
1605}
1606
1607extern "C-unwind" {
1608 /// Move events in a track
1609 ///
1610 /// Moves all of the events in the specified time range by the moveTime. MoveTime maybe negative to
1611 /// move events backwards (towards zero).
1612 ///
1613 /// All time ranges are [starttime
1614 /// <
1615 /// endtime]
1616 ///
1617 ///
1618 /// Parameter `inTrack`: the track
1619 ///
1620 /// Parameter `inStartTime`: the start time for the range of events
1621 ///
1622 /// Parameter `inEndTime`: the end time up to which will form the range of the events to move
1623 ///
1624 /// Parameter `inMoveTime`: amount of beats to move the selected events.
1625 ///
1626 /// # Safety
1627 ///
1628 /// `in_track` must be a valid pointer.
1629 pub fn MusicTrackMoveEvents(
1630 in_track: MusicTrack,
1631 in_start_time: MusicTimeStamp,
1632 in_end_time: MusicTimeStamp,
1633 in_move_time: MusicTimeStamp,
1634 ) -> OSStatus;
1635}
1636
1637extern "C-unwind" {
1638 /// Removes all events within the specified range
1639 ///
1640 /// All time ranges are [starttime
1641 /// <
1642 /// endtime]
1643 ///
1644 /// Parameter `inTrack`: the track
1645 ///
1646 /// Parameter `inStartTime`: the start time for the range of events
1647 ///
1648 /// Parameter `inEndTime`: the end time up to which will form the range of the events to clear
1649 ///
1650 /// # Safety
1651 ///
1652 /// `in_track` must be a valid pointer.
1653 pub fn MusicTrackClear(
1654 in_track: MusicTrack,
1655 in_start_time: MusicTimeStamp,
1656 in_end_time: MusicTimeStamp,
1657 ) -> OSStatus;
1658}
1659
1660extern "C-unwind" {
1661 /// Removes all the events within the specified range
1662 ///
1663 /// Events that fall past the specified range will be moved back by the specified range time.
1664 ///
1665 /// All time ranges are [starttime
1666 /// <
1667 /// endtime]
1668 ///
1669 ///
1670 /// Parameter `inTrack`: the track
1671 ///
1672 /// Parameter `inStartTime`: the start time for the range of events
1673 ///
1674 /// Parameter `inEndTime`: the end time up to which will form the range of the events to cut out
1675 ///
1676 /// # Safety
1677 ///
1678 /// `in_track` must be a valid pointer.
1679 pub fn MusicTrackCut(
1680 in_track: MusicTrack,
1681 in_start_time: MusicTimeStamp,
1682 in_end_time: MusicTimeStamp,
1683 ) -> OSStatus;
1684}
1685
1686extern "C-unwind" {
1687 /// Copies events from one track and inserts them into another
1688 ///
1689 /// Copies all of the events with the specified time range of the source track. It then inserts
1690 /// those events into the destination track. All events at and after inDestInsertTime in inDestTrack
1691 /// are moved forward by the range's duration
1692 ///
1693 /// All time ranges are [starttime
1694 /// <
1695 /// endtime]
1696 ///
1697 ///
1698 /// Parameter `inSourceTrack`: the source track
1699 ///
1700 /// Parameter `inSourceStartTime`: the start time for the range of events
1701 ///
1702 /// Parameter `inSourceEndTime`: the end time up to which will form the range of the events to copy from the source track
1703 ///
1704 /// Parameter `inDestTrack`: the destination track to copy too
1705 ///
1706 /// Parameter `inDestInsertTime`: the time at which the copied events will be inserted.
1707 ///
1708 /// # Safety
1709 ///
1710 /// - `in_source_track` must be a valid pointer.
1711 /// - `in_dest_track` must be a valid pointer.
1712 pub fn MusicTrackCopyInsert(
1713 in_source_track: MusicTrack,
1714 in_source_start_time: MusicTimeStamp,
1715 in_source_end_time: MusicTimeStamp,
1716 in_dest_track: MusicTrack,
1717 in_dest_insert_time: MusicTimeStamp,
1718 ) -> OSStatus;
1719}
1720
1721extern "C-unwind" {
1722 /// Copies events from one track and merges them into another
1723 ///
1724 /// Copies all of the events with the specified time range of the source track. It then merges
1725 /// those events into the destination track starting at inDestInsertTime.
1726 ///
1727 /// All time ranges are [starttime
1728 /// <
1729 /// endtime]
1730 ///
1731 ///
1732 /// Parameter `inSourceTrack`: the source track
1733 ///
1734 /// Parameter `inSourceStartTime`: the start time for the range of events
1735 ///
1736 /// Parameter `inSourceEndTime`: the end time up to which will form the range of the events to copy from the source track
1737 ///
1738 /// Parameter `inDestTrack`: the destination track to copy too
1739 ///
1740 /// Parameter `inDestInsertTime`: the time at which the copied events will be merged.
1741 ///
1742 /// # Safety
1743 ///
1744 /// - `in_source_track` must be a valid pointer.
1745 /// - `in_dest_track` must be a valid pointer.
1746 pub fn MusicTrackMerge(
1747 in_source_track: MusicTrack,
1748 in_source_start_time: MusicTimeStamp,
1749 in_source_end_time: MusicTimeStamp,
1750 in_dest_track: MusicTrack,
1751 in_dest_insert_time: MusicTimeStamp,
1752 ) -> OSStatus;
1753}
1754
1755extern "C-unwind" {
1756 /// Adds a MIDINoteMessage event to a track
1757 ///
1758 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1759 ///
1760 /// Parameter `inTrack`: the track
1761 ///
1762 /// Parameter `inTimeStamp`: the time stamp
1763 ///
1764 /// Parameter `inMessage`: the event
1765 ///
1766 /// # Safety
1767 ///
1768 /// - `in_track` must be a valid pointer.
1769 /// - `in_message` must be a valid pointer.
1770 pub fn MusicTrackNewMIDINoteEvent(
1771 in_track: MusicTrack,
1772 in_time_stamp: MusicTimeStamp,
1773 in_message: NonNull<MIDINoteMessage>,
1774 ) -> OSStatus;
1775}
1776
1777extern "C-unwind" {
1778 /// Adds a MIDIChannelMessage event to a track
1779 ///
1780 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1781 ///
1782 /// Parameter `inTrack`: the track
1783 ///
1784 /// Parameter `inTimeStamp`: the time stamp
1785 ///
1786 /// Parameter `inMessage`: the event
1787 ///
1788 /// # Safety
1789 ///
1790 /// - `in_track` must be a valid pointer.
1791 /// - `in_message` must be a valid pointer.
1792 pub fn MusicTrackNewMIDIChannelEvent(
1793 in_track: MusicTrack,
1794 in_time_stamp: MusicTimeStamp,
1795 in_message: NonNull<MIDIChannelMessage>,
1796 ) -> OSStatus;
1797}
1798
1799extern "C-unwind" {
1800 /// Adds a MIDIRawData event to a track
1801 ///
1802 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1803 ///
1804 /// Parameter `inTrack`: the track
1805 ///
1806 /// Parameter `inTimeStamp`: the time stamp
1807 ///
1808 /// Parameter `inRawData`: the event
1809 ///
1810 /// # Safety
1811 ///
1812 /// - `in_track` must be a valid pointer.
1813 /// - `in_raw_data` must be a valid pointer.
1814 pub fn MusicTrackNewMIDIRawDataEvent(
1815 in_track: MusicTrack,
1816 in_time_stamp: MusicTimeStamp,
1817 in_raw_data: NonNull<MIDIRawData>,
1818 ) -> OSStatus;
1819}
1820
1821extern "C-unwind" {
1822 /// Adds a ExtendedNoteOnEvent to a track
1823 ///
1824 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1825 ///
1826 /// Parameter `inTrack`: the track
1827 ///
1828 /// Parameter `inTimeStamp`: the time stamp
1829 ///
1830 /// Parameter `inInfo`: the event
1831 ///
1832 /// # Safety
1833 ///
1834 /// - `in_track` must be a valid pointer.
1835 /// - `in_info` must be a valid pointer.
1836 #[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
1837 pub fn MusicTrackNewExtendedNoteEvent(
1838 in_track: MusicTrack,
1839 in_time_stamp: MusicTimeStamp,
1840 in_info: NonNull<ExtendedNoteOnEvent>,
1841 ) -> OSStatus;
1842}
1843
1844extern "C-unwind" {
1845 /// Adds a ParameterEvent to a track
1846 ///
1847 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1848 ///
1849 /// Parameter `inTrack`: the track
1850 ///
1851 /// Parameter `inTimeStamp`: the time stamp
1852 ///
1853 /// Parameter `inInfo`: the event
1854 ///
1855 /// # Safety
1856 ///
1857 /// - `in_track` must be a valid pointer.
1858 /// - `in_info` must be a valid pointer.
1859 #[cfg(feature = "AUComponent")]
1860 pub fn MusicTrackNewParameterEvent(
1861 in_track: MusicTrack,
1862 in_time_stamp: MusicTimeStamp,
1863 in_info: NonNull<ParameterEvent>,
1864 ) -> OSStatus;
1865}
1866
1867extern "C-unwind" {
1868 /// Adds a tempo event to a track
1869 ///
1870 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1871 ///
1872 /// Parameter `inTrack`: the track
1873 ///
1874 /// Parameter `inTimeStamp`: the time stamp
1875 ///
1876 /// Parameter `inBPM`: the event
1877 ///
1878 /// # Safety
1879 ///
1880 /// `in_track` must be a valid pointer.
1881 pub fn MusicTrackNewExtendedTempoEvent(
1882 in_track: MusicTrack,
1883 in_time_stamp: MusicTimeStamp,
1884 in_bpm: f64,
1885 ) -> OSStatus;
1886}
1887
1888extern "C-unwind" {
1889 /// Adds a MIDIMetaEvent to a track
1890 ///
1891 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1892 ///
1893 /// Parameter `inTrack`: the track
1894 ///
1895 /// Parameter `inTimeStamp`: the time stamp
1896 ///
1897 /// Parameter `inMetaEvent`: the event
1898 ///
1899 /// # Safety
1900 ///
1901 /// - `in_track` must be a valid pointer.
1902 /// - `in_meta_event` must be a valid pointer.
1903 pub fn MusicTrackNewMetaEvent(
1904 in_track: MusicTrack,
1905 in_time_stamp: MusicTimeStamp,
1906 in_meta_event: NonNull<MIDIMetaEvent>,
1907 ) -> OSStatus;
1908}
1909
1910extern "C-unwind" {
1911 /// Adds a MusicEventUserData event to a track
1912 ///
1913 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1914 ///
1915 /// Parameter `inTrack`: the track
1916 ///
1917 /// Parameter `inTimeStamp`: the time stamp
1918 ///
1919 /// Parameter `inUserData`: the event
1920 ///
1921 /// # Safety
1922 ///
1923 /// - `in_track` must be a valid pointer.
1924 /// - `in_user_data` must be a valid pointer.
1925 pub fn MusicTrackNewUserEvent(
1926 in_track: MusicTrack,
1927 in_time_stamp: MusicTimeStamp,
1928 in_user_data: NonNull<MusicEventUserData>,
1929 ) -> OSStatus;
1930}
1931
1932extern "C-unwind" {
1933 /// Adds a AUPresetEvent to a track
1934 ///
1935 /// The event is added at the specified time stamp. The time stamp should not be less than zero.
1936 ///
1937 /// Parameter `inTrack`: the track
1938 ///
1939 /// Parameter `inTimeStamp`: the time stamp
1940 ///
1941 /// Parameter `inPresetEvent`: the event
1942 ///
1943 /// # Safety
1944 ///
1945 /// - `in_track` must be a valid pointer.
1946 /// - `in_preset_event` must be a valid pointer.
1947 #[cfg(all(feature = "AUComponent", feature = "objc2-core-foundation"))]
1948 pub fn MusicTrackNewAUPresetEvent(
1949 in_track: MusicTrack,
1950 in_time_stamp: MusicTimeStamp,
1951 in_preset_event: NonNull<AUPresetEvent>,
1952 ) -> OSStatus;
1953}
1954
1955extern "C-unwind" {
1956 /// Creates an iterator to iterator over a track's events
1957 ///
1958 /// The iterator should be considered invalid if a track is edited. In that case you should create a new
1959 /// iterator and seek it to the desired position.
1960 ///
1961 ///
1962 /// Parameter `inTrack`: the track upon which to iterate
1963 ///
1964 /// Parameter `outIterator`: the new iterator
1965 ///
1966 /// # Safety
1967 ///
1968 /// - `in_track` must be a valid pointer.
1969 /// - `out_iterator` must be a valid pointer.
1970 pub fn NewMusicEventIterator(
1971 in_track: MusicTrack,
1972 out_iterator: NonNull<MusicEventIterator>,
1973 ) -> OSStatus;
1974}
1975
1976extern "C-unwind" {
1977 /// Dispose an iterator
1978 ///
1979 /// Parameter `inIterator`: the iterator
1980 ///
1981 /// # Safety
1982 ///
1983 /// `in_iterator` must be a valid pointer.
1984 pub fn DisposeMusicEventIterator(in_iterator: MusicEventIterator) -> OSStatus;
1985}
1986
1987extern "C-unwind" {
1988 /// Move the iterator to an event at the specified time
1989 ///
1990 /// If there is no event at the specified time, the iterator will point to the first event after
1991 /// that time.
1992 /// By specifying kMusicTimeStamp_EndOfTrack you will position the iterator to the end of track
1993 /// (which is pointing to the space just AFTER the last event). You can use MusicEventIteratorPreviousEvent
1994 /// to backup to the last event.
1995 /// By specifying 0, you will position the iterator at the first event
1996 ///
1997 /// Parameter `inIterator`: the iterator
1998 ///
1999 /// Parameter `inTimeStamp`: the time stamp to seek too
2000 ///
2001 /// # Safety
2002 ///
2003 /// `in_iterator` must be a valid pointer.
2004 pub fn MusicEventIteratorSeek(
2005 in_iterator: MusicEventIterator,
2006 in_time_stamp: MusicTimeStamp,
2007 ) -> OSStatus;
2008}
2009
2010extern "C-unwind" {
2011 /// Move the iterator to the next event
2012 ///
2013 /// If the iterator was at the last event, then it will move past the last event and will no longer point
2014 /// to an event. You can use check MusicEventIteratorHasCurrentEvent to see if there is an event at the
2015 /// iterator's current position. See also MusicEventIteratorHasNextEvent.
2016 ///
2017 /// Typically this call is used to move the iterator forwards through the track's events.
2018 ///
2019 /// Parameter `inIterator`: the iterator
2020 ///
2021 /// # Safety
2022 ///
2023 /// `in_iterator` must be a valid pointer.
2024 pub fn MusicEventIteratorNextEvent(in_iterator: MusicEventIterator) -> OSStatus;
2025}
2026
2027extern "C-unwind" {
2028 /// Move the iterator to the previous event
2029 ///
2030 /// If the iterator was at the first event, then it will leave the iterator unchanged and return an error.
2031 /// See also MusicEventIteratorHasPreviousEvent
2032 ///
2033 /// Typically this call is used to move the iterator backwards through the track's events.
2034 ///
2035 /// Parameter `inIterator`: the iterator
2036 ///
2037 /// # Safety
2038 ///
2039 /// `in_iterator` must be a valid pointer.
2040 pub fn MusicEventIteratorPreviousEvent(in_iterator: MusicEventIterator) -> OSStatus;
2041}
2042
2043extern "C-unwind" {
2044 /// Retrieves the event data at the iterator.
2045 ///
2046 /// Retrieves the event and other information from the iterator's current position.
2047 ///
2048 /// If you do not want specific information (eg, the time stamp) pass in NULL for that parameter.
2049 ///
2050 ///
2051 /// Parameter `inIterator`: the iterator
2052 ///
2053 /// Parameter `outTimeStamp`: the time stamp of the event
2054 ///
2055 /// Parameter `outEventType`: one of kMusicEventType_XXX that indicates what kind of event type the iterator
2056 /// is currently pointing too
2057 ///
2058 /// Parameter `outEventData`: a reference to the event data. The type of data is described by the eventType. This data
2059 /// is read only and should not be edited in place.
2060 ///
2061 /// Parameter `outEventDataSize`: the size of the data referenced by outEventData
2062 ///
2063 /// # Safety
2064 ///
2065 /// - `in_iterator` must be a valid pointer.
2066 /// - `out_time_stamp` must be a valid pointer.
2067 /// - `out_event_type` must be a valid pointer.
2068 /// - `out_event_data` must be a valid pointer.
2069 /// - `out_event_data_size` must be a valid pointer.
2070 pub fn MusicEventIteratorGetEventInfo(
2071 in_iterator: MusicEventIterator,
2072 out_time_stamp: NonNull<MusicTimeStamp>,
2073 out_event_type: NonNull<MusicEventType>,
2074 out_event_data: NonNull<*const c_void>,
2075 out_event_data_size: NonNull<u32>,
2076 ) -> OSStatus;
2077}
2078
2079extern "C-unwind" {
2080 /// Changes the type or value of an event
2081 ///
2082 /// Allows you to change either the event type, or the values of the event data, that the iterator is
2083 /// currently pointing too. You cannot change the event's time (to do that you should use
2084 /// MusicEventIteratorSetEventTime).
2085 ///
2086 ///
2087 /// Parameter `inIterator`: the iterator
2088 ///
2089 /// Parameter `inEventType`: the new (or existing) type of the event you are changing
2090 ///
2091 /// Parameter `inEventData`: the new event data. The size and type of this event data must match the inEventType
2092 ///
2093 /// # Safety
2094 ///
2095 /// - `in_iterator` must be a valid pointer.
2096 /// - `in_event_data` must be a valid pointer.
2097 pub fn MusicEventIteratorSetEventInfo(
2098 in_iterator: MusicEventIterator,
2099 in_event_type: MusicEventType,
2100 in_event_data: NonNull<c_void>,
2101 ) -> OSStatus;
2102}
2103
2104extern "C-unwind" {
2105 /// Set a new time for an event
2106 ///
2107 /// The iterator will still be pointing to the same event, but as the event will have moved,
2108 /// it may or may not have a next or previous event now (depending of course on the time
2109 /// you moved it to).
2110 ///
2111 ///
2112 /// Parameter `inIterator`: the iterator
2113 ///
2114 /// Parameter `inTimeStamp`: the new time stamp of the event
2115 ///
2116 /// # Safety
2117 ///
2118 /// `in_iterator` must be a valid pointer.
2119 pub fn MusicEventIteratorSetEventTime(
2120 in_iterator: MusicEventIterator,
2121 in_time_stamp: MusicTimeStamp,
2122 ) -> OSStatus;
2123}
2124
2125extern "C-unwind" {
2126 /// Deletes the event pointed to by the iterator
2127 ///
2128 /// The iterator will reference the next event after the event has been deleted.
2129 ///
2130 ///
2131 /// Parameter `inIterator`: the iterator
2132 ///
2133 /// # Safety
2134 ///
2135 /// `in_iterator` must be a valid pointer.
2136 pub fn MusicEventIteratorDeleteEvent(in_iterator: MusicEventIterator) -> OSStatus;
2137}
2138
2139extern "C-unwind" {
2140 /// Does the track have an event previous to the event the iterator is pointing to?
2141 ///
2142 /// To use the iterator going backwards through a track:
2143 /// iter = New Iterator (points at first event)
2144 /// MusicEventIteratorSeek (iter, kMusicTimeStamp_EndOfTrack) // will point it past the last event
2145 /// bool hasPreviousEvent;
2146 /// MusicEventIteratorHasPreviousEvent (iter,
2147 /// &hasPreviousEvent
2148 /// )
2149 /// while (hasPreviousEvent) {
2150 /// MusicEventIteratorPreviousEvent (iter)
2151 /// // do work... MusicEventIteratorGetEventInfo (iter, ...
2152 ///
2153 /// MusicEventIteratorHasPreviousEvent (iter,
2154 /// &hasPreviousEvent
2155 /// );
2156 /// }
2157 ///
2158 /// Parameter `inIterator`: the iterator
2159 ///
2160 /// Parameter `outHasPrevEvent`: true if there is a previous event, false if not
2161 ///
2162 /// # Safety
2163 ///
2164 /// - `in_iterator` must be a valid pointer.
2165 /// - `out_has_prev_event` must be a valid pointer.
2166 pub fn MusicEventIteratorHasPreviousEvent(
2167 in_iterator: MusicEventIterator,
2168 out_has_prev_event: NonNull<Boolean>,
2169 ) -> OSStatus;
2170}
2171
2172extern "C-unwind" {
2173 /// Does the track have an event past the event the iterator is pointing too?
2174 ///
2175 /// To use the iterator going forwards through a track:
2176 /// iter = New Iterator (points at first event)
2177 /// bool hasCurrentEvent;
2178 /// MusicEventIteratorHasCurrentEvent(iter,
2179 /// &hasCurrentEvent
2180 /// );
2181 /// while (hasCurrentEvent) {
2182 /// // do work... MusicEventIteratorGetEventInfo (iter, ...
2183 ///
2184 /// MusicEventIteratorNextEvent (iter)
2185 /// MusicEventIteratorHasCurrentEvent(iter,
2186 /// &hasCurrentEvent
2187 /// );
2188 /// }
2189 ///
2190 ///
2191 /// Parameter `inIterator`: the iterator
2192 ///
2193 /// Parameter `outHasNextEvent`: true if there is a next event, false if not
2194 ///
2195 /// # Safety
2196 ///
2197 /// - `in_iterator` must be a valid pointer.
2198 /// - `out_has_next_event` must be a valid pointer.
2199 pub fn MusicEventIteratorHasNextEvent(
2200 in_iterator: MusicEventIterator,
2201 out_has_next_event: NonNull<Boolean>,
2202 ) -> OSStatus;
2203}
2204
2205extern "C-unwind" {
2206 /// Is there an event at the iterator's current position?
2207 ///
2208 /// Parameter `inIterator`: the iterator
2209 ///
2210 /// Parameter `outHasCurEvent`: true if there is an event, false if not
2211 ///
2212 /// # Safety
2213 ///
2214 /// - `in_iterator` must be a valid pointer.
2215 /// - `out_has_cur_event` must be a valid pointer.
2216 pub fn MusicEventIteratorHasCurrentEvent(
2217 in_iterator: MusicEventIterator,
2218 out_has_cur_event: NonNull<Boolean>,
2219 ) -> OSStatus;
2220}
2221
2222extern "C-unwind" {
2223 /// # Safety
2224 ///
2225 /// `in_sequence` must be a valid pointer.
2226 #[cfg(feature = "objc2-core-foundation")]
2227 #[deprecated = "no longer supported"]
2228 pub fn MusicSequenceLoadSMFDataWithFlags(
2229 in_sequence: MusicSequence,
2230 in_data: &CFData,
2231 in_flags: MusicSequenceLoadFlags,
2232 ) -> OSStatus;
2233}
2234
2235extern "C-unwind" {
2236 /// # Safety
2237 ///
2238 /// - `in_sequence` must be a valid pointer.
2239 /// - `out_data` must be a valid pointer.
2240 #[cfg(feature = "objc2-core-foundation")]
2241 #[deprecated = "no longer supported"]
2242 pub fn MusicSequenceSaveSMFData(
2243 in_sequence: MusicSequence,
2244 out_data: NonNull<*const CFData>,
2245 in_resolution: u16,
2246 ) -> OSStatus;
2247}
2248
2249extern "C-unwind" {
2250 /// # Safety
2251 ///
2252 /// - `in_source_track` must be a valid pointer.
2253 /// - `out_new_track` must be a valid pointer.
2254 #[deprecated = "no longer supported"]
2255 pub fn NewMusicTrackFrom(
2256 in_source_track: MusicTrack,
2257 in_source_start_time: MusicTimeStamp,
2258 in_source_end_time: MusicTimeStamp,
2259 out_new_track: NonNull<MusicTrack>,
2260 ) -> OSStatus;
2261}
2262
2263/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/kmusiceventtype_extendedcontrol?language=objc)
2264pub const kMusicEventType_ExtendedControl: c_uint = 2;
2265
2266/// [Apple's documentation](https://developer.apple.com/documentation/audiotoolbox/extendedcontrolevent?language=objc)
2267#[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
2268#[repr(C)]
2269#[derive(Clone, Copy, Debug, PartialEq)]
2270pub struct ExtendedControlEvent {
2271 pub groupID: MusicDeviceGroupID,
2272 pub controlID: AudioUnitParameterID,
2273 pub value: AudioUnitParameterValue,
2274}
2275
2276#[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
2277unsafe impl Encode for ExtendedControlEvent {
2278 const ENCODING: Encoding = Encoding::Struct(
2279 "ExtendedControlEvent",
2280 &[
2281 <MusicDeviceGroupID>::ENCODING,
2282 <AudioUnitParameterID>::ENCODING,
2283 <AudioUnitParameterValue>::ENCODING,
2284 ],
2285 );
2286}
2287
2288#[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
2289unsafe impl RefEncode for ExtendedControlEvent {
2290 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
2291}
2292
2293extern "C-unwind" {
2294 /// # Safety
2295 ///
2296 /// - `in_track` must be a valid pointer.
2297 /// - `in_info` must be a valid pointer.
2298 #[cfg(all(feature = "AUComponent", feature = "MusicDevice"))]
2299 #[deprecated = "no longer supported"]
2300 pub fn MusicTrackNewExtendedControlEvent(
2301 in_track: MusicTrack,
2302 in_time_stamp: MusicTimeStamp,
2303 in_info: NonNull<ExtendedControlEvent>,
2304 ) -> OSStatus;
2305}