Exemple #1
0
        public static void MyClassInitialize(TestContext testContext)
        {
            toc = new CDImageLayout(1, 1, 1, string.Format("0 {0}", (finalSampleCount / 588).ToString()));
            ar  = new AccurateRipVerify(toc, null);
            ar2 = new AccurateRipVerify(toc, null);
            ar3 = new AccurateRipVerify(toc, null);

            new Random(2423).NextBytes(wav);
            new Random(2423).NextBytes(wav2);
            Random rnd = new Random(987);

            for (int i = 0; i < stride / 4; i++)
            {
                wav2[(int)(rnd.NextDouble() * (wav2.Length - 1))] = (byte)(rnd.NextDouble() * 255);
            }

            AudioBuffer    buff   = new AudioBuffer(AudioPCMConfig.RedBook, 0);
            CDRepairEncode encode = new CDRepairEncode(ar, stride, npar, false, true);

            buff.Prepare(wav, finalSampleCount);
            ar.Init(toc);
            ar.Write(buff);
            ar.Close();
            parity = encode.Parity;
            crc    = encode.CRC;

            decode = new CDRepairEncode(ar2, stride, npar, true, false);
            buff.Prepare(wav2, finalSampleCount);
            ar2.Init(toc);
            ar2.Write(buff);
            ar2.Close();

            int  actualOffset;
            bool hasErrors;

            decode.FindOffset(npar, parity, 0, crc, out actualOffset, out hasErrors);
            fix = decode.VerifyParity(parity, actualOffset);

            decode2 = new CDRepairEncode(ar3, stride, npar, true, false);
            ar3.Init(toc);
            buff.Prepare(new byte[offset * 4], offset);
            ar3.Write(buff);
            buff.Prepare(wav2, finalSampleCount - offset);
            ar3.Write(buff);
            ar3.Close();
            decode2.FindOffset(npar, parity, 0, crc, out actualOffset, out hasErrors);
            fix2 = decode2.VerifyParity(parity, actualOffset);
        }
        public static CDRepairEncode VerifyNoise(CDImageLayout toc, int seed, int offset, int start, int end, int errors, bool do_verify, bool do_encode)
        {
            if (start < 0 || start > end || end > toc.AudioLength * 588)
            {
                throw new ArgumentOutOfRangeException();
            }
            var src    = new NoiseAndErrorsGenerator(AudioPCMConfig.RedBook, end - start, seed, offset + start, errors);
            var buff   = new AudioBuffer(src, 588 * 100);
            var ar     = new AccurateRipVerify(toc, null);
            var encode = new CDRepairEncode(ar, stride, npar, do_verify, do_encode);
            var rnd    = new Random(seed);

            ar.Position = start;
            while (src.Remaining > 0)
            {
                src.Read(buff, rnd.Next(1, buff.Size));
                ar.Write(buff);
            }
            ar.Close();
            return(encode);
        }