@Test public void ShouldSetLastChord() { List<ProgressionUnit> progressionUnits = new ArrayList<ProgressionUnit>(); ProgressionUnit a = new ProgressionUnit(); a.initBars(FOUR.getValue()); ProgressionUnit b = new ProgressionUnit(); b.initBars(FOUR.getValue()); progressionUnits.add(a); progressionUnits.add(b); progressionUnits.forEach(pUnit -> { pUnit.getProgressionUnitBars().get(ChordPositions.CHORD_ONE).setChord(new HiveChord("f_maj")); pUnit.getProgressionUnitBars().get(ChordPositions.CHORD_TWO).setChord(new HiveChord("")); pUnit.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).setChord(new HiveChord("g_maj")); pUnit.getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).setChord(new HiveChord("")); }); List<HiveChord> hiveChordInDatabase = new ArrayList<HiveChord>(); hiveChordInDatabase.add(new HiveChord("c_maj7")); hiveChordInDatabase.add(new HiveChord("d_min7")); hiveChordInDatabase.add(new HiveChord("f_maj7")); hiveChordInDatabase.add(new HiveChord("d_dom7")); hiveChordInDatabase.add(new HiveChord("g_maj7")); hiveChordInDatabase.add(new HiveChord("ab_maj")); chordStructureGenerator.setChordFour(hiveChordInDatabase, progressionUnits); assertFalse(progressionUnits.get(0).getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).getChord().isEqual("ab_maj")); }
public boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits) { HashMap<ProgressionType, HiveChord> typeToLoopMap = new HashMap<>(); for (int i=0; i<progressionUnits.size(); i++) { ProgressionUnit progression = progressionUnits.get(i); if (typeToLoopMap.get(progression.getType()) == null || typeToLoopMap.get(progression.getType()).isEqual("")) { HarmonicLoop fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop(); if (fourthLoop == null) { fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop(); } HiveChord chordThree = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); HiveChord chordFromNextProgression; if(i + 1 < progressionUnits.size()){ chordFromNextProgression = progressionUnits.get(i+1).getProgressionUnitBars().get(ChordPositions.CHORD_ONE).getChord(); }else{ chordFromNextProgression = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); } HiveChord fourthChord = chordSelector.selectFourthChord(fourthLoop, chordThree, chordFromNextProgression, hiveChordInDatabase); if(fourthChord == null || fourthChord.getRawChordName().equalsIgnoreCase("_")){ return false; } typeToLoopMap.put(progression.getType(), fourthChord); } progression.getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).setChord(typeToLoopMap.get(progression.getType())); } return true; }
ChordStructureGenerator implements IChordStructureGenerator { public boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits) { HashMap<ProgressionType, HiveChord> typeToLoopMap = new HashMap<>(); for (int i=0; i<progressionUnits.size(); i++) { ProgressionUnit progression = progressionUnits.get(i); if (typeToLoopMap.get(progression.getType()) == null || typeToLoopMap.get(progression.getType()).isEqual("")) { HarmonicLoop fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop(); if (fourthLoop == null) { fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop(); } HiveChord chordThree = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); HiveChord chordFromNextProgression; if(i + 1 < progressionUnits.size()){ chordFromNextProgression = progressionUnits.get(i+1).getProgressionUnitBars().get(ChordPositions.CHORD_ONE).getChord(); }else{ chordFromNextProgression = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); } HiveChord fourthChord = chordSelector.selectFourthChord(fourthLoop, chordThree, chordFromNextProgression, hiveChordInDatabase); if(fourthChord == null || fourthChord.getRawChordName().equalsIgnoreCase("_")){ return false; } typeToLoopMap.put(progression.getType(), fourthChord); } progression.getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).setChord(typeToLoopMap.get(progression.getType())); } return true; } }
ChordStructureGenerator implements IChordStructureGenerator { public boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits) { HashMap<ProgressionType, HiveChord> typeToLoopMap = new HashMap<>(); for (int i=0; i<progressionUnits.size(); i++) { ProgressionUnit progression = progressionUnits.get(i); if (typeToLoopMap.get(progression.getType()) == null || typeToLoopMap.get(progression.getType()).isEqual("")) { HarmonicLoop fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop(); if (fourthLoop == null) { fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop(); } HiveChord chordThree = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); HiveChord chordFromNextProgression; if(i + 1 < progressionUnits.size()){ chordFromNextProgression = progressionUnits.get(i+1).getProgressionUnitBars().get(ChordPositions.CHORD_ONE).getChord(); }else{ chordFromNextProgression = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); } HiveChord fourthChord = chordSelector.selectFourthChord(fourthLoop, chordThree, chordFromNextProgression, hiveChordInDatabase); if(fourthChord == null || fourthChord.getRawChordName().equalsIgnoreCase("_")){ return false; } typeToLoopMap.put(progression.getType(), fourthChord); } progression.getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).setChord(typeToLoopMap.get(progression.getType())); } return true; }  }
ChordStructureGenerator implements IChordStructureGenerator { public boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits) { HashMap<ProgressionType, HiveChord> typeToLoopMap = new HashMap<>(); for (int i=0; i<progressionUnits.size(); i++) { ProgressionUnit progression = progressionUnits.get(i); if (typeToLoopMap.get(progression.getType()) == null || typeToLoopMap.get(progression.getType()).isEqual("")) { HarmonicLoop fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop(); if (fourthLoop == null) { fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop(); } HiveChord chordThree = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); HiveChord chordFromNextProgression; if(i + 1 < progressionUnits.size()){ chordFromNextProgression = progressionUnits.get(i+1).getProgressionUnitBars().get(ChordPositions.CHORD_ONE).getChord(); }else{ chordFromNextProgression = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); } HiveChord fourthChord = chordSelector.selectFourthChord(fourthLoop, chordThree, chordFromNextProgression, hiveChordInDatabase); if(fourthChord == null || fourthChord.getRawChordName().equalsIgnoreCase("_")){ return false; } typeToLoopMap.put(progression.getType(), fourthChord); } progression.getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).setChord(typeToLoopMap.get(progression.getType())); } return true; }  List<ProgressionType> getProgressionTypes(QueueItem queueItem); QueueState set(QueueState queueState); boolean setChordThree(List<ProgressionUnit> progressionUnits, List<HiveChord> hiveChordInDatabase); boolean setChordTwo(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean set2nd3rd4thChordsFor4BarLoops(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap); boolean setFirstChordInProgressions(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, HiveChord> typeAndFirstChord); }
ChordStructureGenerator implements IChordStructureGenerator { public boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits) { HashMap<ProgressionType, HiveChord> typeToLoopMap = new HashMap<>(); for (int i=0; i<progressionUnits.size(); i++) { ProgressionUnit progression = progressionUnits.get(i); if (typeToLoopMap.get(progression.getType()) == null || typeToLoopMap.get(progression.getType()).isEqual("")) { HarmonicLoop fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).getHarmonicLoop(); if (fourthLoop == null) { fourthLoop = progression.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).getHarmonicLoop(); } HiveChord chordThree = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); HiveChord chordFromNextProgression; if(i + 1 < progressionUnits.size()){ chordFromNextProgression = progressionUnits.get(i+1).getProgressionUnitBars().get(ChordPositions.CHORD_ONE).getChord(); }else{ chordFromNextProgression = progression.getProgressionUnitBars().get(ChordPositions.CHORD_THREE).getChord(); } HiveChord fourthChord = chordSelector.selectFourthChord(fourthLoop, chordThree, chordFromNextProgression, hiveChordInDatabase); if(fourthChord == null || fourthChord.getRawChordName().equalsIgnoreCase("_")){ return false; } typeToLoopMap.put(progression.getType(), fourthChord); } progression.getProgressionUnitBars().get(ChordPositions.CHORD_FOUR).setChord(typeToLoopMap.get(progression.getType())); } return true; }  List<ProgressionType> getProgressionTypes(QueueItem queueItem); QueueState set(QueueState queueState); boolean setChordThree(List<ProgressionUnit> progressionUnits, List<HiveChord> hiveChordInDatabase); boolean setChordTwo(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean setChordFour(List<HiveChord> hiveChordInDatabase, List<ProgressionUnit> progressionUnits); boolean set2nd3rd4thChordsFor4BarLoops(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, List<HiveChord>> progressionTypeListHashMap); boolean setFirstChordInProgressions(List<ProgressionUnit> progressionUnits, HashMap<ProgressionType, HiveChord> typeAndFirstChord);  }