Falco Engine 3.9.0.1 (beta)
AudioSource.cs
Go to the documentation of this file.
1using System;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5namespace FalcoEngine
6{
7 public class AudioSource : Component
8 {
9 internal AudioSource()
10 {
11
12 }
13
14 /*----------- PUBLIC ------------*/
15
19 public bool isPlaying { [MethodImpl(MethodImplOptions.InternalCall)] get; }
20
24 public bool isPaused { [MethodImpl(MethodImplOptions.InternalCall)] get; }
25
29 public bool loop { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
30
34 public bool playOnStart { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
35
39 public float pitch { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
40
44 public float volume { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
45
49 public float minDistance { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
50
54 public float maxDistance { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
55
59 public bool is2D { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
60
64 public AudioClip audioClip { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
65
69 public void Play()
70 {
71 INTERNAL_play();
72 }
73
77 public void Pause()
78 {
79 INTERNAL_pause();
80 }
81
85 public void Resume()
86 {
87 INTERNAL_resume();
88 }
89
93 public void Stop()
94 {
95 INTERNAL_stop();
96 }
97
102 [MethodImpl(MethodImplOptions.InternalCall)]
103 public extern int GetTotalLength();
104
109 [MethodImpl(MethodImplOptions.InternalCall)]
110 public extern int GetPlaybackPosition();
111
116 [MethodImpl(MethodImplOptions.InternalCall)]
117 public extern void SetPlaybackPosition(int seconds);
118
119 /*----------- INTERNAL CALLS ------------*/
120
121 [MethodImpl(MethodImplOptions.InternalCall)]
122 private extern void INTERNAL_play();
123
124 [MethodImpl(MethodImplOptions.InternalCall)]
125 private extern void INTERNAL_pause();
126
127 [MethodImpl(MethodImplOptions.InternalCall)]
128 private extern void INTERNAL_resume();
129
130
131 [MethodImpl(MethodImplOptions.InternalCall)]
132 private extern void INTERNAL_stop();
133 }
134}
float volume
The volume of the audio source (0.0 to 1.0)
Definition: AudioSource.cs:44
float maxDistance
Max distance is the distance where the sound is completely inaudible
Definition: AudioSource.cs:54
bool is2D
Is this audio source 2D or 3D?
Definition: AudioSource.cs:59
float minDistance
Within the min distance the audio source will cease to grow louder in volume
Definition: AudioSource.cs:49
int GetPlaybackPosition()
Get current playback position in seconds
bool isPaused
Returns if this audio source is paused
Definition: AudioSource.cs:24
bool playOnStart
Returns or sets if audio source should start playing after scene is loaded
Definition: AudioSource.cs:34
float pitch
The pitch of the audio source
Definition: AudioSource.cs:39
AudioClip audioClip
Get or set the audio clip for this audio source
Definition: AudioSource.cs:64
int GetTotalLength()
Get total length in seconds
bool isPlaying
Returns if this audio source is playing
Definition: AudioSource.cs:19
void Stop()
Stop playing
Definition: AudioSource.cs:93
bool loop
Return or set whether the audio clip replays after it finishes or not
Definition: AudioSource.cs:29
void Pause()
Pause playing
Definition: AudioSource.cs:77
void SetPlaybackPosition(int seconds)
Set current playback position in seconds
void Resume()
Resume playing
Definition: AudioSource.cs:85
void Play()
Play current audio clip
Definition: AudioSource.cs:69