private void RemoveTempFiles() { foreach (var tmpFile in tempFiles) { if (File.Exists(tmpFile)) { File.Delete(tmpFile); XMusicLogger.AddLog($"Deleting Temporary File - {tmpFile} ...."); } } }
public void ProcessSingleTempoJob(string sourceFileName, float?tempo = null, float?pitch = null) { TempoDelta = tempo; PitchDelta = pitch; XMusicLogger.Init(); GenerateWorkFlow(sourceFileName); using (xConverter = new XConverter()) using (xTempoProcessor = new XTempoProcessor()) { Process(); } RemoveTempFiles(); XMusicLogger.AddLog($"Finished !!"); }
public XJobResult Convert(string srcPath, XFileType dst) { var res = new XJobResult(); XConvertJob p = new XConvertJob(); p.ISourceFileType = srcPath.RetrieveExtension(); p.AlternativeOutputPath = srcPath.GenerateGuidPath(dst); p.DestinationFileType = dst; p.SourceFileName = srcPath; res.EndTime = DateTime.Now; Convert(p); XMusicLogger.AddLog($"{DateTime.Now} : Converting {srcPath} to {p.AlternativeOutputPath}"); res.OutputData = File.ReadAllBytes(p.AlternativeOutputPath); File.Delete(p.AlternativeOutputPath); res.TempFileName = p.AlternativeOutputPath; return(res); }
private void Log(MusicService job) { string msg = string.Empty; if (job.Action == XActionType.Convertion) { msg = $"Converting { job.SourceFileType.ToString()} To { job.DestinationFileType.ToString() }"; } if (job.Action == XActionType.TempoAdjustment) { msg = $"Processing Tempo Adjustment ...."; } if (totalFiles > 1) { msg = $"Processing ({currentFileIndex}) Out Of ({totalFiles}) : {msg}"; } XMusicLogger.AddLog(msg); }
public void ProcessDirectoryTempoJob(string dir, float?tempo = null, float?pitch = null) { var allFiles = Directory.GetFiles(dir); totalFiles = allFiles.Count(); foreach (var file in allFiles) { try { currentFileIndex++; ProcessSingleTempoJob(file, tempo, pitch); } catch (Exception ex) { var trace = ex.StackTrace; XMusicLogger.AddLog(ex.Message); XMusicLogger.AddLog(trace); RemoveTempFiles(); throw ex; } } }