@Test public void ShouldSetCorrectBeatLoopCurrentPositions() { QueueItem queueItem = new QueueItem(); queueItem.setBpm(80); ProgressionUnit unitA = new ProgressionUnit(); unitA.initBars(4); unitA.setComplexity(1); unitA.setBarCount(FOUR.getValue()); unitA.setType(ProgressionUnit.ProgressionType.VERSE); HashMap<Composition.Layer, Boolean> gateA = new HashMap<>(); gateA.put(Composition.Layer.BEAT_LOOP, true); unitA.setGatedLayers(gateA); ProgressionUnit unitB = new ProgressionUnit(); unitB.initBars(4); unitB.setComplexity(1); unitB.setBarCount(FOUR.getValue()); unitB.setType(ProgressionUnit.ProgressionType.CHORUS); HashMap<Composition.Layer, Boolean> gateB = new HashMap<>(); gateB.put(Composition.Layer.BEAT_LOOP, true); unitB.setGatedLayers(gateB); ProgressionUnit unitC = new ProgressionUnit(); unitC.initBars(4); unitC.setComplexity(1); unitC.setBarCount(FOUR.getValue()); unitC.setType(ProgressionUnit.ProgressionType.BRIDGE); HashMap<Composition.Layer, Boolean> gateC = new HashMap<>(); gateC.put(Composition.Layer.BEAT_LOOP, true); unitC.setGatedLayers(gateC); List<ProgressionUnit> pUnits = new ArrayList<>(); pUnits.add(unitA); pUnits.add(unitB); pUnits.add(unitC); ProgressionDTO progressionDTO = new ProgressionDTO(); progressionDTO.setStructure(pUnits); BeatLoop loopA = new BeatLoop() {{ setFileName("beatLoopA"); setBarCount(1); }}; BeatLoop loopB = new BeatLoop() {{ setFileName("beatLoopB"); setBarCount(2); }}; BeatLoop loopC = new BeatLoop() {{ setFileName("beatLoopC"); setBarCount(4); }}; QueueState queueState = new QueueState(); queueState.setDataSource(new SourceData() {{ setBeatLoops(new ArrayList<BeatLoop>() {{ add(loopA); add(loopB); add(loopC); }}); }}); queueItem.setProgression(progressionDTO); queueState.setQueueItem(queueItem); Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType = new HashMap<>(); beatLoopByType.put(ProgressionUnit.ProgressionType.VERSE, loopA); beatLoopByType.put(ProgressionUnit.ProgressionType.CHORUS, loopB); beatLoopByType.put(ProgressionUnit.ProgressionType.BRIDGE, loopC); beatLoopGenerator.setBeatLoops(beatLoopByType, Composition.Layer.BEAT_LOOP, queueState.getStructure()); queueState.getStructure().forEach(pUnit -> { if (pUnit.getType() == ProgressionUnit.ProgressionType.VERSE) { for (int i = 0; i < pUnit.getProgressionUnitBars().size(); i++) { ProgressionUnitBar pUnitBar = pUnit.getProgressionUnitBars().get(i); if (i == 0) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopA")); Assert.assertEquals(1, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 1) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopA")); Assert.assertEquals(1, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 2) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopA")); Assert.assertEquals(1, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 3) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopA")); Assert.assertEquals(1, pUnitBar.getBeatLoop().getCurrentBar()); } } } if (pUnit.getType() == ProgressionUnit.ProgressionType.CHORUS) { for (int i = 0; i < pUnit.getProgressionUnitBars().size(); i++) { ProgressionUnitBar pUnitBar = pUnit.getProgressionUnitBars().get(i); if (i == 0) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopB")); Assert.assertEquals(1, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 1) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopB")); Assert.assertEquals(2, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 2) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopB")); Assert.assertEquals(1, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 3) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopB")); Assert.assertEquals(2, pUnitBar.getBeatLoop().getCurrentBar()); } } } if (pUnit.getType() == ProgressionUnit.ProgressionType.BRIDGE) { for (int i = 0; i < pUnit.getProgressionUnitBars().size(); i++) { ProgressionUnitBar pUnitBar = pUnit.getProgressionUnitBars().get(i); if (i == 0) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopC")); Assert.assertEquals(1, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 1) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopC")); Assert.assertEquals(2, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 2) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopC")); Assert.assertEquals(3, pUnitBar.getBeatLoop().getCurrentBar()); } if (i == 3) { Assert.assertTrue(pUnitBar.getBeatLoop().getFileName().equalsIgnoreCase("beatLoopC")); Assert.assertEquals(4, pUnitBar.getBeatLoop().getCurrentBar()); } } } }); }
public void setBeatLoops(Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits) { progressionUnits.forEach(pUnit -> { try { if (layerType == Composition.Layer.BEAT_LOOP) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopFour); } } else if (layerType == Composition.Layer.BEAT_LOOP_ALT) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopFour); } } } catch (CloneNotSupportedException e) { Application.logger.debug("LOG:", e); } }); }
BeatLoopGenerator implements IBeatLoopGenerator { public void setBeatLoops(Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits) { progressionUnits.forEach(pUnit -> { try { if (layerType == Composition.Layer.BEAT_LOOP) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopFour); } } else if (layerType == Composition.Layer.BEAT_LOOP_ALT) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopFour); } } } catch (CloneNotSupportedException e) { Application.logger.debug("LOG:", e); } }); } }
BeatLoopGenerator implements IBeatLoopGenerator { public void setBeatLoops(Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits) { progressionUnits.forEach(pUnit -> { try { if (layerType == Composition.Layer.BEAT_LOOP) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopFour); } } else if (layerType == Composition.Layer.BEAT_LOOP_ALT) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopFour); } } } catch (CloneNotSupportedException e) { Application.logger.debug("LOG:", e); } }); }  }
BeatLoopGenerator implements IBeatLoopGenerator { public void setBeatLoops(Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits) { progressionUnits.forEach(pUnit -> { try { if (layerType == Composition.Layer.BEAT_LOOP) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopFour); } } else if (layerType == Composition.Layer.BEAT_LOOP_ALT) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopFour); } } } catch (CloneNotSupportedException e) { Application.logger.debug("LOG:", e); } }); }  QueueState generateAndSetBeatLoops(QueueState queueState, Composition.Layer layerType ); void setBeatLoops(Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits); @Override void setBeatLoop(BeatLoop beatLoop, int barIndex, List<ProgressionUnitBar> progressionUnitBars); @Override int getMaxBarCount(ProgressionUnit pUnit, int currentBarIndex); }
BeatLoopGenerator implements IBeatLoopGenerator { public void setBeatLoops(Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits) { progressionUnits.forEach(pUnit -> { try { if (layerType == Composition.Layer.BEAT_LOOP) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoop(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoop(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoop(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoop(loopFour); } } else if (layerType == Composition.Layer.BEAT_LOOP_ALT) { BeatLoop beatLoop = beatLoopByType.get(pUnit.getType()); if (beatLoop.getBarCount() == 1) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopOne); } else if (beatLoop.getBarCount() == 2) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopTwo); } else if (beatLoop.getBarCount() == 4) { BeatLoop loopOne = beatLoop.clone(); loopOne.setCurrentBar(1); BeatLoop loopTwo = beatLoop.clone(); loopTwo.setCurrentBar(2); BeatLoop loopThree = beatLoop.clone(); loopThree.setCurrentBar(3); BeatLoop loopFour = beatLoop.clone(); loopFour.setCurrentBar(4); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_ONE).setBeatLoopAlt(loopOne); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_TWO).setBeatLoopAlt(loopTwo); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_THREE).setBeatLoopAlt(loopThree); pUnit.getProgressionUnitBars().get(LoopPositions.POSITION_FOUR).setBeatLoopAlt(loopFour); } } } catch (CloneNotSupportedException e) { Application.logger.debug("LOG:", e); } }); }  QueueState generateAndSetBeatLoops(QueueState queueState, Composition.Layer layerType ); void setBeatLoops(Map<ProgressionUnit.ProgressionType, BeatLoop> beatLoopByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits); @Override void setBeatLoop(BeatLoop beatLoop, int barIndex, List<ProgressionUnitBar> progressionUnitBars); @Override int getMaxBarCount(ProgressionUnit pUnit, int currentBarIndex); @Autowired
    public AppConfigs appConfigs; }