コード例 #1
0
  public ArrayList<Block> toBlockList() {
    ArrayList<Block> blocks = new ArrayList<Block>();
    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

    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();
      String styleName = record.getStyleName();
      int startIndex = record.getIndex();

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

      ChordBlock block = null;

      for (int slot = startIndex; slot < endIndex; slot++) {
        Chord chord = chords.getChord(slot);

        if (chord != null) {
          block = new ChordBlock(chord.getName(), chord.getRhythmValue());
          block.setStyleName(styleName);
          blocks.add(block);
        }
      }

      // For last block in section
      if (block != null) {
        block.setSectionEnd(record.getIsPhrase() ? Block.PHRASE_END : Block.SECTION_END);
      }
    }

    return blocks;
  }
コード例 #2
0
  public void newSection(int index) {
    int measureLength = chords.getMeasureLength();

    SectionRecord record = records.get(index);
    int startIndex = record.getIndex();

    int endIndex = chords.size();

    if (index + 1 < size()) {
      SectionRecord nextRecord = records.get(index + 1);
      endIndex = nextRecord.getIndex();
    }

    int measure = (endIndex - startIndex) / measureLength;

    if (measure % 2 == 0) measure /= 2;
    else measure = measure / 2 + 1;

    addSection(
        Style.USE_PREVIOUS_STYLE, startIndex + measure * measureLength, record.getIsPhrase());
  }
コード例 #3
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;
  }
コード例 #4
0
 public int measures() {
   int measureLength = chords.getMeasureLength();
   return chords.size() / measureLength;
 }