public void ConversionTest(string path, string hash) { songDataFactory = new SongDataFactory(); songDataFactory.ReportProgress += ReportProgress; //Console.WriteLine("ConversionTest...."); //string input = this.TestContext.Properties["resource_path"].ToString() + resourceAttribute.Path; string input = "resources/examples/" + path; RenoiseSong renoiseSong = songDataFactory.ExtractRenoiseSong(input); songData = songDataFactory.ExtractSongData(renoiseSong, input); converter = new ModConverter(input); converter.EventProgress += ReportProgress; settings = new ModSettings(); settings.ForceProTrackerCompatibility = PROTRACKER_COMPATIBILITY_MODE.NONE; settings.NtscMode = true; settings.PortamentoLossThreshold = 2; settings.VolumeScalingMode = VOLUME_SCALING_MODE.SAMPLE; converter.Settings = settings; byte[] bytes = converter.Convert(songData); string hashGen = MD5Utils.GenerateMd5Hash(bytes); //Write file for later investigation string outputFile = input.Remove(input.Length - 5); // default output file, same as input without .xrns extension outputFile = System.Text.RegularExpressions.Regex.Match(outputFile, @"(?:(?!\.(mod|xm)$).)*").Value; string outputFileExt = System.Text.RegularExpressions.Regex.Match(outputFile, @"\.(mod | xm)$").Value; string destType = "mod"; // add extension to output file in case user has not already specified it if (!outputFileExt.Equals("." + destType, StringComparison.CurrentCultureIgnoreCase)) { outputFile += '.' + destType; } Utility.SaveByteArrayToFile(outputFile, bytes); //So is it what we wanted? Assert.AreEqual(hash, hashGen); }
private byte[] ParseModule(FileType fileType, BackgroundWorker worker, DoWorkEventArgs e) { byte[] output = null; IConverter converter = null; switch (fileType) { case FileType.MOD: ModSettings modsettings = Shared.GetModSettingsFromIni(); converter = new ModConverter(inputFilename); converter.EventProgress += converter_ReportProgress; ((ModConverter)converter).Settings = modsettings; output = converter.Convert(songData); break; case FileType.XM: XmSettings xmsettings = Shared.GetXmSettingsFromIni(); converter = new XMConverter(inputFilename); converter.EventProgress += converter_ReportProgress; //converter.EventProgress += converter_ReportProgress; ((XMConverter)converter).Settings = xmsettings; xmsettings.Tempo = (int)numericUpDownTempo.Value; xmsettings.TicksRow = (int)numericUpDownTicks.Value; output = converter.Convert(songData); break; } //if (fileType == FileType.MOD) // output = MainFactory.ConvertToMod(Shared.GetModSettingsFromConfig()); //else //{ // XmSettings xmSettings = Shared.GetXmSettingsFromConfig(); // xmSettings.Tempo = (int)numericUpDownTempo.Value; // xmSettings.TicksRow = (int)numericUpDownTicks.Value; // output = MainFactory.ConvertToXM(xmSettings); //} return(output); }