public static void DoInit() { // ウインドウモードで起動 DX.ChangeWindowMode(DX.TRUE); DX.SetGraphMode(datacalc.ScreenWidth, datacalc.ScreenHeight, 16); // DXライブラリの初期化 if (DX.DxLib_Init() < 0) { return; } SetGraphicObjects(); Config config = Config.ReadXML("crackinDJ.config"); //ここDLL読み込みに変える iinput = TestGetInput.GetInput(); iinput.Initialize(""); SoundDriver.Init(config.ASIO.DriverName, config.ASIO.Channeloffset); //midiinput = new MIDIinput("Traktor Kontrol S2 MK2 MIDI"); //midiinput.SetConfig(Config.ReadXML("crackinDJ.config")); //midiinput.StartMonitoring(); }
public static void DoTerminate() { SoundDriver.Stop(); SoundDriver.Dispose(); // DXライブラリの後始末 DX.DxLib_End(); }
/// <summary> /// 44100Hz,2chのファイル読み込み("main"で追加される) /// </summary> /// <param name="filename"></param> public static void MainFileLoad(string filename) { IWaveProvider FloatStereo44100Provider; AudioFileReader reader; reader = new AudioFileReader(filename); audiofilereader = reader; Test.Print("Volume消す"); 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"); }
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); } }