103 lines
3.5 KiB
C#
103 lines
3.5 KiB
C#
// using FMOD;
|
|
|
|
// namespace RogueMine.Audio
|
|
// {
|
|
// public class FmodAudioBackend : AudioBackend
|
|
// {
|
|
// public override void Initialize()
|
|
// {
|
|
// CreateSystem();
|
|
// _loadedSounds = new Dictionary<string, FMOD.Sound>();
|
|
// _channelGroups = new Dictionary<string, ChannelGroup>();
|
|
|
|
// CreateBus("Master");
|
|
// }
|
|
// public override void Update() => _system.update();
|
|
|
|
// protected override void PlaySound(Sound sound, string bus = "Master", float pitch = 1, float volume = 1)
|
|
// {
|
|
// var channel = PlaySoundFromPath(sound.Path, GetChannelGroup(bus));
|
|
// channel.setVolume(volume);
|
|
// channel.setPitch(pitch);
|
|
// }
|
|
|
|
// public override void CreateBus(string busName)
|
|
// {
|
|
// ChannelGroup channelGroup;
|
|
// _system.createChannelGroup(busName, out channelGroup);
|
|
// _channelGroups.Add(busName, channelGroup);
|
|
// }
|
|
|
|
// public override void SetBusVolume(string busName, float volume)
|
|
// {
|
|
// var channel = GetChannelGroup(busName);
|
|
// channel.setVolume(volume);
|
|
// }
|
|
|
|
// public override float GetBusVolume(string busName)
|
|
// {
|
|
// float volume;
|
|
// GetChannelGroup(busName).getVolume(out volume);
|
|
// return volume;
|
|
// }
|
|
|
|
// public override void AddBusEffect<T>(T effect, string bus = "Master")
|
|
// {
|
|
// var channelGroup = GetChannelGroup(bus);
|
|
// DSP dsp;
|
|
|
|
// switch (effect)
|
|
// {
|
|
// case AudioEffectReverb:
|
|
// dsp = CreateReverbDsp(effect as AudioEffectReverb);
|
|
// break;
|
|
// default:
|
|
// _system.createDSPByType(DSP_TYPE.UNKNOWN, out dsp);
|
|
// break;
|
|
// }
|
|
|
|
// channelGroup.addDSP(0, dsp);
|
|
// }
|
|
|
|
// private DSP CreateReverbDsp(AudioEffectReverb effectReverb)
|
|
// {
|
|
// DSP dsp;
|
|
// _system.createDSPByType(DSP_TYPE.SFXREVERB, out dsp);
|
|
// return dsp;
|
|
// }
|
|
|
|
// private void CreateSystem()
|
|
// {
|
|
// var result = FMOD.Factory.System_Create(out _system);
|
|
// _system.init(128, INITFLAGS.NORMAL, 0);
|
|
// }
|
|
|
|
// private Channel PlaySoundFromPath(string path, ChannelGroup channelGroup)
|
|
// {
|
|
// FMOD.Channel fmodChannel;
|
|
// FMOD.Sound fmodSound = IsLoaded(path) ? GetSoundFromLoaded(path) : CreateSound(path);
|
|
// _system.playSound(fmodSound, channelGroup, false, out fmodChannel);
|
|
|
|
// return fmodChannel;
|
|
// }
|
|
|
|
// private FMOD.Sound GetSoundFromLoaded(string path) => _loadedSounds[path];
|
|
// private bool IsLoaded(string path) => _loadedSounds.ContainsKey(path);
|
|
|
|
// private FMOD.Sound CreateSound(string path)
|
|
// {
|
|
// FMOD.Sound sound;
|
|
// _system.createSound(path, FMOD.MODE.DEFAULT, out sound);
|
|
// AddToLoaded(path, sound);
|
|
// return sound;
|
|
// }
|
|
|
|
// private void AddToLoaded(string path, FMOD.Sound sound) => _loadedSounds.Add(path, sound);
|
|
|
|
// private ChannelGroup GetChannelGroup(string busName) => _channelGroups[busName];
|
|
|
|
// private FMOD.System _system;
|
|
// private Dictionary<string, FMOD.Sound> _loadedSounds;
|
|
// private Dictionary<string, ChannelGroup> _channelGroups;
|
|
// }
|
|
// } |