예제 #1
0
        // UNECM - UNECM
        // --
        private void button4_Click(object sender, EventArgs e)
        {
            var app = new EcmTools();

            app.onComplete = (s) =>
            {
                if (!s)
                {
                    LOG.log(app.ERROR);
                }
                else
                {
                    LOG.log("ECM COMPLETE");
                }

                FormTools.invoke(this, () => {
                    this.Enabled = true;
                });
            };

            string file = FormTools.fileLoadDialog("ecm")[0];

            if (file != null)
            {
                app.unecm(file + "1");
                this.Enabled = false;
            }
        }
예제 #2
0
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (RestoreParams)jobData;

            INPUT             = Path.Combine(p.tempDir, track.storedFileName);
            OUTPUT            = Path.Combine(p.tempDir, track.getFilenameRaw());
            track.workingFile = OUTPUT;     // Point to the new file

            // -
            var fileExt = Path.GetExtension(track.storedFileName);

            requirePostSizeFix = AudioMaster.isLossyByExt(fileExt);

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                setupHandlers(ecm);
                ecm.unecm(INPUT);
            }
            else
            {
                // No need to convert back, end the task
                if (p.mode == 2)
                {
                    // Point to correct file
                    track.workingFile = INPUT;
                    complete();
                    return;
                }

                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);

                if (fileExt.ToLower() == ".tak")
                {
                    var tak = new Tak(CDCRUSH.TOOLS_PATH);
                    setupHandlers(tak);

                    tak.decodeToStream(INPUT, (_out) => {
                        ffmp.convertWavStreamToPCM(OUTPUT, (_in) => {
                            _out.CopyTo(_in);
                            _in.Close();
                        });
                    });
                }
                else
                {
                    setupHandlers(ffmp);
                    ffmp.audioToPCM(INPUT, track.workingFile);
                }
            }

            log("Restoring track -" + track.storedFileName);
        }// -----------------------------------------
예제 #3
0
        }        // -----------------------------------------

        private void btn_unecm_Click(object sender, EventArgs e)
        {
            if (SELECTED_FILES == null)
            {
                return;
            }
            var app = new EcmTools(prog.CDCRUSH.TOOLS_PATH);

            app.onComplete = (s) => {
                LOG.log("--ECM Complete :: {0}", s);
            };
            app.onProgress = (p) => {
                LOG.log("--ECM Progress :: {0}", p);
            };
            app.unecm(SELECTED_FILES[0]);
        } // -----------------------------------------
예제 #4
0
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (RestoreParams)jobData;

            log("Restoring track -" + track.storedFileName);

            // --
            crushedTrackPath = Path.Combine(p.tempDir, track.storedFileName);
            // Set the final track pathname now, I need this for later.
            track.workingFile = Path.Combine(p.tempDir, track.getFilenameRaw());

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                ecm.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();
                        if (!checkTrackMD5())
                        {
                            fail(msg: "MD5 checksum is wrong!");
                            return;
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ecm.ERROR);
                    }
                };
                ecm.unecm(crushedTrackPath);
                killExtra = () => ecm.kill();
            }
            else
            {
                if (Path.GetExtension(track.storedFileName) == ".ogg")
                {
                    isOgg = true;
                }
                else
                {
                    isFlac = true;             // must be flac
                }

                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                ffmp.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();                 // Don't need it
                        if (isOgg)
                        {
                            correctPCMSize();
                        }
                        if (isFlac)
                        {
                            if (!checkTrackMD5())
                            {
                                fail(msg: "MD5 checksum is wrong!");
                                return;
                            }
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ffmp.ERROR);
                    }
                };

                ffmp.audioToPCM(crushedTrackPath);
                killExtra = () => ffmp.kill();
            }
        }// -----------------------------------------
예제 #5
0
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (RestoreParams)jobData;

            // --
            crushedTrackPath = Path.Combine(p.tempDir, track.storedFileName);
            // Set the final track pathname now, I need this for later.
            track.workingFile = Path.Combine(p.tempDir, track.getFilenameRaw());

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                ecm.onComplete = (s) => {
                    ecm.onProgress = handleProgress;
                    if (s)
                    {
                        deleteOldFile();
                        if (!checkTrackMD5())
                        {
                            fail(msg: "MD5 checksum is wrong!");
                            return;
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ecm.ERROR);
                    }
                };
                ecm.unecm(crushedTrackPath);
                killExtra = () => ecm.kill();
            }
            else
            {
                // No need to convert back
                if (p.flag_encCue)
                {
                    // Fix current file
                    track.workingFile = crushedTrackPath;
                    complete();
                    return;
                }

                // --
                isFlac = (Path.GetExtension(track.storedFileName) == ".flac");

                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                ffmp.onProgress = handleProgress;
                ffmp.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();                 // Don't need it
                        if (!isFlac)
                        {
                            // OGG and MP3 don't restore to the exact byte length
                            correctPCMSize();
                        }
                        else
                        {
                            // FLAC restores to exact bytes
                            if (!checkTrackMD5())
                            {
                                fail(msg: "MD5 checksum is wrong!");
                                return;
                            }
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ffmp.ERROR);
                    }
                };

                ffmp.audioToPCM(crushedTrackPath);
                killExtra = () => ffmp.kill();
            }

            log("Restoring track -" + track.storedFileName);
        }// -----------------------------------------
예제 #6
0
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (CrushParams)jobData;

            // Working file is already set and points to either TEMP or INPUT folder
            INPUT = track.workingFile;
            // NOTE: OUTPUT path is generated later with the setupfiles() function

            // Before compressing the tracks, get and store the MD5 of the track
            using (var md5 = System.Security.Cryptography.MD5.Create())
            {
                using (var str = File.OpenRead(INPUT))
                {
                    track.md5 = BitConverter.ToString(md5.ComputeHash(str)).Replace("-", "").ToLower();
                }
            }

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                setupHandlers(ecm);

                // New filename that is going to be generated:
                setupFiles(".bin.ecm");
                ecm.ecm(INPUT, OUTPUT); // old .bin file from wherever it was to temp/bin.ecm
            }
            else                        // AUDIO TRACK :
            {
                // Get Audio Data. (codecID, codecQuality)
                Tuple <string, int> audioQ = p.audioQuality;

                // New filename that is going to be generated:
                setupFiles(AudioMaster.getCodecExt(audioQ.Item1));

                // I need ffmpeg for both occations
                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                setupHandlers(ffmp);

                if (audioQ.Item1 == "TAK")
                {
                    var tak = new Tak(CDCRUSH.TOOLS_PATH);

                    // This will make FFMPEG read the PCM file, convert it to WAV on the fly
                    // and feed it to TAK, which will convert and save it.
                    ffmp.convertPCMStreamToWavStream((ffmpegIn, ffmpegOut) => {
                        var sourceFile = File.OpenRead(INPUT);
                        tak.encodeFromStream(OUTPUT, (takIn) => {
                            ffmpegOut.CopyTo(takIn);
                            takIn.Close();
                        });
                        sourceFile.CopyTo(ffmpegIn);                    // Feed PCM to FFMPEG
                        ffmpegIn.Close();
                    });
                }
                else
                {
                    // It must be FFMPEG
                    ffmp.encodePCM(audioQ.Item1, audioQ.Item2, INPUT, OUTPUT);
                }
            }    //- end if (track.isData)
        }// -----------------------------------------
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (CrushParams)jobData;

            // Working file is already set and points to either TEMP or INPUT folder
            sourceTrackFile = track.workingFile;

            // Before compressing the tracks, get and store the MD5 of the track
            using (var md5 = System.Security.Cryptography.MD5.Create())
            {
                using (var str = File.OpenRead(sourceTrackFile))
                {
                    track.md5 = BitConverter.ToString(md5.ComputeHash(str)).Replace("-", "").ToLower();
                }
            }

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                ecm.onProgress = handleProgress;
                ecm.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();
                        complete();
                    }
                    else
                    {
                        fail(msg: ecm.ERROR);
                    }
                };

                // In case the task ends abruptly
                killExtra = () => ecm.kill();

                // New filename that is going to be generated:
                setupFiles(".bin.ecm");
                ecm.ecm(sourceTrackFile, track.workingFile); // old .bin file from wherever it was to temp/bin.ecm
            }
            else                                             // AUDIO TRACK :
            {
                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                ffmp.onProgress = handleProgress;
                ffmp.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();
                        complete();
                    }
                    else
                    {
                        fail(msg: ffmp.ERROR);
                    }
                };

                // In case the task ends abruptly
                killExtra = () => ffmp.kill();

                // Cast for easy coding
                Tuple <int, int> audioQ = jobData.audioQuality;

                // NOTE: I know this redundant, but it works :
                switch (audioQ.Item1)
                {
                case 0:                 // FLAC
                    setupFiles(".flac");
                    ffmp.audioPCMToFlac(sourceTrackFile, track.workingFile);
                    break;

                case 1:                 // VORBIS
                    setupFiles(".ogg");
                    ffmp.audioPCMToOggVorbis(sourceTrackFile, audioQ.Item2, track.workingFile);
                    break;

                case 2:                 // OPUS
                    setupFiles(".ogg");
                    // Opus needs an actual bitrate, not an index
                    ffmp.audioPCMToOggOpus(sourceTrackFile, FFmpeg.OPUS_QUALITY[audioQ.Item2], track.workingFile);
                    break;

                case 3:                 // MP3
                    setupFiles(".mp3");
                    ffmp.audioPCMToMP3(sourceTrackFile, audioQ.Item2, track.workingFile);
                    break;
                } //- end switch
            }     //- end if (track.isData)
        }// -----------------------------------------
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (CrushParams)jobData;

            // Working file is already set and points to either TEMP or INPUT folder
            trackFile = track.workingFile;

            // Before compressing the tracks, get and store the MD5 of the track
            using (var md5 = System.Security.Cryptography.MD5.Create())
            {
                using (var str = File.OpenRead(trackFile))
                {
                    track.md5 = BitConverter.ToString(md5.ComputeHash(str)).Replace("-", "").ToLower();
                }
            }

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                ecm.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();
                        complete();
                    }
                    else
                    {
                        fail(msg: ecm.ERROR);
                    }
                };

                // In case the task ends abruptly
                killExtra = () => ecm.kill();

                // New filename that is going to be generated:
                track.storedFileName = track.getTrackName() + ".bin.ecm";
                track.workingFile    = Path.Combine(jobData.tempDir, track.storedFileName);
                ecm.ecm(trackFile, track.workingFile); // old .bin file from wherever it was to temp/bin.ecm
            }
            else                                       // AUDIO TRACK :
            {
                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                ffmp.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();
                        complete();
                    }
                    else
                    {
                        fail(msg: ffmp.ERROR);
                    }
                };

                // In case the task ends abruptly
                killExtra = () => ffmp.kill();

                // Cast for easy coding
                Tuple <int, int> audioQ = jobData.audioQuality;

                switch (audioQ.Item1)
                {
                case 0:                 // FLAC
                    track.storedFileName = track.getTrackName() + ".flac";
                    track.workingFile    = Path.Combine(jobData.tempDir, track.storedFileName);
                    ffmp.audioPCMToFlac(trackFile, track.workingFile);
                    break;

                case 1:                 // VORBIS
                    track.storedFileName = track.getTrackName() + ".ogg";
                    track.workingFile    = Path.Combine(jobData.tempDir, track.storedFileName);
                    ffmp.audioPCMToOggVorbis(trackFile, audioQ.Item2, track.workingFile);
                    break;

                case 2:                 // OPUS
                    track.storedFileName = track.getTrackName() + ".ogg";
                    track.workingFile    = Path.Combine(jobData.tempDir, track.storedFileName);
                    ffmp.audioPCMToOggOpus(trackFile, CDCRUSH.OPUS_QUALITY[audioQ.Item2], track.workingFile);
                    break;
                } //- end switch
            }     //- end if (track.isData)
        }// -----------------------------------------