Split multi-channel WAV files into single channel WAV files.
Перейти к файлу
Wiesław Šoltés 9215ddd2c2 Update to 11.0.0-preview1 2022-08-21 20:40:20 +02:00
.github Add web version 2022-02-06 22:19:21 +01:00
.nuke Update to .NET 6 2021-11-08 23:18:46 +01:00
build Update to 11.0.0-preview1 2022-08-21 20:40:20 +02:00
src Update to 11.0.0-preview1 2022-08-21 20:40:20 +02:00
tests/WavFile.UnitTests Update to .NET 6 2021-11-08 23:18:46 +01:00
wav Renamed folder 2016-09-03 11:47:13 +02:00
.editorconfig Update .editorconfig 2021-07-18 14:16:53 +02:00
.gitattributes Updated gitattributes and gitignore 2017-11-14 18:39:52 +01:00
.gitignore Updated gitattributes and gitignore 2017-11-14 18:39:52 +01:00
LICENSE.TXT Update LICENSE.TXT 2021-02-17 08:17:50 +01:00
NuGet.Config Update NuGet.Config 2020-11-23 15:45:34 +01:00
README.md Update README.md 2021-10-17 22:16:12 +02:00
Reference.txt Added cake build system 2016-09-03 15:04:50 +02:00
SimpleWavSplitter.sln Update to 11.0.0-preview1 2022-08-21 20:40:20 +02:00
_config.yml Set theme jekyll-theme-cayman 2017-05-16 15:01:32 +02:00
azure-pipelines.yml Update azure-pipelines.yml 2022-02-05 23:33:17 +01:00
build.cmd Update to .NET 6 2021-11-08 23:18:46 +01:00
build.ps1 Update to .NET 6 2021-11-08 23:18:46 +01:00
build.sh Update to .NET 6 2021-11-08 23:18:46 +01:00
global.json Update to .NET 6 2021-11-08 23:18:46 +01:00

README.md

SimpleWavSplitter

Gitter

Build Status CI

NuGet NuGet MyGet

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

NuGet

SimpleWavSplitter is delivered as a NuGet package.

You can find the package on NuGet or by using nightly build feed:

  • Add https://www.myget.org/F/simplewavsplitter-nightly/api/v2 to your package sources
  • Alternative nightly build feed https://pkgs.dev.azure.com/wieslawsoltes/GitHub/_packaging/Nightly/nuget/v3/index.json
  • Update your package using WavFile feed

You can install the package like this:

Install-Package WavFile -Pre

Resources

Using SimpleWavSplitter

Please check first the sample apps and the helper class.

  • SimpleWavSplitter.Console
  • SimpleWavSplitter.Avalonia

Split Wav Files

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using WavFile;
using static System.Console;
using static System.Math;

namespace SimpleWavSplitter.Console
{
    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 - Path.GetFileName(fileName).Length);
            }
            else if (args.Count() == 2)
            {
                fileName = args[0];
                outputPath = args[1];
            }
            else
            {
                var v = Assembly.GetExecutingAssembly().GetName().Version;
                WriteLine(
                    string.Format(
                        "SimpleWavSplitterConsole v{0}.{1}.{2}", 
                        v.Major, v.Minor, v.Build));
                Write(Environment.NewLine);
                WriteLine("Usage:");
                WriteLine("SimpleWavSplitter.Console <file.wav> [<OutputPath>]");
                Environment.Exit(-1);
            }

            try
            {
                long bytesTotal = 0;
                var splitter = new WavFileSplitter(
                    value => Write(string.Format("\rProgress: {0:0.0}%", value)));
                var sw = Stopwatch.StartNew();
                bytesTotal = splitter.SplitWavFile(fileName, outputPath, CancellationToken.None);
                sw.Stop();
                Write(Environment.NewLine);
                WriteLine(
                    string.Format(
                        "Data bytes processed: {0} ({1} MB)", 
                        bytesTotal, Round((double)bytesTotal / (1024 * 1024), 1)));
                WriteLine(string.Format("Elapsed time: {0}", sw.Elapsed));
                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                WriteLine(ex.Message);
                WriteLine(ex.StackTrace);
                Environment.Exit(-1);
            }
        }
    }
}

Get Wav Header

using System.IO;
using static System.Console;

string fileName = "test.wav";

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

License

SimpleWavSplitter is licensed under the MIT license.