objc2_phase/generated/PHASESoundEvent.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-avf-audio")]
7use objc2_avf_audio::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 /// *************************************************************************************************
14 ///
15 ///
16 ///
17 /// A PHASESoundEvent is an object that represents a playable sound event in the PHASE system.
18 ///
19 /// See also [Apple's documentation](https://developer.apple.com/documentation/phase/phasesoundevent?language=objc)
20 #[unsafe(super(NSObject))]
21 #[derive(Debug, PartialEq, Eq, Hash)]
22 pub struct PHASESoundEvent;
23);
24
25extern_conformance!(
26 unsafe impl NSObjectProtocol for PHASESoundEvent {}
27);
28
29impl PHASESoundEvent {
30 extern_methods!(
31 #[unsafe(method(init))]
32 #[unsafe(method_family = init)]
33 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
34
35 #[unsafe(method(new))]
36 #[unsafe(method_family = new)]
37 pub unsafe fn new() -> Retained<Self>;
38
39 #[cfg(all(feature = "PHASEEngine", feature = "PHASEMixer"))]
40 /// Creates a new sound event instance
41 ///
42 /// Parameter `engine`: The PHASEEngine object that the sound event will be played by.
43 ///
44 /// Parameter `assetIdentifier`: The identifier registered with the Asset Registry for the particular PHASESoundEventNodeAsset that this sound instance will play.
45 /// If the asset identifier is not registered, this function will fail.
46 ///
47 /// Parameter `mixerParameters`: A dictionary of PHASEMixerParameters objects with keys that match the identifiers of the spatial mixers in the sound event
48 ///
49 /// This will look up the asset in the asset registry and create the necessary objects to play the sound event
50 #[unsafe(method(initWithEngine:assetIdentifier:mixerParameters:error:_))]
51 #[unsafe(method_family = init)]
52 pub unsafe fn initWithEngine_assetIdentifier_mixerParameters_error(
53 this: Allocated<Self>,
54 engine: &PHASEEngine,
55 asset_identifier: &NSString,
56 mixer_parameters: &PHASEMixerParameters,
57 ) -> Result<Retained<Self>, Retained<NSError>>;
58
59 #[cfg(feature = "PHASEEngine")]
60 /// Creates a new sound event instance
61 ///
62 /// Parameter `engine`: The PHASEEngine object that the sound event will be played by.
63 ///
64 /// Parameter `assetIdentifier`: The identifier registered with the Asset Registry for the particular PHASESoundEventNodeAsset that this sound event will play.
65 /// If the asset identifier is not registered, this function will fail.
66 ///
67 /// This will look up the asset in the asset registry and create the necessary objects to play the sound event
68 #[unsafe(method(initWithEngine:assetIdentifier:error:_))]
69 #[unsafe(method_family = init)]
70 pub unsafe fn initWithEngine_assetIdentifier_error(
71 this: Allocated<Self>,
72 engine: &PHASEEngine,
73 asset_identifier: &NSString,
74 ) -> Result<Retained<Self>, Retained<NSError>>;
75
76 #[cfg(all(feature = "PHASETypes", feature = "block2"))]
77 /// Prepare the sound event
78 ///
79 /// Parameter `handler`: The block that will be called when the PHASESoundEvent has finished preparing and is ready to start. Pass in nil for no handler.
80 ///
81 /// This function notifies the engine to begin preparing a sound event, then returns immediately.
82 /// Once the sound event is prepared (or has failed to prepare), you will receive a callback via the completion.
83 /// If you call startWithCompletion() before receiving the callback, the sound event will start as soon as it's prepared.
84 #[unsafe(method(prepareWithCompletion:))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn prepareWithCompletion(
87 &self,
88 handler: Option<&block2::DynBlock<dyn Fn(PHASESoundEventPrepareHandlerReason)>>,
89 );
90
91 #[cfg(all(feature = "PHASETypes", feature = "block2"))]
92 /// Start the sound event
93 ///
94 /// Parameter `handler`: The block that will be called when the sound event has stopped.
95 ///
96 /// This function notifies the engine to start the sound event, then returns immediately.
97 /// Once the sound event is playing (or has failed to start), you will receive a callback via the completion.
98 /// Playback will begin immediately if the sound event has been prepared; otherwise, it will start as soon as it is finished preparing.
99 #[unsafe(method(startWithCompletion:))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn startWithCompletion(
102 &self,
103 handler: Option<&block2::DynBlock<dyn Fn(PHASESoundEventStartHandlerReason)>>,
104 );
105
106 #[cfg(all(
107 feature = "PHASETypes",
108 feature = "block2",
109 feature = "objc2-avf-audio"
110 ))]
111 /// Start the sound event
112 ///
113 /// Parameter `when`: The desired start time based on the engine time retrieved from [PHASEEngine lastRenderTime]
114 /// If the sound event starts immediately with an audible sound, it will begin rendering at this time. The sound event will otherwise begin operating at this time.
115 /// A nil value will start the sound event immediately
116 /// This time is not scaled by unitsPerSecond.
117 ///
118 /// Parameter `handler`: The block that will be called when the sound event has stopped.
119 ///
120 /// This function notifies the engine to start the sound event, then returns immediately.
121 /// Once the sound event is playing (or has failed to start), you will receive a callback via the completion.
122 /// Playback will begin at the requested time if the sound event has finished preparing in time.
123 /// You may wait for preparation to finish with the [PHASESoundEvent prepare:completion] method before calling startAtTime, to ensure that the sound event will start at the desired time.
124 /// However if the desired time is far enough into the future to allow for preparation to happen, you may skip calling prepare entirely and just call startAtTime.
125 #[unsafe(method(startAtTime:completion:))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn startAtTime_completion(
128 &self,
129 when: Option<&AVAudioTime>,
130 handler: Option<&block2::DynBlock<dyn Fn(PHASESoundEventStartHandlerReason)>>,
131 );
132
133 #[cfg(all(feature = "PHASETypes", feature = "block2"))]
134 /// Seeks all leaf nodes in a PHASESoundEvent to a specified time relative to the start of the sound event.
135 ///
136 /// This function notifies the engine to seek the sound event, then returns immediately.
137 /// Once the sound event has seeked to the new offset (or has failed to seek), you will receive a callback via the completion.
138 /// If any leaf nodes do not support seeking, those nodes will ignore this command.
139 /// Nodes that have finished playing or have stopped will not seek.
140 /// Nodes that are sleeping will seek, and will resume at the correct time when they wake up.
141 ///
142 /// Note: The time is scaled by unitsPerSecond internally, so can be provided at the client's native time scale.
143 #[unsafe(method(seekToTime:completion:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn seekToTime_completion(
146 &self,
147 time: c_double,
148 handler: Option<&block2::DynBlock<dyn Fn(PHASESoundEventSeekHandlerReason)>>,
149 );
150
151 #[cfg(all(
152 feature = "PHASETypes",
153 feature = "block2",
154 feature = "objc2-avf-audio"
155 ))]
156 /// Seeks all leaf nodes in a PHASESoundEvent to the specified time, and automatically resumes playback at the specified engine time.
157 ///
158 /// Parameter `time`: The desired time position in seconds to seek the nodes to.
159 ///
160 /// Parameter `engineTime`: The engine time to resume playback.
161 ///
162 /// Parameter `handler`: The completion callback that will be called when seeking is complete.
163 ///
164 /// This is a low latency convenience method that allows for tight deadlines to be met. However if the seek fails the node state will not be changed. You should check the callback and handle the failure appropriately.
165 /// The time parameter will seek the nodes to the equivalent sample position based on the sample rate of the asset.
166 /// The engineTime parameter is the engine timestamp to resume rendering at, based off of [PHASEEngine lastRenderTime].
167 /// If any leaf nodes do not support seeking, those nodes will ignore this command.
168 /// Nodes that have finished playing or have stopped will not seek.
169 /// The time parameter is in seconds and will be scaled by unitsPerSecond.
170 /// The time in the AVAudioTime structure is not scaled by unitsPerSecond.
171 /// The engineTime parameter will use the sample time if valid, if not, then the host time if valid.
172 #[unsafe(method(seekToTime:resumeAtEngineTime:completion:))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn seekToTime_resumeAtEngineTime_completion(
175 &self,
176 time: c_double,
177 engine_time: &AVAudioTime,
178 handler: Option<&block2::DynBlock<dyn Fn(PHASESoundEventSeekHandlerReason)>>,
179 );
180
181 /// Pause the sound event.
182 #[unsafe(method(pause))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn pause(&self);
185
186 /// Resume the sound event.
187 #[unsafe(method(resume))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn resume(&self);
190
191 #[cfg(feature = "objc2-avf-audio")]
192 /// Resume the sound event at a specific time
193 ///
194 /// Parameter `time`: The desired start time based on the engine time retrieved from [PHASEEngine lastRenderTime]
195 ///
196 /// A nil time parameter will resume immediately.
197 /// The device time is not scaled by UnitsPerSecond and is in seconds.
198 #[unsafe(method(resumeAtTime:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn resumeAtTime(&self, time: Option<&AVAudioTime>);
201
202 /// stop and invalidate the sound event
203 #[unsafe(method(stopAndInvalidate))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn stopAndInvalidate(&self);
206
207 #[cfg(feature = "PHASETypes")]
208 /// Sound Event's current rendering state
209 #[unsafe(method(renderingState))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn renderingState(&self) -> PHASERenderingState;
212
213 #[cfg(feature = "PHASETypes")]
214 /// Sound Event's current preparation state
215 #[unsafe(method(prepareState))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn prepareState(&self) -> PHASESoundEventPrepareState;
218
219 #[cfg(feature = "PHASEMetaParameter")]
220 /// A Dictionary containing the MetaParameters associated with this sound event
221 #[unsafe(method(metaParameters))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn metaParameters(&self)
224 -> Retained<NSDictionary<NSString, PHASEMetaParameter>>;
225
226 #[cfg(feature = "PHASEMixer")]
227 /// A Dictionary containing the mix nodes associated with this sound event
228 #[unsafe(method(mixers))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn mixers(&self) -> Retained<NSDictionary<NSString, PHASEMixer>>;
231
232 #[cfg(feature = "PHASESoundEventNodes")]
233 /// A Dictionary containing the push stream nodes associated with this sound event, for pushing buffers to.
234 #[unsafe(method(pushStreamNodes))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn pushStreamNodes(
237 &self,
238 ) -> Retained<NSDictionary<NSString, PHASEPushStreamNode>>;
239
240 #[cfg(feature = "PHASESoundEventNodes")]
241 /// A Dictionary containing the pull stream nodes associated with this sound event, for setting renderBlocks on.
242 #[unsafe(method(pullStreamNodes))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn pullStreamNodes(
245 &self,
246 ) -> Retained<NSDictionary<NSString, PHASEPullStreamNode>>;
247
248 /// A boolean that tell if this sound event will run indefinitely, or finish executing on its own
249 #[unsafe(method(isIndefinite))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn isIndefinite(&self) -> bool;
252 );
253}