2 using System.Collections.Generic;
\r
4 using System.Diagnostics;
\r
6 using System.Threading;
\r
12 public class CDTXVmode
\r
14 public enum ECommand
\r
31 /// プレビューサウンドの再生が発生した
\r
42 public bool Refreshed
\r
51 public int nStartBar
\r
58 /// DTXファイルの再読み込みが必要かどうか
\r
60 public bool NeedReload
\r
64 // private set; // 本来はprivate setにすべきだが、デバッグが簡単になるので、しばらくはprivateなしのままにする。
\r
70 public ECommand Command
\r
76 public ESoundDeviceType soundDeviceType
\r
81 public int nASIOdevice
\r
87 /// 前回からサウンドデバイスが変更されたか
\r
89 public bool ChangedSoundDevice
\r
95 public string filename
\r
103 public string previewFilename
\r
108 public int previewVolume
\r
113 public int previewPan
\r
123 public bool lastGRmode
\r
128 public bool TimeStretch
\r
133 public bool lastTimeStretch
\r
138 public bool VSyncWait
\r
143 public bool lastVSyncWait
\r
155 this.last_path = "";
\r
156 this.last_timestamp = DateTime.MinValue;
\r
157 this.Enabled = false;
\r
158 this.nStartBar = 0;
\r
159 this.Refreshed = false;
\r
160 this.NeedReload = false;
\r
161 this.previewFilename = "";
\r
162 this.GRmode = false;
\r
163 this.lastGRmode = false;
\r
164 this.TimeStretch = false;
\r
165 this.lastTimeStretch = false;
\r
166 this.VSyncWait = true;
\r
167 this.lastVSyncWait = true;
\r
171 /// DTXファイルのリロードが必要かどうか判定する
\r
173 /// <param name="filename">DTXファイル名</param>
\r
174 /// <returns>再読込が必要ならtrue</returns>
\r
175 /// <remarks>プロパティNeedReloadにも結果が入る</remarks>
\r
176 /// <remarks>これを呼び出すたびに、Refreshedをtrueにする</remarks>
\r
177 /// <exception cref="FileNotFoundException"></exception>
\r
178 public bool bIsNeedReloadDTX( string filename )
\r
180 if ( !File.Exists( filename ) ) // 指定したファイルが存在しないなら例外終了
\r
182 Trace.TraceError( "ファイルが見つかりません。({0})", filename );
\r
183 throw new FileNotFoundException();
\r
187 this.Refreshed = true;
\r
189 // 前回とファイル名が異なるか、タイムスタンプが更新されているか、
\r
190 // GRmode等の設定を変更したなら、DTX要更新
\r
191 DateTime current_timestamp = File.GetLastWriteTime( filename );
\r
192 if ( last_path != filename || current_timestamp > last_timestamp ||
\r
193 this.lastGRmode != this.GRmode || this.lastTimeStretch != this.TimeStretch || this.lastVSyncWait != this.VSyncWait )
\r
195 this.last_path = filename;
\r
196 this.last_timestamp = current_timestamp;
\r
197 this.lastGRmode = this.GRmode;
\r
198 this.lastTimeStretch = this.TimeStretch;
\r
199 this.lastVSyncWait = this.VSyncWait;
\r
201 this.NeedReload = true;
\r
204 this.NeedReload = false;
\r
211 /// <param name="arg"></param>
\r
212 /// <param name="nStartBar"></param>
\r
213 /// <param name="command"></param>
\r
214 /// <returns>DTXV用の引数であればtrue</returns>
\r
215 /// <remarks>内部でEnabled, nStartBar, Command, NeedReload, filename, last_path, last_timestampを設定する</remarks>
\r
216 public bool ParseArguments( string arg )
\r
218 bool ret = false, analyzing = true;
\r
219 this.nStartBar = 0;
\r
221 if ( arg != null )
\r
223 //Trace.TraceInformation( "arg=" + arg );
\r
224 while ( analyzing )
\r
230 else if ( arg.StartsWith( "-V", StringComparison.OrdinalIgnoreCase ) ) // サウンド再生
\r
232 // -Vvvv,ppp,"filename"の形式。 vvv=volume, ppp=pan.
\r
233 this.Enabled = true;
\r
234 this.Command = ECommand.Preview;
\r
235 this.Refreshed = true;
\r
237 arg = arg.Substring( 2 );
\r
239 int pVol = arg.IndexOf( ',' );
\r
240 //Trace.TraceInformation( "pVol=" + pVol );
\r
241 string strVol = arg.Substring( 0, pVol );
\r
242 //Trace.TraceInformation( "strVol=" + strVol );
\r
243 this.previewVolume = Convert.ToInt32( strVol );
\r
244 //Trace.TraceInformation( "previewVolume=" + previewVolume );
\r
245 int pPan = arg.IndexOf( ',', pVol + 1 );
\r
246 //Trace.TraceInformation( "pPan=" + pPan );
\r
247 string strPan = arg.Substring( pVol + 1, pPan - pVol - 1 );
\r
248 //Trace.TraceInformation( "strPan=" + strPan );
\r
249 this.previewPan = Convert.ToInt32( strPan );
\r
250 //Trace.TraceInformation( "previewPan=" + previewPan );
\r
252 arg = arg.Substring( pPan + 1 );
\r
253 arg = arg.Trim( new char[] { '\"' } );
\r
254 this.previewFilename = arg;
\r
257 // -S -Nxxx filename
\r
258 else if ( arg.StartsWith( "-S", StringComparison.OrdinalIgnoreCase ) ) // DTXV再生停止
\r
260 this.Enabled = true;
\r
261 this.Command = ECommand.Stop;
\r
262 this.Refreshed = true;
\r
264 arg = arg.Substring( 2 );
\r
266 else if ( arg.StartsWith( "-D", StringComparison.OrdinalIgnoreCase ) )
\r
269 arg = arg.Substring( 2 ); // -D を削除
\r
270 switch ( arg[ 0 ] )
\r
272 #region [ DirectSound ]
\r
274 if ( this.soundDeviceType != ESoundDeviceType.DirectSound )
\r
276 this.ChangedSoundDevice = true;
\r
277 this.soundDeviceType = ESoundDeviceType.DirectSound;
\r
281 this.ChangedSoundDevice = false;
\r
283 arg = arg.Substring( 1 );
\r
288 if ( this.soundDeviceType != ESoundDeviceType.ExclusiveWASAPI )
\r
290 this.ChangedSoundDevice = true;
\r
291 this.soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
\r
295 this.ChangedSoundDevice = false;
\r
297 arg = arg.Substring( 1 );
\r
302 if ( this.soundDeviceType != ESoundDeviceType.ASIO )
\r
304 this.ChangedSoundDevice = true;
\r
305 this.soundDeviceType = ESoundDeviceType.ASIO;
\r
309 this.ChangedSoundDevice = false;
\r
311 arg = arg.Substring( 1 );
\r
313 int nAsioDev = 0, p = 0;
\r
317 if ( '0' <= c && c <= '9' )
\r
320 nAsioDev += c - '0';
\r
322 arg = arg.Substring( 1 );
\r
330 if ( this.nASIOdevice != nAsioDev )
\r
332 this.ChangedSoundDevice = true;
\r
333 this.nASIOdevice = nAsioDev;
\r
338 #region [ GRmode, TimeStretch, VSyncWait ]
\r
340 // Reload判定は、-Nのところで行う
\r
341 this.GRmode = ( arg[ 0 ] == 'Y' );
\r
342 this.TimeStretch = ( arg[ 1 ] == 'Y' );
\r
343 this.VSyncWait = ( arg[ 2 ] == 'Y' );
\r
345 arg = arg.Substring( 3 );
\r
349 else if ( arg.StartsWith( "-N", StringComparison.OrdinalIgnoreCase ) )
\r
351 this.Enabled = true;
\r
352 this.Command = ECommand.Play;
\r
355 arg = arg.Substring( 2 ); // "-N"を除去
\r
356 string[] p = arg.Split( new char[] { ' ' } );
\r
357 this.nStartBar = int.Parse( p[ 0 ] ); // 再生開始小節
\r
358 if ( this.nStartBar < 0 )
\r
360 this.nStartBar = -1;
\r
363 int startIndex = arg.IndexOf( ' ' );
\r
364 string filename = arg.Substring( startIndex + 1 ); // 再生ファイル名(フルパス) これで引数が終わっていることを想定
\r
367 filename = filename.Trim( new char[] { '\"' } );
\r
368 bIsNeedReloadDTX( filename );
\r
370 catch // 指定ファイルが存在しない
\r
382 /// Viewer関連の設定のみを、Config.iniに書き出す
\r
384 public void tUpdateConfigIni()
\r
386 CConfigIni cc = new CConfigIni();
\r
387 string path = CDTXMania.strEXEのあるフォルダ + "Config.ini";
\r
388 if ( File.Exists( path ) )
\r
392 cc.tファイルから読み込み( path );
\r
396 //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
\r
400 cc.nViewerScrollSpeed = CDTXMania.ConfigIni.n譜面スクロール速度;
\r
401 cc.bViewerShowDebugStatus = CDTXMania.ConfigIni.b演奏情報を表示する;
\r
402 cc.bViewerVSyncWait = CDTXMania.ConfigIni.b垂直帰線待ちを行う;
\r
403 cc.bViewerTimeStretch = CDTXMania.ConfigIni.bTimeStretch;
\r
404 cc.bViewerDrums有効 = CDTXMania.ConfigIni.bDrums有効;
\r
405 cc.bViewerGuitar有効 = CDTXMania.ConfigIni.bGuitar有効;
\r
410 private string last_path;
\r
411 private DateTime last_timestamp;
\r