public AudioDecoder(DecoderSettings settings, string path, Stream IO, AudioPCMConfig _pcm) { m_settings = settings; _path = path; _IO = IO != null ? IO : new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x10000, FileOptions.SequentialScan); _br = new BinaryReader(_IO); _largeFile = false; _dataOffset = 0; _samplePos = 0; pcm = _pcm; _dataLen = _IO.CanSeek ? _IO.Length : -1; if (_dataLen < 0) { _sampleLen = -1; } else { _sampleLen = _dataLen / pcm.BlockAlign; if ((_dataLen % pcm.BlockAlign) != 0) { throw new Exception("odd file size"); } } }
public static AudioBuffer ReadAllSamples(DecoderSettings settings, string path, Stream IO = null) { AudioDecoder reader = new AudioDecoder(settings, path, IO); AudioBuffer buff = new AudioBuffer(reader, (int)reader.Length); reader.Read(buff, -1); if (reader.Remaining != 0) { throw new Exception("couldn't read the whole file"); } reader.Close(); return(buff); }
public AudioDecoder(DecoderSettings settings, string path, Stream IO = null) { m_settings = settings; _path = path; _IO = IO ?? new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x10000, FileOptions.SequentialScan); _br = new BinaryReader(_IO); ParseHeaders(); if (_dataLen < 0 || m_settings.IgnoreChunkSizes) { _sampleLen = -1; } else { _sampleLen = _dataLen / pcm.BlockAlign; } }