private void tプレビューサウンドの作成()
        {
            Cスコア cスコア = TJAPlayer3.stage選曲.r現在選択中のスコア;

            if ((cスコア != null) && !string.IsNullOrEmpty(cスコア.譜面情報.strBGMファイル名) && TJAPlayer3.stage選曲.eフェーズID != CStage.Eフェーズ.選曲_NowLoading画面へのフェードアウト)
            {
                string strPreviewFilename = cスコア.ファイル情報.フォルダの絶対パス + cスコア.譜面情報.Presound;
                try
                {
                    strPreviewFilename = cスコア.ファイル情報.フォルダの絶対パス + cスコア.譜面情報.strBGMファイル名;
                    if (TJAPlayer3.ConfigIni.bBGM音を発声する)
                    {
                        this.sound = TJAPlayer3.Sound管理.tサウンドを生成する(strPreviewFilename, ESoundGroup.SongPlayback);
                    }

                    // 2018-08-27 twopointzero - DO attempt to load (or queue scanning) loudness metadata here.
                    //                           Initialization, song enumeration, and/or interactions may have
                    //                           caused background scanning and the metadata may now be available.
                    //                           If is not yet available then we wish to queue scanning.
                    var loudnessMetadata = cスコア.譜面情報.SongLoudnessMetadata
                                           ?? LoudnessMetadataScanner.LoadForAudioPath(strPreviewFilename);
                    TJAPlayer3.SongGainController.Set(cスコア.譜面情報.SongVol, loudnessMetadata, this.sound);

                    this.sound.t再生を開始する(true);

                    if (long再生位置 == -1)
                    {
                        this.long再生開始時のシステム時刻 = CSound管理.rc演奏用タイマ.nシステム時刻ms;
                        this.long再生位置         = cスコア.譜面情報.nデモBGMオフセット;
                        this.sound.t再生位置を変更する(cスコア.譜面情報.nデモBGMオフセット);
                        this.long再生位置 = CSound管理.rc演奏用タイマ.nシステム時刻ms - this.long再生開始時のシステム時刻;
                    }
                    //if( long再生位置 == this.sound.n総演奏時間ms - 10 )
                    //    this.long再生位置 = -1;

                    this.str現在のファイル名 = strPreviewFilename;
                    this.tBGMフェードアウト開始();
                    Trace.TraceInformation("プレビューサウンドを生成しました。({0})", strPreviewFilename);
                    #region [ DTXMania(コメントアウト) ]
                    //this.sound = CDTXMania.Sound管理.tサウンドを生成する( strPreviewFilename );
                    //this.sound.t再生を開始する( true );
                    //this.str現在のファイル名 = strPreviewFilename;
                    //this.tBGMフェードアウト開始();
                    //Trace.TraceInformation( "プレビューサウンドを生成しました。({0})", strPreviewFilename );
                    #endregion
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.ToString());
                    Trace.TraceError("プレビューサウンドの生成に失敗しました。({0})", strPreviewFilename);
                    if (this.sound != null)
                    {
                        this.sound.Dispose();
                    }
                    this.sound = null;
                }
            }
        }
Esempio n. 2
0
        private async void tプレビューサウンドの作成()
        {
            Cスコア cスコア = TJAPlayer3.stage選曲.act曲リスト.r現在選択中のスコア;

            if ((cスコア != null) && !string.IsNullOrEmpty(cスコア.譜面情報.strBGMファイル名) && TJAPlayer3.stage選曲.eフェーズID != CStage.Eフェーズ.選曲_NowLoading画面へのフェードアウト)
            {
                string strPreviewFilename = cスコア.ファイル情報.フォルダの絶対パス + cスコア.譜面情報.strBGMファイル名;
                try
                {
                    // 2020.06.15 Mr-Ojii TJAP2fPCより拝借-----------
                    // 2019.03.22 kairera0467 簡易マルチスレッド化
                    Task <CSound> task = Task.Run <CSound>(() => {
                        token = new CancellationTokenSource();
                        return(this.tプレビューサウンドの作成MT(strPreviewFilename));
                    });
                    CSound tmps = await task;

                    token.Token.ThrowIfCancellationRequested();
                    this.tサウンドの停止MT();


                    this.sound = tmps;
                    //------------

                    // 2018-08-27 twopointzero - DO attempt to load (or queue scanning) loudness metadata here.
                    //                           Initialization, song enumeration, and/or interactions may have
                    //                           caused background scanning and the metadata may now be available.
                    //                           If is not yet available then we wish to queue scanning.
                    var loudnessMetadata = cスコア.譜面情報.SongLoudnessMetadata
                                           ?? LoudnessMetadataScanner.LoadForAudioPath(strPreviewFilename);
                    TJAPlayer3.SongGainController.Set(cスコア.譜面情報.SongVol, loudnessMetadata, this.sound);

                    this.long再生位置 = -1;
                    this.sound.t再生を開始する(true);
                    if (this.long再生位置 == -1)
                    {
                        this.long再生開始時のシステム時刻 = CSound管理.rc演奏用タイマ.nシステム時刻ms;
                        this.long再生位置         = cスコア.譜面情報.nデモBGMオフセット;
                        this.sound.t再生位置を変更する(cスコア.譜面情報.nデモBGMオフセット);
                        this.long再生位置 = CSound管理.rc演奏用タイマ.nシステム時刻ms - this.long再生開始時のシステム時刻;
                    }

                    this.str現在のファイル名 = strPreviewFilename;
                    this.tBGMフェードアウト開始();
                    Trace.TraceInformation("プレビューサウンドを生成しました。({0})", strPreviewFilename);
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.ToString());
                    Trace.TraceError("プレビューサウンドの生成に失敗しました。({0})", strPreviewFilename);
                    if (this.sound != null)
                    {
                        this.sound.Dispose();
                    }
                    this.sound = null;
                }
            }
        }