@Test public void selectMiddleChord() throws Exception { HarmonicLoop loop = new HarmonicLoop(); List<HiveChord> hiveChordInDatabase = new ArrayList<>(); List<HiveChord> hiveChordList = new ArrayList<>(); hiveChordList.add(new HiveChord("dDOM7")); hiveChordList.add(new HiveChord("gMAJ7")); loop.setChords(hiveChordList); HiveChord selectedChord = chordSelector.selectMiddleChord(loop, new HiveChord("g#MAJ7"), new HiveChord("dDIM"), hiveChordInDatabase); Assert.assertTrue(selectedChord.isEqual(loop.getRootOne()) || selectedChord.isEqual(loop.getRootTwo())); }
@Override public HiveChord selectMiddleChord(HarmonicLoop selectedLoop, HiveChord chordOneOfFour, HiveChord chordOneOfNextBar, List<HiveChord> hiveChordInDatabase) { List<HiveChord> compatibleChords = selectedLoop.getValidChords(); if (compatibleChords == null || compatibleChords.size() == 0) { return null; } for (int i = 0; i < compatibleChords.size(); i++) { HiveChord compChord = compatibleChords.get(i); for (int j = 0; j < hiveChordInDatabase.size(); j++) { HiveChord dbChord = hiveChordInDatabase.get(j); if ((chordOneOfFour != null && chordOneOfNextBar != null) && (j > 0 && j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } else if ((chordOneOfFour != null) && (j > 0) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour)) { return compChord; } else if ((chordOneOfNextBar != null) && (j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } } } int index = new Random().nextInt(compatibleChords.size()); return compatibleChords.get(index); }
ChordSelector implements IChordSelector { @Override public HiveChord selectMiddleChord(HarmonicLoop selectedLoop, HiveChord chordOneOfFour, HiveChord chordOneOfNextBar, List<HiveChord> hiveChordInDatabase) { List<HiveChord> compatibleChords = selectedLoop.getValidChords(); if (compatibleChords == null || compatibleChords.size() == 0) { return null; } for (int i = 0; i < compatibleChords.size(); i++) { HiveChord compChord = compatibleChords.get(i); for (int j = 0; j < hiveChordInDatabase.size(); j++) { HiveChord dbChord = hiveChordInDatabase.get(j); if ((chordOneOfFour != null && chordOneOfNextBar != null) && (j > 0 && j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } else if ((chordOneOfFour != null) && (j > 0) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour)) { return compChord; } else if ((chordOneOfNextBar != null) && (j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } } } int index = new Random().nextInt(compatibleChords.size()); return compatibleChords.get(index); } }
ChordSelector implements IChordSelector { @Override public HiveChord selectMiddleChord(HarmonicLoop selectedLoop, HiveChord chordOneOfFour, HiveChord chordOneOfNextBar, List<HiveChord> hiveChordInDatabase) { List<HiveChord> compatibleChords = selectedLoop.getValidChords(); if (compatibleChords == null || compatibleChords.size() == 0) { return null; } for (int i = 0; i < compatibleChords.size(); i++) { HiveChord compChord = compatibleChords.get(i); for (int j = 0; j < hiveChordInDatabase.size(); j++) { HiveChord dbChord = hiveChordInDatabase.get(j); if ((chordOneOfFour != null && chordOneOfNextBar != null) && (j > 0 && j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } else if ((chordOneOfFour != null) && (j > 0) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour)) { return compChord; } else if ((chordOneOfNextBar != null) && (j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } } } int index = new Random().nextInt(compatibleChords.size()); return compatibleChords.get(index); }  }
ChordSelector implements IChordSelector { @Override public HiveChord selectMiddleChord(HarmonicLoop selectedLoop, HiveChord chordOneOfFour, HiveChord chordOneOfNextBar, List<HiveChord> hiveChordInDatabase) { List<HiveChord> compatibleChords = selectedLoop.getValidChords(); if (compatibleChords == null || compatibleChords.size() == 0) { return null; } for (int i = 0; i < compatibleChords.size(); i++) { HiveChord compChord = compatibleChords.get(i); for (int j = 0; j < hiveChordInDatabase.size(); j++) { HiveChord dbChord = hiveChordInDatabase.get(j); if ((chordOneOfFour != null && chordOneOfNextBar != null) && (j > 0 && j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } else if ((chordOneOfFour != null) && (j > 0) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour)) { return compChord; } else if ((chordOneOfNextBar != null) && (j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } } } int index = new Random().nextInt(compatibleChords.size()); return compatibleChords.get(index); }  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 { @Override public HiveChord selectMiddleChord(HarmonicLoop selectedLoop, HiveChord chordOneOfFour, HiveChord chordOneOfNextBar, List<HiveChord> hiveChordInDatabase) { List<HiveChord> compatibleChords = selectedLoop.getValidChords(); if (compatibleChords == null || compatibleChords.size() == 0) { return null; } for (int i = 0; i < compatibleChords.size(); i++) { HiveChord compChord = compatibleChords.get(i); for (int j = 0; j < hiveChordInDatabase.size(); j++) { HiveChord dbChord = hiveChordInDatabase.get(j); if ((chordOneOfFour != null && chordOneOfNextBar != null) && (j > 0 && j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } else if ((chordOneOfFour != null) && (j > 0) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j - 1).isEqualOrTriadMatch(chordOneOfFour)) { return compChord; } else if ((chordOneOfNextBar != null) && (j < hiveChordInDatabase.size() - 1) && dbChord.isEqualOrTriadMatch(compChord) && hiveChordInDatabase.get(j + 1).isEqualOrTriadMatch(chordOneOfNextBar)) { return compChord; } } } int index = new Random().nextInt(compatibleChords.size()); return compatibleChords.get(index); }  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);  }