Package jm.music.data

Examples of jm.music.data.Note


            return;
        }
        double rhythmValueCounter = phraseEndTime;
        int phraseLength = phrase.size() - 1; //-1 due to Vector elements starting at 0
        for (int i = 0; i <= phraseLength; i++) {
            Note nextNote = (Note) phrase.getNoteList().elementAt(phraseLength - i);
            if (rhythmValueCounter >= fadeLength) {
                break;
            }
            double fadeFactor = rhythmValueCounter / fadeLength;
            int dynamic = (int)((double)nextNote.getDynamic() * fadeFactor);
            if (dynamic == 0) {

                // only fade out to dynamic of 1 as 0 is note off
                dynamic = 1;
            }
            nextNote.setDynamic(dynamic);
            rhythmValueCounter += nextNote.getRhythmValue();
        }
  }
View Full Code Here


        int min = Note.MAX_DYNAMIC;
        int curr;
        int mean;
   
    while(enum1.hasMoreElements()){
      Note note = (Note) enum1.nextElement();
      if(note.getPitch() != REST ) { // reject rests
           curr = note.getDynamic();
          if (curr > max) {
                    max = curr;
                }
                if (curr < min) {
                    min = curr;
                }
            }
    }
        mean = (min + max) / 2;
   
    // compress the sucker
        enum1 = phrase.getNoteList().elements();
    while(enum1.hasMoreElements()){
      Note note = (Note) enum1.nextElement();
      curr = (int)(mean + ((note.getDynamic() - mean) * ratio));
      note.setDynamic(curr);
    }
  }
 
View Full Code Here

        if (phrase == null || qValue <= 0.0 || mode == null || key < 0) {
            return;
        }
        Enumeration enum1 = phrase.getNoteList().elements();
    while(enum1.hasMoreElements()){
      Note note = (Note) enum1.nextElement();
      double rv = note.getRhythmValue();
      //rhythm
             note.setRhythmValue((int) Math.round(rv / qValue) * qValue);
            // pitch
            quantizePitch(note, mode, key);
    }
  }
View Full Code Here

      // put one note in to start off the new phrase
        newPhr.addNote(phrase.getNote((int)(Math.random()*phrase.size())));
      // create the rest of the new note order
        for(int i=0;i<phrase.size()-1;) {
          //select a new note from this phrase
            Note n = phrase.getNote((int)(Math.random()*phrase.size()));
          //check if  it is a note already used
          boolean notUsed = true;
      for (int j=0; j< newPhr.size(); j++) {
        if ( n == newPhr.getNote(j)) {
          notUsed = false;
View Full Code Here

        i++;
        pitch = phrase.getNote(i).getPitch();
      }
      // cal caccidental offset
      int accidental = 0;
      Note n = new Note(pitch, 1);
      while (!n.isScale(scale)) {
        n.setPitch(n.getPitch() -1);
        accidental++;
      }
      // calc octave
      if (root == 0) octave = pitch / 12;
      else octave = (pitch - 12 + root) / 12;
View Full Code Here

            return;
        }

        Enumeration enum1 = phrase.getNoteList().elements();
    while(enum1.hasMoreElements()){
      Note note = (Note) enum1.nextElement();
      note.setRhythmValue(note.getRhythmValue() * scaleFactor);
      note.setDuration(note.getDuration() * scaleFactor);
    }
  }
 
View Full Code Here

        double beatCounter = (phrase.getStartTime() < 0.0)
                             ? 0.0
                             : phrase.getStartTime();
        Vector v = phrase.getNoteList();
        for(int i = 0; i < v.size(); i++) {
            Note n = (Note) v.elementAt(i);

      // check to see if that note occurs on an accented beat
      // and if so increase its dynamic level
            for(int j = 0; j < accentedBeats.length; j++){
                if (beatCounter % meter == accentedBeats[j]) {
              int tempDyn = n.getDynamic();
              tempDyn += accentAmount;
              n.setDynamic(tempDyn);
          }
      }
      beatCounter += n.getRhythmValue();
    }
  }
View Full Code Here

    }

    double beatCounter = (phrase.getStartTime() < 0.0) ? 0.0 : phrase.getStartTime();
    Vector v = phrase.getNoteList();
    for(int i = 0; i < v.size(); i++) {
      Note n = (Note) v.elementAt(i);

      // check to see if that note occurs on an accented beat
      // and if so increase its dynamic level
      for(int j = 0; j < accentedBeats.length; j++){
        if (beatCounter % meter == accentedBeats[j]) {
          int tempDyn = n.getDynamic();
          tempDyn += accentAmount;
          n.setDynamic(tempDyn);
        }
      }
      beatCounter += n.getRhythmValue();
    }
  }
View Full Code Here

        }
        // get the curent max
        int max = 0;
        Enumeration enum1 = phrase.getNoteList().elements();
    while(enum1.hasMoreElements()){
            Note n = (Note) enum1.nextElement();
            if (n.getDynamic() > max) max = n.getDynamic();
    }
    // increase the normalisation
    if (max == Note.MAX_DYNAMIC) {
        return;
    }
    int diff = Note.MAX_DYNAMIC - max;
    Enumeration enum2 = phrase.getNoteList().elements();
    while(enum2.hasMoreElements()){
            Note n = (Note) enum2.nextElement();
            n.setDynamic(n.getDynamic() + diff);
            }   
  }
View Full Code Here

            return;
        }
        int currentValue, newValue;
        Enumeration enum1 = phrase.getNoteList().elements();
    while(enum1.hasMoreElements()){
            Note n = (Note) enum1.nextElement();
            currentValue = n.getDynamic();
            // create new dynamic
            do {
                newValue = currentValue + (int)(Math.random() * 2 * amount - amount);               
            } while (newValue < 0 || newValue > 127);
                n.setDynamic(newValue);
            }
  }
View Full Code Here

TOP

Related Classes of jm.music.data.Note

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.