Пример #1
0
  /**
   * Returns a copy of the Score.
   *
   * @return Score a copy of the Score
   */
  public Score copy() {
    // Trace.log(2, "copying Score of size " + size());
    Score newScore = new Score(title, tempo);
    newScore.setMetre(metre[0], metre[1]);
    PartList newPartList = new PartList(partList.size());
    ListIterator<MelodyPart> i = partList.listIterator();

    while (i.hasNext()) newPartList.add(i.next().copy());

    newScore.partList = newPartList;
    newScore.chordProg = chordProg.copy();

    newScore.setChordInstrument(getChordInstrument());
    newScore.setBassInstrument(getBassInstrument());

    newScore.setBassMuted(getBassMuted());
    newScore.setDrumMuted(getDrumMuted());
    newScore.setChordMuted(getChordMuted());
    newScore.setMelodyMuted(getMelodyMuted());
    newScore.setMasterVolumeMuted(getMasterVolumeMuted());

    newScore.setBassVolume(getBassVolume());
    newScore.setDrumVolume(getDrumVolume());
    newScore.setChordVolume(getChordVolume());
    newScore.setMelodyVolume(getMelodyVolume());
    newScore.setMasterVolume(getMasterVolume());

    newScore.countInProg = countInProg == null ? null : countInProg.copy();

    return newScore;
  }
Пример #2
0
 public void dumpMelody(PrintStream out) {
   ListIterator<MelodyPart> i = partList.listIterator();
   while (i.hasNext()) {
     i.next().dump(out);
     out.println();
   }
 }
Пример #3
0
 /**
  * Sets the key signature of the Score
  *
  * @param keySig the key signature to set the Score to
  */
 public void setKeySignature(int keySig) {
   Trace.log(2, "setting key signature of score to " + keySig);
   this.keySig = keySig;
   chordProg.setKeySignature(keySig);
   ListIterator<MelodyPart> i = partList.listIterator();
   while (i.hasNext()) {
     i.next().setKeySignature(keySig);
   }
 }
Пример #4
0
  /**
   * Sets the metre of the Score metre is now represented in most places as a 2-elt array, where the
   * first element is the top of the time signature, and the second element is the bottom.
   */
  public void setMetre(int top, int bottom) {
    metre[0] = top;
    metre[1] = bottom;
    chordProg.setMetre(top, bottom);
    ListIterator<MelodyPart> i = partList.listIterator();

    while (i.hasNext()) {
      i.next().setMetre(top, bottom);
    }
  }
Пример #5
0
  /**
   * Writes the Score to the BufferedWriter passed to this method in Leadsheet notation.
   *
   * @param out a BufferedWriter to save the score onto
   */
  public void saveLeadsheet(BufferedWriter out) throws IOException {
    Chord.initSaveToLeadsheet();
    chordProg.saveLeadsheet(out, "chords");
    out.newLine();

    ListIterator<MelodyPart> i = partList.listIterator();
    while (i.hasNext()) {
      ((MelodyPart) i.next()).saveLeadsheet(out, "melody");
      out.newLine();
    }
  }
Пример #6
0
  /**
   * Creates and returns a String representation of the Score.
   *
   * @return String the Score as a String
   */
  public String toString() {
    String scoreData = "Score: " + '\n';

    scoreData += "ChordProg: " + '\n' + chordProg.toString() + '\n';

    ListIterator<MelodyPart> i = partList.listIterator();
    while (i.hasNext()) {
      scoreData += "Part " + i.nextIndex() + ":" + '\n' + i.next().toString() + '\n';
    }
    return scoreData;
  }
Пример #7
0
 /** Calls makeSwing on each individual Part. */
 public void makeSwing() {
   ListIterator<MelodyPart> i = partList.listIterator();
   while (i.hasNext()) {
     MelodyPart m = i.next();
     Style style = chordProg.getStyle();
     if (style != null) {
       m.setSwing(style.getSwing());
     }
     m.makeSwing(chordProg.getSectionInfo());
   }
 }
Пример #8
0
  /**
   * Return first Note in melody, or null if there is no note
   *
   * @return
   */
  public Note getFirstNote() {
    ListIterator<MelodyPart> i = partList.listIterator();

    while (i.hasNext()) {
      Note note = i.next().getFirstNote();
      if (note != null) {
        return note;
      }
    }

    return null; // TEMP!
  }
Пример #9
0
  public void checkLength() {
    int maxLength = length;

    if (chordProg.size() > maxLength) maxLength = chordProg.size();

    ListIterator<MelodyPart> i = partList.listIterator();
    while (i.hasNext()) {
      MelodyPart part = i.next();
      if (part.size() > maxLength) maxLength = part.size();
    }

    setLength(maxLength);
  }
Пример #10
0
 public void setLength(int newLength) {
   if (newLength == length) {
     return; // avoid unnecessary setting
   }
   Trace.log(3, "setting score length to " + newLength);
   length = newLength;
   if (chordProg != null) {
     chordProg.setSize(length);
   }
   Iterator<MelodyPart> i = partList.listIterator();
   while (i.hasNext()) {
     i.next().setSize(length);
   }
 }
Пример #11
0
  public int getActiveBarsInChorus() {
    int activeBars = chordProg.getActiveBars();
    ListIterator<MelodyPart> i = partList.listIterator();

    while (i.hasNext()) {
      int barsInChorus = i.next().getActiveBars();
      if (barsInChorus > activeBars) {
        activeBars = barsInChorus;
      }
    }
    // System.out.println("active bars = " + activeBars);

    return activeBars; // TEMP!
  }
Пример #12
0
  /**
   * Creates and returns a MIDI sequence from the Score. Calls Part.render on each Part and (for
   * now) creates a new channel for each Part. This means that you can only have 16 Parts, which
   * should be changed in the future.
   *
   * @param ppqn the resolution for the Sequence
   * @return Sequence the MIDI render
   */
  public Sequence render(short ppqn, int transposition, boolean useDrums, int endLimitIndex)
      throws InvalidMidiDataException {
    // to trace sequencing
    // System.out.println("Score: render, start 0, endLimitIndex = " + endLimitIndex);
    MidiSequence seq = new MidiSequence(ppqn);

    long time = 0;

    if (countInProg != null) {
      // Handle count-in render

      int len = getCountInOffset();
      if (endLimitIndex != ENDSCORE) {
        endLimitIndex += len;
      }

      time = countInProg.render(seq, time, seq.getChordTrack(), 0, true, endLimitIndex);
    }

    // System.out.println("time = " + time);

    ListIterator<MelodyPart> i = partList.listIterator();
    while (i.hasNext() && Style.limitNotReached(time, endLimitIndex)) {
      // render the chord progression in parallel with each melody chorus

      long melTime =
          i.next()
              .render(
                  seq,
                  ImproVisor.getMelodyChannel(),
                  time,
                  seq.getMelodyTrack(),
                  transposition,
                  endLimitIndex);

      long chTime =
          chordProg.render(seq, time, seq.getChordTrack(), transposition, useDrums, endLimitIndex);
      time = Math.max(melTime, chTime);
    }

    // System.out.println("seq = " + seq);

    // Find the longest track, and put a Stop event at the end of it
    MidiSynth.endSequence(seq.getSequence());
    // Trace.log(0, "done rendering, tickLength = " + seq.getSequence().getTickLength());

    // System.out.println("countIn size = " + getCountInOffset());
    return seq.getSequence();
  }
Пример #13
0
 /**
  * Returns a PartListIterator
  *
  * @return PartListIterator iterating the parts
  */
 public ListIterator getPartIterator() {
   return partList.listIterator();
 }