Audio Source Component

Each audio source is a node on a graph inside an Audio Engine. You can connect them however you like and apply different effects

Usage

Initialize
State
Pitch Effect
Gain Effect
Doppler Effect
Volume

Initialize

Add component AudioSourceComponent to your entity
1. Select the entity 2. In the Properties window click 'Add' and select Audio Source Component Click 'Find' button and navigate to desired audio file

To access component data get the component inside scripting use:

AudioSource src = GetComponent<AudioSource>();

To have actual sound it needs an Audio Clip. You can assign one by Drag-n-Drop from Content Browser


Volume


void SetVolume(float volume, bool IsVolumeInDecibels = true);

AudioSource src = GetComponent<AudioSource>();
src.SetVolume(10.0f);   //Set volume of sound to 10 decibels
src.SetVolume(100.0f, false);  //Set linear volume of sound to 20 decibels.
//See linear to db conversion

void IncreaseVolume(float volumePercentIncrease, bool IsVolumeInDecibels = true);

AudioSource src = GetComponent<AudioSource>();
src.IncreaseVolume(10.0f);  //Increase current volume by 10% in decibels 10db->11db
src.IncreaseVolume(10.0f, false);   //Increase current volume by 10 decibels. 
//Doesn't scale linearly, see linear to db conversion

void DecreaseVolume(float volumePercentDecrease, bool IsVolumeInDecibels = true);

AudioSource src = GetComponent<AudioSource>();
src.DecreaseVolume(30.0f);  //Reduce current volume by 30%  10db->7db
src.DecreaseVolume(100.0f, false);   //Reduce current volume by 20db