Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active March 22, 2021 12:57
Show Gist options
  • Save GroupDocsGists/da2d3e1b0d6c1d2724d2057eddacd7c7 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/da2d3e1b0d6c1d2724d2057eddacd7c7 to your computer and use it in GitHub Desktop.
Extract Metadata and RIFF INFO of WAV files in C#
// Extract Metadata of WAV files in C#
using (Metadata metadata = new Metadata("audio.wav"))
{
var root = metadata.GetRootPackage<WavRootPackage>();
Console.WriteLine("Bits per Sample: " + root.WavPackage.BitsPerSample); // Bits per Sample
Console.WriteLine("Block Align: " + root.WavPackage.BlockAlign); // Block Align
Console.WriteLine("Byte Rate: " + root.WavPackage.ByteRate); // Byte Rate
Console.WriteLine("Number of Channels: " + root.WavPackage.NumberOfChannels); // Number of Channels
Console.WriteLine("Audio Format: " + root.WavPackage.AudioFormat); // Audio Format
Console.WriteLine("Sample Rate: " + root.WavPackage.SampleRate); // Sample Rate
}
// Extract RIFF INFO of WAV files in C#
using (Metadata metadata = new Metadata("audio.wav"))
{
var root = metadata.GetRootPackage<WavRootPackage>();
Console.WriteLine("Artist: " + root.RiffInfoPackage.Artist); // Artist
Console.WriteLine("Comment: " + root.RiffInfoPackage.Comment); // Comment
Console.WriteLine("Copyright: " + root.RiffInfoPackage.Copyright); // Copyright
Console.WriteLine("CreationDate: " + root.RiffInfoPackage.CreationDate); // Creation Date
Console.WriteLine("Software: " + root.RiffInfoPackage.Software); // Software
Console.WriteLine("Engineer: " + root.RiffInfoPackage.Engineer); // Engineer
Console.WriteLine("Genre: " + root.RiffInfoPackage.Genre); // Genre
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment