コード例 #1
0
ファイル: VsqHandle.cs プロジェクト: scskarsper/Cadencii_UTAU
        /// <summary>
        /// インスタンスを文字列に変換します
        /// </summary>
        /// <returns>インスタンスを変換した文字列</returns>
        public string toString()
        {
            string result = "";

            result += "[h#" + PortUtil.formatDecimal("0000", Index) + "]";
            if (m_type == VsqHandleType.Lyric)
            {
                result += "\n" + "L0=" + L0.toString(addQuotationMark);
                int c = Trailing.Count;
                for (int i = 0; i < c; i++)
                {
                    result += "\n" + "L" + (i + 1) + "=" + Trailing[i].toString(addQuotationMark);
                }
            }
            else if (m_type == VsqHandleType.Vibrato)
            {
                result += "\n" + "IconID=" + IconID + "\n";
                result += "IDS=" + IDS + "\n";
                result += "Original=" + Original + "\n";
                result += "Caption=" + Caption + "\n";
                result += "Length=" + Length + "\n";
                result += "StartDepth=" + StartDepth + "\n";
                result += "DepthBPNum=" + DepthBP.getCount() + "\n";
                if (DepthBP.getCount() > 0)
                {
                    result += "DepthBPX=" + PortUtil.formatDecimal("0.000000", DepthBP.getElement(0).X);
                    for (int i = 1; i < DepthBP.getCount(); i++)
                    {
                        result += "," + PortUtil.formatDecimal("0.000000", DepthBP.getElement(i).X);
                    }
                    result += "\n" + "DepthBPY=" + DepthBP.getElement(0).Y;
                    for (int i = 1; i < DepthBP.getCount(); i++)
                    {
                        result += "," + DepthBP.getElement(i).Y;
                    }
                    result += "\n";
                }
                result += "StartRate=" + StartRate + "\n";
                result += "RateBPNum=" + RateBP.getCount();
                if (RateBP.getCount() > 0)
                {
                    result += "\n" + "RateBPX=" + PortUtil.formatDecimal("0.000000", RateBP.getElement(0).X);
                    for (int i = 1; i < RateBP.getCount(); i++)
                    {
                        result += "," + PortUtil.formatDecimal("0.000000", RateBP.getElement(i).X);
                    }
                    result += "\n" + "RateBPY=" + RateBP.getElement(0).Y;
                    for (int i = 1; i < RateBP.getCount(); i++)
                    {
                        result += "," + RateBP.getElement(i).Y;
                    }
                }
            }
            else if (m_type == VsqHandleType.Singer)
            {
                result += "\n" + "IconID=" + IconID + "\n";
                result += "IDS=" + IDS + "\n";
                result += "Original=" + Original + "\n";
                result += "Caption=" + Caption + "\n";
                result += "Length=" + Length + "\n";
                result += "Language=" + Language + "\n";
                result += "Program=" + Program;
            }
            else if (m_type == VsqHandleType.NoteHeadHandle)
            {
                result += "\n" + "IconID=" + IconID + "\n";
                result += "IDS=" + IDS + "\n";
                result += "Original=" + Original + "\n";
                result += "Caption=" + Caption + "\n";
                result += "Length=" + Length + "\n";
                result += "Duration=" + Duration + "\n";
                result += "Depth=" + Depth;
            }
            else if (m_type == VsqHandleType.DynamicsHandle)
            {
                result += "\n" + "IconID=" + IconID + "\n";
                result += "IDS=" + IDS + "\n";
                result += "Original=" + Original + "\n";
                result += "Caption=" + Caption + "\n";
                result += "StartDyn=" + StartDyn + "\n";
                result += "EndDyn=" + EndDyn + "\n";
                result += "Length=" + Length + "\n";
                if (DynBP != null)
                {
                    if (DynBP.getCount() <= 0)
                    {
                        result += "DynBPNum=0";
                    }
                    else
                    {
                        result += "DynBPX=" + PortUtil.formatDecimal("0.000000", DynBP.getElement(0).X);
                        int c = DynBP.getCount();
                        for (int i = 1; i < c; i++)
                        {
                            result += "," + PortUtil.formatDecimal("0.000000", DynBP.getElement(i).X);
                        }
                        result += "\n" + "DynBPY=" + DynBP.getElement(0).Y;
                        for (int i = 1; i < c; i++)
                        {
                            result += "," + DynBP.getElement(i).Y;
                        }
                    }
                }
                else
                {
                    result += "DynBPNum=0";
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: VsqEvent.cs プロジェクト: scskarsper/Cadencii_UTAU
        public bool equals(VsqEvent item)
        {
            if (this.Clock != item.Clock)
            {
                return(false);
            }
            if (this.ID.type != item.ID.type)
            {
                return(false);
            }
            if (this.ID.type == VsqIDType.Anote)
            {
                #region 音符の比較
                if (this.ID.Note != item.ID.Note)
                {
                    return(false);
                }
                if (this.ID.getLength() != item.ID.getLength())
                {
                    return(false);
                }
                if (this.ID.d4mean != item.ID.d4mean)
                {
                    return(false);
                }
                if (this.ID.DEMaccent != item.ID.DEMaccent)
                {
                    return(false);
                }
                if (this.ID.DEMdecGainRate != item.ID.DEMdecGainRate)
                {
                    return(false);
                }
                if (this.ID.Dynamics != item.ID.Dynamics)
                {
                    return(false);
                }
                if (this.ID.LyricHandle == null && item.ID.LyricHandle != null)
                {
                    return(false);
                }
                if (this.ID.LyricHandle != null && item.ID.LyricHandle == null)
                {
                    return(false);
                }
                if (this.ID.LyricHandle != null && item.ID.LyricHandle != null)
                {
                    if (!this.ID.LyricHandle.L0.equalsForSynth(item.ID.LyricHandle.L0))
                    {
                        return(false);
                    }
                    int count = this.ID.LyricHandle.Trailing.Count;
                    if (count != item.ID.LyricHandle.Trailing.Count)
                    {
                        return(false);
                    }
                    for (int k = 0; k < count; k++)
                    {
                        if (!this.ID.LyricHandle.Trailing[k].equalsForSynth(item.ID.LyricHandle.Trailing[k]))
                        {
                            return(false);
                        }
                    }
                }
                if (this.ID.NoteHeadHandle == null && item.ID.NoteHeadHandle != null)
                {
                    return(false);
                }
                if (this.ID.NoteHeadHandle != null && item.ID.NoteHeadHandle == null)
                {
                    return(false);
                }
                if (this.ID.NoteHeadHandle != null && item.ID.NoteHeadHandle != null)
                {
                    if (!this.ID.NoteHeadHandle.IconID.Equals(item.ID.NoteHeadHandle.IconID))
                    {
                        return(false);
                    }
                    if (this.ID.NoteHeadHandle.getDepth() != item.ID.NoteHeadHandle.getDepth())
                    {
                        return(false);
                    }
                    if (this.ID.NoteHeadHandle.getDuration() != item.ID.NoteHeadHandle.getDuration())
                    {
                        return(false);
                    }
                    if (this.ID.NoteHeadHandle.getLength() != item.ID.NoteHeadHandle.getLength())
                    {
                        return(false);
                    }
                }
                if (this.ID.PMBendDepth != item.ID.PMBendDepth)
                {
                    return(false);
                }
                if (this.ID.PMBendLength != item.ID.PMBendLength)
                {
                    return(false);
                }
                if (this.ID.PMbPortamentoUse != item.ID.PMbPortamentoUse)
                {
                    return(false);
                }
                if (this.ID.pMeanEndingNote != item.ID.pMeanEndingNote)
                {
                    return(false);
                }
                if (this.ID.pMeanOnsetFirstNote != item.ID.pMeanOnsetFirstNote)
                {
                    return(false);
                }
                VibratoHandle hVibratoThis = this.ID.VibratoHandle;
                VibratoHandle hVibratoItem = item.ID.VibratoHandle;
                if (hVibratoThis == null && hVibratoItem != null)
                {
                    return(false);
                }
                if (hVibratoThis != null && hVibratoItem == null)
                {
                    return(false);
                }
                if (hVibratoThis != null && hVibratoItem != null)
                {
                    if (this.ID.VibratoDelay != item.ID.VibratoDelay)
                    {
                        return(false);
                    }
                    if (!hVibratoThis.IconID.Equals(hVibratoItem.IconID))
                    {
                        return(false);
                    }
                    if (hVibratoThis.getStartDepth() != hVibratoItem.getStartDepth())
                    {
                        return(false);
                    }
                    if (hVibratoThis.getStartRate() != hVibratoItem.getStartRate())
                    {
                        return(false);
                    }
                    VibratoBPList vibRateThis = hVibratoThis.getRateBP();
                    VibratoBPList vibRateItem = hVibratoItem.getRateBP();
                    if (vibRateThis == null && vibRateItem != null)
                    {
                        return(false);
                    }
                    if (vibRateThis != null && vibRateItem == null)
                    {
                        return(false);
                    }
                    if (vibRateThis != null && vibRateItem != null)
                    {
                        int numRateCount = vibRateThis.getCount();
                        if (numRateCount != vibRateItem.getCount())
                        {
                            return(false);
                        }
                        for (int k = 0; k < numRateCount; k++)
                        {
                            VibratoBPPair pThis = vibRateThis.getElement(k);
                            VibratoBPPair pItem = vibRateItem.getElement(k);
                            if (pThis.X != pItem.X)
                            {
                                return(false);
                            }
                            if (pThis.Y != pItem.Y)
                            {
                                return(false);
                            }
                        }
                    }
                    VibratoBPList vibDepthThis = hVibratoThis.getDepthBP();
                    VibratoBPList vibDepthItem = hVibratoItem.getDepthBP();
                    if (vibDepthThis == null && vibDepthItem != null)
                    {
                        return(false);
                    }
                    if (vibDepthThis != null && vibDepthItem == null)
                    {
                        return(false);
                    }
                    if (vibDepthThis != null && vibDepthItem != null)
                    {
                        int numDepthCount = vibDepthThis.getCount();
                        if (numDepthCount != vibDepthItem.getCount())
                        {
                            return(false);
                        }
                        for (int k = 0; k < numDepthCount; k++)
                        {
                            VibratoBPPair pThis = vibDepthThis.getElement(k);
                            VibratoBPPair pItem = vibDepthItem.getElement(k);
                            if (pThis.X != pItem.X)
                            {
                                return(false);
                            }
                            if (pThis.Y != pItem.Y)
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (this.ID.vMeanNoteTransition != item.ID.vMeanNoteTransition)
                {
                    return(false);
                }
                #endregion
            }
            else if (this.ID.type == VsqIDType.Singer)
            {
                #region シンガーイベントの比較
                if (this.ID.IconHandle.Program != item.ID.IconHandle.Program)
                {
                    return(false);
                }
                #endregion
            }
            else if (this.ID.type == VsqIDType.Aicon)
            {
                if (!this.ID.IconDynamicsHandle.IconID.Equals(item.ID.IconDynamicsHandle.IconID))
                {
                    return(false);
                }
                if (this.ID.IconDynamicsHandle.isDynaffType())
                {
                    // 強弱記号
                }
                else
                {
                    // クレッシェンド・デクレッシェンド
                    if (this.ID.getLength() != item.ID.getLength())
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #3
0
ファイル: VsqTrack.cs プロジェクト: scskarsper/Cadencii_UTAU
        /// <summary>
        /// クレッシェンド,デクレッシェンド,および強弱記号をダイナミクスカーブに反映させます.
        /// この操作によって,ダイナミクスカーブに設定されたデータは全て削除されます.
        /// </summary>
        public void reflectDynamics()
        {
            VsqBPList dyn = getCurve("dyn");

            dyn.clear();
            for (Iterator <VsqEvent> itr = getDynamicsEventIterator(); itr.hasNext();)
            {
                VsqEvent           item   = itr.next();
                IconDynamicsHandle handle = item.ID.IconDynamicsHandle;
                if (handle == null)
                {
                    continue;
                }
                int clock  = item.Clock;
                int length = item.ID.getLength();

                if (handle.isDynaffType())
                {
                    // 強弱記号
                    dyn.add(clock, handle.getStartDyn());
                }
                else
                {
                    // クレッシェンド,デクレッシェンド
                    int start_dyn = dyn.getValue(clock);

                    // 範囲内のアイテムを削除
                    int count = dyn.size();
                    for (int i = count - 1; i >= 0; i--)
                    {
                        int c = dyn.getKeyClock(i);
                        if (clock <= c && c <= clock + length)
                        {
                            dyn.removeElementAt(i);
                        }
                        else if (c < clock)
                        {
                            break;
                        }
                    }

                    VibratoBPList bplist = handle.getDynBP();
                    if (bplist == null || (bplist != null && bplist.getCount() <= 0))
                    {
                        // カーブデータが無い場合
                        double a = 0.0;
                        if (length > 0)
                        {
                            a = (handle.getEndDyn() - handle.getStartDyn()) / (double)length;
                        }
                        int last_val = start_dyn;
                        for (int i = clock; i < clock + length; i++)
                        {
                            int val = start_dyn + (int)(a * (i - clock));
                            if (val < dyn.getMinimum())
                            {
                                val = dyn.getMinimum();
                            }
                            else if (dyn.getMaximum() < val)
                            {
                                val = dyn.getMaximum();
                            }
                            if (last_val != val)
                            {
                                dyn.add(i, val);
                                last_val = val;
                            }
                        }
                    }
                    else
                    {
                        // カーブデータがある場合
                        int last_val   = handle.getStartDyn();
                        int last_clock = clock;
                        int bpnum      = bplist.getCount();
                        int last       = start_dyn;

                        // bplistに指定されている分のデータ点を追加
                        for (int i = 0; i < bpnum; i++)
                        {
                            VibratoBPPair point      = bplist.getElement(i);
                            int           pointClock = clock + (int)(length * point.X);
                            if (pointClock <= last_clock)
                            {
                                continue;
                            }
                            int    pointValue = point.Y;
                            double a          = (pointValue - last_val) / (double)(pointClock - last_clock);
                            for (int j = last_clock; j <= pointClock; j++)
                            {
                                int val = start_dyn + (int)((j - last_clock) * a);
                                if (val < dyn.getMinimum())
                                {
                                    val = dyn.getMinimum();
                                }
                                else if (dyn.getMaximum() < val)
                                {
                                    val = dyn.getMaximum();
                                }
                                if (val != last)
                                {
                                    dyn.add(j, val);
                                    last = val;
                                }
                            }
                            last_val   = point.Y;
                            last_clock = pointClock;
                        }

                        // bplistの末尾から,clock => clock + lengthまでのデータ点を追加
                        int last2 = last;
                        if (last_clock < clock + length)
                        {
                            double a = (handle.getEndDyn() - last_val) / (double)(clock + length - last_clock);
                            for (int j = last_clock; j < clock + length; j++)
                            {
                                int val = last2 + (int)((j - last_clock) * a);
                                if (val < dyn.getMinimum())
                                {
                                    val = dyn.getMinimum();
                                }
                                else if (dyn.getMaximum() < val)
                                {
                                    val = dyn.getMaximum();
                                }
                                if (val != last)
                                {
                                    dyn.add(j, val);
                                    last = val;
                                }
                            }
                        }
                    }
                }
            }
        }