2016-09-03 12:06:12 +03:00
|
|
|
# SimpleWavSplitter
|
2015-03-28 15:13:26 +03:00
|
|
|
|
|
|
|
Split multi-channel WAV files into single channel WAV files.
|
|
|
|
|
2016-09-03 12:06:12 +03:00
|
|
|
* To run program please install .NET Framework Version 4.5
|
|
|
|
* To build program use Microsoft Visual C# 2015.
|
2015-03-28 15:13:26 +03:00
|
|
|
* Download are available at: https://github.com/wieslawsoltes/SimpleWavSplitter
|
|
|
|
|
2016-09-02 13:54:55 +03:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
### Split Wav Files
|
|
|
|
|
|
|
|
```C#
|
|
|
|
using System;
|
2016-09-03 15:13:51 +03:00
|
|
|
using System.Diagnostics;
|
|
|
|
using System.IO;
|
2016-09-02 13:54:55 +03:00
|
|
|
using System.Linq;
|
2016-09-03 15:13:51 +03:00
|
|
|
using System.Reflection;
|
|
|
|
using System.Threading;
|
2016-09-02 13:54:55 +03:00
|
|
|
using WavFile;
|
2016-09-03 15:13:51 +03:00
|
|
|
using static System.Console;
|
|
|
|
using static System.Math;
|
2016-09-02 13:54:55 +03:00
|
|
|
|
2016-09-03 15:13:51 +03:00
|
|
|
namespace SimpleWavSplitter.Console
|
2016-09-02 13:54:55 +03:00
|
|
|
{
|
2016-09-03 15:13:51 +03:00
|
|
|
class Program
|
2016-09-02 13:54:55 +03:00
|
|
|
{
|
2016-09-03 15:13:51 +03:00
|
|
|
static void Main(string[] args)
|
2016-09-02 13:54:55 +03:00
|
|
|
{
|
2016-09-03 15:13:51 +03:00
|
|
|
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;
|
|
|
|
var title = string.Format("SimpleWavSplitterConsole v{0}.{1}.{2}", v.Major, v.Minor, v.Build);
|
|
|
|
WriteLine(title);
|
|
|
|
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);
|
|
|
|
}
|
2016-09-02 13:54:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Get Wav Header
|
|
|
|
|
|
|
|
```C#
|
2016-09-03 15:13:51 +03:00
|
|
|
using System.IO;
|
|
|
|
using static System.Console;
|
|
|
|
|
2016-09-02 13:54:55 +03:00
|
|
|
string fileName = "test.wav";
|
2016-09-03 15:13:51 +03:00
|
|
|
|
|
|
|
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
|
2016-09-02 13:54:55 +03:00
|
|
|
{
|
|
|
|
var h = WavFileInfo.ReadFileHeader(f);
|
2016-09-03 15:13:51 +03:00
|
|
|
Write(string.Format(
|
|
|
|
"FileName:\t\t{0}\nFileSize:\t\t{1}\n{2}",
|
|
|
|
Path.GetFileName(fileName),
|
|
|
|
f.Length.ToString(),
|
|
|
|
h.ToString()));
|
2016-09-02 13:54:55 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2015-03-28 15:13:26 +03:00
|
|
|
## License
|
|
|
|
|
|
|
|
SimpleWavSplitter is licensed under the [MIT license](LICENSE.TXT).
|