Beispiel #1
0
        /// <summary>
        /// Removes dynamic difficulty levels from the files the user chooses.
        /// </summary>
        private async Task RemoveDDImpl()
        {
            var fileNames = await services
                            .OpenFileDialog(
                "Select RS2014 XML File(s) to Remove DD From",
                FileFilter.RSXmlFiles,
                multiSelect : true)
                            .ConfigureAwait(false);

            if (fileNames?.Length > 0)
            {
                ShowInStatusbar("Removing DD...");

#if DEBUG
                Stopwatch stopwatch = Stopwatch.StartNew();
#endif

                await Task.Run(() => Parallel.ForEach(
                                   fileNames,
                                   new ParallelOptions
                {
                    MaxDegreeOfParallelism = Math.Max(1, Environment.ProcessorCount / 4)
                },
                                   async fn =>
                {
                    var arrangement = InstrumentalArrangement.Load(fn);
                    await DDRemover.RemoveDD(arrangement, MatchPhrasesToSections, DeleteTranscriptionTrack).ConfigureAwait(false);
                    string oldFileName = Path.GetFileName(fn);
                    string newFileName = oldFileName.StartsWith("DDC_") ?
                                         oldFileName.Substring(4) :
                                         oldFileName;
                    arrangement.Save(Path.Combine(Path.GetDirectoryName(fn) !, "NDD_" + newFileName));
                }));

                string files      = (fileNames.Length == 1) ? "File" : "Files";
                string statusText = $"Removing DD completed. {files} saved with NDD_ prefix.";
#if DEBUG
                statusText += " Elapsed: " + stopwatch.ElapsedMilliseconds;
#endif
                ShowInStatusbar(statusText);
            }
        }
Beispiel #2
0
        private ArrangementData GetArrangementData(string filename)
        {
            var fileInfo     = new FileInfo(filename);
            var timeModified = fileInfo.LastWriteTime;

            if (!ArrangementCache.TryGetArrangementData(filename, out ArrangementData arrData, timeModified))
            {
                var Song = InstrumentalArrangement.Load(filename);

                arrData = new ArrangementData
                {
                    Sections      = Song.Sections,
                    Ebeats        = Song.Ebeats,
                    FirstBeatTime = Song.StartBeat,
                    SongLength    = Song.MetaData.SongLength,
                    TimeModified  = timeModified
                };

                // Try to find a solo section in the latter half of the song. If not found, use the first one
                var soloSections = Song.Sections.Where(s => s.Name == "solo");
                var soloSection  = soloSections.FirstOrDefault(s => s.Time >= arrData.SongLength / 2) ?? soloSections.FirstOrDefault();
                arrData.SoloSectionTime = soloSection?.Time;

                // Get notes and chords
                var(notes, chords) = GetNotesAndChordsFromSong(Song);

                // Get MIDI notes
                arrData.MidiNotes            = GetMidiNotes(Song, notes, chords, out int minMidiNote);
                arrData.LowOctaveMinMidiNote = minMidiNote;

                ArrangementCache.AddArrangementData(filename, arrData);
            }

            FirstBeatTime = arrData.FirstBeatTime;
            SongLength    = arrData.SongLength;
            if (arrData.SoloSectionTime.HasValue)
            {
                SoloSectionTime = arrData.SoloSectionTime.Value;
            }

            return(arrData);
        }
 public PreProcessorBlocksTests()
 {
     testArrangement = InstrumentalArrangement.Load(@".\TestFiles\preTest_RS2.xml");
 }
        public PostProcessorBlocksTests(ConfigurationFixture fixture)
        {
            XMLProcessor.Preferences = fixture.Configuration;

            testArrangement = InstrumentalArrangement.Load(@".\TestFiles\postTest_RS2.xml");
        }