- Creation of sound resources
- Playing effects even after calling scene is removed
- Stopping/Playing from stopped point of all effects
- Removal of all effects
- Clone this repo or download as a zip
- Copy directory
audio_manager
to your project - Create singleton (autoload) using
audio_manager.tscn
- Call manager functions inside your scenes (check example code in
/test/audio_test.gd
)
Sound Name
- name of the sound that will be referenced in function callsVolumne Change Min
- Minimal change in dB that sound can randomly play atVolumne Change Max
- Maximum change in dB that sound can randomly play atPitch Scale Min
- Minimum pitch that sound can randomly play at, described as sample rate multiplierPitch Scale Max
- Maximum pitch that sound can randomly play at, described as sample rate multiplierMax Distance
- Maximum distance from which sound can be heard at in pxArea Mask
- Integer, determinesarea_mask
layer, for better explanation check documentation
- Go to audio_manager/audio_manager.tscn and
AudioManager
Node inside the scene - In inspector under
Sound Resource List
tab click+Add Element
- Click on
<empty>
and pickNew ComponentSoundResource
from the dropdown - Click on newly created
ComponentSoundResource
to edit it's values, changes to at leastSoundName
andSoundFile
are necessary.
- In desired location under
FileSystem
tab right click ->Create new
->Resource...
- Search for
ComponentSoundResource
and pick it - Select save location
- Select created resource in
FileSystem
- In
Inspector
tab edit desired values, changes to at leastSoundName
andSoundFile
are necessary - Go to audio_manager/audio_manager.tscn and
AudioManager
Node inside the scene - In inspector under
Sound Resource List
tab click+Add Element
- Click on
<empty>
and pickQuickLoad
orLoad
from the dropdown - Select created Resource.
Example resource: test\resources\example_sound_resource.tres
Remember, resource file name is not used in function call but rather name that you put in SoundName
variable.
This is recommended way, sounds created as resource are more easily reused between projects and more "safe" as for example small changes related to list code won't remove all created sounds.
All methods are inside audio_manager/audio_manager.tscn.
Finds a sound with name sound_name
and plays it from 2D position
. If sound is not found debug message is displayed in console but no error is thrown.
Stops all sounds that are currently playing, new sounds played after this method call are not stopped.
Resumes all sounds.
All created sounds, even stopped, are removed.
To test and showcase functionality of the manager, run default scene (test_scene.tscn
).
Keybinds:
- Q - plays example sound
- W - plays example sound with variable pitch and volume
- E - plays example sound with variable pitch and volume (sound created from Resource)
- P - pauses/resumes all sounds
- A - removes all sounds
- Between scene persistence
- Delayed/stopped in
play_sound
- Music player
- Crossfading (general dynamic music control)