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