Example #1
0
 internal void InitDSPSettings(uint srcChannels)
 {
     dspSettings = new FAudio.F3DAUDIO_DSP_SETTINGS();
     dspSettings.DopplerFactor       = 1.0f;
     dspSettings.SrcChannelCount     = srcChannels;
     dspSettings.DstChannelCount     = SoundEffect.Device().DeviceDetails.OutputFormat.Format.nChannels;
     dspSettings.pMatrixCoefficients = Marshal.AllocHGlobal(
         4 *
         (int)dspSettings.SrcChannelCount *
         (int)dspSettings.DstChannelCount
         );
     memset(
         dspSettings.pMatrixCoefficients,
         '\0',
         (IntPtr)(4 * dspSettings.SrcChannelCount * dspSettings.DstChannelCount)
         );
     SetPanMatrixCoefficients();
 }
Example #2
0
        public SoundBank(AudioEngine audioEngine, string filename)
        {
            if (audioEngine == null)
            {
                throw new ArgumentNullException("audioEngine");
            }
            if (String.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }

            byte[]   buffer = TitleContainer.ReadAllBytes(filename);
            GCHandle pin    = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            FAudio.FACTAudioEngine_CreateSoundBank(
                audioEngine.handle,
                pin.AddrOfPinnedObject(),
                (uint)buffer.Length,
                0,
                0,
                out handle
                );

            pin.Free();
            buffer = null;

            engine        = audioEngine;
            selfReference = new WeakReference(this, true);
            dspSettings   = new FAudio.F3DAUDIO_DSP_SETTINGS();
            dspSettings.SrcChannelCount     = 1;
            dspSettings.DstChannelCount     = engine.channels;
            dspSettings.pMatrixCoefficients = Marshal.AllocHGlobal(
                4 *
                (int)dspSettings.SrcChannelCount *
                (int)dspSettings.DstChannelCount
                );
            engine.RegisterSoundBank(handle, selfReference);
            IsDisposed = false;
        }
Example #3
0
        public SoundBank(AudioEngine audioEngine, string filename)
        {
            if (audioEngine == null)
            {
                throw new ArgumentNullException("audioEngine");
            }
            if (String.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }

            IntPtr bufferLen;
            IntPtr buffer = TitleContainer.ReadToPointer(filename, out bufferLen);

            FAudio.FACTAudioEngine_CreateSoundBank(
                audioEngine.handle,
                buffer,
                (uint)bufferLen,
                0,
                0,
                out handle
                );

            FNAPlatform.FreeFilePointer(buffer);

            engine        = audioEngine;
            selfReference = new WeakReference(this, true);
            dspSettings   = new FAudio.F3DAUDIO_DSP_SETTINGS();
            dspSettings.SrcChannelCount     = 1;
            dspSettings.DstChannelCount     = engine.channels;
            dspSettings.pMatrixCoefficients = Marshal.AllocHGlobal(
                4 *
                (int)dspSettings.SrcChannelCount *
                (int)dspSettings.DstChannelCount
                );
            engine.RegisterPointer(handle, selfReference);
            IsDisposed = false;
        }
Example #4
0
        internal void InitDSPSettings(uint srcChannels)
        {
            dspSettings = new FAudio.F3DAUDIO_DSP_SETTINGS();
            dspSettings.DopplerFactor   = 1.0f;
            dspSettings.SrcChannelCount = srcChannels;
            dspSettings.DstChannelCount = SoundEffect.Device().DeviceDetails.OutputFormat.Format.nChannels;

            int memsize = (
                4 *
                (int)dspSettings.SrcChannelCount *
                (int)dspSettings.DstChannelCount
                );

            dspSettings.pMatrixCoefficients = Marshal.AllocHGlobal(memsize);
            unsafe
            {
                byte *memPtr = (byte *)dspSettings.pMatrixCoefficients;
                for (int i = 0; i < memsize; i += 1)
                {
                    memPtr[i] = 0;
                }
            }
            SetPanMatrixCoefficients();
        }