Exemple #1
0
 public Harmony randomHarmony(List<Harmony> harmonies) {
   int harmonyIndex = 0;
   if (isOuterBoundaryIncluded) {
     harmonyIndex = RandomUtil.randomInt(0, harmonies.size());
   } else {
     harmonyIndex = RandomUtil.randomInt(1, harmonies.size() - 1);
   }
   return harmonies.get(harmonyIndex);
 }
Exemple #2
0
 @Override
 public List<Note> createVariation(Note firstNote, Note secondNote) {
   if (variationPattern.getNoteLengths().contains(secondNote.getLength())) {
     secondNoteChanged = true;
     double[] pattern = RandomUtil.getRandomFromDoubleArray(variationPattern.getPatterns());
     Scale scale = RandomUtil.getRandomFromList(scales);
     int newPitchClass = scale.pickPreviousPitchFromScale(firstNote.getPitchClass());
     int ic = Util.intervalClass(newPitchClass - firstNote.getPitchClass());
     int newPitch = firstNote.getPitch() - ic;
     List<Note> notes = generateAccentedNonChordNote(secondNote, newPitchClass, newPitch, pattern);
     notes.add(0, firstNote);
     return notes;
   } else {
     return Collections.singletonList(firstNote.copy());
   }
 }