Exemplo n.º 1
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            float gain = this.InputGain != 0f ? (float)Math.Pow(10, this.InputGain / 20f) : 1f;

            WavProcess.ApplyGain(gain, buffer, count);

            if (offset != 0)
            {
                throw new ArgumentException("Offsets are not supported.");
            }
            count = _encoder.Convert(buffer, count, buffer);
            base.Write(buffer, offset, count);
        }
Exemplo n.º 2
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            Array.Clear(buffer, 0, count);

            var packet = this.Dequeue();

            if (packet != null)
            {
                count = _decoder.Convert(packet.Data, packet.Data.Length, buffer);
                packet.Dispose();
                float gain = this.Gain != 0f ? (float)Math.Pow(10, this.Gain / 20f) : 1f;
                WavProcess.ApplyGain(gain, buffer, count);
            }

            return(count);
        }
Exemplo n.º 3
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            float gain = this.Gain != 0f ? (float)Math.Pow(10, this.Gain / 20f) : 1f;

            this.Level = WavProcess.ApplyGain(gain, buffer, count);

            if (_client != null)
            {
                count = _encoder.Convert(buffer, count, buffer);
                if (count >= _client.PayloadSize && (_predicate == null || _predicate()))
                {
                    _client.Send(_timeStamp, buffer);
                }
            }
            _timeStamp += _codec.SamplesPerPacket;
        }