Init.
This commit is contained in:
29
Source/Audio/AudioBackend.cs
Normal file
29
Source/Audio/AudioBackend.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace DaggerFramework.Audio
|
||||
{
|
||||
public abstract class AudioBackend
|
||||
{
|
||||
public abstract void Initialize();
|
||||
public abstract void Update();
|
||||
// BUS
|
||||
public abstract void CreateBus(string busName);
|
||||
public abstract void SetBusVolume(string busName, float volume);
|
||||
public abstract float GetBusVolume(string busName);
|
||||
|
||||
// SOUND
|
||||
protected abstract void PlaySound(Sound sound, string bus = "Master", float pitch = 1.0f, float volume = 1.0f);
|
||||
public void PlaySound(Sound sound, string bus = "Master") => PlaySound(sound, bus, sound.PitchScale, sound.Volume);
|
||||
public void PlaySoundVariation(Sound sound, string bus = "Master", float pitchVariation = 0.1f)
|
||||
{
|
||||
var maxPitch = sound.PitchScale + pitchVariation;
|
||||
var minPitch = sound.PitchScale - pitchVariation;
|
||||
|
||||
var pitch = (float)_random.NextDouble() * (maxPitch - minPitch) + minPitch;
|
||||
PlaySound(sound, bus, pitch, sound.Volume);
|
||||
}
|
||||
|
||||
// EFFECTS
|
||||
public abstract void AddBusEffect<T>(T effect, string bus = "Master") where T : AudioEffect;
|
||||
|
||||
private LehmerRandom _random = new LehmerRandom();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user