Beispiel #1
0
  @Test
  public void testCreateVariation() {
    Note firstNote = note().pc(4).pitch(64).pos(0).len(12).ocatve(5).build();
    List<Note> notes = variation.createVariation(firstNote, null);
    assertEquals(firstNote.getPitch(), notes.get(0).getPitch());
    assertEquals(firstNote.getPitch() + 1, notes.get(1).getPitch());

    assertEquals(6, notes.get(0).getLength());
    assertEquals(6, notes.get(1).getLength());
  }
Beispiel #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());
   }
 }