public void Dispose() { if (RiffSource != null) { RiffSource.Dispose(); } RiffSource = null; }
public void Load(Stream stream) { try { RiffSource = null; var rm = new RiffMaster(); rm.LoadStream(stream); RiffSource = rm; //analyze the file to make sure its an OK wave file if (rm.riff.type != "WAVE") { throw new Blob_WaveFile_Exception("Not a RIFF WAVE file"); } var fmt = rm.riff.subchunks.FirstOrDefault(chunk => chunk.tag == "fmt ") as RiffMaster.RiffSubchunk_fmt; if (fmt == null) { throw new Blob_WaveFile_Exception("Not a valid RIFF WAVE file (missing fmt chunk"); } if (1 != rm.riff.subchunks.Count(chunk => chunk.tag == "data")) { //later, we could make a Stream which would make an index of data chunks and walk around them throw new Blob_WaveFile_Exception("Multi-data-chunk WAVE files not supported"); } if (fmt.format_tag != RiffMaster.RiffSubchunk_fmt.FORMAT_TAG.WAVE_FORMAT_PCM) { throw new Blob_WaveFile_Exception("Not a valid PCM WAVE file (only PCM is supported)"); } if (fmt.channels != 2 || fmt.bitsPerSample != 16 || fmt.samplesPerSec != 44100) { throw new Blob_WaveFile_Exception("Not a CDA format WAVE file (conversion not yet supported)"); } //acquire the start of the data chunk var dataChunk = rm.riff.subchunks.FirstOrDefault(chunk => chunk.tag == "data") as RiffMaster.RiffSubchunk; waveDataStreamPos = dataChunk.Position; mDataLength = dataChunk.Length; } catch { Dispose(); throw; } }
public void Load(Stream stream) { try { RiffSource = null; var rm = new RiffMaster(); rm.LoadStream(stream); RiffSource = rm; //analyze the file to make sure its an OK wave file if (rm.riff.type != "WAVE") { throw new Blob_WaveFile_Exception("Not a RIFF WAVE file"); } var fmt = rm.riff.subchunks.FirstOrDefault(chunk => chunk.tag == "fmt ") as RiffMaster.RiffSubchunk_fmt; if (fmt == null) { throw new Blob_WaveFile_Exception("Not a valid RIFF WAVE file (missing fmt chunk"); } if (1 != rm.riff.subchunks.Count(chunk => chunk.tag == "data")) { //later, we could make a Stream which would make an index of data chunks and walk around them throw new Blob_WaveFile_Exception("Multi-data-chunk WAVE files not supported"); } if (fmt.format_tag != RiffMaster.RiffSubchunk_fmt.FORMAT_TAG.WAVE_FORMAT_PCM) { throw new Blob_WaveFile_Exception("Not a valid PCM WAVE file (only PCM is supported)"); } if (fmt.channels != 2 || fmt.bitsPerSample != 16 || fmt.samplesPerSec != 44100) { throw new Blob_WaveFile_Exception("Not a CDA format WAVE file (conversion not yet supported)"); } //acquire the start of the data chunk var dataChunk = rm.riff.subchunks.FirstOrDefault(chunk => chunk.tag == "data") as RiffMaster.RiffSubchunk; waveDataStreamPos = dataChunk.Position; mDataLength = dataChunk.Length; } catch { Dispose(); throw; } }
public void Dispose() { if (RiffSource != null) RiffSource.Dispose(); RiffSource = null; }
public void Dispose() { RiffSource?.Dispose(); RiffSource = null; }