class SetMelodicSynthEvent implements IEventChain {

    @Override
    public QueueState set(QueueState queueState) {

            Map<ProgressionType, List<HiveChord>> pTypeToChords = new HashMap<>();
            for (ProgressionUnit progressionUnit : queueState.getStructure()) {
                List<HiveChord> chords = new ArrayList<>();
                for (ProgressionUnitBar pBar : progressionUnit.getProgressionUnitBars()) {
                    chords.add(pBar.getChord());
                }
                pTypeToChords.put(progressionUnit.getType(), chords);
            }

            Map<ProgressionType, List<String>> pTypeToMelody = new HashMap<>();
            for (Map.Entry<ProgressionType, List<HiveChord>> entry : pTypeToChords.entrySet()) {
                List<String> jFugueMelody = melodydGenerator.generate(entry.getValue(), numOfAltMelodies);
                List<String> melodies = new ArrayList<>();
                for (String melody: jFugueMelody) {
                    melodies.add("T" + queueState.getQueueItem().getBpm() + " " + melody);
                }

                pTypeToMelody.put(entry.getKey(), melodies);
            }

            for (ProgressionUnit progressionUnit : queueState.getStructure()) {
                progressionUnit.addMelodies(pTypeToMelody.get(progressionUnit.getType()));
            }


        return queueState;
    }

    @Autowired public  SetMelodicSynthEvent(MelodyGenerator melodydGenerator, MelodicExtractor melodicExtractor, IBachChoraleDal bachChoraleDal);

}