objc2_scene_kit/generated/
SCNAudioSource.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    /// The SCNAudioSource class represents an audio source that can be added to a SCNNode.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnaudiosource?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct SCNAudioSource;
19);
20
21extern_conformance!(
22    unsafe impl NSCoding for SCNAudioSource {}
23);
24
25extern_conformance!(
26    unsafe impl NSCopying for SCNAudioSource {}
27);
28
29unsafe impl CopyingHelper for SCNAudioSource {
30    type Result = Self;
31}
32
33extern_conformance!(
34    unsafe impl NSObjectProtocol for SCNAudioSource {}
35);
36
37extern_conformance!(
38    unsafe impl NSSecureCoding for SCNAudioSource {}
39);
40
41impl SCNAudioSource {
42    extern_methods!(
43        /// Convenience initializer that creates an AVAudioNode from the named audio asset in the main bundle.
44        #[unsafe(method(initWithFileNamed:))]
45        #[unsafe(method_family = init)]
46        pub unsafe fn initWithFileNamed(
47            this: Allocated<Self>,
48            name: &NSString,
49        ) -> Option<Retained<Self>>;
50
51        /// Convenience initializer that creates an AVAudioNode from the URL that contain a audio asset.
52        #[unsafe(method(initWithURL:))]
53        #[unsafe(method_family = init)]
54        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
55
56        /// Convenience class initializer that caches audioSources.
57        #[unsafe(method(audioSourceNamed:))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn audioSourceNamed(file_name: &NSString) -> Option<Retained<Self>>;
60
61        /// Marks the audio source as positional so that the audio mix considers relative position and velocity with regards to the SCNSceneRenderer's current listener node. Defaults to YES.
62        ///
63        /// shouldStream must be set to false in order to get positional audio (see shouldStream).
64        ///
65        /// See: SCNSceneRenderer audioListener.
66        #[unsafe(method(isPositional))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn isPositional(&self) -> bool;
69
70        /// Setter for [`isPositional`][Self::isPositional].
71        #[unsafe(method(setPositional:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn setPositional(&self, positional: bool);
74
75        /// The default volume for this audio buffer. Default is 1.0 (full volume).
76        #[unsafe(method(volume))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn volume(&self) -> c_float;
79
80        /// Setter for [`volume`][Self::volume].
81        #[unsafe(method(setVolume:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn setVolume(&self, volume: c_float);
84
85        /// The default rate for this audio buffer. Default is 1.0 (original rate of the audio source).
86        #[unsafe(method(rate))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn rate(&self) -> c_float;
89
90        /// Setter for [`rate`][Self::rate].
91        #[unsafe(method(setRate:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setRate(&self, rate: c_float);
94
95        /// The default reverbBlend for this audio buffer. Default is 0.0 (no sound is sent to the reverb).
96        #[unsafe(method(reverbBlend))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn reverbBlend(&self) -> c_float;
99
100        /// Setter for [`reverbBlend`][Self::reverbBlend].
101        #[unsafe(method(setReverbBlend:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn setReverbBlend(&self, reverb_blend: c_float);
104
105        /// Specifies whether the audio source should loop or not. Defaults to NO.
106        #[unsafe(method(loops))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn loops(&self) -> bool;
109
110        /// Setter for [`loops`][Self::loops].
111        #[unsafe(method(setLoops:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setLoops(&self, loops: bool);
114
115        /// Specifies whether the audio source should be streamed or not. Defaults to NO.
116        #[unsafe(method(shouldStream))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn shouldStream(&self) -> bool;
119
120        /// Setter for [`shouldStream`][Self::shouldStream].
121        #[unsafe(method(setShouldStream:))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn setShouldStream(&self, should_stream: bool);
124
125        /// Load and uncompress the audio source in memory. This method has no effect if "shouldStream" is set to YES or if the audio source is already loaded.
126        ///
127        /// This method let you preload your audio sources. If an audio source is not preloaded, it will be loaded anyway when playing it.
128        #[unsafe(method(load))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn load(&self);
131    );
132}
133
134/// Methods declared on superclass `NSObject`.
135impl SCNAudioSource {
136    extern_methods!(
137        #[unsafe(method(init))]
138        #[unsafe(method_family = init)]
139        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
140
141        #[unsafe(method(new))]
142        #[unsafe(method_family = new)]
143        pub unsafe fn new() -> Retained<Self>;
144    );
145}
146
147extern_class!(
148    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnaudioplayer?language=objc)
149    #[unsafe(super(NSObject))]
150    #[derive(Debug, PartialEq, Eq, Hash)]
151    pub struct SCNAudioPlayer;
152);
153
154extern_conformance!(
155    unsafe impl NSObjectProtocol for SCNAudioPlayer {}
156);
157
158impl SCNAudioPlayer {
159    extern_methods!(
160        #[unsafe(method(init))]
161        #[unsafe(method_family = init)]
162        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
163
164        /// Init an audio player with a source. Most people should use audioPlayerWithSource as it permits to recycle previous players instead of creating new ones for each instance.
165        #[unsafe(method(initWithSource:))]
166        #[unsafe(method_family = init)]
167        pub unsafe fn initWithSource(
168            this: Allocated<Self>,
169            source: &SCNAudioSource,
170        ) -> Retained<Self>;
171
172        #[cfg(feature = "objc2-avf-audio")]
173        /// Init an audio player with an AVAudioNode. Most people should use audioPlayerWithAVAudioNode as it permits to recycle previous players instead of creating new ones for each instance.
174        #[unsafe(method(initWithAVAudioNode:))]
175        #[unsafe(method_family = init)]
176        pub unsafe fn initWithAVAudioNode(
177            this: Allocated<Self>,
178            audio_node: &AVAudioNode,
179        ) -> Retained<Self>;
180
181        /// Create an audio player with a source.
182        #[unsafe(method(audioPlayerWithSource:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn audioPlayerWithSource(source: &SCNAudioSource) -> Retained<Self>;
185
186        #[cfg(feature = "objc2-avf-audio")]
187        /// Create an audio player with a custom AVAudioNode instance.
188        #[unsafe(method(audioPlayerWithAVAudioNode:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn audioPlayerWithAVAudioNode(audio_node: &AVAudioNode) -> Retained<Self>;
191
192        #[cfg(feature = "block2")]
193        /// This block is called when the playback starts in case a valid audio source is present.
194        #[unsafe(method(willStartPlayback))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn willStartPlayback(&self) -> *mut block2::DynBlock<dyn Fn()>;
197
198        #[cfg(feature = "block2")]
199        /// Setter for [`willStartPlayback`][Self::willStartPlayback].
200        #[unsafe(method(setWillStartPlayback:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setWillStartPlayback(
203            &self,
204            will_start_playback: Option<&block2::DynBlock<dyn Fn()>>,
205        );
206
207        #[cfg(feature = "block2")]
208        /// This block is called when the playback stops in case a valid audio source is present.
209        #[unsafe(method(didFinishPlayback))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn didFinishPlayback(&self) -> *mut block2::DynBlock<dyn Fn()>;
212
213        #[cfg(feature = "block2")]
214        /// Setter for [`didFinishPlayback`][Self::didFinishPlayback].
215        #[unsafe(method(setDidFinishPlayback:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setDidFinishPlayback(
218            &self,
219            did_finish_playback: Option<&block2::DynBlock<dyn Fn()>>,
220        );
221
222        #[cfg(feature = "objc2-avf-audio")]
223        /// The audioNode. If this player was not initialised with a custom AVAudioNode this contains the internal audio player node used by scene kit internally.
224        #[unsafe(method(audioNode))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn audioNode(&self) -> Option<Retained<AVAudioNode>>;
227
228        /// The audioSource if there is one.
229        #[unsafe(method(audioSource))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn audioSource(&self) -> Option<Retained<SCNAudioSource>>;
232    );
233}
234
235/// Methods declared on superclass `NSObject`.
236impl SCNAudioPlayer {
237    extern_methods!(
238        #[unsafe(method(new))]
239        #[unsafe(method_family = new)]
240        pub unsafe fn new() -> Retained<Self>;
241    );
242}
243
244/// SCNAudioSupport.
245#[cfg(feature = "SCNNode")]
246impl SCNNode {
247    extern_methods!(
248        /// Add an audio player to the node and starts playing it right away.
249        #[unsafe(method(addAudioPlayer:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn addAudioPlayer(&self, player: &SCNAudioPlayer);
252
253        /// Remove all audio players from this node and stop playing them.
254        #[unsafe(method(removeAllAudioPlayers))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn removeAllAudioPlayers(&self);
257
258        /// Remove the given audio player from this node and stop playing it.
259        #[unsafe(method(removeAudioPlayer:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn removeAudioPlayer(&self, player: &SCNAudioPlayer);
262
263        /// Get an array with all the audio players connected and playing on this node.
264        #[unsafe(method(audioPlayers))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn audioPlayers(&self) -> Retained<NSArray<SCNAudioPlayer>>;
267    );
268}