public VibratoPointIteratorBySec(VsqFileEx vsq, VibratoBPList rate, int start_rate, VibratoBPList depth, int start_depth, int clock_start, int clock_width, float sec_resolution) { this.vsq = vsq; this.rate = rate; this.start_rate = start_rate; this.depth = depth; this.start_depth = start_depth; this.clock_start = clock_start; this.clock_width = clock_width; this.sec_resolution = sec_resolution; sec0 = vsq.getSecFromClock(clock_start); sec1 = vsq.getSecFromClock(clock_start + clock_width); count = (int)((sec1 - sec0) / sec_resolution); phase = 0; start_rate = rate.getValue(0.0f, start_rate); start_depth = depth.getValue(0.0f, start_depth); amplitude = start_depth * 2.5f / 127.0f / 2.0f; // ビブラートの振幅。 period = getPeriodFromRate(start_rate); //ビブラートの周期、秒 omega = (float)(2.0 * Math.PI / period); // 角速度(rad/sec) sec = sec0; fadewidth = (float)(sec1 - sec0) * 0.2f; }
/// <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(); }
public VibratoPointIteratorByClock(TempoVector tempo_table, VibratoBPList rate, int start_rate, VibratoBPList depth, int start_depth, int clock_start, int clock_width) { this.mTempoTable = tempo_table; this.mRate = rate; this.mStartRate = start_rate; this.mDepth = depth; this.mStartDepth = start_depth; this.mClockStart = clock_start; this.mClockWidth = clock_width; rewind(); }
private XmlElement createVibratoCurveNode(int start_value, VibratoBPList curve) { var result = doc_.CreateElement("seqAttr"); Func <VibratoBPPair, XmlElement> CreateElem = (pair) => { var elem = doc_.CreateElement("elem"); int x = (int)(pair.X * 65536); elem.AppendChild(createNode("posNrm", x)); elem.AppendChild(createNode("elv", pair.Y)); return(elem); }; result.AppendChild(CreateElem(new VibratoBPPair(0.0f, start_value))); int count = curve.getCount(); for (int i = 0; i < count; ++i) { var pair = curve.getElement(i); var elem = CreateElem(curve.getElement(i)); result.AppendChild(elem); } return(result); }
public DrawObject(DrawObjectType type, VsqFileEx vsq, Rectangle rect, string text_, int accent_, int decay, int velocity, int internal_id, int vibrato_delay, bool overwrapped, bool symbol_protected, VibratoBPList vib_rate, VibratoBPList vib_depth, int vib_start_rate, int vib_start_depth, int note_, UstEnvelope ust_envelope, int length, int clock, bool is_valid_for_utau, bool is_valid_for_straight, int vib_delay, int intensity) { this.mType = type; mRectangleInPixel = rect; mText = text_; mAccent = accent_; mDecay = decay; mVelocity = velocity; mInternalID = internal_id; mVibratoDelayInPixel = vibrato_delay; mIsOverlapped = overwrapped; mIsSymbolProtected = symbol_protected; mIntensity = intensity; mNote = note_; mUstEnvelope = ust_envelope; this.mLength = length; this.mClock = clock; this.mIsValidForUtau = is_valid_for_utau; this.mIsValidForStraight = is_valid_for_straight; this.mVibDelay = vib_delay; int viblength = length - vib_delay; if (viblength > 0 && vib_rate != null && vib_depth != null) { VibratoPointIteratorByClock itr = new VibratoPointIteratorByClock(vsq.TempoTable, vib_rate, vib_start_rate, vib_depth, vib_start_depth, clock + vib_delay, viblength); mVibratoPit = new float[viblength]; for (int i = 0; i < viblength; i++) { if (!itr.hasNext()) { break; } double v = itr.next(); mVibratoPit[i] = (float)v; } } }
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(); }