示例#1
0
        /// <summary>
        /// 指定したコントロールカーブにベジエ曲線を追加します。
        /// </summary>
        /// <param name="curve_type"></param>
        /// <param name="chain"></param>
        public void addBezierChain(CurveType curve_type, BezierChain chain, int chain_id)
        {
            BezierChain add = (BezierChain)chain.clone();

            add.id = chain_id;
            this.get(curve_type).Add(add);
        }
示例#2
0
        public void remove(CurveType curve_type, int chain_id)
        {
            List <BezierChain> list = this.get(curve_type);

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].id == chain_id)
                {
                    list.RemoveAt(i);
                    break;
                }
            }
        }
示例#3
0
        public void setBezierChain(CurveType curve_type, int chain_id, BezierChain item)
        {
            List <BezierChain> list = this.get(curve_type);
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                if (list[i].id == chain_id)
                {
                    list[i] = item;
                    break;
                }
            }
        }
示例#4
0
        public BezierChain getBezierChain(CurveType curve_type, int chain_id)
        {
            List <BezierChain> list = this.get(curve_type);
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                if (list[i].id == chain_id)
                {
                    return(list[i]);
                }
            }
            return(null);
        }
 public void addPointAll(CurveType curve, long[] ids)
 {
     if (!curve.equals(mPointCurveType))
     {
         mPointIDs.Clear();
         mPointCurveType = curve;
     }
     for (int i = 0; i < ids.Length; i++)
     {
         if (!mPointIDs.Contains(ids[i]))
         {
             mPointIDs.Add(ids[i]);
         }
     }
     checkSelectedItemExistence();
 }
示例#6
0
        public Object clone()
        {
            BezierCurves ret = new BezierCurves();

            for (int j = 0; j < Utility.CURVE_USAGE.Length; j++)
            {
                CurveType          ct  = Utility.CURVE_USAGE[j];
                List <BezierChain> src = this.get(ct);
                ret.set(ct, new List <BezierChain>());
                int count = src.Count;
                for (int i = 0; i < count; i++)
                {
                    ret.get(ct).Add((BezierChain)src[i].clone());
                }
            }
            return(ret);
        }
        public FormBezierPointEditController(
            TrackSelector parent,
            CurveType curve_type,
            int selected_chain_id,
            int selected_point_id)
        {
            ui = (FormBezierPointEditUi) new FormBezierPointEditUiImpl(this);

            applyLanguage();
            m_parent     = parent;
            m_curve_type = curve_type;
            m_track      = AppManager.getSelected();
            m_chain_id   = selected_chain_id;
            m_point_id   = selected_point_id;
            bool               found    = false;
            VsqFileEx          vsq      = AppManager.getVsqFile();
            BezierCurves       attached = vsq.AttachedCurves.get(m_track - 1);
            List <BezierChain> chains   = attached.get(m_curve_type);

            for (int i = 0; i < chains.Count; i++)
            {
                if (chains[i].id == m_chain_id)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                return;
            }
            bool smooth = false;

            foreach (var bp in attached.getBezierChain(m_curve_type, m_chain_id).points)
            {
                if (bp.getID() == m_point_id)
                {
                    m_point = bp;
                    smooth  =
                        (bp.getControlLeftType() != BezierControlType.None) ||
                        (bp.getControlRightType() != BezierControlType.None);
                    break;
                }
            }
            updateStatus();
        }
        public FormCurvePointEdit(FormMain main_window, long editing_id, CurveType curve)
        {
            InitializeComponent();
            mMainWindow = main_window;
            registerEventHandlers();
            setResources();
            applyLanguage();
            m_editing_id = editing_id;
            m_curve      = curve;

            VsqBPPairSearchContext context = AppManager.getVsqFile().Track[AppManager.getSelected()].getCurve(m_curve.getName()).findElement(m_editing_id);

            txtDataPointClock.Text = context.clock + "";
            txtDataPointValue.Text = context.point.value + "";
            txtDataPointValue.SelectAll();

            btnUndo.Enabled = AppManager.editHistory.hasUndoHistory();
            btnRedo.Enabled = AppManager.editHistory.hasRedoHistory();
        }
示例#9
0
        public int getNextId(CurveType curve_type)
        {
            List <BezierChain> bc = this.get(curve_type);
            int  ret   = bc.Count;
            bool found = true;

            while (found)
            {
                found = false;
                for (int i = 0; i < bc.Count; i++)
                {
                    if (bc[i].id == ret)
                    {
                        found = true;
                        ret++;
                        break;
                    }
                }
            }
            return(ret);
        }
 public void addPoint(CurveType curve, long id)
 {
     addPointAll(curve, new long[] { id });
     checkSelectedItemExistence();
 }
 public void clearPoint()
 {
     mPointIDs.Clear();
     mPointCurveType = CurveType.Empty;
     checkSelectedItemExistence();
 }
示例#12
0
 public void set(CurveType curve, List <BezierChain> value)
 {
     if (curve.equals(CurveType.BRE))
     {
         Brethiness = value;
     }
     else if (curve.equals(CurveType.BRI))
     {
         Brightness = value;
     }
     else if (curve.equals(CurveType.CLE))
     {
         Clearness = value;
     }
     else if (curve.equals(CurveType.DYN))
     {
         Dynamics = value;
     }
     else if (curve.equals(CurveType.fx2depth))
     {
         FX2Depth = value;
     }
     else if (curve.equals(CurveType.GEN))
     {
         GenderFactor = value;
     }
     else if (curve.equals(CurveType.harmonics))
     {
         Harmonics = value;
     }
     else if (curve.equals(CurveType.OPE))
     {
         Opening = value;
     }
     else if (curve.equals(CurveType.POR))
     {
         PortamentoTiming = value;
     }
     else if (curve.equals(CurveType.PIT))
     {
         PitchBend = value;
     }
     else if (curve.equals(CurveType.PBS))
     {
         PitchBendSensitivity = value;
     }
     else if (curve.equals(CurveType.reso1amp))
     {
         Reso1Amp = value;
     }
     else if (curve.equals(CurveType.reso1bw))
     {
         Reso1BW = value;
     }
     else if (curve.equals(CurveType.reso1freq))
     {
         Reso1Freq = value;
     }
     else if (curve.equals(CurveType.reso2amp))
     {
         Reso2Amp = value;
     }
     else if (curve.equals(CurveType.reso2bw))
     {
         Reso2BW = value;
     }
     else if (curve.equals(CurveType.reso2freq))
     {
         Reso2Freq = value;
     }
     else if (curve.equals(CurveType.reso3amp))
     {
         Reso3Amp = value;
     }
     else if (curve.equals(CurveType.reso3bw))
     {
         Reso3BW = value;
     }
     else if (curve.equals(CurveType.reso3freq))
     {
         Reso3Freq = value;
     }
     else if (curve.equals(CurveType.reso4amp))
     {
         Reso4Amp = value;
     }
     else if (curve.equals(CurveType.reso4bw))
     {
         Reso4BW = value;
     }
     else if (curve.equals(CurveType.reso4freq))
     {
         Reso4Freq = value;
     }
     else if (curve.equals(CurveType.VibratoDepth))
     {
         VibratoDepth = value;
     }
     else if (curve.equals(CurveType.VibratoRate))
     {
         VibratoRate = value;
     }
 }
示例#13
0
 public List <BezierChain> get(CurveType curve)
 {
     if (curve.equals(CurveType.BRE))
     {
         return(Brethiness);
     }
     else if (curve.equals(CurveType.BRI))
     {
         return(Brightness);
     }
     else if (curve.equals(CurveType.CLE))
     {
         return(Clearness);
     }
     else if (curve.equals(CurveType.DYN))
     {
         return(Dynamics);
     }
     else if (curve.equals(CurveType.fx2depth))
     {
         return(FX2Depth);
     }
     else if (curve.equals(CurveType.GEN))
     {
         return(GenderFactor);
     }
     else if (curve.equals(CurveType.harmonics))
     {
         return(Harmonics);
     }
     else if (curve.equals(CurveType.OPE))
     {
         return(Opening);
     }
     else if (curve.equals(CurveType.POR))
     {
         return(PortamentoTiming);
     }
     else if (curve.equals(CurveType.PIT))
     {
         return(PitchBend);
     }
     else if (curve.equals(CurveType.PBS))
     {
         return(PitchBendSensitivity);
     }
     else if (curve.equals(CurveType.reso1amp))
     {
         return(Reso1Amp);
     }
     else if (curve.equals(CurveType.reso1bw))
     {
         return(Reso1BW);
     }
     else if (curve.equals(CurveType.reso1freq))
     {
         return(Reso1Freq);
     }
     else if (curve.equals(CurveType.reso2amp))
     {
         return(Reso2Amp);
     }
     else if (curve.equals(CurveType.reso2bw))
     {
         return(Reso2BW);
     }
     else if (curve.equals(CurveType.reso2freq))
     {
         return(Reso2Freq);
     }
     else if (curve.equals(CurveType.reso3amp))
     {
         return(Reso3Amp);
     }
     else if (curve.equals(CurveType.reso3bw))
     {
         return(Reso3BW);
     }
     else if (curve.equals(CurveType.reso3freq))
     {
         return(Reso3Freq);
     }
     else if (curve.equals(CurveType.reso4amp))
     {
         return(Reso4Amp);
     }
     else if (curve.equals(CurveType.reso4bw))
     {
         return(Reso4BW);
     }
     else if (curve.equals(CurveType.reso4freq))
     {
         return(Reso4Freq);
     }
     else if (curve.equals(CurveType.VibratoDepth))
     {
         return(VibratoDepth);
     }
     else if (curve.equals(CurveType.VibratoRate))
     {
         return(VibratoRate);
     }
     else
     {
         return(null);
     }
 }
示例#14
0
        /// <summary>
        /// 指定した種類のコントロールカーブにベジエ曲線を追加します。
        /// AddBezierChainとの違い、オーバーラップする部分があれば自動的に結合されます。
        /// chainには2個以上のデータ点が含まれている必要がある
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="chain"></param>
        public void mergeBezierChain(CurveType curve, BezierChain chain)
        {
            if (chain.points.Count <= 1)
            {
                return;
            }
            int chain_start = (int)chain.getStart();
            int chain_end   = (int)chain.getEnd();

            // まず、全削除する必要のあるBezierChainを検索
            List <int>         delete_list = new List <int>();
            List <BezierChain> src         = this.get(curve);

            //foreach ( int id in this[curve].Keys ) {
            for (int j = 0; j < src.Count; j++)
            {
                //BezierChain bc = this[curve][id];
                BezierChain bc = src[j];
                if (bc.points.Count <= 0)
                {
                    continue;
                }
                int bc_start = (int)bc.getStart();
                int bc_end   = (int)bc.getEnd();
                if (chain_start <= bc_start && bc_end <= chain_end)
                {
                    delete_list.Add(bc.id);
                }
            }

            // 削除を実行
            foreach (var id in delete_list)
            {
                remove(curve, id);
                //this[curve].Remove( id );
            }

            // マージする必要があるかどうかを検査。
            bool processed = true;

            while (processed)
            {
                processed = false;
                List <BezierChain> list = this.get(curve);
                //foreach ( int id in this[curve].Keys ) {
                for (int j = 0; j < list.Count; j++)
                {
                    //BezierChain bc = this[curve][id];
                    BezierChain bc    = list[j];
                    int         id    = bc.id;
                    int         start = (int)bc.getStart();
                    int         end   = (int)bc.getEnd();

                    // 被っている箇所が2箇所以上ある可能性があるので、ifでヒットしてもbreakしない
                    if (start < chain_start && chain_start <= end && end < chain_end)
                    {
                        // bcのchain_start ~ endを削除し、chain_startで結合
                        BezierChain bc_edit = null;
                        try {
                            bc_edit = bc.extractPartialBezier(start, chain_start);
                        } catch (Exception ex) {
                            Logger.write(typeof(BezierCurves) + ".mergeBezierChain; ex=" + ex + "\n");
                            continue;
                        }
                        bc_edit.id = bc.id;
                        int last = bc_edit.size() - 1;

                        // 接合部分では、制御点無しでステップ変化する
                        bc_edit.points[last].setControlRightType(BezierControlType.None);
                        chain.points[0].setControlLeftType(BezierControlType.None);

                        int copy_start = 0;
                        if (bc_edit.points[last].getBase().getY() == chain.points[0].getBase().getY())
                        {
                            // bcの終点とchainの始点の座標が一致している場合
                            if (bc_edit.points[last].getControlLeftType() != BezierControlType.None)
                            {
                                bc_edit.points[last].setControlLeftType(BezierControlType.Master);
                            }
                            bc_edit.points[last].setControlRight(chain.points[0].controlLeft);
                            if (chain.points[0].getControlRightType() != BezierControlType.None)
                            {
                                bc_edit.points[last].setControlLeftType(BezierControlType.Master);
                            }
                            copy_start = 1;
                        }
                        for (int i = copy_start; i < chain.points.Count; i++)
                        {
                            chain.points[i].setID(bc_edit.getNextId());
                            bc_edit.add(chain.points[i]);
                        }
                        //this[curve].Remove( id );
                        remove(curve, id);
                        chain       = bc_edit;
                        chain_start = (int)chain.getStart();
                        chain_end   = (int)chain.getEnd();
                        processed   = true;
                        break;
                    }
                    else if (chain_start < start && start <= chain_end && chain_end < end)
                    {
                        // bcのstart ~ chain_endを削除し、chain_endで結合
                        BezierChain bc_edit = null;
                        try {
                            bc_edit = bc.extractPartialBezier(chain_end, end);
                        } catch (Exception ex) {
                            Logger.write(typeof(BezierCurves) + ".mergeBezierChain; ex=" + ex + "\n");
                            continue;
                        }
                        bc_edit.id = bc.id;
                        int last = chain.size() - 1;

                        // 接合部分では、制御点無しでステップ変化する
                        bc_edit.points[0].setControlLeftType(BezierControlType.None);
                        chain.points[last].setControlRightType(BezierControlType.None);

                        int copy_end = last;
                        if (chain.points[last].getBase().getY() == bc_edit.points[0].getBase().getY())
                        {
                            // bcの終点とchainの始点の座標が一致している場合
                            if (chain.points[last].getControlLeftType() != BezierControlType.None)
                            {
                                chain.points[last].setControlLeftType(BezierControlType.Master);
                            }
                            chain.points[last].setControlRight(bc_edit.points[0].controlLeft);
                            if (bc_edit.points[0].getControlRightType() != BezierControlType.None)
                            {
                                chain.points[last].setControlLeftType(BezierControlType.Master);
                            }
                            copy_end = last - 1;
                        }
                        for (int i = 0; i <= copy_end; i++)
                        {
                            chain.points[i].setID(bc_edit.getNextId());
                            bc_edit.add(chain.points[i]);
                        }
                        //this[curve].Remove( id );
                        remove(curve, id);
                        chain       = bc_edit;
                        chain_start = (int)chain.getStart();
                        chain_end   = (int)chain.getEnd();
                        processed   = true;
                        break;
                    }
                    else if (start < chain_start && chain_end < end)
                    {
                        // bcのchain_start ~ chain_endをchainで置き換え
                        // left + chain + right
                        BezierChain left = null;
                        try {
                            left = bc.extractPartialBezier(start, chain_start);
                        } catch (Exception ex) {
                            Logger.write(typeof(BezierCurves) + ".mergeBezierChain; ex=" + ex + "\n");
                            continue;
                        }
                        BezierChain right = null;
                        try {
                            right = bc.extractPartialBezier(chain_end, end);
                        } catch (Exception ex) {
                            Logger.write(typeof(BezierCurves) + ".mergeBezierChain; ex=" + ex + "\n");
                            continue;
                        }
                        left.id = bc.id;

                        // 接合部ではステップ変化
                        left.points[left.size() - 1].setControlRightType(BezierControlType.None);
                        chain.points[0].setControlLeftType(BezierControlType.None);
                        chain.points[chain.size() - 1].setControlRightType(BezierControlType.None);
                        right.points[0].setControlLeftType(BezierControlType.None);

                        int copy_start = 0;
                        int copy_end   = chain.size() - 1;

                        if (left.points[left.size() - 1].getBase().getY() == chain.points[0].getBase().getY())
                        {
                            // bcの終点とchainの始点の座標が一致している場合
                            if (left.points[left.size() - 1].getControlLeftType() != BezierControlType.None)
                            {
                                left.points[left.size() - 1].setControlLeftType(BezierControlType.Master);
                            }
                            left.points[left.size() - 1].setControlRight(chain.points[0].controlLeft);
                            if (chain.points[0].getControlRightType() != BezierControlType.None)
                            {
                                left.points[left.size() - 1].setControlLeftType(BezierControlType.Master);
                            }
                            copy_start = 1;
                        }

                        if (chain.points[chain.size() - 1].getBase().getY() == right.points[0].getBase().getY())
                        {
                            // bcの終点とchainの始点の座標が一致している場合
                            if (chain.points[chain.size() - 1].getControlLeftType() != BezierControlType.None)
                            {
                                chain.points[chain.size() - 1].setControlLeftType(BezierControlType.Master);
                            }
                            chain.points[chain.size() - 1].setControlRight(right.points[0].controlLeft);
                            if (right.points[0].getControlRightType() != BezierControlType.None)
                            {
                                chain.points[chain.size() - 1].setControlLeftType(BezierControlType.Master);
                            }
                            copy_end = chain.size() - 2;
                        }

                        // 追加
                        for (int i = copy_start; i <= copy_end; i++)
                        {
                            chain.points[i].setID(left.getNextId());
                            left.add(chain.points[i]);
                        }
                        for (int i = 0; i < right.points.Count; i++)
                        {
                            right.points[i].setID(left.getNextId());
                            left.add(right.points[i]);
                        }
                        //this[curve].Remove( id );
                        remove(curve, id);
                        chain       = left;
                        chain_start = (int)chain.getStart();
                        chain_end   = (int)chain.getEnd();
                        processed   = true;
                        break;
                    }
                }
            }

            if (!processed)
            {
                chain.id = this.getNextId(curve);
            }
            //this[curve].Add( chain.ID, chain );
            addBezierChain(curve, chain, chain.id);
        }