コード例 #1
0
        /// <summary>
        /// ビブラートのRateまたはDepthカーブを指定したサイズで描画します
        /// </summary>
        /// <param name="list">描画するカーブ</param>
        /// <param name="start_value"></param>
        /// <param name="drawer"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        private void drawVibratoCurve(VibratoBPList list, int start_value, LineGraphDrawer drawer, int width, int height)
        {
            int size = 0;

            if (list != null)
            {
                size = list.getCount();
            }
            drawer.clear();
            drawer.setBaseLineY(height);
            int iy0 = height - (int)(start_value / 127.0 * height);

            drawer.append(0, iy0);
            int lasty = iy0;

            for (int i = 0; i < size; i++)
            {
                VibratoBPPair p  = list.getElement(i);
                int           ix = (int)(p.X * width);
                int           iy = height - (int)(p.Y / 127.0 * height);
                drawer.append(ix, iy);
                lasty = iy;
            }
            drawer.append(width + drawer.getDotSize() * 2, lasty);
            drawer.flush();
        }
コード例 #2
0
        public void pictureResulting_Paint(Object sender, PaintEventArgs e)
        {
            // 背景を描画
            int raw_width  = pictureResulting.Width;
            int raw_height = pictureResulting.Height;

            System.Drawing.Graphics g = e.Graphics;
            g.FillRectangle(System.Drawing.Brushes.LightGray, 0, 0, raw_width, raw_height);

            // 選択中のハンドルを取得
            VibratoHandle handle = mSelected;

            if (handle == null)
            {
                return;
            }

            // 描画の準備
            LineGraphDrawer d = getDrawerResulting();

            d.setGraphics(g);

            // ビブラートのピッチベンドを取得するイテレータを取得
            int    width       = raw_width;
            int    vib_length  = 960;
            int    tempo       = 500000;
            double vib_seconds = tempo * 1e-6 / 480.0 * vib_length;
            // 480クロックは0.5秒
            VsqFileEx     vsq         = new VsqFileEx("Miku", 1, 4, 4, tempo);
            VibratoBPList list_rate   = handle.getRateBP();
            VibratoBPList list_depth  = handle.getDepthBP();
            int           start_rate  = handle.getStartRate();
            int           start_depth = handle.getStartDepth();

            if (list_rate == null)
            {
                list_rate = new VibratoBPList(new float[] { 0.0f }, new int[] { start_rate });
            }
            if (list_depth == null)
            {
                list_depth = new VibratoBPList(new float[] { 0.0f }, new int[] { start_depth });
            }
            // 解像度
            float resol = (float)(vib_seconds / width);

            if (resol <= 0.0f)
            {
                return;
            }
            VibratoPointIteratorBySec itr =
                new VibratoPointIteratorBySec(
                    vsq,
                    list_rate, start_rate,
                    list_depth, start_depth,
                    0, vib_length, resol);

            // 描画
            int height = raw_height - MARGIN * 2;

            d.clear();
            //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            int x = 0;
            int lastx = 0;
            int lasty = -10;
            int tx = 0, ty = 0;

            for (; itr.hasNext(); x++)
            {
                double pitch = itr.next().getY();
                int    y     = height - (int)((pitch + 1.25) / 2.5 * height) + MARGIN - 1;
                int    dx    = x - lastx; // xは単調増加
                int    dy    = Math.Abs(y - lasty);
                tx = x;
                ty = y;
                //if ( dx > MIN_DELTA || dy > MIN_DELTA ) {
                d.append(x, y);
                lastx = x;
                lasty = y;
                //}
            }
            d.append(tx, ty);
            d.flush();
        }