SimpleWavSplitter/README.md

149 строки
5.5 KiB
Markdown
Исходник Обычный вид История

2016-09-03 12:06:12 +03:00
# SimpleWavSplitter
2016-09-03 16:04:50 +03:00
[![Gitter](https://badges.gitter.im/wieslawsoltes/SimpleWavSplitter.svg)](https://gitter.im/wieslawsoltes/SimpleWavSplitter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
2018-12-12 01:28:16 +03:00
[![Build status](https://dev.azure.com/wieslawsoltes/GitHub/_apis/build/status/Sources/SimpleWavSplitter)](https://dev.azure.com/wieslawsoltes/GitHub/_build/latest?definitionId=60)
2016-09-03 16:04:50 +03:00
[![NuGet](https://img.shields.io/nuget/v/WavFile.svg)](https://www.nuget.org/packages/WavFile)
[![MyGet](https://img.shields.io/myget/simplewavsplitter-nightly/vpre/WavFile.svg?label=myget)](https://www.myget.org/gallery/simplewavsplitter-nightly)
Split multi-channel WAV files into single channel WAV files.
2017-05-16 11:21:18 +03:00
* To build program use Microsoft Visual C# 2017.
* Download are available at: https://github.com/wieslawsoltes/SimpleWavSplitter
2017-01-03 19:19:34 +03:00
### Download
2017-01-03 19:18:28 +03:00
| Platforn | Type | Version | Download |
|----------------------------------------|-------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2019-04-04 10:08:02 +03:00
| Windows/Linux/OSX (GUI) | Portable | 0.8.0 | [SimpleWavSplitter.Avalonia-Release-0.8.0.zip](https://github.com/wieslawsoltes/SimpleWavSplitter/releases/download/0.8.0/SimpleWavSplitter.Avalonia-Release-0.8.0.zip) |
| Windows/Linux/OSX (Console) | Portable | 0.8.0 | [SimpleWavSplitter.Console-Release-0.8.0.zip](https://github.com/wieslawsoltes/SimpleWavSplitter/releases/download/0.8.0/SimpleWavSplitter.Console-Release-0.8.0.zip) |
2017-01-03 19:18:28 +03:00
2017-01-03 19:19:34 +03:00
### Mirrors
2017-01-03 19:18:28 +03:00
[![Softpedia Download Mirror](http://www.softpedia.com/_img/softpedia_100_free.png)](http://www.softpedia.com/get/Multimedia/Audio/Audio-Editors-Recorders/SimpleWavSplitter.shtml)
2016-09-03 16:04:50 +03:00
## NuGet
SimpleWavSplitter is delivered as a NuGet package.
You can find the package on [NuGet](https://www.nuget.org/packages/WavFile/) or by using nightly build feed:
* Add `https://www.myget.org/F/simplewavsplitter-nightly/api/v2` to your package sources
* Update your package using `WavFile` feed
You can install the package like this:
`Install-Package WavFile -Pre`
### Package Dependencies
Does not require any external dependencies.
### Package Sources
* https://api.nuget.org/v3/index.json
* https://www.myget.org/F/simplewavsplitter-nightly/api/v2
## Resources
* [GitHub source code repository.](https://github.com/wieslawsoltes/SimpleWavSplitter)
## Using SimpleWavSplitter
2016-09-02 13:54:55 +03:00
2017-10-31 15:34:41 +03:00
Please check first the sample apps and the [helper class](https://github.com/wieslawsoltes/SimpleWavSplitter/blob/master/src/WavFile/SimpleWavFileSplitter.cs).
2017-04-18 19:03:52 +03:00
* SimpleWavSplitter.Console
* SimpleWavSplitter.Avalonia
2016-09-02 13:54:55 +03:00
### 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;
2016-09-04 14:02:08 +03:00
WriteLine(
string.Format(
"SimpleWavSplitterConsole v{0}.{1}.{2}",
v.Major, v.Minor, v.Build));
2016-09-03 15:13:51 +03:00
Write(Environment.NewLine);
WriteLine("Usage:");
WriteLine("SimpleWavSplitter.Console <file.wav> [<OutputPath>]");
Environment.Exit(-1);
}
try
{
long bytesTotal = 0;
2016-09-04 14:02:08 +03:00
var splitter = new WavFileSplitter(
value => Write(string.Format("\rProgress: {0:0.0}%", value)));
2016-09-03 15:13:51 +03:00
var sw = Stopwatch.StartNew();
bytesTotal = splitter.SplitWavFile(fileName, outputPath, CancellationToken.None);
sw.Stop();
Write(Environment.NewLine);
2016-09-04 14:02:08 +03:00
WriteLine(
string.Format(
"Data bytes processed: {0} ({1} MB)",
bytesTotal, Round((double)bytesTotal / (1024 * 1024), 1)));
2016-09-03 15:13:51 +03:00
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
{
2016-09-04 14:00:49 +03:00
var h = WavFileInfo.ReadFileHeader(fs);
Write(
string.Format(
"FileName:\t\t{0}\nFileSize:\t\t{1}\n{2}",
Path.GetFileName(fileName), fs.Length, h));
2016-09-02 13:54:55 +03:00
}
```
## License
SimpleWavSplitter is licensed under the [MIT license](LICENSE.TXT).