@Test public void getsSingleChordTwoBarsPrior() { List<HiveChord> hiveChordInDatabase = Arrays.asList(new HiveChord("cMAJ7"), new HiveChord("a#MIN7"), new HiveChord("dDom7"), new HiveChord("d#Maj7"), new HiveChord("a#Min7"), new HiveChord("a#Min7"), new HiveChord("dDom7"), new HiveChord("d#Maj7"), new HiveChord("a#Min7"), new HiveChord("_"), new HiveChord("fDom7"), new HiveChord("cMaj7"), new HiveChord("c#_sus4"), new HiveChord("_"), new HiveChord("cMaj7"), new HiveChord("d#Dom7"), new HiveChord("dMin7b5"), new HiveChord("cMaj7")); HiveChord selectedChordA = chordSelector.getChordTwoBarsPrior(new HiveChord("a#Min7"), hiveChordInDatabase); boolean hasMatch = (selectedChordA.getChordName().equals("ddom7") || selectedChordA.getChordName().equals("d#maj7")); assertThat(hasMatch).isTrue(); HiveChord selectedChordB = chordSelector.getChordTwoBarsPrior(new HiveChord("cMaj7"), hiveChordInDatabase); assertThat(selectedChordB.getChordName()).isEqualTo("d#dom7"); }
public HiveChord getChordTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase) { List<HiveChord> chordCandidates = getChordCandidatesTwoBarsPrior(currentChord, hiveChordInDatabase); int max = chordCandidates.size(); int randomIndex = new Random().nextInt(max); HiveChord chordCandidate = chordCandidates.get(randomIndex); if (chordCandidate == null) { return null; } return chordCandidate; }
ChordSelector implements IChordSelector { public HiveChord getChordTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase) { List<HiveChord> chordCandidates = getChordCandidatesTwoBarsPrior(currentChord, hiveChordInDatabase); int max = chordCandidates.size(); int randomIndex = new Random().nextInt(max); HiveChord chordCandidate = chordCandidates.get(randomIndex); if (chordCandidate == null) { return null; } return chordCandidate; } }
ChordSelector implements IChordSelector { public HiveChord getChordTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase) { List<HiveChord> chordCandidates = getChordCandidatesTwoBarsPrior(currentChord, hiveChordInDatabase); int max = chordCandidates.size(); int randomIndex = new Random().nextInt(max); HiveChord chordCandidate = chordCandidates.get(randomIndex); if (chordCandidate == null) { return null; } return chordCandidate; }  }
ChordSelector implements IChordSelector { public HiveChord getChordTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase) { List<HiveChord> chordCandidates = getChordCandidatesTwoBarsPrior(currentChord, hiveChordInDatabase); int max = chordCandidates.size(); int randomIndex = new Random().nextInt(max); HiveChord chordCandidate = chordCandidates.get(randomIndex); if (chordCandidate == null) { return null; } return chordCandidate; }  HashMap<ProgressionType, HiveChord> selectFirstChordForType(List<ProgressionType> progressionTypes, List<HiveChord> hiveChordInDatabase); @Override HashMap<ProgressionType, List<HiveChord>> selectChordsFrom4BarLoop(List<ProgressionUnit> progressionUnits); HiveChord tempRandomChordSelect(List<HiveChord> getHiveChordInDatabase); HiveChord getChordTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase); List<HiveChord> getChordCandidatesTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase); HiveChord selectChordBetweenChords(HiveChord chordOne, HiveChord chordTwo, List<HiveChord> hiveChordInDatabase); @Override HiveChord selectChordBetweenChordsAndLoop(HiveChord chordOne, HiveChord chordTwo, HarmonicLoop harmonicLoop, List<HiveChord> hiveChordInDatabase); List<HiveChord> getChordCandidatesBetweenChords(HiveChord chordOne, HiveChord chordTwo, List<HiveChord> hiveChordInDatabase); @Override HiveChord selectMiddleChord(HarmonicLoop selectedLoop, HiveChord chordOneOfFour, HiveChord chordOneOfNextBar, List<HiveChord> hiveChordInDatabase); @Override HiveChord selectFourthChord(HarmonicLoop selectedLoop, HiveChord thirdChord, HiveChord nextChord, List<HiveChord> hiveChordInDatabase); }
ChordSelector implements IChordSelector { public HiveChord getChordTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase) { List<HiveChord> chordCandidates = getChordCandidatesTwoBarsPrior(currentChord, hiveChordInDatabase); int max = chordCandidates.size(); int randomIndex = new Random().nextInt(max); HiveChord chordCandidate = chordCandidates.get(randomIndex); if (chordCandidate == null) { return null; } return chordCandidate; }  HashMap<ProgressionType, HiveChord> selectFirstChordForType(List<ProgressionType> progressionTypes, List<HiveChord> hiveChordInDatabase); @Override HashMap<ProgressionType, List<HiveChord>> selectChordsFrom4BarLoop(List<ProgressionUnit> progressionUnits); HiveChord tempRandomChordSelect(List<HiveChord> getHiveChordInDatabase); HiveChord getChordTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase); List<HiveChord> getChordCandidatesTwoBarsPrior(HiveChord currentChord, List<HiveChord> hiveChordInDatabase); HiveChord selectChordBetweenChords(HiveChord chordOne, HiveChord chordTwo, List<HiveChord> hiveChordInDatabase); @Override HiveChord selectChordBetweenChordsAndLoop(HiveChord chordOne, HiveChord chordTwo, HarmonicLoop harmonicLoop, List<HiveChord> hiveChordInDatabase); List<HiveChord> getChordCandidatesBetweenChords(HiveChord chordOne, HiveChord chordTwo, List<HiveChord> hiveChordInDatabase); @Override HiveChord selectMiddleChord(HarmonicLoop selectedLoop, HiveChord chordOneOfFour, HiveChord chordOneOfNextBar, List<HiveChord> hiveChordInDatabase); @Override HiveChord selectFourthChord(HarmonicLoop selectedLoop, HiveChord thirdChord, HiveChord nextChord, List<HiveChord> hiveChordInDatabase);  }