private static Pattern createFirstPattern(
     IntervalComparatorElement element, String connector, double baseFreq) {
   String pat = createPatternForInterval(element.getInterval(), connector, baseFreq);
   Pattern p = new Pattern(pat);
   p.setInstrument(GeneralTaskSettings.getSettings().getInstrumentIndex());
   p.setTempo(GeneralTaskSettings.getSettings().getTempo());
   return p;
 }
  private static Pattern createSecondPattern(
      IntervalComparatorElement element, String connector, double baseOfSecond) {

    double higherFreq =
        calculateHigherFreq(baseOfSecond, element.getInterval().getJfugueRep(), element.getRatio());
    String pat = buildPattern(Note.getFrequencyForNote((int) baseOfSecond), higherFreq, connector);
    Pattern p = new Pattern(pat);
    p.setInstrument(GeneralTaskSettings.getSettings().getInstrumentIndex());
    p.setTempo(GeneralTaskSettings.getSettings().getTempo());
    return p;
  }
 /**
  * Creates the pattern for new chord.
  *
  * @param newStructure the new structure
  * @return the linked list
  */
 public static LinkedList<Pattern> createPatternForNewChord(List<Interval> newStructure) {
   LinkedList<Pattern> patterns = new LinkedList<>();
   Interval array[] = new Interval[newStructure.size()];
   String melPattern =
       createPatternForStructureNoAccelerator(
           newStructure.toArray(array), StringConstants.MEL_CONNECTOR, 60);
   String harmPattern =
       createPatternForStructureNoAccelerator(
           newStructure.toArray(array), StringConstants.HARM_CONNECTOR, 60);
   Pattern p = new Pattern(melPattern);
   p.setInstrument(1);
   patterns.add(p);
   Pattern p2 = new Pattern(harmPattern);
   p2.setInstrument(2);
   patterns.add(p2);
   return patterns;
 }
 /**
  * Creates the patterns for chords.
  *
  * @param structures the structures
  * @return the linked list
  */
 public static LinkedList<Pattern> createPatternsForChords(LinkedList<CustomChord> structures) {
   LinkedList<Pattern> patterns = new LinkedList<>();
   String connector =
       GeneralTaskSettings.getSettings().getPlaytype() == PlayType.Harmonically
           ? StringConstants.HARM_CONNECTOR
           : StringConstants.MEL_CONNECTOR;
   structures.forEach(
       struct -> {
         String pat = createChordPattern(generateMidis(struct), connector);
         if (pat == null)
           throw new PatternCreationException("Method createPatternForStructure failed");
         Pattern p = new Pattern(pat);
         p.setInstrument(GeneralTaskSettings.getSettings().getInstrumentIndex());
         p.setTempo(GeneralTaskSettings.getSettings().getTempo());
         patterns.add(p);
       });
   return patterns;
 }
Esempio n. 5
0
  public static void main(String[] args) {

    // Specify the transformation rules for this Lindenmayer system
    Map<String, String> rules =
        new HashMap<String, String>() {
          {
            put("Cmajw", "Cmajw Fmajw");
            put("Fmajw", "Rw Bbmajw");
            put("Bbmajw", "Rw Fmajw");
            put("C5q", "C5q G5q E6q C6q");
            put("E6q", "G6q D6q F6i C6i D6q");
            put("G6i+D6i", "Rq Rq G6i+D6i G6i+D6i Rq");
            put(
                "axiom",
                "axiom V0 I[Flute] Rq C5q V1 I[Tubular_Bells] Rq Rq Rq G6i+D6i V2 I[Piano] Cmajw E6q V3 I[Warm] E6q G6i+D6i V4 I[Voice] C5q E6q");
          }
        };

    // Set up the ReplacementMapPreprocessor to iterate 3 times
    // and not require brackets around replacements
    ReplacementMapPreprocessor rmp = ReplacementMapPreprocessor.getInstance();
    rmp.setReplacementMap(rules);
    rmp.setIterations(4);
    rmp.setRequireAngleBrackets(false);

    // Create a Pattern that contains the L-System axiom
    Pattern axiom =
        new Pattern(
            "T120 "
                + "V0 I[Flute] Rq C5q "
                + "V1 I[Tubular_Bells] Rq Rq Rq G6i+D6i "
                + "V2 I[Piano] Cmajw E6q "
                + "V3 I[Warm] E6q G6i+D6i "
                + "V4 I[Voice] C5q E6q");

    //		Pattern axiom = new Pattern("T120 axiom");

    Player player = new Player();
    System.out.println(rmp.preprocess(axiom.toString(), null));
    player.play(axiom);
  }
 @Test
 public void testCreateChordProgressionWithDashes() {
   ChordProgression cp = new ChordProgression("I-vi7-ii-V7"); // This is a turnaround
   Pattern pattern = cp.setKey(new Key("Amajw")).getPattern();
   assertTrue(pattern.toString().equalsIgnoreCase("A4MAJw F#5MIN7w B4MINw E5MAJ7w"));
 }
 @Test
 public void testCreateChordProgressionWithSpaces() {
   ChordProgression cp = new ChordProgression("iv v i");
   Pattern pattern = cp.setKey(Key.DEFAULT_KEY).getPattern();
   assertTrue(pattern.toString().equalsIgnoreCase("F4MIN G4MIN C4MIN"));
 }
 @Test
 public void testCreateChordProgressionWithNoKey() {
   ChordProgression cp = new ChordProgression("IV V I");
   Pattern pattern = cp.getPattern();
   assertTrue(pattern.toString().equalsIgnoreCase("F4MAJ G4MAJ C4MAJ"));
 }