/// <summary> /// 描画処理 /// </summary> /// <param name="cdjdata"></param> private static void DoDraw(CdjData cdjdata, InputState inputstate) { //4拍子の線 DrawBeatline.Draw(); //判定ラインの下側の絵 DrawLowFrame.Draw(); //MyDraw.SetDrawBlendMode(DX.DX_BLENDMODE_ALPHA, 228); //フェーダーの描画(あとで) drawfader.draw(inputstate); //キューイングのディスクとか再生ラインとかカットイン矢印とかを描く foreach (DiscQueCutData o in cdjdata.lstquedata) { o.Draw(); } //スクラッチユニット(シャカシャカで1つ)を1個ずつ描く foreach (ScratchUnit scunit in cdjdata.lstscratchunit) { scunit.Draw(); } DrawEffect.Draw(); // 裏画面の内容を表画面に反映する DX.ScreenFlip(); }
public static CdjData TestMakeCDJData() { CdjData t = CdjXmlData.Read("c:/cdj.xml"); CdjXmlData cdjXML; cdjXML = new CdjXmlData(120, "test", 5); cdjXML.SOUND = "Crackin'DJ_02.mp3"; cdjXML.AddQue(1, 0, 0); cdjXML.AddScratch(192 + 24, new List <int> { 12, -12, 12, -12 }); cdjXML.AddScratch(192 + 96, new List <int> { 24, 12, -12 }); cdjXML.AddQue(2, 0, 0); cdjXML.AddQue(2, 24, 0); cdjXML.AddQue(2, 48, 0); cdjXML.AddQue(3, 0, 180); cdjXML.AddQue(4, 0, 360); cdjXML.DataFinalize(); cdjXML.Write("c:/cdj.cd"); CdjData cdj = cdjXML.MakeCdjData(); return(cdj); }
public static CdjData Read(string filename) { CdjXmlData cdjXML; Object o = new CdjXmlData(); MyUtil.XML.Read(filename, ref o); cdjXML = (CdjXmlData)o; CdjData t = cdjXML.MakeCdjData(); cdjXML.quedata = new List <RECORD>(); cdjXML.scratchdata = new List <RECORD>(); foreach (RECORD r in cdjXML.DATALIST) { if (r.datatype == 0) { cdjXML.quedata.Add(r); } else { cdjXML.scratchdata.Add(r); } } cdjXML.DataFinalize(); return(cdjXML.MakeCdjData()); }
public static void DoMain(CdjData cdjdata) { //ファイル読み込み、再生 SoundDriver.MainFileLoad(cdjdata.SOUND); SoundDriver.Play(); //inpfader.Initial(); //ムービーファイル int MovieGraphHandle; int MovieGraphHandle1, MovieGraphHandle2; MovieGraphHandle1 = DX.LoadGraph("B3_TYPE42.avi"); MovieGraphHandle2 = DX.LoadGraph("E_Map_TYPE01a.avi"); // 描画先を裏画面に変更 DX.SetDrawScreen(DX.DX_SCREEN_BACK); // 画像を左右に動かす処理のための変数を初期化 now.set_startbpm(0, cdjdata.BPM); //now.set_startbpm(DX.GetNowCount(), music.BPM); Random random = new Random(); InputState preinputstate = new InputState(); int dbg = 0; // メインループ while (DX.ProcessMessage() != -1 && DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) == 0) { InputState inputstate = iinput.Update();//入力プラグインから現在の入力状況を返却 //前回入力情報を加味 inputstate.SetCutin(preinputstate); //再生終了で抜ける処理を書く // 画面をクリア DX.ClearDrawScreen(); now.settime((int)SoundDriver.MainCurrentTime().TotalMilliseconds); cdjdata.SetStep(now.judgementlinestep); //ムービー処理 { // 画像を描画する座標を更新 if ((DX.GetJoypadInputState(DX.DX_INPUT_KEY_PAD1) & DX.PAD_INPUT_RIGHT) != 0) { MovieGraphHandle = MovieGraphHandle1; } else { MovieGraphHandle = MovieGraphHandle2; } // 画像を描画 //ムービー DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, 0); //ムービー調整 if (DX.GetMovieStateToGraph(MovieGraphHandle1) != 1) { DX.SeekMovieToGraph(MovieGraphHandle1, 0); DX.PlayMovieToGraph(MovieGraphHandle1); } if (DX.GetMovieStateToGraph(MovieGraphHandle2) != 1) { DX.SeekMovieToGraph(MovieGraphHandle2, 0); DX.PlayMovieToGraph(MovieGraphHandle2); } } //キューイングのディスクとか再生ラインとかカットイン矢印とかを描く foreach (DiscQueCutData o in cdjdata.lstquedata) { o.Cutin(inputstate.CutinState); if (o.ActiveState == EnumActiveState.NEXT) { if (o.lr == CdjData.Left) { o.Queing(inputstate.Left.Angle); } else { o.Queing(inputstate.Right.Angle); } } } //if (cdjdata.nowlr == 1 && inputFader.GetFaderState()== EnumFaderState.RIGHT) //{ // //waveOut.Volume = 0; //} //else if (cdjdata.nowlr == -1 && inputFader.GetFaderState() == EnumFaderState.LEFT) //{ // //waveOut.Volume = 0; //} //else //{ // //waveOut.Volume = DEF_VOLUME; //} //---------------------------------------------------------------------------------------- //デバッグ用 /* * DX.DrawString(0, 0, "fader" + inputFader.GetFaderValue(), DX.GetColor(255, 255, 255)); * DX.DrawString(0, 20, "cutin" + inputFader.GetCutInState().ToString(), DX.GetColor(255, 255, 255)); * DX.DrawString(0, 40, "angle" + RecordR.DeltaAngle.ToString(), DX.GetColor(255, 255, 255)); * DX.DrawString(0, 60, "Pos " + midiinput.Pos(-1).ToString(), DX.GetColor(255, 255, 255)); * DX.DrawString(0, 80, "Spd " + midiinput.Speed(-1).ToString(), DX.GetColor(255, 255, 255)); */ //---------------------------------------------------------------------------------------- //描画処理 DoDraw(cdjdata, inputstate); preinputstate = inputstate.Clone(); } }
public static void DoMain(CdjData cdjdata) { //using NAudio.Wave; //シンプル再生(2つ作れば多重再生可能) IWaveProvider FloatStereo44100Provider; AudioFileReader reader; reader = new AudioFileReader(cdjdata.SOUND); reader.Volume = 0.1F; IWaveProvider stereo; if (reader.WaveFormat.Channels == 1) { if (reader.WaveFormat.Encoding == WaveFormatEncoding.IeeeFloat) { //NAudio.Wave.SampleProviders.MonoToStereoSampleProvider s = new NAudio.Wave.SampleProviders.MonoToStereoSampleProvider(reader); stereo = new Wave16ToFloatProvider(new MonoToStereoProvider16(new WaveFloatTo16Provider(reader))); WaveFormatConversionProvider conv = new WaveFormatConversionProvider(new WaveFormat(44100, 2), stereo); } else if (reader.WaveFormat.Encoding == WaveFormatEncoding.Pcm) { stereo = new Wave16ToFloatProvider(new MonoToStereoProvider16(reader)); } else { return; } } else { stereo = reader; } FloatStereo44100Provider = stereo;//最終的にこの形式に統一44100にするかどうかは検討の余地あり SoundDriver.AddWaveProvider(FloatStereo44100Provider, "main"); SoundDriver.Play(); //while (waveOut.PlaybackState == PlaybackState.Playing) //{ // Application.DoEvents(); // this.Text = reader.CurrentTime.ToString(); //} // 再生の終了を待つ // // 再生の終了を待たずにWaveOutのインスタンスが破棄されると、その時点で再生が停止する //inputAnalogFader inpfader = new inputAnalogFader(); inputMIDIFader inpfader = new inputMIDIFader(midiinput); inputMIDIRecord RecordL = new inputMIDIRecord(CdjData.Left, midiinput); inputMIDIRecord RecordR = new inputMIDIRecord(CdjData.Right, midiinput); inpfader.Initial(); SetDrawObjects(); //GHplaylineL = DX.LoadGraph("playline.png"); //GHplaylineR = DX.LoadGraph("playline2.png"); int MovieGraphHandle; int MovieGraphHandle1, MovieGraphHandle2; MovieGraphHandle1 = DX.LoadGraph("B3_TYPE42.avi"); MovieGraphHandle2 = DX.LoadGraph("E_Map_TYPE01a.avi"); // 描画先を裏画面に変更 DX.SetDrawScreen(DX.DX_SCREEN_BACK); // 画像を左右に動かす処理のための変数を初期化 now.set_startbpm(0, cdjdata.BPM); //now.set_startbpm(DX.GetNowCount(), music.BPM); Random random = new Random(); int dbg = 0; // メインループ while (DX.ProcessMessage() != -1) { //再生終了で抜ける /* * if ((DX.GetJoypadInputState(DX.DX_INPUT_KEY_PAD1) & DX.PAD_INPUT_9) != 0) * { * waveOut.Dispose(); * break; * } * if(waveOut.PlaybackState == PlaybackState.Stopped) * { * waveOut.Dispose(); * break; * } */ // 画面をクリア DX.ClearDrawScreen(); now.settime((int)reader.CurrentTime.TotalMilliseconds); cdjdata.SetStep(now.judgementlinestep); //ムービー処理 { // 画像を描画する座標を更新 if ((DX.GetJoypadInputState(DX.DX_INPUT_KEY_PAD1) & DX.PAD_INPUT_RIGHT) != 0) { MovieGraphHandle = MovieGraphHandle1; } else { MovieGraphHandle = MovieGraphHandle2; } // 画像を描画 //ムービー DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, 0); //ムービー調整 if (DX.GetMovieStateToGraph(MovieGraphHandle1) != 1) { DX.SeekMovieToGraph(MovieGraphHandle1, 0); DX.PlayMovieToGraph(MovieGraphHandle1); } if (DX.GetMovieStateToGraph(MovieGraphHandle2) != 1) { DX.SeekMovieToGraph(MovieGraphHandle2, 0); DX.PlayMovieToGraph(MovieGraphHandle2); } } //キューイングのディスクとか再生ラインとかカットイン矢印とかを描く foreach (DiscQueCutData o in cdjdata.lstquedata) { o.Cutin(inputFader.GetCutInState()); if (o.ActiveState == EnumActiveState.NEXT) { if (o.lr == CdjData.Left) { o.Queing(RecordL.DeltaAngle); } else { o.Queing(RecordR.DeltaAngle); } } } if (cdjdata.nowlr == 1 && inputFader.GetFaderState() == EnumFaderState.RIGHT) { //waveOut.Volume = 0; } else if (cdjdata.nowlr == -1 && inputFader.GetFaderState() == EnumFaderState.LEFT) { //waveOut.Volume = 0; } else { //waveOut.Volume = DEF_VOLUME; } RecordL.Update(); RecordR.Update(); inpfader.Update(); midiinput.update(DateTime.Now); //inputFader.GetFaderState(); //---------------------------------------------------------------------------------------- //デバッグ用 DX.DrawString(0, 0, "fader" + inputFader.GetFaderValue(), DX.GetColor(255, 255, 255)); DX.DrawString(0, 20, "cutin" + inputFader.GetCutInState().ToString(), DX.GetColor(255, 255, 255)); DX.DrawString(0, 40, "angle" + RecordR.DeltaAngle.ToString(), DX.GetColor(255, 255, 255)); DX.DrawString(0, 60, "Pos " + midiinput.Pos(-1).ToString(), DX.GetColor(255, 255, 255)); DX.DrawString(0, 80, "Spd " + midiinput.Speed(-1).ToString(), DX.GetColor(255, 255, 255)); //---------------------------------------------------------------------------------------- //描画処理 DoDraw(cdjdata); } }
/// <summary> /// XML読み込み後実際の曲データに変換して返す /// </summary> /// <returns></returns> public CdjData MakeCdjData() { CdjData rtn = new CdjData(); rtn.BPM = this.BPM; rtn.TITLE = this.TITLE; rtn.LEVEL = this.LEVEL; rtn.SOUND = this.SOUND; rtn.GAP = this.GAP; rtn.JACKET = this.JACKET; rtn.LABEL = this.LABEL; rtn.lstquedata = new List <DiscQueCutData>(); DiscQueCutData preque = new DiscQueCutData { startstep = 0 }; bool bfirst = true; foreach (RECORD o in this.quedata) { DiscQueCutData q = new DiscQueCutData(); if (bfirst) { q.ActiveState = EnumActiveState.NEXT; } else { q.ActiveState = EnumActiveState.INACTIVE; } q.startstep = o.startstep; q.endstep = o.endstep; q.lr = o.lr; q.quecount = o.data[0]; if (q.quecount < 360) { if (preque.endstep - preque.startstep > datacalc.resolution) { q.activemillis = datacalc.step2millis(BPM, preque.endstep - datacalc.resolution); } else { q.activemillis = datacalc.step2millis(BPM, preque.startstep); } } else { q.activemillis = datacalc.step2millis(BPM, preque.startstep); } q.judge = EnumJudge.NOTYET; rtn.lstquedata.Add(q); preque = q; bfirst = false; } rtn.lstscratchunit = new List <ScratchUnit>(); foreach (RECORD o in this.scratchdata) { ScratchUnit scunit = MakeScratchUnit(o); rtn.lstscratchunit.Add(scunit); } return(rtn); }