コード例 #1
0
    public void Update()
    {
        deltaPos   = _midi.Pos(_LR) - prePos;
        prePos     = _midi.Pos(_LR);
        deltaangle = (double)deltaPos * 360 / 50;

        //deltaangle = _midi.Speed(_LR) * 3.33;//1倍速で60/1秒なら200/60度
        //; preangle = angle;
    }
コード例 #2
0
    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);
        }
    }
コード例 #3
0
 public inputMIDIRecord(int LR, MIDIinput midi)
 {
     _LR    = LR;
     _midi  = midi;
     prePos = midi.Pos(LR);
 }