/// <summary> /// ノートを追加するコマンドを発行します。 /// </summary> /// <param name="track"></param> /// <param name="item"></param> /// <returns></returns> public static VsqCommand generateCommandEventAdd(int track, VsqEvent item) { VsqCommand command = new VsqCommand(); command.Type = VsqCommandType.EVENT_ADD; command.Args = new Object[2]; command.Args[0] = track; command.Args[1] = (VsqEvent)item.clone(); return(command); }
public static VsqCommand generateCommandEventReplace(int track, VsqEvent item) { VsqCommand command = new VsqCommand(); command.Type = VsqCommandType.EVENT_REPLACE; command.Args = new Object[2]; command.Args[0] = track; command.Args[1] = item.clone(); return(command); }
/// <summary> /// このトラックの指定した範囲を削除し,削除範囲以降の部分を削除開始位置までシフトします /// </summary> /// <param name="clock_start"></param> /// <param name="clock_end"></param> public void removePart(int clock_start, int clock_end) { int dclock = clock_end - clock_start; // 削除する範囲に歌手変更イベントが存在するかどうかを検査。 VsqEvent t_last_singer = null; for (Iterator <VsqEvent> itr = getSingerEventIterator(); itr.hasNext();) { VsqEvent ve = itr.next(); if (clock_start <= ve.Clock && ve.Clock < clock_end) { t_last_singer = ve; } if (ve.Clock == clock_end) { t_last_singer = null; // 後でclock_endの位置に補うが、そこにに既に歌手変更イベントがあるとまずいので。 } } VsqEvent last_singer = null; if (t_last_singer != null) { last_singer = (VsqEvent)t_last_singer.clone(); last_singer.Clock = clock_end; } bool changed = true; // イベントの削除 while (changed) { changed = false; int numEvents = getEventCount(); for (int i = 0; i < numEvents; i++) { VsqEvent itemi = getEvent(i); if (clock_start <= itemi.Clock && itemi.Clock < clock_end) { removeEvent(i); changed = true; break; } } } // クロックのシフト if (last_singer != null) { addEvent(last_singer); //歌手変更イベントを補う } int num_events = getEventCount(); for (int i = 0; i < num_events; i++) { VsqEvent itemi = getEvent(i); if (clock_end <= itemi.Clock) { itemi.Clock -= dclock; } } for (int i = 0; i < VsqTrack.CURVES.Length; i++) { string curve = VsqTrack.CURVES[i]; VsqBPList bplist = getCurve(curve); if (bplist == null) { continue; } VsqBPList buf_bplist = (VsqBPList)bplist.clone(); bplist.clear(); int value_at_end = buf_bplist.getValue(clock_end); bool at_end_added = false; foreach (var key in buf_bplist.keyClockIterator()) { if (key < clock_start) { bplist.add(key, buf_bplist.getValue(key)); } else if (clock_end <= key) { if (key == clock_end) { at_end_added = true; } bplist.add(key - dclock, buf_bplist.getValue(key)); } } if (!at_end_added) { bplist.add(clock_end - dclock, value_at_end); } } }