Ejemplo n.º 1
0
  public long render(
      MidiSequence seq,
      long time,
      Track track,
      int transposition,
      boolean useDrums,
      int endLimitIndex,
      boolean constantBass)
      throws InvalidMidiDataException {
    // to trace sequencing info:
    // System.out.println("Sequencing SectionInfo time = "
    // + time + " endLimitIndex = " + endLimitIndex + " useDrums = " + useDrums);

    // Iterate over list of sections, each a Style

    int chordsSize = chords.size();

    int endIndex;

    // m is a second iterator intended to stay one step ahead of k
    // so as to get the start of the next section

    Style mostRecentStyle = new Style();

    ListIterator<SectionRecord> k = records.listIterator();
    ListIterator<SectionRecord> m = records.listIterator();
    if (m.hasNext()) {
      m.next();
    }

    while (k.hasNext()) // && (endLimitIndex == ENDSCORE || endIndex <= endLimitIndex) )
    {
      SectionRecord record = k.next();
      Style style;
      if (record.getUsePreviousStyle()) {
        style = mostRecentStyle;
        // System.out.println("using previous style " + style);
      } else {
        style = record.getStyle();
        mostRecentStyle = style;
      }

      int startIndex = record.getIndex();

      endIndex = m.hasNext() ? m.next().getIndex() : chordsSize;

      if (style != null) {
        time =
            style.render(
                seq,
                time,
                chords,
                startIndex,
                endIndex,
                transposition,
                useDrums,
                endLimitIndex,
                constantBass);
      }
    }
    return time;
  }