@Test public void shouldSelectAtonalLoop() { ProgressionUnitBar barOne = new ProgressionUnitBar(); barOne.setChord(new HiveChord("a#min7")); ProgressionUnitBar barTwo = new ProgressionUnitBar(); barTwo.setChord(new HiveChord("a#min")); ProgressionUnitBar barThree = new ProgressionUnitBar(); barThree.setChord(new HiveChord("d#min7")); ProgressionUnitBar barFour = new ProgressionUnitBar(); barFour.setChord(new HiveChord("d#min")); ProgressionUnit unitA = new ProgressionUnit(); unitA.setComplexity(1); unitA.initBars(FOUR.getValue()); unitA.setType(CHORUS); unitA.setProgressionUnitBars(Arrays.asList(barOne, barTwo, barThree, barFour)); List<ProgressionUnit> pUnits = new ArrayList<>(); pUnits.add(unitA); ProgressionDTO progressionDTO = new ProgressionDTO(); progressionDTO.setStructure(pUnits); QueueState queueState = new QueueState(); QueueItem queueItem = new QueueItem(); queueItem.setBpm(80); queueItem.setProgression(progressionDTO); queueState.setQueueItem(queueItem); queueState = ambienceGenerator.generateAndSetAmbienceLoops(queueState, Composition.Layer.AMBIENCE_LOOP); assertThat(queueState.getStructure().get(0).getProgressionUnitBars().get(0).getAmbienceLoop().getId()).isEqualTo(1); }
public QueueState generateAndSetAmbienceLoops(QueueState queueState, Composition.Layer layerType) { float secondsInBar = LoopUtils.getBeatsInSeconds(queueState.getQueueItem().getBpm(), 4); float maxSampleLength = secondsInBar * 4f; Map<ProgressionUnit.ProgressionType, AmbienceLoop> ambienceLoopsByType = new HashMap<>(); for (int i = 0; i < queueState.getStructure().size(); i++) { ProgressionUnit progressionUnit = queueState.getStructure().get(i); if (ambienceLoopsByType.get(progressionUnit.getType()) == null) { AmbienceLoop ambienceLoop; if (progressionUnit.isLayerGated(layerType)) { ambienceLoop = ShimHelper.getShimAsAmbienceLoop(); } else { ambienceLoop = getLoop(maxSampleLength, progressionUnit); } float barCount = LoopUtils.getBarCountForLoop(ambienceLoop.getAudioLength(), secondsInBar); float exactSampleLength = audioUtils.getAudioLength(appConfigs.getAmbienceFullPath(ambienceLoop)); float newLoopLengthInSeconds = LoopUtils.getBarGroupLengthInSeconds((float) secondsInBar, (float) barCount); float shimLength = newLoopLengthInSeconds - exactSampleLength; ambienceLoop.setShimLength(shimLength); ambienceLoopsByType.put(progressionUnit.getType(), ambienceLoop); } } setAmbienceLoops(ambienceLoopsByType, layerType, queueState.getStructure()); return queueState; }
AmbienceGenerator implements IAmbienceGenerator { public QueueState generateAndSetAmbienceLoops(QueueState queueState, Composition.Layer layerType) { float secondsInBar = LoopUtils.getBeatsInSeconds(queueState.getQueueItem().getBpm(), 4); float maxSampleLength = secondsInBar * 4f; Map<ProgressionUnit.ProgressionType, AmbienceLoop> ambienceLoopsByType = new HashMap<>(); for (int i = 0; i < queueState.getStructure().size(); i++) { ProgressionUnit progressionUnit = queueState.getStructure().get(i); if (ambienceLoopsByType.get(progressionUnit.getType()) == null) { AmbienceLoop ambienceLoop; if (progressionUnit.isLayerGated(layerType)) { ambienceLoop = ShimHelper.getShimAsAmbienceLoop(); } else { ambienceLoop = getLoop(maxSampleLength, progressionUnit); } float barCount = LoopUtils.getBarCountForLoop(ambienceLoop.getAudioLength(), secondsInBar); float exactSampleLength = audioUtils.getAudioLength(appConfigs.getAmbienceFullPath(ambienceLoop)); float newLoopLengthInSeconds = LoopUtils.getBarGroupLengthInSeconds((float) secondsInBar, (float) barCount); float shimLength = newLoopLengthInSeconds - exactSampleLength; ambienceLoop.setShimLength(shimLength); ambienceLoopsByType.put(progressionUnit.getType(), ambienceLoop); } } setAmbienceLoops(ambienceLoopsByType, layerType, queueState.getStructure()); return queueState; } }
AmbienceGenerator implements IAmbienceGenerator { public QueueState generateAndSetAmbienceLoops(QueueState queueState, Composition.Layer layerType) { float secondsInBar = LoopUtils.getBeatsInSeconds(queueState.getQueueItem().getBpm(), 4); float maxSampleLength = secondsInBar * 4f; Map<ProgressionUnit.ProgressionType, AmbienceLoop> ambienceLoopsByType = new HashMap<>(); for (int i = 0; i < queueState.getStructure().size(); i++) { ProgressionUnit progressionUnit = queueState.getStructure().get(i); if (ambienceLoopsByType.get(progressionUnit.getType()) == null) { AmbienceLoop ambienceLoop; if (progressionUnit.isLayerGated(layerType)) { ambienceLoop = ShimHelper.getShimAsAmbienceLoop(); } else { ambienceLoop = getLoop(maxSampleLength, progressionUnit); } float barCount = LoopUtils.getBarCountForLoop(ambienceLoop.getAudioLength(), secondsInBar); float exactSampleLength = audioUtils.getAudioLength(appConfigs.getAmbienceFullPath(ambienceLoop)); float newLoopLengthInSeconds = LoopUtils.getBarGroupLengthInSeconds((float) secondsInBar, (float) barCount); float shimLength = newLoopLengthInSeconds - exactSampleLength; ambienceLoop.setShimLength(shimLength); ambienceLoopsByType.put(progressionUnit.getType(), ambienceLoop); } } setAmbienceLoops(ambienceLoopsByType, layerType, queueState.getStructure()); return queueState; } AmbienceGenerator(IShimGenerator shimGenerator, IAmbienceLoopsDal ambienceLoopsDal, IAudioUtils audioUtils, AppConfigs appConfigs); }
AmbienceGenerator implements IAmbienceGenerator { public QueueState generateAndSetAmbienceLoops(QueueState queueState, Composition.Layer layerType) { float secondsInBar = LoopUtils.getBeatsInSeconds(queueState.getQueueItem().getBpm(), 4); float maxSampleLength = secondsInBar * 4f; Map<ProgressionUnit.ProgressionType, AmbienceLoop> ambienceLoopsByType = new HashMap<>(); for (int i = 0; i < queueState.getStructure().size(); i++) { ProgressionUnit progressionUnit = queueState.getStructure().get(i); if (ambienceLoopsByType.get(progressionUnit.getType()) == null) { AmbienceLoop ambienceLoop; if (progressionUnit.isLayerGated(layerType)) { ambienceLoop = ShimHelper.getShimAsAmbienceLoop(); } else { ambienceLoop = getLoop(maxSampleLength, progressionUnit); } float barCount = LoopUtils.getBarCountForLoop(ambienceLoop.getAudioLength(), secondsInBar); float exactSampleLength = audioUtils.getAudioLength(appConfigs.getAmbienceFullPath(ambienceLoop)); float newLoopLengthInSeconds = LoopUtils.getBarGroupLengthInSeconds((float) secondsInBar, (float) barCount); float shimLength = newLoopLengthInSeconds - exactSampleLength; ambienceLoop.setShimLength(shimLength); ambienceLoopsByType.put(progressionUnit.getType(), ambienceLoop); } } setAmbienceLoops(ambienceLoopsByType, layerType, queueState.getStructure()); return queueState; } AmbienceGenerator(IShimGenerator shimGenerator, IAmbienceLoopsDal ambienceLoopsDal, IAudioUtils audioUtils, AppConfigs appConfigs); QueueState generateAndSetAmbienceLoops(QueueState queueState, Composition.Layer layerType); int numberOfLoopsRequired(ProgressionUnit progression, BeatLoop beatLoop); AmbienceLoop getLoop(float maxSampleLength, ProgressionUnit progressionUnit); float getSampleLength(String filePath); @Override void setAmbienceLoops(Map<ProgressionUnit.ProgressionType, AmbienceLoop> ambienceLoopsByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits); }
AmbienceGenerator implements IAmbienceGenerator { public QueueState generateAndSetAmbienceLoops(QueueState queueState, Composition.Layer layerType) { float secondsInBar = LoopUtils.getBeatsInSeconds(queueState.getQueueItem().getBpm(), 4); float maxSampleLength = secondsInBar * 4f; Map<ProgressionUnit.ProgressionType, AmbienceLoop> ambienceLoopsByType = new HashMap<>(); for (int i = 0; i < queueState.getStructure().size(); i++) { ProgressionUnit progressionUnit = queueState.getStructure().get(i); if (ambienceLoopsByType.get(progressionUnit.getType()) == null) { AmbienceLoop ambienceLoop; if (progressionUnit.isLayerGated(layerType)) { ambienceLoop = ShimHelper.getShimAsAmbienceLoop(); } else { ambienceLoop = getLoop(maxSampleLength, progressionUnit); } float barCount = LoopUtils.getBarCountForLoop(ambienceLoop.getAudioLength(), secondsInBar); float exactSampleLength = audioUtils.getAudioLength(appConfigs.getAmbienceFullPath(ambienceLoop)); float newLoopLengthInSeconds = LoopUtils.getBarGroupLengthInSeconds((float) secondsInBar, (float) barCount); float shimLength = newLoopLengthInSeconds - exactSampleLength; ambienceLoop.setShimLength(shimLength); ambienceLoopsByType.put(progressionUnit.getType(), ambienceLoop); } } setAmbienceLoops(ambienceLoopsByType, layerType, queueState.getStructure()); return queueState; } AmbienceGenerator(IShimGenerator shimGenerator, IAmbienceLoopsDal ambienceLoopsDal, IAudioUtils audioUtils, AppConfigs appConfigs); QueueState generateAndSetAmbienceLoops(QueueState queueState, Composition.Layer layerType); int numberOfLoopsRequired(ProgressionUnit progression, BeatLoop beatLoop); AmbienceLoop getLoop(float maxSampleLength, ProgressionUnit progressionUnit); float getSampleLength(String filePath); @Override void setAmbienceLoops(Map<ProgressionUnit.ProgressionType, AmbienceLoop> ambienceLoopsByType, Composition.Layer layerType, List<ProgressionUnit> progressionUnits);  }