예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SoundInSource"/> class.
        /// </summary>
        /// <param name="soundIn">The soundIn which provides recorded data.</param>
        /// <param name="bufferSize">Size of the internal buffer in bytes.</param>
        /// <remarks>
        /// Note that soundIn has to be already initialized.
        /// Note that old data ("old" gets specified by the bufferSize) gets overridden.
        /// For example, if the bufferSize is about 5 seconds big, data which got recorded 6 seconds ago, won't be available anymore.
        /// </remarks>
        public SoundInSource(ISoundIn soundIn, int bufferSize)
        {
            if (soundIn == null)
            {
                throw new ArgumentNullException("soundIn");
            }
            ThrowIfSoundInNotInitialized(soundIn);

            _buffer = new WriteableBufferingSource(soundIn.WaveFormat, bufferSize)
            {
                FillWithZeros = false
            };
            _soundIn = soundIn;
            _soundIn.DataAvailable += OnDataAvailable;
        }
예제 #2
0
        /// <summary>
        /// Disposes the <see cref="SoundInSource"/>.
        /// </summary>
        /// <param name="disposing">Not used.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (SoundIn != null)
                {
                    SoundIn.DataAvailable -= OnDataAvailable;
                    _soundIn = null;
                }

                if (_buffer != null)
                {
                    _buffer.Dispose();
                    _buffer = null;
                }
            }
            _disposed = true;
        }