Esempio n. 1
0
 // How many measures in a Phrase ?
 private double countMeasures(Phrase p) {
   double answer = 0.0;
   for (int i = 0; i < p.size(); ++i) {
     answer = answer + p.getNote(i).getRhythmValue();
   }
   return answer / p.getNumerator();
 }
Esempio n. 2
0
 // Move all notes from one Phrase to another
 private void moveAll(Phrase fromPhrase, Phrase toPhrase) {
   Note theNote;
   while ((fromPhrase.size() > 0)) {
     theNote = fromPhrase.getNote(0);
     toPhrase.addNote(theNote);
     fromPhrase.removeNote(0);
   }
 }
Esempio n. 3
0
 // zoomIn is called after the parts before and after have
 // already been detached from the Phrase.  They are
 // re-attached when we zoom out
 public void zoomIn(Phrase before, Phrase thePhrase, Phrase after) {
   phrase = thePhrase;
   beforeZoom = before;
   afterZoom = after;
   beforeZoom.empty();
   afterZoom.empty();
   setLocation(20, 20);
   show();
 }
Esempio n. 4
0
  // Zoom in on the selected measures
  private void zoom() {
    int n = getIntegerValue(startMeasureEdit) - 1;
    int m = getIntegerValue(measureCountEdit);

    beforeZoom.empty();
    afterZoom.empty();

    moveMeasures(phrase, beforeZoom, n);
    moveAll(phrase, afterZoom);
    moveMeasures(afterZoom, phrase, n + m - countMeasures(beforeZoom));
  }
Esempio n. 5
0
 // Move measures from the start of one Phrase to another
 private void moveMeasures(Phrase fromPhrase, Phrase toPhrase, double nMeasures) {
   double beatCount = nMeasures * fromPhrase.getNumerator();
   double beatValue;
   Note theNote;
   while ((beatCount > 0.005) && (fromPhrase.size() > 0)) {
     theNote = fromPhrase.getNote(0);
     beatValue = theNote.getRhythmValue();
     toPhrase.addNote(theNote);
     fromPhrase.removeNote(0);
     beatCount -= beatValue;
   }
 }
Esempio n. 6
0
 /**
  * Display the jMusic Phrase in a ShowScore window, at the specified x <br>
  * and y coordinates, measured in pixels.
  *
  * @param Phrase
  * @param xLoc the left-right location of the window
  * @param yLoc the up-down location of the window
  */
 public static void sketch(Phrase phr, int xLoc, int yLoc) {
   Score s = new Score("Phrase: " + phr.getTitle());
   Part p = new Part();
   p.addPhrase(phr);
   s.addPart(p);
   new SketchScore(s, xLoc, yLoc);
 }
Esempio n. 7
0
 /**
  * Print the jMusic Phrase in standard output
  *
  * @param Phrase
  */
 public static void internal(Phrase phrase) {
   System.out.println(phrase.toString());
 }
Esempio n. 8
0
  // Recombine before, Phrase and after into longer Phrase
  public static void zoomOut(Phrase before, Phrase thePhrase, Phrase after) {
    for (int i = 0; i < thePhrase.size(); ++i) {
      before.addNote(thePhrase.getNote(i));
    }

    for (int i = 0; i < after.size(); ++i) {
      before.addNote(after.getNote(i));
    }

    thePhrase.empty();
    for (int i = 0; i < before.size(); ++i) {
      thePhrase.addNote(before.getNote(i));
    }

    before.empty();
    after.empty();
  }