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
229 else if (arg.StartsWith("-V", StringComparison.OrdinalIgnoreCase)) // サウンド再生
\r
231 // -Vvvv,ppp,"filename"の形式。 vvv=volume, ppp=pan.
\r
232 this.Enabled = true;
\r
233 this.Command = ECommand.Preview;
\r
234 this.Refreshed = true;
\r
236 arg = arg.Substring(2);
\r
238 int pVol = arg.IndexOf(','); //Trace.TraceInformation( "pVol=" + pVol );
\r
239 string strVol = arg.Substring(0, pVol); //Trace.TraceInformation( "strVol=" + strVol );
\r
240 this.previewVolume = Convert.ToInt32(strVol); //Trace.TraceInformation( "previewVolume=" + previewVolume );
\r
241 int pPan = arg.IndexOf(',', pVol + 1); //Trace.TraceInformation( "pPan=" + pPan );
\r
242 string strPan = arg.Substring(pVol + 1, pPan - pVol - 1); //Trace.TraceInformation( "strPan=" + strPan );
\r
243 this.previewPan = Convert.ToInt32(strPan); //Trace.TraceInformation( "previewPan=" + previewPan );
\r
245 arg = arg.Substring(pPan + 1);
\r
246 arg = arg.Trim(new char[] { '\"' });
\r
247 this.previewFilename = arg;
\r
250 // -S -Nxxx filename
\r
251 else if (arg.StartsWith("-S", StringComparison.OrdinalIgnoreCase)) // DTXV再生停止
\r
253 this.Enabled = true;
\r
254 this.Command = ECommand.Stop;
\r
255 this.Refreshed = true;
\r
257 arg = arg.Substring(2);
\r
259 else if (arg.StartsWith("-D", StringComparison.OrdinalIgnoreCase))
\r
262 arg = arg.Substring(2); // -D を削除
\r
265 #region [ DirectSound ]
\r
267 if (this.soundDeviceType != ESoundDeviceType.DirectSound)
\r
269 this.ChangedSoundDevice = true;
\r
270 this.soundDeviceType = ESoundDeviceType.DirectSound;
\r
274 this.ChangedSoundDevice = false;
\r
276 arg = arg.Substring(1);
\r
281 if (this.soundDeviceType != ESoundDeviceType.ExclusiveWASAPI)
\r
283 this.ChangedSoundDevice = true;
\r
284 this.soundDeviceType = ESoundDeviceType.ExclusiveWASAPI;
\r
288 this.ChangedSoundDevice = false;
\r
290 arg = arg.Substring(1);
\r
295 if (this.soundDeviceType != ESoundDeviceType.ASIO)
\r
297 this.ChangedSoundDevice = true;
\r
298 this.soundDeviceType = ESoundDeviceType.ASIO;
\r
302 this.ChangedSoundDevice = false;
\r
304 arg = arg.Substring(1);
\r
306 int nAsioDev = 0, p = 0;
\r
310 if ('0' <= c && c <= '9')
\r
313 nAsioDev += c - '0';
\r
315 arg = arg.Substring(1);
\r
323 if (this.nASIOdevice != nAsioDev)
\r
325 this.ChangedSoundDevice = true;
\r
326 this.nASIOdevice = nAsioDev;
\r
331 #region [ GRmode, TimeStretch, VSyncWait ]
\r
333 // Reload判定は、-Nのところで行う
\r
334 this.GRmode = (arg[0] == 'Y');
\r
335 this.TimeStretch = (arg[1] == 'Y');
\r
336 this.VSyncWait = (arg[2] == 'Y');
\r
338 arg = arg.Substring(3);
\r
342 else if (arg.StartsWith("-N", StringComparison.OrdinalIgnoreCase))
\r
344 this.Enabled = true;
\r
345 this.Command = ECommand.Play;
\r
348 arg = arg.Substring(2); // "-N"を除去
\r
349 string[] p = arg.Split(new char[] { ' ' });
\r
350 this.nStartBar = int.Parse(p[0]); // 再生開始小節
\r
351 if (this.nStartBar < 0)
\r
353 this.nStartBar = -1;
\r
356 int startIndex = arg.IndexOf(' ');
\r
357 string filename = arg.Substring(startIndex + 1); // 再生ファイル名(フルパス) これで引数が終わっていることを想定
\r
360 filename = filename.Trim(new char[] { '\"' });
\r
361 bIsNeedReloadDTX(filename);
\r
363 catch // 指定ファイルが存在しない
\r
375 //string[] s = { "Stop", "Play", "Preview" };
\r
376 //Trace.TraceInformation( "Command: " + s[ (int) this.Command ] );
\r
381 /// Viewer関連の設定のみを更新して、Config.iniに書き出す
\r
383 public void tUpdateConfigIni()
\r
385 /// Viewer関連の設定のみを更新するために、
\r
386 /// 1. 現在のconfig.ini相当の情報を、別変数にコピーしておく
\r
387 /// 2. config.iniを読み込みなおす
\r
388 /// 3. 別変数のコピーから、Viewer関連の設定を、configに入れ込む
\r
389 /// 4. Config.iniを保存する
\r
391 CConfigXml ConfigIni_backup = (CConfigXml) CDTXMania.Instance.ConfigIni.Clone(); // #36612 2016.9.12 yyagi
\r
392 CDTXMania.Instance.LoadConfig();
\r
394 // CConfigIni cc = new CConfigIni();
\r
395 //string path = CDTXMania.Instance.strEXEのあるフォルダ + "Config.ini";
\r
396 //if (File.Exists(path))
\r
398 // FileInfo fi = new FileInfo(path);
\r
399 // if (fi.Length > 0) // Config.iniが0byteだったなら、読み込まない
\r
403 // CDTXMania..tファイルから読み込み(path);
\r
407 // //ConfigIni = new CConfigIni(); // 存在してなければ新規生成
\r
413 for (EPart inst = EPart.Drums; inst <= EPart.Bass; ++inst)
\r
415 CDTXMania.Instance.ConfigIni.nViewerScrollSpeed[inst].Value = ConfigIni_backup.nScrollSpeed[inst];
\r
417 CDTXMania.Instance.ConfigIni.bViewerShowDebugStatus.Value = ConfigIni_backup.bDebugInfo;
\r
418 CDTXMania.Instance.ConfigIni.bViewerVSyncWait.Value = ConfigIni_backup.bVSyncWait;
\r
419 CDTXMania.Instance.ConfigIni.bViewerTimeStretch.Value = ConfigIni_backup.bTimeStretch;
\r
420 CDTXMania.Instance.ConfigIni.bViewerDrumsActive.Value = ConfigIni_backup.bDrums有効;
\r
421 CDTXMania.Instance.ConfigIni.bViewerGuitarActive.Value = ConfigIni_backup.bGuitar有効;
\r
423 CDTXMania.Instance.ConfigIni.rcViewerWindow.W = ConfigIni_backup.rcWindow.W;
\r
424 CDTXMania.Instance.ConfigIni.rcViewerWindow.H = ConfigIni_backup.rcWindow.H;
\r
425 CDTXMania.Instance.ConfigIni.rcViewerWindow.X = ConfigIni_backup.rcWindow.X;
\r
426 CDTXMania.Instance.ConfigIni.rcViewerWindow.Y = ConfigIni_backup.rcWindow.Y;
\r
428 CDTXMania.Instance.SaveConfig();
\r
430 ConfigIni_backup = null;
\r
433 private string last_path;
\r
434 private DateTime last_timestamp;
\r