40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
namespace DaggerFramework.Audio
|
|
{
|
|
public abstract class AudioBackend : IDisposable
|
|
{
|
|
public abstract void Initialize();
|
|
public abstract void Update();
|
|
public abstract void Shutdown();
|
|
// BUS
|
|
public abstract void CreateBus(string busName);
|
|
public abstract void SetBusVolume(string busName, float volume);
|
|
public abstract float GetBusVolume(string busName);
|
|
|
|
// SOUND
|
|
public 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, default, default);
|
|
public void PlaySoundVariation(Sound sound, string bus = "Master", float pitchVariation = 0.1f, float volume = 1.0f)
|
|
{
|
|
var maxPitch = 1.0f + pitchVariation;
|
|
var minPitch = 1.0f - pitchVariation;
|
|
|
|
var pitch = (float)_random.NextDouble() * (maxPitch - minPitch) + minPitch;
|
|
PlaySound(sound, bus, pitch, volume);
|
|
}
|
|
|
|
// EFFECTS
|
|
public abstract void AddBusEffect<T>(T effect, string bus = "Master") where T : AudioEffect;
|
|
|
|
public void Dispose()
|
|
{
|
|
Shutdown();
|
|
}
|
|
|
|
private LehmerRandom _random = new LehmerRandom();
|
|
}
|
|
|
|
public struct SoundInstance
|
|
{
|
|
|
|
}
|
|
} |