Пример #1
0
        private async Task ScanPrivateFolderAsync(DirectoryInfo privateFolder)
        {
            var beatmaps = new List <Beatmap>();

            foreach (var fileInfo in privateFolder.EnumerateFiles(searchPattern: "*.osu", searchOption: SearchOption.TopDirectoryOnly))
            {
                if (_scanCts.IsCancellationRequested)
                {
                    return;
                }
                try
                {
                    var osuFile = await OsuFile.ReadFromFileAsync(@"\\?\" + fileInfo.FullName,
                                                                  options =>
                    {
                        options.IncludeSection("General", "Metadata", "TimingPoints", "Difficulty", "HitObjects", "Events");
                        options.IgnoreSample();
                        options.IgnoreStoryboard();
                    });

                    var beatmap = GetBeatmapObj(osuFile, fileInfo);
                    beatmaps.Add(beatmap);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"{ex.Message} ignored '{fileInfo.FullName}'");
                }
            }

            _beatmapDbOperator.AddNewMaps(beatmaps);
        }
        public static async Task AddToCollectionAsync(Collection col, IList <Beatmap> entries)
        {
            if (entries.Count <= 0)
            {
                return;
            }
            if (string.IsNullOrEmpty(col.ImagePath))
            {
                var first   = entries[0];
                var osuFile =
                    await OsuFile.ReadFromFileAsync(Path.Combine(Domain.OsuSongPath, first.FolderName,
                                                                 first.BeatmapFileName));

                if (osuFile.Events.BackgroundInfo != null)
                {
                    var imgPath = Path.Combine(Domain.OsuSongPath, first.FolderName,
                                               osuFile.Events.BackgroundInfo.Filename);
                    if (File.Exists(imgPath))
                    {
                        col.ImagePath = imgPath;
                        _appDbOperator.UpdateCollection(col);
                    }
                }
            }

            _appDbOperator.AddMapsToCollection(entries, col);
        }
Пример #3
0
        static void Main(string[] args)
        {
            var o = OsuFile.ReadFromFileAsync(@"D:\ValveUnhandledExceptionFilter.txt").Result;

            var fileName = "op.avi";
            var fi       = new FileInfo(@"F:\项目\GitHub\CoosuLocal\folder \" + fileName);

            if (fi.Exists)
            {
                Console.WriteLine(fi.FullName);
            }

            var directDirName    = fi.DirectoryName;
            var dir              = fi.Directory;
            var dirFullName      = dir.FullName;
            var dirName          = dir.Name;
            var toStringResult   = dir.ToString();
            var pathWithCombine  = Path.Combine(dirFullName, fi.Name);
            var pathWithCombine2 = Path.Combine(toStringResult, fi.Name);

            Console.WriteLine(pathWithCombine);
            Console.WriteLine(pathWithCombine2);

            var sb = OsuFile.ReadFromFileAsync(
                @"D:\Games\osu!\Songs\EastNewSound - Gensoukyou Matsuribayashi (Aki)\EastNewSound - Gensoukyou Matsuribayashi (Aki) (yf_bmp) [test].osu").Result;

            foreach (var rawHitObject in sb.HitObjects.HitObjectList)
            {
                var ticks = rawHitObject.SliderInfo.Ticks;
                var slids = rawHitObject.SliderInfo.BallTrail;
            }
        }
        public static async Task AddToCollectionAsync(Collection col, IList <Beatmap> entries)
        {
            var appDbOperator = new AppDbOperator();

            if (entries == null || entries.Count <= 0)
            {
                return;
            }
            if (string.IsNullOrEmpty(col.ImagePath))
            {
                var first = entries[0];
                var dir   = first.InOwnFolder
                    ? Path.Combine(Domain.CustomSongPath, first.FolderName)
                    : Path.Combine(Domain.OsuSongPath, first.FolderName);
                var filePath = Path.Combine(dir, first.BeatmapFileName);
                var osuFile  = await OsuFile.ReadFromFileAsync(@"\\?\" + filePath, options =>
                {
                    options.IncludeSection("Events");
                    options.IgnoreSample();
                    options.IgnoreStoryboard();
                });

                if (osuFile.Events.BackgroundInfo != null)
                {
                    var imgPath = Path.Combine(dir, osuFile.Events.BackgroundInfo.Filename);
                    if (File.Exists(imgPath))
                    {
                        col.ImagePath = imgPath;
                        appDbOperator.UpdateCollection(col);
                    }
                }
            }

            appDbOperator.AddMapsToCollection(entries, col);
        }
Пример #5
0
        public async Task LoadFromDirectoryAsync(string path)
        {
            DirectoryInfo di = new DirectoryInfo(path);

            FileInfo[] files = di.GetFiles("*.osu");
            foreach (var file in files)
            {
                FileList.Add(await OsuFile.ReadFromFileAsync(file.FullName));
            }
        }
Пример #6
0
        public static async Task <bool> AddToCollectionAsync([NotNull] Collection col, IList <Beatmap> beatmaps)
        {
            var controller = Service.Get <ObservablePlayController>();

            await using var dbContext = new ApplicationDbContext();
            if (beatmaps == null || beatmaps.Count <= 0)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(col.ImagePath))
            {
                var first    = beatmaps[0];
                var dir      = first.GetFolder(out var isFromDb, out var freePath);
                var filePath = isFromDb ? Path.Combine(dir, first.BeatmapFileName) : freePath;
                var osuFile  = await OsuFile.ReadFromFileAsync(filePath, options =>
                {
                    options.IncludeSection("Events");
                    options.IgnoreSample();
                    options.IgnoreStoryboard();
                });

                if (!osuFile.ReadSuccess)
                {
                    return(false);
                }
                if (osuFile.Events.BackgroundInfo != null)
                {
                    var imgPath = Path.Combine(dir, osuFile.Events.BackgroundInfo.Filename);
                    if (File.Exists(imgPath))
                    {
                        col.ImagePath = imgPath;
                        await dbContext.AddOrUpdateCollection(col);
                    }
                }
            }

            await dbContext.AddBeatmapsToCollection(beatmaps, col);

            if (col.IsDefault)
            {
                foreach (var beatmap in beatmaps)
                {
                    if (controller.PlayList.CurrentInfo.Beatmap.Equals(beatmap))
                    {
                        controller.PlayList.CurrentInfo.BeatmapDetail.Metadata.IsFavorite = true;
                        break;
                    }
                }
            }

            return(true);
        }
Пример #7
0
        private async Task ScanPrivateFolderAsync(DirectoryInfo privateFolder)
        {
            foreach (var fileInfo in privateFolder.EnumerateFiles(searchPattern: "*.osu", searchOption: SearchOption.TopDirectoryOnly))
            {
                if (_scanCts.IsCancellationRequested)
                {
                    return;
                }

                var osuFile = await OsuFile.ReadFromFileAsync(fileInfo.FullName);
                await AddFileAsync(osuFile, fileInfo);
            }
        }
Пример #8
0
        public static async Task <bool> AddToCollectionAsync([NotNull] Collection col, IList <Beatmap> entries)
        {
            var controller    = Service.Get <ObservablePlayController>();
            var appDbOperator = new AppDbOperator();

            if (entries == null || entries.Count <= 0)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(col.ImagePath))
            {
                var first    = entries[0];
                var dir      = first.GetFolder(out var isFromDb, out var freePath);
                var filePath = isFromDb ? Path.Combine(dir, first.BeatmapFileName) : freePath;
                var osuFile  = await OsuFile.ReadFromFileAsync(filePath, options =>
                {
                    options.IncludeSection("Events");
                    options.IgnoreSample();
                    options.IgnoreStoryboard();
                });

                if (!osuFile.ReadSuccess)
                {
                    return(false);
                }
                if (osuFile.Events.BackgroundInfo != null)
                {
                    var imgPath = Path.Combine(dir, osuFile.Events.BackgroundInfo.Filename);
                    if (File.Exists(imgPath))
                    {
                        col.ImagePath = imgPath;
                        appDbOperator.UpdateCollection(col);
                    }
                }
            }

            appDbOperator.AddMapsToCollection(entries, col);
            foreach (var beatmap in entries)
            {
                if (!controller.PlayList.CurrentInfo.Beatmap.GetIdentity().Equals(beatmap.GetIdentity()) ||
                    !col.LockedBool)
                {
                    continue;
                }
                controller.PlayList.CurrentInfo.BeatmapDetail.Metadata.IsFavorite = false;
                break;
            }

            return(true);
        }
Пример #9
0
        private static async Task ExportOsu()
        {
            var path = "F:\\milkitic\\Songs\\" +
                       "1346316 Nekomata Master feat. Mimi Nyami - TWINKLING\\" +
                       "Nekomata Master feat. Mimi Nyami - TWINKLING (yf_bmp) [Another].osu";

            //var path = "E:\\Games\\osu!\\Songs\\3198 Rhapsody - Emerald Sword\\" +
            //           //"1376486 Risshuu feat. Choko - Take\\" +
            //           "Rhapsody - Emerald Sword (Reikin) [net].osu";

            var folder  = Path.GetDirectoryName(path);
            var osuFile = await OsuFile.ReadFromFileAsync(path);

            if (!osuFile.ReadSuccess)
            {
                throw osuFile.ReadException;
            }

            using var engine = new AudioPlaybackEngine();
            var mp3Path = Path.Combine(folder, osuFile?.General.AudioFilename ?? ".");

            var fileCache = new FileCache();

            await using var directChannel   = new DirectChannel(mp3Path, osuFile.General.AudioLeadIn, engine);
            await using var hitsoundChannel = new HitsoundChannel(osuFile, engine, fileCache)
                        {
                            ManualOffset = 50,
                        };
            await using var sampleChannel = new SampleChannel(osuFile, engine, new Subchannel[]
            {
                directChannel, hitsoundChannel
            }, fileCache)
                        {
                            ManualOffset = 50,
                        };

            var    exporter = new Mp3Exporter(new MultiElementsChannel[] { directChannel, hitsoundChannel, sampleChannel }, engine);
            string pre      = null;
            await exporter.ExportAsync("test.mp3", progress =>
            {
                var p = $"Progress: {progress:P0}";
                if (pre != p)
                {
                    Console.WriteLine(p);
                    pre = p;
                }
            });
        }
Пример #10
0
        private async Task ScanPrivateFolderAsync(DirectoryInfo privateFolder)
        {
            var beatmaps = new List <Beatmap>();

            foreach (var fileInfo in privateFolder.EnumerateFiles("*.osu", SearchOption.TopDirectoryOnly))
            {
                if (_scanCts.IsCancellationRequested)
                {
                    return;
                }
                try
                {
                    var osuFile = await OsuFile.ReadFromFileAsync(fileInfo.FullName,
                                                                  options =>
                    {
                        options.IncludeSection("General", "Metadata", "TimingPoints", "Difficulty", "HitObjects",
                                               "Events");
                        options.IgnoreSample();
                        options.IgnoreStoryboard();
                    });

                    if (!osuFile.ReadSuccess)
                    {
                        Logger.Warn(osuFile.ReadException, "Osu file format error, skipped {0}", fileInfo.FullName);
                        continue;
                    }

                    var beatmap = GetBeatmapObj(osuFile, fileInfo);
                    beatmaps.Add(beatmap);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Error during scanning file, ignored {0}", fileInfo.FullName);
                }
            }

            try
            {
                await using var dbContext = new ApplicationDbContext();
                await dbContext.AddNewBeatmaps(beatmaps);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
        }
Пример #11
0
        public static async Task AddToCollectionAsync(Collection col, BeatmapEntry entry)
        {
            if (string.IsNullOrEmpty(col.ImagePath))
            {
                var osuFile =
                    await OsuFile.ReadFromFileAsync(Path.Combine(Domain.OsuSongPath, entry.FolderName,
                                                                 entry.BeatmapFileName));

                if (osuFile.Events.BackgroundInfo != null)
                {
                    var imgPath = Path.Combine(Domain.OsuSongPath, entry.FolderName, osuFile.Events.BackgroundInfo.Filename);
                    if (File.Exists(imgPath))
                    {
                        col.ImagePath = imgPath;
                        DbOperate.UpdateCollection(col);
                    }
                }
            }
            DbOperate.AddMapToCollection(entry, col);
        }
Пример #12
0
        public static async Task <string> GetThumbByBeatmapDbId(Beatmap beatmap)
        {
            return(await Task.Run(async() =>
            {
                await Lock.WaitAsync();
                try
                {
                    await using var dbContext = new ApplicationDbContext();
                    var thumb = await dbContext.GetThumb(beatmap);
                    if (thumb != null)
                    {
                        if (File.Exists(thumb.ThumbPath))
                        {
                            return thumb.ThumbPath;
                        }
                    }

                    var folder = beatmap.GetFolder(out var isFromDb, out var freePath);
                    var osuFilePath = isFromDb ? Path.Combine(folder, beatmap.BeatmapFileName) : freePath;

                    if (!File.Exists(osuFilePath))
                    {
                        return null;
                    }

                    var osuFile = await OsuFile.ReadFromFileAsync(osuFilePath, options =>
                    {
                        options.IncludeSection("Events");
                        options.IgnoreSample();
                        options.IgnoreStoryboard();
                    })
                                  .ConfigureAwait(false);
                    if (!osuFile.ReadSuccess)
                    {
                        return null;
                    }

                    var guidStr = Guid.NewGuid().ToString();

                    var sourceBgFile = osuFile.Events?.BackgroundInfo?.Filename;
                    if (string.IsNullOrWhiteSpace(sourceBgFile))
                    {
                        await dbContext.AddOrUpdateThumbPath(beatmap, null);
                        return null;
                    }

                    var sourceBgPath = Path.Combine(folder, sourceBgFile);

                    if (!File.Exists(sourceBgPath))
                    {
                        //_appDbOperator.SetMapThumb(dataModel.BeatmapDbId, null);
                        return null;
                    }

                    ResizeImageAndSave(sourceBgPath, guidStr, height: 200);
                    await dbContext.AddOrUpdateThumbPath(beatmap, guidStr);
                    return guidStr;
                }
                catch (Exception ex)
                {
                    Logger.Error("Error while creating beatmap thumb cache: {0}", beatmap.ToString());
                    return default;
                }
                finally
                {
                    Lock.Release();
                }
            }));
        }
Пример #13
0
 public async Task LoadFromFileAsync(string path)
 {
     FileList.Add(await OsuFile.ReadFromFileAsync(path));
 }
Пример #14
0
        /// <summary>
        /// Play a new file by file path.
        /// </summary>
        private async Task PlayNewFile(string path, bool play)
        {
            var sw = Stopwatch.StartNew();

            var             playerInst  = InstanceManage.GetInstance <PlayersInst>();
            var             dbInst      = InstanceManage.GetInstance <OsuDbInst>();
            ComponentPlayer audioPlayer = null;

            if (path == null)
            {
                return;
            }
            if (File.Exists(path))
            {
                try
                {
                    var osuFile = await OsuFile.ReadFromFileAsync(path); //50 ms

                    var fi = new FileInfo(path);
                    if (!fi.Exists)
                    {
                        throw new FileNotFoundException("Cannot locate.", fi.FullName);
                    }
                    var dir = fi.Directory.FullName;

                    /* Clear */
                    ClearHitsoundPlayer();

                    /* Set new hitsound player*/
                    playerInst.SetAudioPlayer(path, osuFile);
                    audioPlayer = playerInst.AudioPlayer;
                    SignUpPlayerEvent(audioPlayer);
                    await audioPlayer.InitializeAsync(); //700 ms

                    /* Set Meta */
                    var nowIdentity = new MapIdentity(fi.Directory.Name, osuFile.Metadata.Version);

                    MapInfo mapInfo = DbOperate.GetMapFromDb(nowIdentity);
                    Beatmap beatmap = BeatmapQuery.FilterByIdentity(nowIdentity);

                    bool isFavorite = IsMapFavorite(mapInfo); //50 ms

                    audioPlayer.HitsoundOffset = mapInfo.Offset;
                    Offset.Value = audioPlayer.HitsoundOffset;

                    var currentInfo = new CurrentInfo(
                        osuFile.Metadata.Artist,
                        osuFile.Metadata.ArtistUnicode,
                        osuFile.Metadata.Title,
                        osuFile.Metadata.TitleUnicode,
                        osuFile.Metadata.Creator,
                        osuFile.Metadata.Source,
                        osuFile.Metadata.TagList,
                        osuFile.Metadata.BeatmapId,
                        osuFile.Metadata.BeatmapSetId,
                        beatmap?.DiffSrNoneStandard ?? 0,
                        osuFile.Difficulty.HpDrainRate,
                        osuFile.Difficulty.CircleSize,
                        osuFile.Difficulty.ApproachRate,
                        osuFile.Difficulty.OverallDifficulty,
                        audioPlayer.Duration,
                        nowIdentity,
                        mapInfo,
                        beatmap,
                        isFavorite); // 20 ms
                    InstanceManage.GetInstance <PlayerList>().CurrentInfo = currentInfo;
                    ViewModel.Player.CurrentInfo = currentInfo;

                    /*start of ui*/
                    LblTitle.Content  = osuFile.Metadata.TitleMeta.ToUnicodeString();
                    LblArtist.Content = osuFile.Metadata.ArtistMeta.ToUnicodeString();
                    ((ToolTip)NotifyIcon.TrayToolTip).Content =
                        (string)LblArtist.Content + " - " + (string)LblTitle.Content;
                    /*end of ui*/

                    /* Set Lyric */
                    SetLyricSynchronously();

                    /* Set Progress */
                    PlayProgress.Maximum = audioPlayer.Duration;
                    PlayProgress.Value   = 0;

                    PlayerViewModel.Current.Duration = InstanceManage.GetInstance <PlayersInst>().AudioPlayer.Duration;

                    /* Set Storyboard */
                    if (true)
                    {
                        // Todo: Set Storyboard
                    }

                    /* Set Video */
                    bool showVideo = PlayerViewModel.Current.EnableVideo && !ViewModel.IsMiniMode;
                    if (VideoElement != null)
                    {
                        await SafelyRecreateVideoElement(showVideo);

                        if (showVideo)
                        {
                            var videoName = osuFile.Events.VideoInfo?.Filename;
                            if (videoName == null)
                            {
                                VideoElement.Source           = null;
                                VideoElementBorder.Visibility = Visibility.Hidden;
                            }
                            else
                            {
                                var vPath = Path.Combine(dir, videoName);
                                if (File.Exists(vPath))
                                {
                                    VideoElement.Source = new Uri(vPath);
                                    _videoOffset        = -(osuFile.Events.VideoInfo.Offset);
                                    if (_videoOffset >= 0)
                                    {
                                        _waitAction = () => { };
                                        _position   = TimeSpan.FromMilliseconds(_videoOffset);
                                    }
                                    else
                                    {
                                        _waitAction = () => { Thread.Sleep(TimeSpan.FromMilliseconds(-_videoOffset)); };
                                    }
                                }
                                else
                                {
                                    VideoElement.Source           = null;
                                    VideoElementBorder.Visibility = Visibility.Hidden;
                                }
                            }
                        }
                    }

                    /* Set Background */
                    if (osuFile.Events.BackgroundInfo != null)
                    {
                        var bgPath = Path.Combine(dir, osuFile.Events.BackgroundInfo.Filename);
                        BlurScene.Source = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null;
                        Thumb.Source     = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null;
                    }
                    else
                    {
                        BlurScene.Source = null;
                    }

                    /* Start Play */
                    switch (MainFrame.Content)
                    {
                    case RecentPlayPage recentPlayPage:
                        var item = recentPlayPage.DataModels.FirstOrDefault(k =>
                                                                            k.GetIdentity().Equals(nowIdentity));
                        recentPlayPage.RecentList.SelectedItem = item;
                        break;

                    case CollectionPage collectionPage:
                        collectionPage.MapList.SelectedItem =
                            collectionPage.ViewModel.Beatmaps.FirstOrDefault(k =>
                                                                             k.GetIdentity().Equals(nowIdentity));
                        break;
                    }

                    _videoPlay = play;
                    if (play)
                    {
                        if (showVideo && VideoElement?.Source != null)
                        {
                            // use event to control here.
                            //VideoPlay();
                            //App.HitsoundPlayer.Play();
                        }
                        else
                        {
                            audioPlayer.Play();
                        }
                    }

                    //if (!App.PlayerList.Entries.Any(k => k.GetIdentity().Equals(nowIdentity)))
                    //    App.PlayerList.Entries.Add(entry);
                    PlayerConfig.Current.CurrentPath = path;
                    PlayerConfig.SaveCurrent();

                    DbOperate.UpdateMap(nowIdentity);
                }
                catch (Exception ex)
                {
                    var result = MsgBox.Show(this, @"发生未处理的异常问题:" + (ex.InnerException ?? ex), Title,
                                             MessageBoxButton.OK, MessageBoxImage.Error);
                    if (result == MessageBoxResult.OK)
                    {
                        if (audioPlayer == null)
                        {
                            return;
                        }
                        if (audioPlayer.PlayerStatus != PlayerStatus.Playing)
                        {
                            await PlayNextAsync(false, true);
                        }
                    }

                    Console.WriteLine(ex);
                }
            }
            else
            {
                MsgBox.Show(this, @"所选文件不存在,可能是db没有及时更新。请关闭此播放器或osu后重试。",
                            Title, MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
        }
Пример #15
0
        static async Task Main(string[] args)
        {
            Configuration.Instance.SetLogger(LoggerFactory.Create(k => k.AddConsole()));

            //var path = "E:\\Games\\osu!\\Songs\\3198 Rhapsody - Emerald Sword\\" +
            //           //"1376486 Risshuu feat. Choko - Take\\" +
            //           "Rhapsody - Emerald Sword (Reikin) [net].osu";
            //var path = "E:\\Games\\osu!\\Songs\\take yf\\" +
            //           //"1376486 Risshuu feat. Choko - Take\\" +
            //           "Risshuu feat. Choko - Take (yf_bmp) [test].osu";
            var path = "F:\\milkitic\\Songs\\" +
                       "1376486 Risshuu feat. Choko - Take\\" +
                       "Risshuu feat. Choko - Take (yf_bmp) [Ta~ke take take take take take tatata~].osu";
            var folder  = Path.GetDirectoryName(path);
            var osuFile = await OsuFile.ReadFromFileAsync(path);

            if (!osuFile.ReadSuccess)
            {
                throw osuFile.ReadException;
            }

            var player = new OsuMixPlayer(osuFile);
            await player.Initialize();

            bool finished = false;

            player.PlayStatusChanged += status =>
            {
                if (status == PlayStatus.Finished)
                {
                    finished = true;
                }
            };
            await player.Play();

            var cts = new CancellationTokenSource();

            Task.Run(() =>
            {
                while (true)
                {
                    var i = Console.ReadLine();
                    if (i == "q")
                    {
                        cts.Cancel();
                        return;
                    }
                }
            });

            while (!cts.IsCancellationRequested && player.PlayStatus != PlayStatus.Finished)
            {
                Console.WriteLine(player.Position + "/" + player.Duration);
                Thread.Sleep(200);
            }

            await player.Stop();

            await player.DisposeAsync();

            Console.WriteLine("done");
        }
Пример #16
0
        public override void Measure() //todo: Will lead to NullReferenceException when recreated window on some maps: s/552702
        {
            if (!_isStart && _status != OsuModel.Status)
            {
                _isStart = true;
            }

            if (!_isStart)
            {
                return;
            }

            if (_crtMapFile != OsuModel.Idle.NowMap.FilenameFull)
            {
                string oldMapBg   = _crtMapBg;
                string oldMapPath = _crtMapPath;
                _crtMapFile = OsuModel.Idle.NowMap.FilenameFull;
                _crtMapBg   = OsuModel.Idle.NowMap.BackgroundFilename;
                _crtMapPath = OsuModel.Idle.NowMap.Folder;

                LogUtil.LogInfo((_crtMapBg == null).ToString());
                if (oldMapPath != _crtMapPath || oldMapBg != _crtMapBg)
                {
                    var currentBgPath = Path.Combine(_crtMapPath, OsuModel.Idle.NowMap.BackgroundFilename);
                    if (File.Exists(currentBgPath))
                    {
                        _oldBg        = _newBg;
                        _newBg        = RenderTarget.LoadBitmap(currentBgPath);
                        _lastBgIsNull = false;
                    }
                    else if (_defaultBg != null)
                    {
                        if (_lastBgIsNull)
                        {
                            return;
                        }
                        _oldBg        = _newBg;
                        _newBg        = _defaultBg;
                        _lastBgIsNull = true;
                    }
                    else
                    {
                        return;
                    }

                    _fixedRectOld = _fixedRect;

                    _fixedRect = GetBgPosition(_newBg.Size);
                    var size = Settings.Render.WindowSize;
                    if (_newBg != null)
                    {
                        _newBgObj = new BitmapObject(RenderTarget, _newBg, Origin.Default,
                                                     new Mathe.RawPoint(size.Width / 2, size.Height / 2));
                        _newBgObjEffect = new BitmapObject(RenderTarget, _newBg, Origin.Default,
                                                           new Mathe.RawPoint(size.Width / 2, size.Height / 2), true);
                    }
                    if (_oldBg != null)
                    {
                        _oldBgObj = new BitmapObject(RenderTarget, _oldBg, Origin.Default,
                                                     new Mathe.RawPoint(size.Width / 2, size.Height / 2));
                    }
                    _transformStyle = _rnd.Next(0, 3);
                    if (_sw.ElapsedMilliseconds < 600 && _sw.ElapsedMilliseconds != 0)
                    {
                        _transformStyle = 99;
                    }
                }

                try
                {
                    OsuFile file = OsuFile.ReadFromFileAsync(OsuModel.Idle.NowMap.FilenameFull).Result;
                    _barList  = file.TimingPoints.GetTimingBars();
                    _11List   = file.TimingPoints.GetTimings(1);
                    _kiaiList = file.TimingPoints.GetTimingKiais();
                }
                catch (NotSupportedException e)
                {
                    LogUtil.LogError(e.Message);
                    _barList  = new double[0];
                    _11List   = new double[0];
                    _kiaiList = new RangeValue <double> [0];
                }

                _sw.Restart();
            }
        }