OSDN Git Service

現在の小節位置からの再生に対応。ただし、BGMや動画の途中再生はまだ。
authorくまかみ工房 <kumakamikoubou@gmail.com>
Mon, 7 Nov 2016 08:35:48 +0000 (17:35 +0900)
committerくまかみ工房 <kumakamikoubou@gmail.com>
Mon, 7 Nov 2016 08:35:48 +0000 (17:35 +0900)
SSTFEditor/メインフォーム.cs
StrokeStyleT/StrokeStyleT.cs
StrokeStyleT/ステージ/演奏/スクロール譜面.cs
StrokeStyleT/ステージ/演奏/演奏ステージ.cs

index 9b448d9..98bc2ab 100644 (file)
@@ -302,7 +302,7 @@ namespace SSTFEditor
                        this.SSTサービス = null;    // サービスは解放処理なし
                        try
                        {
-                               this.SSTファクトリ.Close();
+                               this.SSTファクトリ?.Close();
                        }
                        catch( CommunicationException )
                        {
index 607fe88..aeea031 100644 (file)
@@ -53,6 +53,11 @@ namespace SST
                        get { return !StrokeStyleT.ビュアーモードである; }
                        set { StrokeStyleT.ビュアーモードである = !value; }
                }
+               public static SST.ViewerMessage 最後に取得したビュアーメッセージ
+               {
+                       get;
+                       protected set;
+               } = null;
                public static FDK.入力.Keyboard キーボード入力
                {
                        get { return StrokeStyleT.bs_キーボード入力; }
@@ -587,6 +592,8 @@ namespace SST
                                                        //----------------
                                                        var msg = this.ビュアーメッセージを取得する();
 
+                                                       StrokeStyleT.最後に取得したビュアーメッセージ = msg;    // 保存する。(演奏ステージから参照する)
+
                                                        if( null != msg )
                                                        {
                                                                #region " (A) 演奏開始 "
@@ -596,33 +603,22 @@ namespace SST
                                                                        this.演奏ステージ.現在のフェーズ.Value == ステージ.演奏.演奏ステージ.フェーズ.演奏中 )
                                                                        )
                                                                {
-                                                                       // MusicNode を作成する。
-                                                                       var node = (SST.曲.MusicNode) null;
                                                                        try
                                                                        {
-                                                                               node = new 曲.MusicNode( msg.曲ファイルパス );
-                                                                       }
-                                                                       catch
-                                                                       {
-                                                                               FDK.Log.ERROR( $"MusicNode の作成に失敗しました。" );
-                                                                               node = null;
-                                                                       }
+                                                                               // MusicNode を作成し、現在選択されているノードとして登録する。
+                                                                               StrokeStyleT.曲ツリー管理.現在選択されているノード = new 曲.MusicNode( msg.曲ファイルパス );
 
-                                                                       // 作成に成功したときのみ次へ進む。
-                                                                       if( null != node )
-                                                                       {
                                                                                // 演奏を停止する。
                                                                                this.演奏ステージ.非活性化する( this.デバイスリソース );
                                                                                this.演奏ステージ.BGMを解放する();
-
-                                                                               // 現在選択されているノードとして登録する。
-                                                                               StrokeStyleT.曲ツリー管理.現在選択されているノード = node;
-
-                                                                               // todo: 演奏開始小節番号を保存し、反映する。
-
+                                                                                
                                                                                // 曲読込ステージへ。
                                                                                this.現在のステージ = this.曲読込ステージ;
-                                                                               this.曲読込ステージ.活性化する( this.デバイスリソース );
+                                                                               this.現在のステージ.活性化する( this.デバイスリソース );
+                                                                       }
+                                                                       catch
+                                                                       {
+                                                                               FDK.Log.ERROR( $"MusicNode の作成に失敗しました。" );
                                                                        }
                                                                }
                                                                //----------------
index df031bc..208b44f 100644 (file)
@@ -64,6 +64,31 @@ namespace SST.ステージ.演奏
                {
                        this.画面の高さdpx = dr.設計画面サイズdpx.Height;
                }
+               public double 演奏開始小節番号を設定しその時刻secを返す( int 演奏開始小節番号 )
+               {
+                       var スコア = StrokeStyleT.演奏スコア;
+
+                       if( null == スコア )
+                               return 0.0;
+
+                       for( int i = 0; i < スコア.チップリスト.Count; i++ )
+                       {
+                               var チップ = スコア.チップリスト[ i ];
+
+                               if( チップ.小節番号 < 演奏開始小節番号 )
+                               {
+                                       チップ.ヒット済みの状態にする();
+                               }
+                               else
+                               {
+                                       this.描画開始チップ番号 = i;
+                                       return チップ.発声時刻sec - 0.5; // ちょっと早めの時刻を返す。
+                               }
+                       }
+
+                       return 0.0;
+               }
+
                public void 演奏を停止する()
                {
                        this.描画開始チップ番号 = -1;
index a4a1d71..2f36754 100644 (file)
@@ -12,8 +12,9 @@ namespace SST.ステージ.演奏
        /// 入力:
        ///  StrokeStyleT.演奏スコア(ビュアーモードなら null でも可)
        ///  StrokeStyleT.ユーザ管理.現在選択されているユーザ(譜面スクロール速度の倍率)
-       ///  StrokeStyleT.ビュアーモードである
        ///  StrokeStyleT.Wasapiデバイス.AudioClock
+       ///  StrokeStyleT.ビュアーモードである
+       ///  StrokeStyleT.最後に取得したビュアーメッセージ
        ///  
        /// 出力:
        ///  (A) クリアまたは失敗した場合
@@ -150,7 +151,16 @@ namespace SST.ステージ.演奏
                        {
                                this.活性化した直後である = false;
                                this.FPS = new FDK.カウンタ.FPS();
-                               this.演奏開始時刻sec = this.サウンドタイマ.現在のデバイス位置secを取得する( StrokeStyleT.Wasapiデバイス.AudioClock );
+
+                               double 演奏開始位置の先頭からの時間sec = 0.0;
+                               var msg = StrokeStyleT.最後に取得したビュアーメッセージ;
+                               if( null != msg )
+                               {
+                                       演奏開始位置の先頭からの時間sec = this.スクロール譜面.演奏開始小節番号を設定しその時刻secを返す( msg.演奏開始小節番号 );
+                               }
+                               this.演奏開始時刻sec = 
+                                       this.サウンドタイマ.現在のデバイス位置secを取得する( StrokeStyleT.Wasapiデバイス.AudioClock ) -        // '+' じゃないので注意!
+                                       演奏開始位置の先頭からの時間sec;
                        }
                        //----------------
                        #endregion