Split multi-channel WAV files into single channel WAV files.
Перейти к файлу
Wiesław Šoltés e27d58ecb0 Updated readme 2016-09-03 11:57:06 +02:00
src Updated project structure 2016-09-03 11:54:45 +02:00
wav Renamed folder 2016-09-03 11:47:13 +02:00
.gitattributes Initial commit 2012-11-12 20:16:11 +01:00
.gitignore Initial commit 2012-11-12 20:16:11 +01:00
LICENSE.TXT Updated project structure 2016-09-03 11:54:45 +02:00
README.md Updated readme 2016-09-03 11:57:06 +02:00
Reference.txt Moved Reference file 2016-09-03 11:23:06 +02:00
SimpleWavSplitter.sln Updated project structure 2016-09-03 11:54:45 +02:00

README.md

SimpleWavSplitter

Split multi-channel WAV files into single channel WAV files.

Examples

Split Wav Files

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WavFile;

class Program
{
    static void Main(string[] args)
    {
        string fileName = string.Empty;
        string outputPath = string.Empty;

        if (args.Count() == 1)
        {
            fileName = args[0];
            outputPath = fileName.Remove(fileName.Length - System.IO.Path.GetFileName(fileName).Length);
        }
        else if (args.Count() == 2)
        {
            fileName = args[0];
            outputPath = args[1];
        }
        else
        {
            System.Console.WriteLine("SimpleWavSplitter.Console");
            System.Console.WriteLine("");
            System.Console.WriteLine("Usage:");
            System.Console.WriteLine("SimpleWavSplitter.Console <*.wav> [<OutputPath>]");
            System.Environment.Exit(-1);
        }

        long bytesTotal = 0;
        var splitter = new WavFileSplitter(new SplitProgress());
        var sw = System.Diagnostics.Stopwatch.StartNew();

        try
        {
            bytesTotal = splitter.SplitWavFile(fileName, outputPath, System.Threading.CancellationToken.None);
        }
        catch (Exception ex)
        {
            System.Console.WriteLine("Error: {0}", ex.Message);
            System.Environment.Exit(-1);
        }

        System.Console.WriteLine("");
        sw.Stop();
        string stat1 = string.Format("Data bytes processed: {0} ({1} MB)", bytesTotal, Math.Round((double)bytesTotal / (1024 * 1024), 1));
        System.Console.WriteLine(stat1);
        string stat2 = string.Format("Elapsed time: {0}", sw.Elapsed);
        System.Console.WriteLine(stat2);
        System.Environment.Exit(0);
    }
}
using System;
using WavFile;

public class SplitProgress : IProgress
{
    public void Update(double value)
    {
        string text = string.Format("\rProgress: {0:0.0}%", value);
        System.Console.Write(text);
    }
}

Get Wav Header

string fileName = "test.wav";
using (System.IO.FileStream f = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
    var h = WavFileInfo.ReadFileHeader(f);
    string text = string.Format("FileName:\t\t{0}\nFileSize:\t\t{1}\n{2}", 
        System.IO.Path.GetFileName(fileName),
        f.Length.ToString(),
        h.ToString());
    System.Console.Write(text);
}

License

SimpleWavSplitter is licensed under the MIT license.