Skip to content

This library helps you manipulate Wave files (eg reverse a Wave file).

License

Notifications You must be signed in to change notification settings

DavidKlempfner/WaveFileManipulator

Repository files navigation

WaveFileManipulator is an open source .NET .wav file manipulation library written by David Klempfner

WaveFileManipulator logo

Features

  • Reverse the audio
  • Get the metadata into a handy model
  • Use your own implementations

Metadata

The metadata model includes the following:

  • All canonical/standard .wav file format values
  • Non standard INFO text segments
  • Public constants so you know the start index for sections within the metadata

Metadata example

Info

NuGet Package

Your Own Implementation

Want to try a different array reversing algorithm? You can pass in your own implementation of IReverser into the Manipulator ctor.

Examples

  • Reverse the audio
using System.IO;
using WaveFileManipulator;

class Program
{
    static void Main(string[] args)
    {
        var filePath = @"C:\File.wav";
        var manipulator = new Manipulator(filePath);
        var reversedByteArray = manipulator.Reverse();
        using (FileStream reversedFileStream = new FileStream(@"C:\ReversedFile.wav", FileMode.Create, FileAccess.Write, FileShare.Write))
        {
            reversedFileStream.Write(reversedByteArray, 0, reversedByteArray.Length);
        }
    }
}
  • View the metadata, given a byte array
using WaveFileManipulator;

class Program
{
    static void Main(string[] args)
    {
        byte[] byteArray = GetBytesFromWaveFile();
        var metadata = new Metadata(byteArray);
    }
}
  • View the metadata, given a file path
using WaveFileManipulator;

class Program
{
    static void Main(string[] args)
    {
        var filePath = @"C:\File.wav";
        var manipulator = new Manipulator(filePath);
        var metadata = manipulator.Metadata;        
    }
}
  • Find the start index of a chunk
using WaveFileManipulator;

class Program
{
    static void Main(string[] args)
    {
        var audioFormatStartIndex = AudioFormat.StartIndex;    
    }
}
  • Get the expected value of a section
using WaveFileManipulator;
public class Program
{
    static void Main(string[] args)
    {
        var filePath = @"C:\File.wav";
        var manipulator = new Manipulator(filePath);
        var expectedChunkIdValue = manipulator.Metadata.ChunkId.ExpectedValue; //ChunkId should be "RIFF".        
    }
}
  • Find out if the value of a section is expected
using WaveFileManipulator;
public class Program
{
    static void Main(string[] args)
    {
        var filePath = @"C:\File.wav";
        var manipulator = new Manipulator(filePath);        
        var isChunkIdRiff = manipulator.Metadata.ChunkId.IsValueExpected; 
    }
}

About

This library helps you manipulate Wave files (eg reverse a Wave file).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages