public string Describe(string fileName) { StringBuilder stringBuilder = new StringBuilder(); using (WaveFileReader wf = new WaveFileReader(fileName)) { stringBuilder.AppendFormat("{0} {1}Hz {2} channels {3} bits per sample\r\n", wf.WaveFormat.Encoding, wf.WaveFormat.SampleRate, wf.WaveFormat.Channels, wf.WaveFormat.BitsPerSample); stringBuilder.AppendFormat("Extra Size: {0} Block Align: {1} Average Bytes Per Second: {2}\r\n", wf.WaveFormat.ExtraSize, wf.WaveFormat.BlockAlign, wf.WaveFormat.AverageBytesPerSecond); stringBuilder.AppendFormat("WaveFormat: {0}\r\n", wf.WaveFormat); stringBuilder.AppendFormat("Length: {0} bytes: {1} \r\n", wf.Length, wf.TotalTime); foreach (RiffChunk chunk in wf.ExtraChunks) { stringBuilder.AppendFormat("Chunk: {0}, length {1}\r\n", chunk.IdentifierAsString, chunk.Length); byte[] data = wf.GetChunkData(chunk); DescribeChunk(chunk, stringBuilder, data); } } return(stringBuilder.ToString()); }
/// <summary> /// Checks if the cue and list chunks exist and if so, creates a cue list /// </summary> internal static CueList FromChunks(WaveFileReader reader) { CueList cueList = null; byte[] cueChunkData = null; byte[] listChunkData = null; foreach (RiffChunk chunk in reader.ExtraChunks) { if (chunk.IdentifierAsString.ToLower() == "cue ") { cueChunkData = reader.GetChunkData(chunk); } else if (chunk.IdentifierAsString.ToLower() == "list") { listChunkData = reader.GetChunkData(chunk); } } if (cueChunkData != null && listChunkData != null) { cueList = new CueList(cueChunkData, listChunkData); } return cueList; }