コード例 #1
0
ファイル: Part.java プロジェクト: andrewsuzuki/TotallyTabular
  /**
   * Overwrites a section of the Part (starting at the specified index) with the Units contained in
   * the given Part. WARNING: DOES NOT WORK IF GIVEN PART WILL EXTEND OVER END OF THIS PART. TODO:
   * Fix this. //rk Maybe I fixed it
   *
   * @param part the Part to paste into this
   * @param index the slot at which to start pasting over
   */
  public void pasteOver(Part part, int index) {
    // Trace.log(3, "pasteOver " + part + " onto " + index);
    int limit = size();
    int incoming = part.size();
    if (index + incoming < limit) {
      limit = index + incoming;
    }

    for (int i = 0, j = index; j < limit; i++, j++) {
      Unit unit = part.getUnit(i);
      if (unit != null) {
        Unit newUnit = unit.copy();
        setUnit(j, newUnit);
      } else {
        setUnit(j, null);
      }
    }
  }
コード例 #2
0
ファイル: Part.java プロジェクト: andrewsuzuki/TotallyTabular
  /**
   * A rewritten version of pastOver
   *
   * @param part the Part to paste into this
   * @param index the slot at which to start pasting over
   */
  public void newPasteOver(Part part, int index) {
    Trace.log(3, "pasteOver " + part + " onto " + index + " " + this.hashCode());
    int limit = size();
    int incoming = part.size();
    //        if( index + incoming < limit )
    //          {
    //          limit = index + incoming;
    //          }

    int i = 0;
    int j = index;
    for (; i < incoming && j < limit; i++, j++) {
      Unit unit = part.getUnit(i);
      if (unit == null) {
        newSetUnit(j, null);
      } else {
        newSetUnit(j, unit.copy());
      }
    }
  }
コード例 #3
0
ファイル: Part.java プロジェクト: andrewsuzuki/TotallyTabular
  /**
   * Modified from pasteOver for time warping Overwrites a section of the Part (starting at the
   * specified index) with the Units contained in the given Part.
   *
   * @param part the Part to paste into this
   * @param index the slot at which to start pasting over
   */
  public void altPasteOver(Part part, int index) {
    int limit = size();
    int incoming = part.size();
    if (index + incoming < limit) {
      limit = index + incoming;
    }

    // How to prevent long duration last note??

    //   int lastSlot = index + incoming - 1;

    //   setUnit(lastSlot, new Rest());

    for (int i = 0, j = index; j < limit; i++, j++) {
      Unit unit = part.getUnit(i);
      if (unit != null) {
        Unit newUnit = unit.copy();
        int rhythmValue = newUnit.getRhythmValue();
        setUnit(j, newUnit);
      } else {
        setUnit(j, null);
      }
    }
  }