Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WaveBank"/> class from a wave bank stream.
        /// </summary>
        /// <param name="audioEngine">The engine.</param>
        /// <param name="stream">The wave bank stream.</param>
        /// <unmanaged>HRESULT IXACT3Engine::CreateInMemoryWaveBank([In] const void* pvBuffer,[In] unsigned int dwSize,[In] unsigned int dwFlags,[In] unsigned int dwAllocAttributes,[Out, Fast] IXACT3WaveBank** ppWaveBank)</unmanaged>
        public WaveBank(AudioEngine audioEngine, Stream stream)
        {
            this.audioEngine = audioEngine;
            isAudioEngineReadonly = true;

            if (stream is DataStream)
            {
                audioEngine.CreateInMemoryWaveBank(((DataStream) stream).PositionPointer, (int) (stream.Length - stream.Position), 0, 0, this);
                return;
            }

            rawBuffer = Utilities.ReadStream(stream);
            rawBufferHandle = GCHandle.Alloc(rawBuffer, GCHandleType.Pinned);
            audioEngine.CreateInMemoryWaveBank(rawBufferHandle.AddrOfPinnedObject(), rawBuffer.Length, 0, 0, this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WaveBank"/> class from a wave bank stream.
        /// </summary>
        /// <param name="audioEngine">The engine.</param>
        /// <param name="stream">The wave bank stream.</param>
        /// <unmanaged>HRESULT IXACT3Engine::CreateInMemoryWaveBank([In] const void* pvBuffer,[In] unsigned int dwSize,[In] unsigned int dwFlags,[In] unsigned int dwAllocAttributes,[Out, Fast] IXACT3WaveBank** ppWaveBank)</unmanaged>
        public WaveBank(AudioEngine audioEngine, Stream stream)
        {
            this.audioEngine      = audioEngine;
            isAudioEngineReadonly = true;

            if (stream is DataStream)
            {
                audioEngine.CreateInMemoryWaveBank(((DataStream)stream).PositionPointer, (int)(stream.Length - stream.Position), 0, 0, this);
                return;
            }

            rawBuffer       = Utilities.ReadStream(stream);
            rawBufferHandle = GCHandle.Alloc(rawBuffer, GCHandleType.Pinned);
            audioEngine.CreateInMemoryWaveBank(rawBufferHandle.AddrOfPinnedObject(), rawBuffer.Length, 0, 0, this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WaveBank"/> class from a wave bank stream.
        /// </summary>
        /// <param name="audioEngine">The engine.</param>
        /// <param name="stream">The wave bank stream.</param>
        /// <unmanaged>HRESULT IXACT3Engine::CreateInMemoryWaveBank([In] const void* pvBuffer,[In] unsigned int dwSize,[In] unsigned int dwFlags,[In] unsigned int dwAllocAttributes,[Out, Fast] IXACT3WaveBank** ppWaveBank)</unmanaged>
        public WaveBank(AudioEngine audioEngine, Stream stream)
        {
            this.audioEngine = audioEngine;
            isAudioEngineReadonly = true;

            if (stream is DataStream)
            {
                audioEngine.CreateInMemoryWaveBank(((DataStream) stream).DataPointer, (int) stream.Length, 0, 0, this);
                return;
            }

            var data = Utilities.ReadStream(stream);
            unsafe
            {
                fixed (void* pData = data)
                    audioEngine.CreateInMemoryWaveBank((IntPtr)pData, data.Length, 0, 0, this);
            }
        }