}/*mtd*/ /// <summary> /// KOnstruktor inicializuje základní třídu, z níž jsou odvozeny třídy pro DSP efekty. /// </summary> /// <param name="fmod">Instance FMODSystem</param> /// <param name="plugin">Instance DSP pluginu</param> /// <param name="channelGroup">Instance skupiny kanálů</param> protected DSPBase(FmodSystem fmod, Plugin plugin, ChannelGroup channelGroup) { _fmod = fmod ?? throw new ArgumentNullException(nameof(fmod)); _plugin = plugin; _dsp = _fmod.CreateDSPByPlugin(_plugin); _channelGroup = channelGroup ?? throw new InvalidOperationException(nameof(channelGroup)); _channelGroup.AddDSP(ChannelControlDSPIndex.DSPTail, _dsp); } /*mtd*/
public static void Init() { _fmodSystem = Fmod.CreateSystem(); _fmodSystem.Init(32); _basePlugin = _fmodSystem.LoadPlugin("resonanceaudio.dll"); _listenerPlugin = _fmodSystem.GetNestedPlugin(_basePlugin, 0); _listenerDSP = _fmodSystem.CreateDSPByPlugin(_listenerPlugin); _soundFieldPlugin = _fmodSystem.GetNestedPlugin(_basePlugin, 1); _sourcePlugin = _fmodSystem.GetNestedPlugin(_basePlugin, 2); _masterChannelGroup = _fmodSystem.MasterChannelGroup; _spatialChannelGroup = _fmodSystem.CreateChannelGroup("spatial"); _masterChannelGroup.AddGroup(_spatialChannelGroup, false); _masterChannelGroup.AddDSP(ChannelControlDSPIndex.DspHead, _listenerDSP); }
public override void Initialize() { base.Initialize(); System.Init(32); sound = System.CreateSound(MediaPath("stereo.ogg"), Mode.Loop_Normal); channel = System.PlaySound(sound, paused: true); dsp = MyCustomDSP.CreateDsp(System); masterGroup = System.MasterChannelGroup; masterGroup.AddDSP(0, dsp); dsp.Bypass = true; }
public override void Initialize() { base.Initialize(); System.Init(32); reverbGroup = System.CreateChannelGroup("reverb"); mainGroup = System.CreateChannelGroup("main"); System.MasterChannelGroup.AddGroup(mainGroup); System.MasterChannelGroup.Volume = 0.25f; reverbUnit = System.CreateDSPByType(DSPType.ConvolutionReverb); reverbGroup.AddDSP(ChannelControlDSPIndex.DSPTail, reverbUnit); var tmpsound = System.CreateSound(MediaPath("standrews.wav"), Mode.Default | Mode.OpenOnly); tmpsound.GetFormat(out _, out SoundFormat sFormat, out int irSoundChannels, out _); if (sFormat != SoundFormat.PCM16) { Console.WriteLine("Sound file's format is not PCM16."); Environment.Exit(-1); } int irSoundLength = (int)tmpsound.GetLength(TimeUnit.PCM); //Allocate a pre-pinned array, tracked by the GC so we have no need to free it ourselves. this.IRData = GC.AllocateArray <short>(irSoundLength * irSoundChannels + 1, pinned: true); tmpsound.ReadData <short>(IRData); const int ReverbParamIR = 0; const int ReverbParamDry = 2; reverbUnit.SetParameterData(ReverbParamIR, Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(IRData)), (uint)IRData.Length * sizeof(short)); reverbUnit.SetParameterFloat(ReverbParamDry, -80f); tmpsound.Release(); sound = System.CreateSound(MediaPath("singing.wav"), Mode._3D | Mode.Loop_Normal); }