private void RunBeatmapScanner(CancellationToken token) { List <FileInfo> mapFiles = new List <FileInfo>(); // Files that should be found in the result so they are not considered for removal HashSet <string> filesToRemove = new HashSet <string>(difficultyLastWriteTimes.Keys); // Scan folder layout foreach (var searchPath in searchPaths) { foreach (var file in Directory.EnumerateFiles(searchPath, "*.ksh", SearchOption.AllDirectories)) { if (token.IsCancellationRequested) { return; } var fileInfo = new FileInfo(file); mapFiles.Add(fileInfo); filesToRemove.Remove(fileInfo.FullName); // Do not remove this map, it still exists } } // Process removals databaseScheduler.Add(() => RemoveDifficulties(filesToRemove)); // Process found map files foreach (var mapFile in mapFiles) { if (!IsDifficultyAddedOrChanged(mapFile)) { continue; // Skip unchanged maps } // Try to load map metadata try { var stream = File.OpenRead(mapFile.FullName); BeatmapKsh mapKsh = new BeatmapKsh(stream, true); Beatmap.Beatmap map = new Beatmap.Beatmap(mapKsh); databaseScheduler.Add(() => { AddDifficulty(mapFile, map.Metadata); }); } catch (BeatmapParserException) { Debug.WriteLine($"Corrupted map [{mapFile.Name}], not adding it to the database"); if (difficultyLastWriteTimes.ContainsKey(mapFile.FullName)) { // Difficulty existed, remove it now since it is corrupt databaseScheduler.Add(() => RemoveDifficulties(new HashSet <string> { mapFile.FullName })); } } } // Notify finished databaseScheduler.Add(() => SearchFinished?.Invoke(this, null)); IsSearchRunning = false; }
/// <summary> /// Hook up the effect controller to playback events /// </summary> /// <param name="playback"></param> public void Initializer(BeatmapPlayback playback, AudioTrack track, SampleManager sampleManager) { Debug.Assert(this.playback == null); // Only do this once, or dispose first this.sampleManager = sampleManager; this.playback = playback; this.track = track; playback.ObjectActivated += PlaybackOnObjectActivated; playback.ObjectDeactivated += PlaybackOnObjectDeactivated; beatmap = playback.Beatmap; laserSlamSample = sampleManager.Get("laser_slam0.wav"); // TODO: Pass in to this function as PlaybackContext context = new PlaybackContext { Playback = playback, Track = track, }; }
public override void Reset() { base.Reset(); beatmap = LoadTestBeatmap("C18H27NO3", out beatmapRootPath); //beatmap = LoadTestBeatmap("soflan", out beatmapRootPath, "two"); //beatmap = LoadTestBeatmap("bb", out beatmapRootPath, "grv"); //beatmap = LoadTestBeatmap("cc", out beatmapRootPath, "grv"); playback.Beatmap = beatmap; playback.ViewDuration = 0.4f; // Load beatmap audio string audioPath = Path.Combine(beatmapRootPath, beatmap.Metadata.AudioPath); audioTrackStream = File.Open(audioPath, FileMode.Open); audioTrack = new AudioTrackBass(audioTrackStream, false); //var retrigger = new Retrigger(); //retrigger.Duration = beatmap.TimingPoints[0].GetDivisionDuration(new TimeDivision(1, 4)); //retrigger.Gating = 0.25f; //retrigger.LoopCount = 4; //audioTrack.AddDsp(retrigger); audioTrack.Start(); Add(gameView = new GameRenderView { RelativeSizeAxes = Axes.Both, Size = Vector2.One }); playback.ViewDurationChanged += (sender, args) => { gameView.renderer.ViewDuration = playback.ViewDuration; }; gameView.renderer.ViewDuration = playback.ViewDuration; Add(controllerWindow = new ControllerWindow(audioTrack, playback)); controllerWindow.Show(); effectController.Initializer(playback, audioTrack, game.Audio.Sample); }