Exemple #1
0
        private bool FixBassTuning()
        {
            // fix old toolkit behavior
            if (Arrangement.TuningStrings == null)
            {
                Arrangement.TuningStrings = new TuningStrings { String0 = 0, String1 = 0, String2 = 0, String3 = 0, String4 = 0, String5 = 0 };
                return false;
            }

            if (_gameVersion == GameVersion.RS2012)
                return false;

            var bassFix = false;
            //Low tuning fix for bass, If lowest string is B and bass fix not applied 
            if (Arrangement.TuningStrings.String0 < -4 && Arrangement.TuningPitch != 220.00)
                if (_fixLowBass)
                    bassFix = true;
                else
                    bassFix |= MessageBox.Show(@"The bass tuning may be too low.  Apply Low Bass Tuning Fix?" + Environment.NewLine + @"Note: The fix may revert if bass Arrangement is re-saved in EOF.  ", @"Warning ... Low Bass Tuning", MessageBoxButtons.YesNo) == DialogResult.Yes;

            // Fix Low Bass Tuning
            if (bassFix && TuningFrequency.ApplyBassFix(Arrangement, _fixLowBass))
            {
                Arrangement.TuningStrings = Song2014.LoadFromFile(Arrangement.SongXml.File).Tuning;
                Arrangement.TuningPitch = 220.00;
                txtFrequency.Text = "220.00";

                return true;
            }

            return false;
        }
Exemple #2
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a DVB cable frequency.
 /// </summary>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(CableFrequency frequency)
 {
     this.frequency = frequency;
     symbolRate     = frequency.SymbolRate;
     fec            = frequency.FEC;
     modulation     = frequency.Modulation;
 }
        /// <summary>
        /// Initialise a new instance of the SimulationDataProvider class.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="tuningFrequency"></param>
        public SimulationDataProvider(string fileName, TuningFrequency tuningFrequency)
        {
            this.fileName        = fileName;
            this.tuningFrequency = tuningFrequency;

            resourceMutex = new Mutex();
        }
Exemple #4
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a ISDB satellite frequency.
 /// </summary>
 /// <param name="satellite">The satellite to tune to.</param>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(Satellite satellite, ISDBSatelliteFrequency frequency)
 {
     this.frequency     = frequency;
     this.satellite     = satellite;
     symbolRate         = frequency.SymbolRate;
     fec                = frequency.FEC;
     signalPolarization = frequency.Polarization;
 }
Exemple #5
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a Clear QAM frequency.
 /// </summary>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(ClearQamFrequency frequency)
 {
     this.frequency = frequency;
     symbolRate     = frequency.SymbolRate;
     fec            = frequency.FEC;
     modulation     = frequency.Modulation;
     channelNumber  = frequency.ChannelNumber;
 }
Exemple #6
0
        public AttributesHeader2014(string arrangementFileName, Arrangement arrangement, DLCPackageData info, Platform platform)
        {
            IsVocal     = arrangement.ArrangementType == Sng.ArrangementType.Vocal;
            SongContent = (IsVocal) ? null : Song2014.LoadFromFile(arrangement.SongXml.File);
            var dlcName = info.Name.ToLower();

            var albumUrn = String.Format(URN_TEMPLATE, TagValue.Image.GetDescription(), TagValue.DDS.GetDescription(), String.Format("album_{0}", dlcName));
            var jsonUrn  = String.Format(URN_TEMPLATE, TagValue.Database.GetDescription(), TagValue.JsonDB.GetDescription(), String.Format("{0}_{1}", dlcName, arrangementFileName));

            //FILL ATTRIBUTES
            this.AlbumArt              = albumUrn;
            ArrangementName            = arrangement.Name.ToString();
            DLC                        = true;
            DLCKey                     = info.Name;
            LeaderboardChallengeRating = 0;
            ManifestUrn                = jsonUrn;
            MasterID_RDV               = arrangement.MasterId;
            PersistentID               = arrangement.Id.ToString().Replace("-", "").ToUpper();
            Shipping                   = true;
            SKU                        = "RS2";
            SongKey                    = info.Name;

            if (!IsVocal)
            {
                AlbumName      = AlbumNameSort = info.SongInfo.Album;
                ArtistName     = info.SongInfo.Artist;
                CentOffset     = arrangement.TuningPitch != 0 ? TuningFrequency.Frequency2Cents(arrangement.TuningPitch) : 0.0;
                ArtistNameSort = info.SongInfo.ArtistSort;
                CapoFret       = (arrangement.Sng2014.Metadata.CapoFretId == 0xFF) ? CapoFret = 0 : Convert.ToDecimal(arrangement.Sng2014.Metadata.CapoFretId);
                DNA_Chords     = arrangement.Sng2014.DNACount[(int)DNAId.Chord];
                DNA_Riffs      = arrangement.Sng2014.DNACount[(int)DNAId.Riff];
                DNA_Solo       = arrangement.Sng2014.DNACount[(int)DNAId.Solo];
                NotesEasy      = arrangement.Sng2014.NoteCount[0];
                NotesMedium    = arrangement.Sng2014.NoteCount[1];
                NotesHard      = arrangement.Sng2014.NoteCount[2];
                EasyMastery    = NotesEasy / NotesHard;
                MediumMastery  = NotesMedium / NotesHard;
                Representative = Convert.ToInt32(!arrangement.BonusArr);
                RouteMask      = (int)arrangement.RouteMask;

                // TODO this is not quite it but much closer
                SongDiffEasy   = SongContent.SongLength / NotesEasy;
                SongDiffMed    = SongContent.SongLength / NotesMedium;
                SongDiffHard   = SongContent.SongLength / NotesHard;
                SongDifficulty = SongDiffHard;

                SongLength   = (double?)Math.Round(SongContent.SongLength, 3, MidpointRounding.AwayFromZero);
                SongName     = info.SongInfo.SongDisplayName;
                SongNameSort = info.SongInfo.SongDisplayNameSort;
                SongYear     = info.SongInfo.SongYear;

                var tunDef = TuningDefinitionRepository.Instance().Select(arrangement.Tuning, platform.version);
                Tuning = tunDef.Tuning;
            }
        }
        private static bool getStations(TuningFrequency frequency)
        {
            bool tuned = tuneFrequency(frequency);

            if (!tuned)
            {
                return(false);
            }

            FrequencyScanner       frequencyScanner = new FrequencyScanner(graph);
            Collection <TVStation> stations         = frequencyScanner.FindTVStations(frequency);

            if (stations != null)
            {
                Logger.Instance.Write("Found " + stations.Count + " stations on frequency " + frequency);
                int addedCount = 0;

                foreach (TVStation tvStation in stations)
                {
                    TVStation excludedStation = TVStation.FindExcludedStation(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);
                    if (excludedStation == null)
                    {
                        if (tvStation.NextFollowingAvailable && tvStation.ScheduleAvailable)
                        {
                            bool added = TVStation.AddStation(tvStation);
                            if (added)
                            {
                                //allStations.Add(tvStation);
                                addedCount++;
                                Logger.Instance.Write("Included station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                            }
                        }
                        else
                        {
                            Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ") No EPG data");
                        }
                    }
                    else
                    {
                        Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                    }
                }

                Logger.Instance.Write("Added " + addedCount + " stations for frequency " + frequency);
            }
            frequencyScanner = null;
            return(true);
        }
Exemple #8
0
        private void UpdateCentOffset()
        {
            var value = frequencyTB.Text;

            if (!String.IsNullOrEmpty(value))
            {
                double freq    = 440;
                var    isValid = Double.TryParse(value, out freq);
                if (isValid && freq > 0)
                {
                    string noteName;
                    TuningFrequency.Frequency2Note(freq, out noteName);
                    centOffsetDisplay.Text = String.Format("{0:0.00}", TuningFrequency.Frequency2Cents(freq));
                    noteDisplay.Text       = noteName;
                }
            }
        }
        private static bool tuneFrequency(TuningFrequency frequency)
        {
            Logger.Instance.Write("Tuning to frequency " + frequency.Frequency + " on " + frequency.TunerType);

            TuningSpec    tuningSpec;
            TunerNodeType tunerNodeType;
            int           frequencyRetries = 0;

            if (frequency.TunerType == TunerType.Satellite)
            {
                tuningSpec    = new TuningSpec(Satellite.CurrentSatellite, (SatelliteFrequency)frequency);
                tunerNodeType = TunerNodeType.Satellite;
            }
            else if (frequency.TunerType == TunerType.Terrestrial)
            {
                tuningSpec    = new TuningSpec((TerrestrialFrequency)frequency);
                tunerNodeType = TunerNodeType.Terrestrial;
            }
            else
            {
                tuningSpec    = new TuningSpec((CableFrequency)frequency);
                tunerNodeType = TunerNodeType.Cable;
            }


            bool finished = false;

            while (!finished)
            {
                graph = BDAGraph.FindTuner(RunParameters.SelectedTuner, tunerNodeType, tuningSpec);
                if (graph == null)
                {
                    Logger.Instance.Write("Tuner not available");
                    return(false);
                }

                TimeSpan timeout = new TimeSpan();
                bool     done    = false;
                bool     locked  = false;


                if (RunParameters.Options.Contains("NOSIGLOCK"))
                {
                    Logger.Instance.Write("Option NOSIGLOCK: No lock check, wait 5 seconds instead");
                    locked = true;
                    Thread.Sleep(5000);
                }
                else
                {
                    while (!done)
                    {
                        if (cancelGraph)
                        {
                            graph.Dispose();
                            return(false);
                        }

                        locked = graph.SignalLocked;
                        if (!locked)
                        {
                            int signalQuality = graph.SignalQuality;
                            if (signalQuality > 0)
                            {
                                Logger.Instance.Write("Signal not locked but signal quality > 0");
                                locked = true;
                                done   = true;
                            }
                            else
                            {
                                Logger.Instance.Write("Signal not locked and signal quality not > 0");
                                Thread.Sleep(1000);
                                timeout = timeout.Add(new TimeSpan(0, 0, 1));
                                done    = (timeout.TotalSeconds == RunParameters.LockTimeout.TotalSeconds);
                            }
                        }
                        else
                        {
                            done = true;
                        }
                    }
                }

                if (!locked)
                {
                    Logger.Instance.Write("Failed to acquire signal");
                    graph.Dispose();

                    if (frequencyRetries == 1)
                    {
                        return(false);
                    }
                    else
                    {
                        frequencyRetries++;
                        Logger.Instance.Write("Retrying frequency");
                    }
                }
                else
                {
                    finished = true;
                    Logger.Instance.Write("Signal acquired: lock is " + graph.SignalLocked + " quality is " + graph.SignalQuality + " strength is " + graph.SignalStrength);
                }
            }

            return(true);
        }
        private void processServiceDescriptionSection(ServiceDescriptionSection serviceDescriptionSection, Collection <TVStation> tvStations, TuningFrequency frequency)
        {
            foreach (ServiceDescription serviceDescription in serviceDescriptionSection.ServiceDescriptions)
            {
                bool processStation = checkServiceInfo(serviceDescription);

                if (processStation)
                {
                    TVStation tvStation = new TVStation(serviceDescription.ServiceName);
                    tvStation.ProviderName = serviceDescription.ProviderName;
                    if (useActualFrequency)
                    {
                        tvStation.Frequency = NetworkInformationSection.GetFrequency(serviceDescriptionSection.OriginalNetworkID, serviceDescriptionSection.TransportStreamID) * 10;
                        if (tvStation.Frequency == 0)
                        {
                            tvStation.Frequency = frequency.Frequency;
                            Logger.Instance.Write("Station : " + tvStation.Name + " not found in Network Information Table");
                        }
                    }
                    else
                    {
                        tvStation.Frequency = frequency.Frequency;
                    }

                    tvStation.OriginalNetworkID      = serviceDescriptionSection.OriginalNetworkID;
                    tvStation.TransportStreamID      = serviceDescriptionSection.TransportStreamID;
                    tvStation.ServiceID              = serviceDescription.ServiceID;
                    tvStation.Encrypted              = serviceDescription.Scrambled;
                    tvStation.ServiceType            = serviceDescription.ServiceType;
                    tvStation.ScheduleAvailable      = serviceDescription.EITSchedule;
                    tvStation.NextFollowingAvailable = serviceDescription.EITPresentFollowing;

                    tvStation.TunerType = frequency.TunerType;
                    if (frequency.TunerType == TunerType.Satellite)
                    {
                        Satellite satellite = ((SatelliteFrequency)frequency).Provider as Satellite;
                        if (satellite != null)
                        {
                            tvStation.Satellite = satellite;
                        }
                    }

                    if (RunParameters.Instance.Options.Contains("USECHANNELID"))
                    {
                        if (serviceDescription.ChannelNumber != -1)
                        {
                            tvStation.OriginalChannelNumber = serviceDescription.ChannelNumber;
                        }
                    }

                    addStation(tvStations, tvStation);
                }
            }
        }
Exemple #11
0
        public bool LoadXmlArrangement(string xmlFilePath)
        {
            if (IsAlreadyAdded(xmlFilePath))
            {
                MessageBox.Show(@"XML Arrangement: " + Path.GetFileName(xmlFilePath) + @"   " + Environment.NewLine +
                                @"has already been added.  Please choose a new file. ",
                                DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            try
            {
                bool isVocal     = false;
                bool isShowlight = false;
                try
                {
                    xmlSong = Song2014.LoadFromFile(xmlFilePath);
                    Arrangement.XmlComments = Song2014.ReadXmlComments(xmlFilePath);
                }
                catch (Exception ex)
                {
                    if (ex.InnerException.Message.ToLower().Contains("<vocals"))
                    {
                        isVocal = true;
                    }
                    else if (ex.InnerException.Message.ToLower().Contains("<showlights"))
                    {
                        isShowlight = true;
                    }
                    else
                    {
                        MessageBox.Show(@"Unable to get information from XML arrangement:  " + Environment.NewLine +
                                        Path.GetFileName(xmlFilePath) + Environment.NewLine +
                                        @"It may not be a valid arrangement or " + Environment.NewLine +
                                        @"your version of the EOF may be out of date." + Environment.NewLine +
                                        ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                }

                // SETUP FIELDS
                if (isVocal)
                {
                    arrangementTypeCombo.SelectedItem = ArrangementType.Vocal;
                    _arrangement.ArrangementType      = ArrangementType.Vocal;
                }
                else if (isShowlight)
                {
                    arrangementTypeCombo.SelectedItem = ArrangementType.ShowLight;
                    _arrangement.ArrangementType      = ArrangementType.ShowLight;
                }
                else
                {
                    var version = GameVersion.None;
                    //Detect arrangement GameVersion
                    if (xmlSong != null && xmlSong.Version != null)
                    {
                        var verAttrib = Convert.ToInt32(xmlSong.Version);
                        if (verAttrib <= 6)
                        {
                            version = GameVersion.RS2012;
                        }
                        else if (verAttrib >= 7)
                        {
                            version = GameVersion.RS2014;
                        }
                    }
                    else
                    {
                        switch (currentGameVersion)
                        {
                        case GameVersion.RS2012:
                            // add missing XML elements
                            xmlSong.Version = "4";
                            xmlSong.Tuning  = new TuningStrings {
                                String0 = 0, String1 = 0, String2 = 0, String3 = 0, String4 = 0, String5 = 0
                            };
                            xmlSong.ArrangementProperties = new SongArrangementProperties2014 {
                                StandardTuning = 1
                            };
                            version = GameVersion.RS2012;
                            break;

                        case GameVersion.None:
                            using (var obj = new Rs1Converter())
                            {
                                xmlSong = null;
                                xmlSong = obj.SongToSong2014(Song.LoadFromFile(XmlFilePath.Text));
                            }
                            currentGameVersion = GameVersion.RS2014;
                            break;

                        default:
                            MessageBox.Show("Your version of EOF may be out of date, please update.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            break;
                        }
                    }

                    // TODO: fix error checking logic for new types of conversion
                    if (currentGameVersion != version && version != GameVersion.None)
                    {
                        Debug.WriteLine("Please choose valid Rocksmith {0} arrangement file!", currentGameVersion);
                        //XmlFilePath.Text = "";
                        //return;
                    }

                    // SONG AND ARRANGEMENT INFO / ROUTE MASK
                    BonusCheckBox.Checked = Equals(xmlSong.ArrangementProperties.BonusArr, 1);
                    MetronomeCb.Checked   = Equals(xmlSong.ArrangementProperties.Metronome, 2);
                    if (!EditMode)
                    {
                        string arr = xmlSong.Arrangement.ToLowerInvariant();
                        if (arr.Contains("guitar") || arr.Contains("lead") || arr.Contains("rhythm") || arr.Contains("combo"))
                        {
                            arrangementTypeCombo.SelectedItem = ArrangementType.Guitar;

                            if (arr.Contains("combo"))
                            {
                                arrangementNameCombo.SelectedItem = ArrangementName.Combo;
                                if (currentGameVersion != GameVersion.RS2012)
                                {
                                    RouteMask = RouteMask.Lead;
                                }
                            }
                            else if (arr.Contains("guitar_22") || arr.Contains("lead") || Equals(xmlSong.ArrangementProperties.PathLead, 1))
                            {
                                arrangementNameCombo.SelectedItem = ArrangementName.Lead;
                                if (currentGameVersion != GameVersion.RS2012)
                                {
                                    RouteMask = RouteMask.Lead;
                                }
                            }
                            else if (arr.Contains("guitar") || arr.Contains("rhythm") || Equals(xmlSong.ArrangementProperties.PathRhythm, 1))
                            {
                                arrangementNameCombo.SelectedItem = ArrangementName.Rhythm;
                                if (currentGameVersion != GameVersion.RS2012)
                                {
                                    RouteMask = RouteMask.Rhythm;
                                }
                            }
                        }
                        else if (arr.Contains("bass"))
                        {
                            arrangementTypeCombo.SelectedItem = ArrangementType.Bass;
                            Picked.Checked = Equals(xmlSong.ArrangementProperties.BassPick, 1);

                            if (currentGameVersion != GameVersion.RS2012)
                            {
                                RouteMask = RouteMask.Bass;
                                //Low tuning fix for bass, If lowest string is B and bass fix not applied TODO:applyonly when 'generate'
                                if (xmlSong.Tuning.String0 < -4 && Arrangement.TuningPitch != 220)
                                {
                                    bassFix |= MessageBox.Show(@"The bass tuning may be too low.  Apply Low Bass Tuning Fix?" + Environment.NewLine +
                                                               @"Note: The fix will revert if bass arrangement is re-saved in EOF.  ",
                                                               @"Warning ... Low Bass Tuning", MessageBoxButtons.YesNo) == DialogResult.Yes;
                                }
                            }
                        }
                    }

                    if (currentGameVersion != GameVersion.RS2012)
                    {
                        //Tones setup //TODO: add parsing tones events
                        Arrangement.ToneBase        = xmlSong.ToneBase;
                        Arrangement.ToneA           = xmlSong.ToneA;
                        Arrangement.ToneB           = xmlSong.ToneB;
                        Arrangement.ToneC           = xmlSong.ToneC;
                        Arrangement.ToneD           = xmlSong.ToneD;
                        Arrangement.ToneMultiplayer = null;
                        SetupTones(Arrangement);

                        // Fix Low Bass Tuning
                        if (bassFix)
                        {
                            bassFix = false;
                            Arrangement.SongXml.File = XmlFilePath.Text;

                            if (Arrangement.TuningStrings == null)
                            {
                                // need to load tuning here from the xml arrangement
                                Arrangement.TuningStrings = new TuningStrings();
                                Arrangement.TuningStrings = xmlSong.Tuning;
                            }

                            if (!TuningFrequency.ApplyBassFix(Arrangement))
                            {
                                MessageBox.Show("This bass arrangement is already at 220Hz pitch.  ", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                var commentsList = Arrangement.XmlComments.ToList();
                                commentsList.Add(new XComment("Low Bass Tuning Fixed"));
                                Arrangement.XmlComments = commentsList;
                            }

                            xmlSong.Tuning = Arrangement.TuningStrings;
                        }
                    }

                    // Setup tuning
                    ArrangementType selectedType;
                    if (xmlSong.Arrangement.ToLower() == "bass")
                    {
                        selectedType = ArrangementType.Bass;
                    }
                    else
                    {
                        selectedType = ArrangementType.Guitar;
                    }

                    FillTuningCombo(selectedType, currentGameVersion);

                    // find tuning in tuningComboBox list and make selection
                    int foundTuning = -1;
                    for (int tcbIndex = 0; tcbIndex < tuningComboBox.Items.Count; tcbIndex++)
                    {
                        tuningComboBox.SelectedIndex = tcbIndex;
                        TuningDefinition tuning = (TuningDefinition)tuningComboBox.Items[tcbIndex];
                        if (tuning.Tuning == xmlSong.Tuning)
                        {
                            foundTuning = tcbIndex;
                            break;
                        }
                    }

                    if (foundTuning == -1 && selectedType != ArrangementType.Bass)
                    {
                        tuningComboBox.SelectedIndex = 0;
                        ShowTuningForm(selectedType, new TuningDefinition(xmlSong.Tuning, currentGameVersion)); //FIXME: Don't use this for QuickAdd call
                    }

                    // E Standard, Drop D, and Open E tuning are now the same for both guitar and bass
                    if (foundTuning == -1 && selectedType == ArrangementType.Bass)
                    {
                        tuningComboBox.SelectedIndex = 0;
                        MessageBox.Show("Toolkit was not able to automatically set tuning for" + Environment.NewLine +
                                        "Bass Arrangement: " + Path.GetFileName(xmlFilePath) + Environment.NewLine +
                                        "Use the tuning selector dropdown or Tuning Editor" + Environment.NewLine +
                                        "to customize bass tuning (as defined for six strings).  ", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    tuningComboBox.Refresh();
                    Arrangement.Tuning        = tuningComboBox.SelectedItem.ToString();
                    Arrangement.TuningStrings = xmlSong.Tuning;
                    Arrangement.CapoFret      = xmlSong.Capo;
                    frequencyTB.Text          = Arrangement.TuningPitch.ToString(CultureInfo.InvariantCulture);

                    // bastard bass hack
                    if (Arrangement.Tuning.ToLower().Contains("fixed"))
                    {
                        frequencyTB.Text = "220";
                    }

                    //UpdateCentOffset();//bad way to update tuning info, IMO

                    // save converted RS1 to RS2014 Song2014 XML
                    if (version == GameVersion.None)
                    {
                        var srcDir        = Path.GetDirectoryName(XmlFilePath.Text);
                        var srcName       = Path.GetFileNameWithoutExtension(XmlFilePath.Text);
                        var backupSrcPath = String.Format("{0}_{1}.xml", Path.Combine(srcDir, srcName), "RS1");

                        // backup original RS1 file
                        File.Copy(XmlFilePath.Text, backupSrcPath);

                        // write converted RS1 file
                        using (var stream = new FileStream(XmlFilePath.Text, FileMode.Create))
                            xmlSong.Serialize(stream, true);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"Unable to get information from XML arrangement:  " + Environment.NewLine +
                                Path.GetFileName(xmlFilePath) + Environment.NewLine +
                                @"It may not be a valid arrangement or " + Environment.NewLine +
                                @"your version of the EOF may be out of date." + Environment.NewLine +
                                ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            return(true);
        }
Exemple #12
0
        public AttributesHeader2014(string arrangementFileName, Arrangement arrangement, DLCPackageData info, Platform platform)
        {
            if (arrangement.ArrangementType == ArrangementType.ShowLight)
            {
                return;
            }

            IsVocal     = arrangement.ArrangementType == Sng.ArrangementType.Vocal;
            SongContent = (IsVocal) ? null : Song2014.LoadFromFile(arrangement.SongXml.File);
            var dlcName = info.Name.ToLower();

            var albumUrn = String.Format(URN_TEMPLATE, TagValue.Image.GetDescription(), TagValue.DDS.GetDescription(), String.Format("album_{0}", dlcName));
            var jsonUrn  = String.Format(URN_TEMPLATE, TagValue.Database.GetDescription(), TagValue.JsonDB.GetDescription(), String.Format("{0}_{1}", dlcName, arrangementFileName));

            //FILL ATTRIBUTES
            this.AlbumArt              = albumUrn;
            JapaneseVocal             |= arrangement.Name == Sng.ArrangementName.JVocals;
            ArrangementName            = IsVocal ? Sng.ArrangementName.Vocals.ToString() : arrangement.Name.ToString(); //HACK: weird vocals stuff
            DLC                        = true;
            DLCKey                     = info.Name;
            LeaderboardChallengeRating = 0;
            ManifestUrn                = jsonUrn;
            MasterID_RDV               = arrangement.MasterId;
            PersistentID               = arrangement.Id.ToString().Replace("-", "").ToUpper();
            Shipping                   = true;
            SKU                        = "RS2";
            SongKey                    = info.Name;

            if (!IsVocal)
            {
                AlbumName      = AlbumNameSort = info.SongInfo.Album;
                ArtistName     = info.SongInfo.Artist;
                CentOffset     = (!arrangement.TuningPitch.Equals(0)) ? TuningFrequency.Frequency2Cents(arrangement.TuningPitch) : 0.0;
                ArtistNameSort = info.SongInfo.ArtistSort;
                CapoFret       = (arrangement.Sng2014.Metadata.CapoFretId == 0xFF) ? CapoFret = 0 : Convert.ToDecimal(arrangement.Sng2014.Metadata.CapoFretId);
                DNA_Chords     = arrangement.Sng2014.DNACount[(int)DNAId.Chord];
                DNA_Riffs      = arrangement.Sng2014.DNACount[(int)DNAId.Riff];
                DNA_Solo       = arrangement.Sng2014.DNACount[(int)DNAId.Solo];
                NotesEasy      = arrangement.Sng2014.NoteCount[0];
                NotesMedium    = arrangement.Sng2014.NoteCount[1];
                NotesHard      = arrangement.Sng2014.NoteCount[2];
                EasyMastery    = NotesEasy / NotesHard;
                MediumMastery  = NotesMedium / NotesHard;
                Metronome      = (int?)arrangement.Metronome;
                Representative = Convert.ToInt32(!arrangement.BonusArr);
                RouteMask      = (int)arrangement.RouteMask;

                // TODO use ManifestFunctions.GetSongDifficulty() method (fix generation alghorythm)
                SongDiffEasy   = SongContent.SongLength / NotesEasy;
                SongDiffMed    = SongContent.SongLength / NotesMedium;
                SongDiffHard   = SongContent.SongLength / NotesHard;
                SongDifficulty = SongDiffHard;

                SongLength   = (double?)Math.Round(SongContent.SongLength, 3, MidpointRounding.AwayFromZero);
                SongName     = info.SongInfo.SongDisplayName;
                SongNameSort = info.SongInfo.SongDisplayNameSort;
                SongYear     = info.SongInfo.SongYear;

                //Detect tuning
                var tuning = TuningDefinitionRepository.Instance().SelectAny(SongContent.Tuning, platform.version);
                if (tuning == null)
                {
                    tuning        = new TuningDefinition();
                    tuning.Tuning = SongContent.Tuning;
                    tuning.Name   = tuning.UIName = arrangement.Tuning;
                    if (String.IsNullOrEmpty(tuning.Name))
                    {
                        tuning.Name = tuning.UIName = tuning.NameFromStrings(arrangement.TuningStrings, arrangement.ArrangementType == ArrangementType.Bass);
                    }
                    tuning.Custom      = true;
                    tuning.GameVersion = GameVersion.RS2014;
                    TuningDefinitionRepository.Instance().Add(tuning, true);
                }
                Tuning = tuning.Tuning;
            }
        }
Exemple #13
0
        public AttributesHeader2014(string arrangementFileName, Arrangement arrangement, DLCPackageData info, Platform platform)
        {
            if (arrangement.ArrangementType == ArrangementType.ShowLight)
            {
                return;
            }

            IsVocal  = arrangement.ArrangementType == ArrangementType.Vocal;
            song2014 = (IsVocal) ? null : Song2014.LoadFromFile(arrangement.SongXml.File);
            var dlcName = info.Name.ToLower();

            var albumUrn = String.Format(URN_TEMPLATE, TagValue.Image.GetDescription(), TagValue.DDS.GetDescription(), String.Format("album_{0}", dlcName));
            var jsonUrn  = String.Format(URN_TEMPLATE, TagValue.Database.GetDescription(), TagValue.JsonDB.GetDescription(), String.Format("{0}_{1}", dlcName, arrangementFileName));

            //FILL ATTRIBUTES
            this.AlbumArt              = albumUrn;
            JapaneseVocal             |= arrangement.ArrangementName == Sng.ArrangementName.JVocals;
            ArrangementName            = IsVocal ? Sng.ArrangementName.Vocals.ToString() : arrangement.ArrangementName.ToString(); //HACK: weird vocals stuff
            DLC                        = true;
            DLCKey                     = info.Name;
            LeaderboardChallengeRating = 0;
            ManifestUrn                = jsonUrn;
            MasterID_RDV               = arrangement.MasterId;
            PersistentID               = arrangement.Id.ToString().Replace("-", "").ToUpper();
            Shipping                   = true;
            SKU                        = "RS2";
            SongKey                    = info.Name; // proof same same

            if (IsVocal)
            {
                return;
            }
            // added better AlbumNameSort feature
            AlbumName      = info.SongInfo.Album;
            AlbumNameSort  = info.SongInfo.AlbumSort;
            ArtistName     = info.SongInfo.Artist;
            CentOffset     = (!arrangement.TuningPitch.Equals(0)) ? TuningFrequency.Frequency2Cents(arrangement.TuningPitch) : 0.0;
            ArtistNameSort = info.SongInfo.ArtistSort;
            BassPick       = arrangement.ArrangementType == ArrangementType.Bass ? (int)arrangement.PluckedType : 0;
            CapoFret       = (arrangement.Sng2014.Metadata.CapoFretId == 0xFF) ? CapoFret = 0 : Convert.ToDecimal(arrangement.Sng2014.Metadata.CapoFretId);
            DNA_Chords     = arrangement.Sng2014.DNACount[(int)DNAId.Chord];
            DNA_Riffs      = arrangement.Sng2014.DNACount[(int)DNAId.Riff];
            DNA_Solo       = arrangement.Sng2014.DNACount[(int)DNAId.Solo];
            NotesEasy      = arrangement.Sng2014.NoteCount[0];
            NotesMedium    = arrangement.Sng2014.NoteCount[1];
            NotesHard      = arrangement.Sng2014.NoteCount[2];
            EasyMastery    = Math.Round((double)(NotesEasy / NotesHard), 9);
            MediumMastery  = Math.Round((double)(NotesMedium / NotesHard), 9);
            Metronome      = arrangement.Metronome == Sng.Metronome.None ? null : (int?)arrangement.Metronome;
            // TODO: check for bug here
            // if there is an equivalent bonus arrangement then Representative is set to "1" otherwise "0"
            Representative = Convert.ToInt32(!arrangement.BonusArr);
            RouteMask      = (int)arrangement.RouteMask;

            ManifestFunctions.GetSongDifficulty(this, song2014);

            SongLength         = Math.Round(song2014.SongLength, 3, MidpointRounding.AwayFromZero);
            SongName           = info.SongInfo.SongDisplayName;
            SongNameSort       = info.SongInfo.SongDisplayNameSort;
            JapaneseSongName   = string.IsNullOrEmpty(info.SongInfo.JapaneseSongName) ? null : info.SongInfo.JapaneseSongName;
            JapaneseArtistName = string.IsNullOrEmpty(info.SongInfo.JapaneseArtistName) ? null : info.SongInfo.JapaneseArtistName;
            SongYear           = info.SongInfo.SongYear;

            //Detect tuning
            var tuning = TuningDefinitionRepository.Instance.Detect(song2014.Tuning, platform.version, arrangement.ArrangementType == ArrangementType.Bass);

            Tuning = tuning.Tuning; //can we just use SongContent.Tuning
        }
Exemple #14
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a ISDB errestrial frequency.
 /// </summary>
 /// <param name="frequency">The terrestrial frequency to tune to.</param>
 public TuningSpec(ISDBTerrestrialFrequency frequency)
 {
     this.frequency = frequency;
     bandwidth      = frequency.Bandwidth;
 }
Exemple #15
0
        private void btnFixLowBassTuning_Click(object sender, EventArgs e)
        {
            string[] srcPaths;
            bool     alreadyFixed;
            bool     hasBass;

            // GET PATH
            using (var ofd = new OpenFileDialog())
            {
                ofd.Title       = "Select the CDLC(s) which to apply Bass Tuning Fix";
                ofd.Filter      = "All Files (*.*)|*.*|Rocksmith 2014 PC|*_p.psarc|Rocksmith 2014 Mac|*_m.psarc|Rocksmith 2014 Xbox|*_xbox|Rocksmith 2014 PS3|*.edat";
                ofd.Multiselect = true;
                ofd.FileName    = destPath;

                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                srcPaths = ofd.FileNames;
            }

            var fixLowBass = ConfigRepository.Instance().GetBoolean("creator_fixlowbass");

            ToggleUIControls(false);
            errorsFound = new StringBuilder();
            GlobalExtension.UpdateProgress        = this.pbUpdateProgress;
            GlobalExtension.CurrentOperationLabel = this.lblCurrentOperation;
            Thread.Sleep(100); // give Globals a chance to initialize
            Stopwatch sw = new Stopwatch();

            sw.Restart();

            foreach (var srcPath in srcPaths)
            {
                // UNPACK
                var packagePlatform = srcPath.GetPlatform();
                var tmpPath         = Path.GetTempPath();
                Application.DoEvents();

                string unpackedDir;
                try
                {
                    unpackedDir = Packer.Unpack(srcPath, tmpPath, overwriteSongXml: true, predefinedPlatform: packagePlatform);
                }
                catch (Exception ex)
                {
                    errorsFound.AppendLine(String.Format("Error trying unpack file '{0}': {1}", Path.GetFileName(srcPath), ex.Message));
                    continue;
                }

                destPath = Path.Combine(Path.GetDirectoryName(srcPaths[0]), Path.GetFileName(unpackedDir));

                GlobalExtension.ShowProgress(String.Format("Loading '{0}' ...", Path.GetFileName(srcPath)), 40);

                // Same name xbox issue fix
                //if (packagePlatform.platform == GamePlatform.XBox360)
                //    destPath = String.Format("{0}_{1}", destPath, GamePlatform.XBox360.ToString());

                DirectoryExtension.Move(unpackedDir, destPath, true);
                unpackedDir = destPath;

                // Low Bass Tuning Fix is for Rocksmith 2014 Only
                packagePlatform = new Platform(packagePlatform.platform, GameVersion.RS2014);
                // LOAD DATA
                var info = DLCPackageData.LoadFromFolder(unpackedDir, packagePlatform, packagePlatform, false);

                switch (packagePlatform.platform)
                {
                case GamePlatform.Pc:
                    info.Pc = true;
                    break;

                case GamePlatform.Mac:
                    info.Mac = true;
                    break;

                case GamePlatform.XBox360:
                    info.XBox360 = true;
                    break;

                case GamePlatform.PS3:
                    info.PS3 = true;
                    break;
                }

                //apply bass fix
                GlobalExtension.ShowProgress(String.Format("Applying Bass Tuning Fix '{0}' ...", Path.GetFileName(srcPath)), 60);
                alreadyFixed = false;
                hasBass      = false;

                for (int i = 0; i < info.Arrangements.Count; i++)
                {
                    Arrangement arr = info.Arrangements[i];
                    if (arr.ArrangementType == ArrangementType.Bass)
                    {
                        hasBass = true;

                        if (arr.TuningStrings.String0 < -4 && arr.TuningPitch != 220.0)
                        {
                            if (!TuningFrequency.ApplyBassFix(arr, fixLowBass))
                            {
                                if (chkVerbose.Checked)
                                {
                                    MessageBox.Show(Path.GetFileName(srcPath) + "  " + Environment.NewLine + "bass arrangement is already at 220Hz pitch.  ", "Error ... Applying Low Bass Tuning Fix", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }

                                alreadyFixed = true;
                            }
                        }
                        else
                        {
                            if (chkVerbose.Checked)
                            {
                                MessageBox.Show(Path.GetFileName(srcPath) + "  " + Environment.NewLine + "bass arrangement tuning does not need to be fixed.  ", "Error ... Applying Low Bass Tuning Fix", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }

                            alreadyFixed = true;
                        }
                    }
                }

                // don't repackage a song that is already fixed or doesn't have bass
                if (alreadyFixed || !hasBass)
                {
                    if (chkVerbose.Checked && !hasBass)
                    {
                        MessageBox.Show(Path.GetFileName(srcPath) + "  " + Environment.NewLine + "has no bass arrangement.  ", "Error ... Applying Low Bass Tuning Fix", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    DirectoryExtension.SafeDelete(unpackedDir);
                    continue;
                }

                var ndx     = srcPath.LastIndexOf('_');
                var srcName = srcPath.Substring(0, ndx);
                var srcExt  = srcPath.Substring(ndx, srcPath.Length - ndx);

                if (!chkQuickBassFix.Checked)
                {
                    using (var ofd = new SaveFileDialog())
                    {
                        ofd.Title    = "Select a name for the Low Bass Tuning Fixed file.";
                        ofd.Filter   = "All Files (*.*)|*.*|Rocksmith 2014 PC|*_p.psarc|Rocksmith 2014 Mac|*_m.psarc|Rocksmith 2014 Xbox|*_xbox|Rocksmith 2014 PS3|*.edat";
                        ofd.FileName = String.Format("{0}_{1}_bassfix{2}", info.SongInfo.ArtistSort, info.SongInfo.SongDisplayNameSort, srcExt);

                        if (ofd.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        destPath = ofd.FileName;
                    }
                }
                else
                {
                    destPath = String.Format("{0}_bassfix{1}", srcName, srcExt);
                }

                if (Path.GetFileName(destPath).Contains(" ") && info.PS3)
                {
                    if (!ConfigRepository.Instance().GetBoolean("creator_ps3pkgnamewarn"))
                    {
                        MessageBox.Show(String.Format("PS3 package name can't support space character due to encryption limitation. {0} Spaces will be automatic removed for your PS3 package name.", Environment.NewLine), MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        ConfigRepository.Instance()["creator_ps3pkgnamewarn"] = true.ToString();
                    }
                }

                if (chkDeleteSourceFile.Checked)
                {
                    try
                    {
                        File.Delete(srcPath);
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex.Message);
                        MessageBox.Show("Access rights required to delete source package, or an error occurred. Package still may exist. Try running as Administrator.");
                    }
                }

                // Generate Fixed Low Bass Tuning Package
                GlobalExtension.ShowProgress(String.Format("Repackaging '{0}' ...", Path.GetFileName(srcPath)), 80);
                // TODO consider user of regular packer here
                RocksmithToolkitLib.DLCPackage.DLCPackageCreator.Generate(destPath, info, packagePlatform);

                if (!GeneralExtensions.IsInDesignMode)
                {
                    DirectoryExtension.SafeDelete(unpackedDir);
                }
            }

            sw.Stop();
            GlobalExtension.ShowProgress("Finished applying low bass tuning fix (elapsed time): " + sw.Elapsed, 100);
            if (String.IsNullOrEmpty(destPath))
            {
                destPath = srcPaths[0];
            }

            PromptComplete(destPath, errMsg: errorsFound.ToString());
            GlobalExtension.Dispose();
            ToggleUIControls(true);
        }
        public AttributesHeader2014(string arrangementFileName, Arrangement arrangement, DLCPackageData info, Platform platform)
        {
            if (arrangement.ArrangementType == ArrangementType.ShowLight)
            {
                return;
            }

            IsVocal  = arrangement.ArrangementType == ArrangementType.Vocal;
            song2014 = (IsVocal) ? null : Song2014.LoadFromFile(arrangement.SongXml.File);
            var dlcName = info.Name.ToLower();

            var albumUrn = String.Format(URN_TEMPLATE, TagValue.Image.GetDescription(), TagValue.DDS.GetDescription(), String.Format("album_{0}", dlcName));
            var jsonUrn  = String.Format(URN_TEMPLATE, TagValue.Database.GetDescription(), TagValue.JsonDB.GetDescription(), String.Format("{0}_{1}", dlcName, arrangementFileName));

            //FILL ATTRIBUTES
            this.AlbumArt              = albumUrn;
            JapaneseVocal             |= arrangement.ArrangementName == Sng.ArrangementName.JVocals;
            ArrangementName            = IsVocal ? Sng.ArrangementName.Vocals.ToString() : arrangement.ArrangementName.ToString(); //HACK: weird vocals stuff
            DLCKey                     = info.Name;                                                                                // in RS2 DLCKey = SongKey, in RS1 they are different
            SongKey                    = info.Name;
            LeaderboardChallengeRating = 0;
            ManifestUrn                = jsonUrn;
            MasterID_RDV               = arrangement.MasterId; // must be unique else in-game hang occures
            PersistentID               = arrangement.Id.ToString().Replace("-", "").ToUpper();
            Shipping                   = true;                 // false = hides the arrangement in-game

            // DLC property controls whether album artwork marker is shown in-game setlist, but
            // has side effect that 'Alternate Arrangements' are locked for newer player profiles
            DLC = true; // false = requires UPlay to unlock

            // TODO: monitor this change
            if (info.ToolkitInfo == null || info.ToolkitInfo.PackageAuthor == "Ubisoft")
            {
                SKU = "RS2"; // shows purple marker w/ "DLC" text overlay
            }
            else
            {
                SKU = ""; // hides album artwork marker in-game setlist
            }
            // this SKU and DLCKey combination shows black marker w/ "RS1" text overlay on album artwork in-game setlist
            // SKU = "RS1";
            // DLCKey = "RS1CompatibilityDisc";

            if (IsVocal)
            {
                return;
            }

            // added better AlbumNameSort feature
            AlbumName      = info.SongInfo.Album;
            AlbumNameSort  = info.SongInfo.AlbumSort;
            ArtistName     = info.SongInfo.Artist;
            CentOffset     = (!arrangement.TuningPitch.Equals(0)) ? TuningFrequency.Frequency2Cents(arrangement.TuningPitch) : 0.0;
            ArtistNameSort = info.SongInfo.ArtistSort;
            BassPick       = arrangement.ArrangementType == ArrangementType.Bass ? (int)arrangement.PluckedType : 0;
            CapoFret       = (arrangement.Sng2014.Metadata.CapoFretId == 0xFF) ? CapoFret = 0 : Convert.ToDecimal(arrangement.Sng2014.Metadata.CapoFretId);
            DNA_Chords     = arrangement.Sng2014.DNACount[(int)DNAId.Chord];
            DNA_Riffs      = arrangement.Sng2014.DNACount[(int)DNAId.Riff];
            DNA_Solo       = arrangement.Sng2014.DNACount[(int)DNAId.Solo];
            NotesEasy      = arrangement.Sng2014.NoteCount[0];
            NotesMedium    = arrangement.Sng2014.NoteCount[1];
            NotesHard      = arrangement.Sng2014.NoteCount[2];
            EasyMastery    = Math.Round((double)(NotesEasy / NotesHard), 9);
            MediumMastery  = Math.Round((double)(NotesMedium / NotesHard), 9);
            Metronome      = arrangement.Metronome == Sng.Metronome.None ? null : (int?)arrangement.Metronome;
            // TODO: monitor this change
            // Representative = Convert.ToInt32(!arrangement.BonusArr);
            Representative = arrangement.ArrangementPropeties.Represent;
            RouteMask      = (int)arrangement.RouteMask;

            ManifestFunctions.GetSongDifficulty(this, song2014);

            SongLength         = Math.Round(song2014.SongLength, 3, MidpointRounding.AwayFromZero);
            SongName           = info.SongInfo.SongDisplayName;
            SongNameSort       = info.SongInfo.SongDisplayNameSort;
            JapaneseSongName   = string.IsNullOrEmpty(info.SongInfo.JapaneseSongName) ? null : info.SongInfo.JapaneseSongName;
            JapaneseArtistName = string.IsNullOrEmpty(info.SongInfo.JapaneseArtistName) ? null : info.SongInfo.JapaneseArtistName;
            SongYear           = info.SongInfo.SongYear;

            //Detect tuning
            var tuning = TuningDefinitionRepository.Instance.Detect(song2014.Tuning, platform.version, arrangement.ArrangementType == ArrangementType.Bass);

            Tuning = tuning.Tuning; //can we just use SongContent.Tuning
        }
        /// <summary>
        /// Initialise a new instance of the PluginDataProvider class.
        /// </summary>
        /// <param name="tuningFrequency">The tuning frequency.</param>
        /// <param name="runReference">A unique reference for this run.</param>
        public PluginDataProvider(TuningFrequency tuningFrequency, string runReference)
        {
            this.tuningFrequency = tuningFrequency;

            resourceMutex = new Mutex(false, "DVBLogic Plugin Resource Mutex " + runReference);
        }