} // ----------------------------------------- /// <summary> /// Compress a CD to output folder /// </summary> /// <param name="_Input">Input file, must be `.cue`</param> /// <param name="_Output">Output folder, If null, it will be same as input file folder</param> /// <param name="_Audio">Audio Quality to encode the audio tracks with.</param> /// <param name="_Cover">Cover Image to store in the archive</param> /// <param name="_Title">Title of the CD</param> /// <param name="onComplete">Completed (completeStatus,CrushedSize)</param> /// <returns></returns> public static bool startJob_CrushCD(string _Input, string _Output, Tuple <int, int> _Audio, string _Cover, string _Title, int compressionLevel, Action <bool, int, CueReader> onComplete) { if (LOCKED) { ERROR = "Engine is working"; return(false); } if (!FFMPEG_OK) { ERROR = "FFmpeg is not set"; return(false); } LOCKED = true; // Set the running parameters for the Crush (compress) job var par = new CrushParams { inputFile = _Input, outputDir = _Output, audioQuality = _Audio, cover = _Cover, cdTitle = _Title, compressionLevel = compressionLevel, expectedTracks = HACK_CD_TRACKS }; // Create the job and set it up var j = new JobCrush(par); j.MAX_CONCURRENT = MAX_TASKS; j.onComplete = (s) => { LOCKED = false; ERROR = j.ERROR[1]; // Note: job.jobData is a general use object that was set up in the job // I can read it and get things that I want from it if (s) { onComplete(s, j.jobData.crushedSize, j.jobData.cd); // Hack, send CDINFO and SIZE as well } else { onComplete(s, 0, null); } }; j.onJobStatus = jobStatusHandler; // For status and progress updates j.start(); return(true); } // -----------------------------------------
} // ----------------------------------------- /// <summary> /// Compress a CD to output folder /// </summary> /// <param name="_Input">Input file, must be `.cue`</param> /// <param name="_Output">Output folder, If null, it will be same as input file folder</param> /// <param name="_Audio">Audio Quality to encode the audio tracks with.</param> /// <param name="_Cover">Cover Image to store in the archive</param> /// <param name="_Title">Title of the CD</param> /// <param name="onComplete">Completed (completeStatus,MD5,CrushedSize)</param> /// <returns></returns> public static bool crushCD(string _Input, string _Output, int _Audio, string _Cover, string _Title, Action <bool, string, int> onComplete) { // NOTE : JOB checks for input file if (LOCKED) { ERROR = "Engine is working"; return(false); } if (!FFMPEG_OK) { ERROR = "FFmpeg is not set"; return(false); } LOCKED = true; var par = new CrushParams(); par.inputFile = _Input; par.outputDir = _Output; par.audioQuality = _Audio; par.cover = _Cover; par.cdTitle = _Title; var j = new JobCrush(par); j.MAX_CONCURRENT = MAX_TASKS; j.onComplete = (s) => { LOCKED = false; ERROR = j.ERROR[1]; if (s) { CueReader cd = (CueReader)j.jobData.cd; onComplete(s, cd.getFirstDataTrackMD5(), j.jobData.crushedSize); // Hack, send CDINFO and SIZE as well } else { onComplete(s, "", 0); } }; j.onJobStatus = jobStatusHandler; // For status and progress updates j.start(); return(true); } // -----------------------------------------
} // ----------------------------------------- /// <summary> /// Starts either a CRUSH or CONVERT Job /// - Crush will encode all tracks and then create a .CRUSHED archive that can be restored lates /// - Convert will just encode all audio tracks and create new .CUE/.BIN/.ENCODED AUDIO FILES /// - [CONVERT] can create files in a folder or inside an Archive /// /// </summary> /// <param name="_Mode">0:Crush, 1:Convert, 2:Convert + ARCHIVE</param> /// <param name="_Input">Must be a valid CUE file </param> /// <param name="_Output">Output Directory - IF EMPTY will be same dir as INPUT</param> /// <param name="_Audio">Audio Settings TUPLE. Check `AudioMaster`</param> /// <param name="_ArchSet">Archive Settings Index. Check `ArchiveMaster` -1 for no archive</param> /// <param name="_Title">Name of the CD</param> /// <param name="_Cover">Path of Cover Image to store in the archive - CAN BE EMPTY</param> /// <param name="onComplete">Complete Calback (completeStatus,jobData object)</param> /// <returns>Preliminary Success</returns> public static bool startJob_Convert_Crush( int _Mode, string _Input, string _Output, Tuple <string, int> _Audio, int _ArchSet, string _Title, string _Cover, Action <bool, CrushParams> onComplete) { if (LOCKED) { ERROR = "Engine is working"; return(false); } if (!FFMPEG_OK) { ERROR = "FFmpeg is not set"; return(false); } LOCKED = true; // Set the running parameters for the job var par = new CrushParams { inputFile = _Input, outputDir = _Output, audioQuality = _Audio, cover = _Cover, cdTitle = _Title, archiveSettingsInd = _ArchSet, expectedTracks = HACK_CD_TRACKS, mode = _Mode }; var job = new JobCrush(par); job.MAX_CONCURRENT = MAX_TASKS; job.onJobStatus = jobStatusHandler; // For status and progress updates, FORM sets this. job.onComplete = (s) => { LOCKED = false; ERROR = job.ERROR[1]; onComplete(s, job.jobData); }; job.start(); return(true); }