Class AudioManager
A manager file that allows adjusting an
Namespace: OmiyaGames.Audio
Assembly: cs.temp.dll.dll
Syntax
public static class AudioManager
Remarks
Copyright (c) 2022 Omiya Games Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Revision | Description |
---|---|
Version: 0.1.0-exp.1 Date: 2/12/2022 Author: Taro Omiya | Initial verison. |
Version: 1.0.0-exp.1 Date: 6/21/2022 Author: Taro Omiya | Adding more helper methods and documentation. |
Fields
ADDRESSABLE_NAME
Name of the addressable.
Declaration
public const string ADDRESSABLE_NAME = "AudioSettings"
Field Value
Type | Description |
---|---|
String |
CONFIG_NAME
The configuration name stored in Editor Settings.
Declaration
public const string CONFIG_NAME = "com.omiyagames.audio"
Field Value
Type | Description |
---|---|
String |
SIDEBAR_PATH
The name this settings will appear in the Project Setting's left-sidebar.
Declaration
public const string SIDEBAR_PATH = "Project/Omiya Games/Audio"
Field Value
Type | Description |
---|---|
String |
UXML_PATH
Path to UXML file.
Declaration
public const string UXML_PATH = "Packages/com.omiyagames.audio/Editor/Audio.uxml"
Field Value
Type | Description |
---|---|
String |
Properties
Ambience
The background ambience layer. Allows playing and managing BackgroundAudio clips.
Declaration
public static AudioLayer.Background Ambience { get; }
Property Value
Type | Description |
---|---|
AudioLayer.Background |
Main
The main layer of audio. This affects the volume and pitch of all audio sources wired to any layer in this manager.
Declaration
public static AudioLayer Main { get; }
Property Value
Type | Description |
---|---|
AudioLayer |
Mixer
The main mixer of this game.
Declaration
public static AudioMixer Mixer { get; }
Property Value
Type | Description |
---|---|
AudioMixer |
Music
The background music layer. Allows playing and managing BackgroundAudio clips.
Declaration
public static AudioLayer.Background Music { get; }
Property Value
Type | Description |
---|---|
AudioLayer.Background |
MuteVolumeDb
The volume considered low enough to be "mute" according to Mixer.
Declaration
public static float MuteVolumeDb { get; }
Property Value
Type | Description |
---|---|
Single |
SoundEffects
The layer dedicated to sound effects. This affects the volume and pitch of any audio sources wired to DefaultUiGroup or DefaultGroup.
Declaration
public static AudioLayer.Spatial SoundEffects { get; }
Property Value
Type | Description |
---|---|
AudioLayer.Spatial |
Status
Indicates whether the manager is either still in the middle of setting up, or is already setup.
Declaration
public static Data.Status Status { get; }
Property Value
Type | Description |
---|---|
Data.Status |
Voices
The layer dedicated to voices. This affects the volume and pitch of any audio sources wired to DefaultUiGroup or DefaultGroup.
Declaration
public static AudioLayer.Spatial Voices { get; }
Property Value
Type | Description |
---|---|
AudioLayer.Spatial |
Methods
CalculateClipLengthSeconds(AudioClip)
Calculates how long an
Declaration
public static double CalculateClipLengthSeconds(AudioClip clip)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | Clip to calculate the duration of. |
Returns
Type | Description |
---|---|
Double | How long |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If |
CalculateTimeSample(AudioClip, Double)
Calculates which
Declaration
public static int CalculateTimeSample(AudioClip clip, double timeStamp)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | Clip to process. |
Double | timeStamp | The timestamp on the |
Returns
Type | Description |
---|---|
Int32 | The time sample |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If |
ArgumentOutOfRangeException | If |
ConvertPercentToVolumeDb(Single)
Converts a fraction between 0
and 1
to decibels.
Declaration
public static float ConvertPercentToVolumeDb(float percent)
Parameters
Type | Name | Description |
---|---|---|
Single | percent | The fraction between |
Returns
Type | Description |
---|---|
Single | Equivalent decibel value. |
Setup(Boolean)
Sets up this manager as a coroutine.
Declaration
public static IEnumerator Setup(bool forceSetup = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | forceSetup | If set to true, forces setting up this manager from scratch. Otherwise, checks whether the manager has been setup or not; if not, runs the setup process. |
Returns
Type | Description |
---|---|
IEnumerator | Coroutine to setup this manager. |
Remarks
Always, always call this method first before using this manager. It is OK to call this method multiple time.