@Test public void shouldGetCurrentBarFor1BarLoops(){ int resultOne = melodicExtractor.getCurrentBarIndex(1, 1, 1); assertThat(resultOne).isEqualTo(0); }
public int getCurrentBarIndex(int barCount, int currentBar, int index){ switch (barCount){ case 1: return 0; case 2: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 0; }else if(index >= 12 && index <16){ return 1; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } case 4: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 2; }else if(index >= 12 && index <16){ return 3; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } default: throw new RuntimeException("ERROR getCurrentBarIndex bar count - " + barCount); } }
MelodicExtractor { public int getCurrentBarIndex(int barCount, int currentBar, int index){ switch (barCount){ case 1: return 0; case 2: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 0; }else if(index >= 12 && index <16){ return 1; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } case 4: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 2; }else if(index >= 12 && index <16){ return 3; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } default: throw new RuntimeException("ERROR getCurrentBarIndex bar count - " + barCount); } } }
MelodicExtractor { public int getCurrentBarIndex(int barCount, int currentBar, int index){ switch (barCount){ case 1: return 0; case 2: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 0; }else if(index >= 12 && index <16){ return 1; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } case 4: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 2; }else if(index >= 12 && index <16){ return 3; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } default: throw new RuntimeException("ERROR getCurrentBarIndex bar count - " + barCount); } }  }
MelodicExtractor { public int getCurrentBarIndex(int barCount, int currentBar, int index){ switch (barCount){ case 1: return 0; case 2: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 0; }else if(index >= 12 && index <16){ return 1; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } case 4: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 2; }else if(index >= 12 && index <16){ return 3; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } default: throw new RuntimeException("ERROR getCurrentBarIndex bar count - " + barCount); } }  QueueState extractedAndSetHarmony(QueueState queueState); List<HarmonyExtraction> createHarmonicExtractionForBar(ProgressionUnitBar progressionUnitBar); HarmonyExtraction extractedAndSetHarmony(ProgressionUnitBar progressionUnitBar, int noteIndex); int getCurrentBarIndex(int barCount, int currentBar, int index); }
MelodicExtractor { public int getCurrentBarIndex(int barCount, int currentBar, int index){ switch (barCount){ case 1: return 0; case 2: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 0; }else if(index >= 12 && index <16){ return 1; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } case 4: if(index < 4){ return 0; }else if(index >=4 && index <8){ return 1; }else if(index >=8 && index <12){ return 2; }else if(index >= 12 && index <16){ return 3; }else{ throw new RuntimeException("ERROR getCurrentBarIndex out of bound index : " + index); } default: throw new RuntimeException("ERROR getCurrentBarIndex bar count - " + barCount); } }  QueueState extractedAndSetHarmony(QueueState queueState); List<HarmonyExtraction> createHarmonicExtractionForBar(ProgressionUnitBar progressionUnitBar); HarmonyExtraction extractedAndSetHarmony(ProgressionUnitBar progressionUnitBar, int noteIndex); int getCurrentBarIndex(int barCount, int currentBar, int index);  }