public WavFileStream(Stream stream) { _stream = stream; var bytes = new byte[20]; if (_stream.Read(bytes, 0, bytes.Length) < bytes.Length || BitConverter.ToInt32(bytes, 4) == 0 || BitConverter.ToInt32(bytes, 8) != 0x45564157 || // "WAVE" BitConverter.ToInt32(bytes, 12) != 0x20746d66) // "fmt " { throw new FileFormatException("Badly formed RIFF file."); } var fmtBytes = new byte[BitConverter.ToInt32(bytes, 16)]; _stream.Read(fmtBytes, 0, fmtBytes.Length); _format = new WaveFormat(fmtBytes); while (_stream.Read(bytes, 0, 8) == 8) { var dataType = BitConverter.ToInt32(bytes, 0); var dataSize = BitConverter.ToInt32(bytes, 4); if (dataType == 0x61746164) { return; } _stream.Seek(dataSize, SeekOrigin.Current); } throw new FileFormatException("Could not find wave data."); }
public CodecInfo(VoiceCodec codec, int sampleRate) { switch (codec) { case VoiceCodec.Gsm610: this.PayloadType = Gsm610PayloadType; this.SampleRate = sampleRate; int blocksPerPacket = 1; while ((blocksPerPacket * Gsm610SamplesPerBlock * 1000) / sampleRate <= MinBufferLength) { blocksPerPacket++; } this.SamplesPerPacket = Gsm610SamplesPerBlock * blocksPerPacket; this.EncodedBufferSize = Gsm610BytesPerBlock * blocksPerPacket; this.DecodedBufferSize = this.SamplesPerPacket * 2; this.EncodedFormat = new WaveFormatGsm610(sampleRate); this.DecodedFormat = new WaveFormatPcm(sampleRate, 16, 1); break; default: throw new ArgumentException("Unsupported codec."); } }
internal AudioOutputClient(IAudioClient client, WaveFormat format) : base(client, format) { _render = this.GetService<IAudioRenderClient>(); }
internal AudioInputClient(IAudioClient client, WaveFormat format) : base(client, format) { _capture = this.GetService<IAudioCaptureClient>(); }
public AudioOutputClient GetOutputClient(WaveFormat format = null) { return new AudioOutputClient(this.CreateClient(), format); }
internal AudioInputClient(IAudioClient client, WaveFormat format) : base(client, format) { _capture = this.GetService <IAudioCaptureClient>(); }
internal AudioOutputClient(IAudioClient client, WaveFormat format) : base(client, format) { _render = this.GetService <IAudioRenderClient>(); }