-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·49 lines (35 loc) · 1.13 KB
/
Program.cs
File metadata and controls
executable file
·49 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.IO;
using GroovyCodecs.Mp3;
using GroovyCodecs.WavFile;
namespace GroovyCodecs.Coder
{
class Program
{
private static IMp3Encoder _lameEnc;
static void Main(string[] args)
{
var files =Directory.GetFiles("../testfiles/", "*.wav", SearchOption.AllDirectories);
foreach(var file in files)
{
_lameEnc = new Mp3Encoder();
var audioFile = new WavReader();
audioFile.OpenFile(file);
var srcFormat = audioFile.GetFormat();
_lameEnc.SetFormat(srcFormat, srcFormat);
var inBuffer = audioFile.readWav();
var outBuffer = new byte[inBuffer.Length];
var timer = new System.Diagnostics.Stopwatch();
timer.Start();
var len = _lameEnc.EncodeBuffer(inBuffer, 0, inBuffer.Length, outBuffer);
timer.Stop();
_lameEnc.Close();
// _lameDec = new LameDecoder();
var outFile = File.Create(file + ".mp3");
outFile.Write(outBuffer, 0, len);
outFile.Close();
Console.WriteLine($"Converted {file} to MP3 in {timer.ElapsedMilliseconds / 1000}s");
}
}
}
}