public void computeFile(String path, String filename)
{
// Read a sample noise file
byte[] someBytes = File.ReadAllBytes(path);
short[] someShorts = new short[someBytes.Length / 2];
Buffer.BlockCopy(someBytes, 0, someShorts, 0, someBytes.Length);
double[] noise = IntToDouble(someShorts);
int[] reductionTab = new int[] { 0, 10, 20, 30, 50};
foreach(int i in reductionTab)
{
String tmppath = path;
// Execute;
double[] output = applyNoiseToVoice(timit_raw_L, noise, i);
// Output to file
short[] outShorts = DoubleToShort(output);
byte[] outBytes = new byte[2 * outShorts.Length];
Buffer.BlockCopy(outShorts, 0, outBytes, 0, 2 * outShorts.Length);
String tmpfilename = filename.Remove(0, 12); // Remove the path from filename
tmpfilename = tmpfilename.Remove(tmpfilename.Length - 3, 3);
tmpfilename += "raw";
tmppath = tmppath.Remove(tmppath.Length - 4, 4);
tmppath = tmppath.Remove(0, 3);
tmppath = String.Concat(@"E:\EvalNoise\", tmppath);
tmppath = String.Concat(tmppath, String.Concat("_", i.ToString(), @"db\"));
String file_fullpath = String.Concat(tmppath, tmpfilename);
Console.WriteLine(tmppath);
if (!Directory.Exists(tmppath))
{
Directory.CreateDirectory(tmppath);
}
File.WriteAllBytes(file_fullpath, outBytes);
}
}