@Test public void shouldCreateCorrectSequenceMap() { BachChorale bOne = new BachChorale(); bOne.setChord("emin7"); BachChorale bTwo = new BachChorale(); bTwo.setChord("emin"); BachChorale bThree = new BachChorale(); bThree.setChord("cmaj"); BachChorale bFour = new BachChorale(); bFour.setChord("dmin7"); BachChorale bFive = new BachChorale(); bFive.setChord("emin"); BachChorale bSix = new BachChorale(); bSix.setChord("gmaj"); List<BachChorale> bachChorales = Arrays.asList(bOne, bTwo, bThree, bFour, bFive, bSix); Map<ProgressionType, int[]> map = new HashMap<>(); map.put(ProgressionType.VERSE, new int[]{2, 2}); map.put(ProgressionType.CHORUS, new int[]{1, 3}); map.put(ProgressionType.BRIDGE, new int[]{6, 0}); Map<ProgressionType, List<String>> output = setMelodicSynthEvent.createTypeToChordSequenceMap(map, bachChorales); assertThat(output.get(ProgressionType.VERSE)).isEqualTo(Arrays.asList("cmaj", "dmin7")); assertThat(output.get(ProgressionType.CHORUS)).isEqualTo(Arrays.asList("dmin7")); assertThat(output.get(ProgressionType.BRIDGE)).isEqualTo(Arrays.asList("emin7", "emin", "cmaj", "dmin7", "emin", "gmaj")); }
public Map<ProgressionType, List<String>> createTypeToChordSequenceMap(Map<ProgressionType, int[]> typeToMatchLengthAndOffset, List<BachChorale> chorales) { Map<ProgressionType, List<String>> typeToChordSequence = new HashMap<>(); for (Map.Entry<ProgressionType, int[]> map : typeToMatchLengthAndOffset.entrySet()) { int startIndex = map.getValue()[1]; int endIndex = map.getValue()[1] + map.getValue()[0]; List<String> chordSequence = chorales.subList(startIndex, endIndex).stream().map(c -> c.getChord()).collect(Collectors.toList()); typeToChordSequence.put(map.getKey(), chordSequence); } return typeToChordSequence; }
SetMelodicSynthEvent implements IEventChain { public Map<ProgressionType, List<String>> createTypeToChordSequenceMap(Map<ProgressionType, int[]> typeToMatchLengthAndOffset, List<BachChorale> chorales) { Map<ProgressionType, List<String>> typeToChordSequence = new HashMap<>(); for (Map.Entry<ProgressionType, int[]> map : typeToMatchLengthAndOffset.entrySet()) { int startIndex = map.getValue()[1]; int endIndex = map.getValue()[1] + map.getValue()[0]; List<String> chordSequence = chorales.subList(startIndex, endIndex).stream().map(c -> c.getChord()).collect(Collectors.toList()); typeToChordSequence.put(map.getKey(), chordSequence); } return typeToChordSequence; } }
SetMelodicSynthEvent implements IEventChain { public Map<ProgressionType, List<String>> createTypeToChordSequenceMap(Map<ProgressionType, int[]> typeToMatchLengthAndOffset, List<BachChorale> chorales) { Map<ProgressionType, List<String>> typeToChordSequence = new HashMap<>(); for (Map.Entry<ProgressionType, int[]> map : typeToMatchLengthAndOffset.entrySet()) { int startIndex = map.getValue()[1]; int endIndex = map.getValue()[1] + map.getValue()[0]; List<String> chordSequence = chorales.subList(startIndex, endIndex).stream().map(c -> c.getChord()).collect(Collectors.toList()); typeToChordSequence.put(map.getKey(), chordSequence); } return typeToChordSequence; } @Autowired  SetMelodicSynthEvent(MelodyGenerator melodydGenerator, MelodicExtractor melodicExtractor, IBachChoraleDal bachChoraleDal); }
SetMelodicSynthEvent implements IEventChain { public Map<ProgressionType, List<String>> createTypeToChordSequenceMap(Map<ProgressionType, int[]> typeToMatchLengthAndOffset, List<BachChorale> chorales) { Map<ProgressionType, List<String>> typeToChordSequence = new HashMap<>(); for (Map.Entry<ProgressionType, int[]> map : typeToMatchLengthAndOffset.entrySet()) { int startIndex = map.getValue()[1]; int endIndex = map.getValue()[1] + map.getValue()[0]; List<String> chordSequence = chorales.subList(startIndex, endIndex).stream().map(c -> c.getChord()).collect(Collectors.toList()); typeToChordSequence.put(map.getKey(), chordSequence); } return typeToChordSequence; } @Autowired  SetMelodicSynthEvent(MelodyGenerator melodydGenerator, MelodicExtractor melodicExtractor, IBachChoraleDal bachChoraleDal); @Override QueueState set(QueueState queueState); Map<ProgressionType, List<BachChorale>> createTypeToBachChorales(List<BachChorale> choralesDb, Map<ProgressionType, List<HarmonyExtraction>> typeToHarmonicExtractionMap); List<String> findUnusedNotes(List<String> usedNotes, List<String> availableNotes); Map<ProgressionType, List<String>> createTypeToChordSequenceMap(Map<ProgressionType, int[]> typeToMatchLengthAndOffset, List<BachChorale> chorales); List<BachChorale> createMatchingChorales(List<BachChorale> bachChorales, List<HarmonyExtraction> harmonyExtractions); LongestMatchResponse getLongestMatch(List<BachChorale> bachChorales, List<HarmonyExtraction> harmonyExtractions); int interateCollection(int indexOffset, List<BachChorale> bachChorales, List<HarmonyExtraction> extractions); }
SetMelodicSynthEvent implements IEventChain { public Map<ProgressionType, List<String>> createTypeToChordSequenceMap(Map<ProgressionType, int[]> typeToMatchLengthAndOffset, List<BachChorale> chorales) { Map<ProgressionType, List<String>> typeToChordSequence = new HashMap<>(); for (Map.Entry<ProgressionType, int[]> map : typeToMatchLengthAndOffset.entrySet()) { int startIndex = map.getValue()[1]; int endIndex = map.getValue()[1] + map.getValue()[0]; List<String> chordSequence = chorales.subList(startIndex, endIndex).stream().map(c -> c.getChord()).collect(Collectors.toList()); typeToChordSequence.put(map.getKey(), chordSequence); } return typeToChordSequence; } @Autowired  SetMelodicSynthEvent(MelodyGenerator melodydGenerator, MelodicExtractor melodicExtractor, IBachChoraleDal bachChoraleDal); @Override QueueState set(QueueState queueState); Map<ProgressionType, List<BachChorale>> createTypeToBachChorales(List<BachChorale> choralesDb, Map<ProgressionType, List<HarmonyExtraction>> typeToHarmonicExtractionMap); List<String> findUnusedNotes(List<String> usedNotes, List<String> availableNotes); Map<ProgressionType, List<String>> createTypeToChordSequenceMap(Map<ProgressionType, int[]> typeToMatchLengthAndOffset, List<BachChorale> chorales); List<BachChorale> createMatchingChorales(List<BachChorale> bachChorales, List<HarmonyExtraction> harmonyExtractions); LongestMatchResponse getLongestMatch(List<BachChorale> bachChorales, List<HarmonyExtraction> harmonyExtractions); int interateCollection(int indexOffset, List<BachChorale> bachChorales, List<HarmonyExtraction> extractions);  }