public static SoundInput FindFormat(Stream file) { uint signature = FormatCatalog.ReadSignature(file); for (;;) { var range = FormatCatalog.Instance.LookupSignature <AudioFormat> (signature); foreach (var impl in range) { try { file.Position = 0; SoundInput sound = impl.TryOpen(file); if (null != sound) { return(sound); } } catch (System.Exception X) { FormatCatalog.Instance.LastError = X; } } if (0 == signature) { break; } signature = 0; } return(null); }
public override void Write(SoundInput source, Stream output) { using (var buffer = new BinaryWriter(output, Encoding.ASCII, true)) { uint total_size = (uint)(0x2e - 8 + source.PcmSize); buffer.Write(Signature); buffer.Write(total_size); buffer.Write(0x45564157); // 'WAVE' buffer.Write(0x20746d66); // 'fmt ' buffer.Write(0x12); buffer.Write(source.Format.FormatTag); buffer.Write(source.Format.Channels); buffer.Write(source.Format.SamplesPerSecond); buffer.Write(source.Format.AverageBytesPerSecond); buffer.Write(source.Format.BlockAlign); buffer.Write(source.Format.BitsPerSample); buffer.Write((ushort)0); buffer.Write(0x61746164); // 'data' buffer.Write((uint)source.PcmSize); source.Position = 0; source.CopyTo(output); } }
public static SoundInput Read(IBinaryStream file) { foreach (var impl in FormatCatalog.Instance.FindFormats <AudioFormat> (file.Name, file.Signature)) { try { file.Position = 0; SoundInput sound = impl.TryOpen(file); if (null != sound) { return(sound); } } catch (OperationCanceledException) { throw; } catch (System.Exception X) { FormatCatalog.Instance.LastError = X; } } return(null); }
public override void Write(SoundInput source, Stream output) { WriteRiffHeader(output, source.Format, (uint)source.PcmSize); source.Position = 0; source.CopyTo(output); }
public virtual void Write(SoundInput source, Stream output) { throw new System.NotImplementedException("AudioFormat.Write not implemenented"); }