From b41f93cd0ed2bb71e6c75d5690f769596da39c78 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 3 Mar 2016 08:51:07 +0400 Subject: [PATCH] (RawPcmInput): class representing raw PCM sound input. --- GameRes/Audio.cs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/GameRes/Audio.cs b/GameRes/Audio.cs index 88924082..24cc0d7e 100644 --- a/GameRes/Audio.cs +++ b/GameRes/Audio.cs @@ -114,6 +114,50 @@ namespace GameRes #endregion } + /// + /// Class representing raw PCM sound input. + /// + public class RawPcmInput : SoundInput + { + public override string SourceFormat { get { return "raw"; } } + + public override int SourceBitrate + { + get { return (int)Format.AverageBytesPerSecond * 8; } + } + + public RawPcmInput (Stream file, WaveFormat format) : base (file) + { + this.Format = format; + this.PcmSize = file.Length; + } + + #region IO.Stream methods + public override long Position + { + get { return Source.Position; } + set { Source.Position = value; } + } + + public override bool CanSeek { get { return Source.CanSeek; } } + + public override long Seek (long offset, SeekOrigin origin) + { + return Source.Seek (offset, origin); + } + + public override int Read (byte[] buffer, int offset, int count) + { + return Source.Read (buffer, offset, count); + } + + public override int ReadByte () + { + return Source.ReadByte(); + } + #endregion + } + public abstract class AudioFormat : IResource { public override string Type { get { return "audio"; } }