/// 入力:
/// StrokeStyleT.演奏スコア(ビュアーモードなら null でも可)
/// StrokeStyleT.ユーザ管理.現在選択されているユーザ(譜面スクロール速度の倍率)
- /// StrokeStyleT.ビュアーモードである
/// StrokeStyleT.Wasapiデバイス.AudioClock
+ /// StrokeStyleT.ビュアーモードである
+ /// StrokeStyleT.最後に取得したビュアーメッセージ
///
/// 出力:
/// (A) クリアまたは失敗した場合
this.スクロール譜面.ヒット判定数加算 = ( hitType ) => {
this.ヒットした回数[ hitType ]++;
};
- this.スクロール譜面.背景動画再生開始 = () => {
+ this.スクロール譜面.背景動画の長さsec = () => {
+ return ( null != this.BGM ) ? this.BGM.長さsec : 0.0;
+ };
+ this.スクロール譜面.背景動画再生開始 = ( 開始位置sec ) => {
+ this.背景動画.再生を開始する( 開始位置sec );
this.背景動画開始済み.Value = true;
+ if( null != this.BGM )
+ {
+ this.BGM.位置sec = 開始位置sec;
+ this.BGM?.Play();
+ }
+ this.BGM再生開始済み = true;
};
this.スクロール譜面.チップヒット = ( chip ) => {
this.回転羽.発火する( chip.チップ種別 );
- this.ドラムサウンド.発声する( chip.チップ種別, chip.音量 * 0.25f );
+ if( this.Autoチップのドラム音を再生する )
+ this.ドラムサウンド.発声する( chip.チップ種別, chip.音量 * 0.25f );
};
this.スクロール譜面.ステージクリア = () => {
- this.現在のフェーズ.Value = ( StrokeStyleT.ビュアーモードである ) ? フェーズ.ビュアーメッセージ待機中 : フェーズ.クリアor失敗;
+ this.現在のフェーズ.Value = フェーズ.クリアor失敗;
};
this.スクロール譜面.リアルタイム演奏時刻sec = () => {
return this.現在の演奏時刻secを返す();
// 動画を子リストに追加。
this.子リスト.Add( this.背景動画 = new 動画( StrokeStyleT.演奏スコア.背景動画ファイル名, StrokeStyleT.Config.動画デコーダのキューサイズ ) );
- // 動画から BGM を作成してミキサーに追加。
- this.BGM = new FDK.メディア.サウンド.WASAPI排他.Sound();
- this.BGM.ファイルから作成する( StrokeStyleT.演奏スコア.背景動画ファイル名 );
- StrokeStyleT.Wasapiデバイス.サウンドをミキサーに追加する( this.BGM ); // 作成に失敗した Sound を追加しても鳴らないだけなので、ノーチェックで大丈夫。
+ // 動画から BGM を作成。
+ this.BGM = StrokeStyleT.サウンドデバイス.CreateSound( StrokeStyleT.演奏スコア.背景動画ファイル名 );
}
else
{
foreach( var 判定 in typeof( ヒット判定種別 ).GetEnumValues() )
this.ヒットした回数[ (ヒット判定種別) 判定 ] = 0;
- this.現在のフェーズ.Value = ( StrokeStyleT.ビュアーモードである ) ? フェーズ.ビュアーメッセージ待機中 : フェーズ.演奏中;
+ // 最初のフェーズを設定する。
+ if( StrokeStyleT.ビュアーモードである )
+ {
+ // 演奏スコアが設定済みなら演奏開始。それ以外ならメッセージ待機へ。
+ this.現在のフェーズ.Value = ( null != StrokeStyleT.演奏スコア ) ? フェーズ.演奏中 : フェーズ.ビュアーメッセージ待機中;
+ }
+ else
+ {
+ // 演奏開始。
+ this.現在のフェーズ.Value = フェーズ.演奏中;
+ }
+
this.活性化した直後である = true;
}
protected override void On非活性化( デバイスリソース dr )
{
this.活性化した直後である = false;
this.FPS = new FDK.カウンタ.FPS();
- this.演奏開始時刻sec = this.サウンドタイマ.現在のデバイス位置secを取得する( StrokeStyleT.Wasapiデバイス.AudioClock );
+
+ double 演奏開始位置の先頭からの時間sec = 0.0;
+ int 演奏開始小節番号 = 0;
+ var msg = StrokeStyleT.最後に取得したビュアーメッセージ;
+ if( null != msg )
+ {
+ 演奏開始小節番号 = msg.演奏開始小節番号;
+ this.Autoチップのドラム音を再生する = msg.ドラムチップ発声;
+ }
+ 演奏開始位置の先頭からの時間sec = this.スクロール譜面.演奏開始小節番号を設定しその時刻secを返す( 演奏開始小節番号 );
+
+ long position, qpcPosition, frequency;
+ StrokeStyleT.サウンドデバイス.GetClock( out position, out qpcPosition, out frequency );
+
+ this.演奏開始時刻sec =
+ this.サウンドタイマ.現在のデバイス位置secを取得する( position, qpcPosition, frequency )
+ - 演奏開始位置の先頭からの時間sec; // 「+」じゃないので注意!
}
//----------------
#endregion
// 背景動画が再生されているのにBGMがまだ再生されていないなら、再生を開始する。
if( false == this.BGM再生開始済み )
{
- this.BGM?.再生を開始する();
+ this.BGM?.Play();
this.BGM再生開始済み = true;
}
}
this.スクロール譜面.チップを進行描画する( dr, 演奏時刻sec );
this.回転羽.進行描画する( dr );
this.FPS.VPSをカウントする();
- this.FPS.FPSをカウントする();
this.FPS画像.表示文字列 = $"VPS: {this.FPS.現在のVPS.ToString()} / FPS: {this.FPS.現在のFPS.ToString()}";
this.FPS画像.進行描画する( dr, 0f, 0f );
// ESC 押下 → キャンセル
if( StrokeStyleT.キーボード入力.キーが押された( SharpDX.DirectInput.Key.Escape ) &&
- ( false == StrokeStyleT.ビュアーモードである ) )
+ StrokeStyleT.ビュアーモードではない ) // ビュアーモードでは無効。
{
this.BGMを解放する();
this.現在のフェーズ.Value = フェーズ.キャンセル;
Math.Max( StrokeStyleT.ユーザ管理.現在選択されているユーザ.譜面スクロール速度の倍率 - 0.5, 0.5 ); // 最小 0.5
}
}
+ public void 演奏を停止する()
+ {
+ this.スクロール譜面?.演奏を停止する();
+ this.背景動画開始済み.Value = false;
+ this.BGMを解放する();
+ }
public void BGMを解放する()
{
if( null != this.BGM ) // 背景動画がなければ BGM も null である
{
- StrokeStyleT.Wasapiデバイス.サウンドをミキサーから削除する( this.BGM );
+ this.BGM.Stop();
FDK.Utilities.解放する( ref this.BGM );
}
}
protected bool BGM再生開始済み = false;
protected FDK.同期.RWLock<double> 現在進行描画中の譜面スクロール速度の倍率 = new FDK.同期.RWLock<double>( 0.0 );
protected double 演奏開始時刻sec = 0.0;
- protected readonly FDK.メディア.サウンド.WASAPI排他.SoundTimer サウンドタイマ = new FDK.メディア.サウンド.WASAPI排他.SoundTimer();
+ protected bool Autoチップのドラム音を再生する = true;
+ protected readonly FDK.メディア.サウンド.WASAPI.SoundTimer サウンドタイマ = new FDK.メディア.サウンド.WASAPI.SoundTimer();
protected readonly SST.ステージ.演奏.コンボ コンボ;
protected readonly SST.ステージ.演奏.レーンフレーム レーンフレーム;
protected readonly SST.ステージ.演奏.スクロール譜面 スクロール譜面;
/// 解放は、演奏ステージクラスの非活性化後に、外部から行われる。
/// <see cref="SST.ステージ.演奏.演奏ステージ.BGMを解放する"/>
/// </remarks>
- protected FDK.メディア.サウンド.WASAPI排他.Sound BGM = null;
+ protected FDK.メディア.サウンド.WASAPI.Sound BGM = null;
protected FDK.カウンタ.FPS FPS = null;
/// <summary>
/// 動的子Activity。背景動画を再生しない場合は null のまま。
private double 現在の演奏時刻secを返す()
{
- return this.サウンドタイマ.現在のデバイス位置secを取得する( StrokeStyleT.Wasapiデバイス.AudioClock ) - this.演奏開始時刻sec;
+ long position, qpcPosition, frequency;
+ StrokeStyleT.サウンドデバイス.GetClock( out position, out qpcPosition, out frequency );
+
+ return this.サウンドタイマ.現在のデバイス位置secを取得する( position, qpcPosition, frequency ) - this.演奏開始時刻sec;
}
}
}