Beispiel #1
0
        public CueBin DumpCueBin(string baseName, CueBinPrefs prefs)
        {
            if (Structure.Sessions.Count > 1)
                throw new NotSupportedException("can't dump cue+bin with more than 1 session yet");

            CueBin ret = new CueBin();
            ret.baseName = baseName;
            ret.disc = this;

            if (!prefs.OneBlobPerTrack)
            {
                //this is the preferred mode of dumping things. we will always write full sectors.
                string cue = new CUE_Format().GenerateCUE_OneBin(Structure,prefs);
                var bfd = new CueBin.BinFileDescriptor {name = baseName + ".bin"};
                ret.cue = string.Format("FILE \"{0}\" BINARY\n", bfd.name) + cue;
                ret.bins.Add(bfd);
                bfd.SectorSize = 2352;

                //skip the mandatory track 1 pregap! cue+bin files do not contain it
                for (int i = 150; i < Structure.LengthInSectors; i++)
                {
                    bfd.abas.Add(i);
                    bfd.aba_zeros.Add(false);
                }
            }
            else
            {
                //we build our own cue here (unlike above) because we need to build the cue and the output data at the same time
                StringBuilder sbCue = new StringBuilder();

                for (int i = 0; i < Structure.Sessions[0].Tracks.Count; i++)
                {
                    var track = Structure.Sessions[0].Tracks[i];
                    var bfd = new CueBin.BinFileDescriptor
                        {
                            name = baseName + string.Format(" (Track {0:D2}).bin", track.Number),
                            SectorSize = Cue.BINSectorSizeForTrackType(track.TrackType)
                        };
                    ret.bins.Add(bfd);
                    int aba = 0;

                    //skip the mandatory track 1 pregap! cue+bin files do not contain it
                    if (i == 0) aba = 150;

                    for (; aba < track.LengthInSectors; aba++)
                    {
                        int thisaba = track.Indexes[0].aba + aba;
                        bfd.abas.Add(thisaba);
                        bfd.aba_zeros.Add(false);
                    }
                    sbCue.AppendFormat("FILE \"{0}\" BINARY\n", bfd.name);

                    sbCue.AppendFormat("  TRACK {0:D2} {1}\n", track.Number, Cue.TrackTypeStringForTrackType(track.TrackType));
                    foreach (var index in track.Indexes)
                    {
                        int x = index.aba - track.Indexes[0].aba;
                        if (index.Number == 0 && index.aba == track.Indexes[1].aba)
                        {
                            //dont emit index 0 when it is the same as index 1, it is illegal for some reason
                        }
                        //else if (i==0 && index.num == 0)
                        //{
                        //    //don't generate the first index, it is illogical
                        //}
                        else
                        {
                            //track 1 included the lead-in at the beginning of it. sneak past that.
                            //if (i == 0) x -= 150;
                            sbCue.AppendFormat("    INDEX {0:D2} {1}\n", index.Number, new Timestamp(x).Value);
                        }
                    }
                }

                ret.cue = sbCue.ToString();
            }

            return ret;
        }
Beispiel #2
0
        public CueBin DumpCueBin(string baseName, CueBinPrefs prefs)
        {
            if (Structure.Sessions.Count > 1)
            {
                throw new NotSupportedException("can't dump cue+bin with more than 1 session yet");
            }

            CueBin ret = new CueBin();

            ret.baseName = baseName;
            ret.disc     = this;

            if (!prefs.OneBlobPerTrack)
            {
                //this is the preferred mode of dumping things. we will always write full sectors.
                string cue = new CUE_Format().GenerateCUE_OneBin(Structure, prefs);
                var    bfd = new CueBin.BinFileDescriptor {
                    name = baseName + ".bin"
                };
                ret.cue = string.Format("FILE \"{0}\" BINARY\n", bfd.name) + cue;
                ret.bins.Add(bfd);
                bfd.SectorSize = 2352;

                //skip the mandatory track 1 pregap! cue+bin files do not contain it
                for (int i = 150; i < Structure.LengthInSectors; i++)
                {
                    bfd.abas.Add(i);
                    bfd.aba_zeros.Add(false);
                }
            }
            else
            {
                //we build our own cue here (unlike above) because we need to build the cue and the output data at the same time
                StringBuilder sbCue = new StringBuilder();

                for (int i = 0; i < Structure.Sessions[0].Tracks.Count; i++)
                {
                    var track = Structure.Sessions[0].Tracks[i];
                    var bfd   = new CueBin.BinFileDescriptor
                    {
                        name       = baseName + string.Format(" (Track {0:D2}).bin", track.Number),
                        SectorSize = Cue.BINSectorSizeForTrackType(track.TrackType)
                    };
                    ret.bins.Add(bfd);
                    int aba = 0;

                    //skip the mandatory track 1 pregap! cue+bin files do not contain it
                    if (i == 0)
                    {
                        aba = 150;
                    }

                    for (; aba < track.LengthInSectors; aba++)
                    {
                        int thisaba = track.Indexes[0].aba + aba;
                        bfd.abas.Add(thisaba);
                        bfd.aba_zeros.Add(false);
                    }
                    sbCue.AppendFormat("FILE \"{0}\" BINARY\n", bfd.name);

                    sbCue.AppendFormat("  TRACK {0:D2} {1}\n", track.Number, Cue.TrackTypeStringForTrackType(track.TrackType));
                    foreach (var index in track.Indexes)
                    {
                        int x = index.aba - track.Indexes[0].aba;
                        if (index.Number == 0 && index.aba == track.Indexes[1].aba)
                        {
                            //dont emit index 0 when it is the same as index 1, it is illegal for some reason
                        }
                        //else if (i==0 && index.num == 0)
                        //{
                        //    //don't generate the first index, it is illogical
                        //}
                        else
                        {
                            //track 1 included the lead-in at the beginning of it. sneak past that.
                            //if (i == 0) x -= 150;
                            sbCue.AppendFormat("    INDEX {0:D2} {1}\n", index.Number, new Timestamp(x).Value);
                        }
                    }
                }

                ret.cue = sbCue.ToString();
            }

            return(ret);
        }