예제 #1
0
 /**
  * Return the style to apply
  *
  * @return Style
  */
 public Map<String, String> getStyle() {
   return style.getStyle();
 }
예제 #2
0
  public void makeSwing(SectionInfo sectionInfo) {
    // The index here iterates through the start of every beat

    Style previousStyle = Style.getStyle("swing"); // TEMP: FIX!
    for (int i = 0; i + beatValue - 1 < size; i += beatValue) {
      SectionRecord record = sectionInfo.getSectionRecordBySlot(i);

      Style s;
      if (record.getUsePreviousStyle()) {
        s = previousStyle;
      } else {
        s = record.getStyle();
        previousStyle = s;
      }

      if (s == null) {
        ErrorLog.log(ErrorLog.FATAL, "It will not be possible to continue");
      }

      double swingValue = s.getSwing();

      // System.out.println("i = " + i + ", style = " + s + " swing = " + swingValue);

      // FIX: Notice the problem here when i < size, the original condition, is used.

      // we get the Units where a second sixteenth note would fall,
      // an eighth note, and a fourth sixteenth note

      Unit unit1 = slots.get(i + 1 * beatValue / 4);
      Unit unit2 = slots.get(i + 1 * beatValue / 2);
      Unit unit3 = slots.get(i + 3 * beatValue / 4);

      // we only use swingValue if there is no second sixteenth note
      // (we don't want to swingValue a beat of four sixteenths)

      if (unit1 == null && unit2 != null) {

        /* formerly:
        // swingValue if there is a second eighth note
        if(unit2.getRhythmValue() == beatValue/2) {
            slots.set(i+beatValue/2, null);
            slots.set(i+(int)(beatValue*swingValue), unit2);
        }
        */

        int trailingRhythm = unit2.getRhythmValue();

        // swingValue if there is a second eighth note or longer
        if (trailingRhythm >= beatValue / 2) {

          int offset = (int) (beatValue * swingValue);
          Unit unit2mod = unit2.copy();
          unit2mod.setRhythmValue(unit2.getRhythmValue() - offset);
          slots.set(i + beatValue / 2, null);
          slots.set(i + offset, unit2mod);
        }
      }
    }

    try {
      // After the Units are shifted, go through and reset each rhythm value
      Part.PartIterator i = iterator();
      while (i.hasNext()) {
        int index = i.nextIndex();
        slots.get(index).setRhythmValue(getUnitRhythmValue(index));
        i.next();
      }
    } catch (Exception e) {

    }
  }