コード例 #1
0
        public static StreamingSourceVoice Create(XAudio2 xaudio2, IWaveSource waveSource, int bufferSize = 100)
        {
            var    voiceCallback = new VoiceCallback();
            IntPtr ptr           = xaudio2.CreateSourceVoicePtr(waveSource.WaveFormat, VoiceFlags.None,
                                                                XAudio2.DefaultFrequencyRatio, voiceCallback,
                                                                null, null);

            return(new StreamingSourceVoice(ptr, voiceCallback, waveSource, bufferSize));
        }
コード例 #2
0
        private static IntPtr CreateSourceVoice(XAudio2 xaudio2, IWaveSource waveSource, VoiceCallback callback)
        {
            if (xaudio2 == null)
            {
                throw new ArgumentNullException("xaudio2");
            }
            if (waveSource == null)
            {
                throw new ArgumentNullException("waveSource");
            }

            return(xaudio2.CreateSourceVoicePtr(waveSource.WaveFormat, VoiceFlags.None,
                                                XAudio2.DefaultFrequencyRatio, callback,
                                                null, null));
        }
コード例 #3
0
        /// <summary>
        ///     Creates an instance of the <see cref="StreamingSourceVoice" /> class.
        /// </summary>
        /// <param name="xaudio2">Instance of the <see cref="XAudio2" /> class.</param>
        /// <param name="waveSource"><see cref="IWaveSource" /> which provides the audio data to stream.</param>
        /// <param name="bufferSize">
        ///     Buffersize of the internal used buffers in milliseconds. Values in the range from 70ms to
        ///     200ms are recommended.
        /// </param>
        /// <returns>Configured <see cref="StreamingSourceVoice" /> instance.</returns>
        public static StreamingSourceVoice Create(XAudio2 xaudio2, IWaveSource waveSource, int bufferSize = 100)
        {
            var voiceCallback = new VoiceCallback();
            IntPtr ptr = xaudio2.CreateSourceVoicePtr(waveSource.WaveFormat, VoiceFlags.None,
                XAudio2.DefaultFrequencyRatio, voiceCallback,
                null, null);

            return new StreamingSourceVoice(ptr, voiceCallback, waveSource, bufferSize);
        }
コード例 #4
0
ファイル: StreamingSourceVoice.cs プロジェクト: opcon/cscore
        private static IntPtr CreateSourceVoice(XAudio2 xaudio2, IWaveSource waveSource, VoiceCallback callback)
        {
            if (xaudio2 == null)
                throw new ArgumentNullException("xaudio2");
            if (waveSource == null)
                throw new ArgumentNullException("waveSource");

            return xaudio2.CreateSourceVoicePtr(waveSource.WaveFormat, VoiceFlags.None,
                XAudio2.DefaultFrequencyRatio, callback,
                null, null);
        }