pyunity.audio module¶
Classes to manage the playback of audio.
It uses the sdl2.sdlmixer library.
A variable in the config
module called
audio
will be set to False
if the
mixer module cannot be initialized.
-
class
pyunity.audio.
AudioClip
(path)[source]¶ Bases:
object
Class to store information about an audio file.
-
path
¶ Path to the file
Type: str
-
music
¶ Sound chunk that can be played with an SDL2 Mixer Channel. Only set when the AudioClip is played in an
AudioSource
.Type: sdl2.sdlmixer.mixer.Mix_Chunk
-
-
class
pyunity.audio.
AudioListener
[source]¶ Bases:
pyunity.core.Component
Class to receive audio events and to base spatial sound from. By default the Main Camera has an AudioListener, but you can also remove it and add a new one to another GameObject in a Scene. There can only be one AudioListener, otherwise sound is disabled.
-
AddComponent
(component)¶ Calls AddComponent on the component’s GameObject.
Parameters: component (Component) – Component to add. Must inherit from Component
-
DeInit
()[source]¶ Stops all AudioSources, frees memory that is used by the AudioClips and de-initializes the SDL2 Mixer.
-
GetComponent
(component)¶ Calls GetComponent on the component’s GameObject.
Parameters: componentClass (Component) – Component to get. Must inherit from Component
-
GetComponents
(component)¶ Calls GetComponents on the component’s GameObject.
Parameters: componentClass (Component) – Component to get. Must inherit from Component
-
-
class
pyunity.audio.
AudioSource
[source]¶ Bases:
pyunity.core.Component
Manages playback on an AudioSource.
-
PlayOnStart
¶ Whether it plays on start or not.
Type: bool
-
Loop
¶ Whether it loops or not. This is not fully supported.
Type: bool
-
AddComponent
(component)¶ Calls AddComponent on the component’s GameObject.
Parameters: component (Component) – Component to add. Must inherit from Component
-
GetComponent
(component)¶ Calls GetComponent on the component’s GameObject.
Parameters: componentClass (Component) – Component to get. Must inherit from Component
-
GetComponents
(component)¶ Calls GetComponents on the component’s GameObject.
Parameters: componentClass (Component) – Component to get. Must inherit from Component
-
Playing
¶ Gets if the AudioSource is playing.
-
RemoveComponent
(component)¶ Calls RemoveComponent on the component’s GameObject.
Parameters: component (Component) – Component to remove. Must inherit from Component
-
RemoveComponents
(component)¶ Calls RemoveComponents on the component’s GameObject.
Parameters: component (Component) – Component to remove. Must inherit from Component
-