Attention
You are viewing PyUnity docs under the develop
branch.
As such, they are only applicable if you installed from source.
Go to https://docs.pyunity.x10.bz/en/latest/ for the most recent
release.
pyunity.audio module¶
Source code: pyunity/audio.py
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[source]¶
Bases:
object
Class to store information about an audio file.
- 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.AudioSource[source]¶
Bases:
Component
Manages playback on an AudioSource.
- SetClip(clip)[source]¶
Sets a clip for the AudioSource to play.
- Parameters:
clip (AudioClip) – AudioClip to play
- property Playing¶
Gets if the AudioSource is playing.
- class pyunity.audio.AudioListener[source]¶
Bases:
SingleComponent
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.