@Test public void ShouldMatchTemplateLengthsWhenReferenceIsGreater() { List<RhythmicAccents> rAccents = new ArrayList<RhythmicAccents>(){{ add(new RhythmicAccents()); add(new RhythmicAccents()); add(new RhythmicAccents()); add(new RhythmicAccents()); }}; HarmonicLoop referenceLoop = new HarmonicLoop(); referenceLoop.setRhythmicAccents(rAccents); List<RhythmicAccents> accents = new ArrayList<RhythmicAccents>(){{ add(new RhythmicAccents()); }}; HarmonicLoop loop = new HarmonicLoop(); loop.setRhythmicAccents(accents); NormalizedAccents normalizedAccents = rhythmWeighter.normalizeAccentLengths(referenceLoop,loop); Assert.assertNotNull(normalizedAccents); Assert.assertNotNull(normalizedAccents.getAccentsList()); Assert.assertNotNull(normalizedAccents.getReferenceAccentList()); Assert.assertEquals(4, normalizedAccents.getAccentsList().size()); Assert.assertEquals(normalizedAccents.getNormalizedAccents().size(),normalizedAccents.getNormalizedReferenceAccents().size()); Assert.assertEquals(normalizedAccents.getReferenceAccentList().size(), normalizedAccents.getAccentsList().size()); }
@Override public NormalizedAccents normalizeAccentLengths(IRhythmicLoop referenceLoop, IRhythmicLoop loop) { NormalizedAccents normalizedAccents = new NormalizedAccents(); int refAccentsLength = referenceLoop.getRhythmicAccents().size(); RhythmicAccents ra1 = referenceLoop.getRhythmicAccents().get(0); int accentsLength = loop.getRhythmicAccents().size(); RhythmicAccents ra2 = loop.getRhythmicAccents().get(0); if(refAccentsLength == accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); normalizedAccents.setAccentsList(loop.getRhythmicAccents()); }else if(refAccentsLength > accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = (int)(refAccentsLength / accentsLength); List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { loop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setAccentsList(newAccents); }else if(accentsLength > refAccentsLength){ normalizedAccents.setAccentsList(loop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = accentsLength / refAccentsLength; List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { referenceLoop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setReferenceAccentList(newAccents); } return normalizedAccents; }
RhythmWeighter implements IRhythmWeighter { @Override public NormalizedAccents normalizeAccentLengths(IRhythmicLoop referenceLoop, IRhythmicLoop loop) { NormalizedAccents normalizedAccents = new NormalizedAccents(); int refAccentsLength = referenceLoop.getRhythmicAccents().size(); RhythmicAccents ra1 = referenceLoop.getRhythmicAccents().get(0); int accentsLength = loop.getRhythmicAccents().size(); RhythmicAccents ra2 = loop.getRhythmicAccents().get(0); if(refAccentsLength == accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); normalizedAccents.setAccentsList(loop.getRhythmicAccents()); }else if(refAccentsLength > accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = (int)(refAccentsLength / accentsLength); List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { loop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setAccentsList(newAccents); }else if(accentsLength > refAccentsLength){ normalizedAccents.setAccentsList(loop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = accentsLength / refAccentsLength; List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { referenceLoop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setReferenceAccentList(newAccents); } return normalizedAccents; } }
RhythmWeighter implements IRhythmWeighter { @Override public NormalizedAccents normalizeAccentLengths(IRhythmicLoop referenceLoop, IRhythmicLoop loop) { NormalizedAccents normalizedAccents = new NormalizedAccents(); int refAccentsLength = referenceLoop.getRhythmicAccents().size(); RhythmicAccents ra1 = referenceLoop.getRhythmicAccents().get(0); int accentsLength = loop.getRhythmicAccents().size(); RhythmicAccents ra2 = loop.getRhythmicAccents().get(0); if(refAccentsLength == accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); normalizedAccents.setAccentsList(loop.getRhythmicAccents()); }else if(refAccentsLength > accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = (int)(refAccentsLength / accentsLength); List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { loop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setAccentsList(newAccents); }else if(accentsLength > refAccentsLength){ normalizedAccents.setAccentsList(loop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = accentsLength / refAccentsLength; List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { referenceLoop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setReferenceAccentList(newAccents); } return normalizedAccents; }  }
RhythmWeighter implements IRhythmWeighter { @Override public NormalizedAccents normalizeAccentLengths(IRhythmicLoop referenceLoop, IRhythmicLoop loop) { NormalizedAccents normalizedAccents = new NormalizedAccents(); int refAccentsLength = referenceLoop.getRhythmicAccents().size(); RhythmicAccents ra1 = referenceLoop.getRhythmicAccents().get(0); int accentsLength = loop.getRhythmicAccents().size(); RhythmicAccents ra2 = loop.getRhythmicAccents().get(0); if(refAccentsLength == accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); normalizedAccents.setAccentsList(loop.getRhythmicAccents()); }else if(refAccentsLength > accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = (int)(refAccentsLength / accentsLength); List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { loop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setAccentsList(newAccents); }else if(accentsLength > refAccentsLength){ normalizedAccents.setAccentsList(loop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = accentsLength / refAccentsLength; List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { referenceLoop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setReferenceAccentList(newAccents); } return normalizedAccents; }  @Override int weightNonMatchNoNeighbours(List<String> referenceAccents, List<String> accents); @Override int weightNonMatchNonMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override int weightNonMatchWithMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override int weightMatchNoNeighbours(List<String> referenceAccents, List<String> accents); @Override int weightMatchNonMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override int weightMatchWithMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override WeightClass calculateRhythmicWeight(IRhythmicLoop referenceLoop, IRhythmicLoop loop); @Override NormalizedAccents normalizeAccentLengths(IRhythmicLoop referenceLoop, IRhythmicLoop loop); }
RhythmWeighter implements IRhythmWeighter { @Override public NormalizedAccents normalizeAccentLengths(IRhythmicLoop referenceLoop, IRhythmicLoop loop) { NormalizedAccents normalizedAccents = new NormalizedAccents(); int refAccentsLength = referenceLoop.getRhythmicAccents().size(); RhythmicAccents ra1 = referenceLoop.getRhythmicAccents().get(0); int accentsLength = loop.getRhythmicAccents().size(); RhythmicAccents ra2 = loop.getRhythmicAccents().get(0); if(refAccentsLength == accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); normalizedAccents.setAccentsList(loop.getRhythmicAccents()); }else if(refAccentsLength > accentsLength){ normalizedAccents.setReferenceAccentList(referenceLoop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = (int)(refAccentsLength / accentsLength); List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { loop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setAccentsList(newAccents); }else if(accentsLength > refAccentsLength){ normalizedAccents.setAccentsList(loop.getRhythmicAccents()); int loopsRequired = 0; loopsRequired = accentsLength / refAccentsLength; List<RhythmicAccents> newAccents = new ArrayList<>(); for(Integer i=0; i < loopsRequired; i++) { referenceLoop.getRhythmicAccents().forEach(accent -> { newAccents.add(accent); }); } normalizedAccents.setReferenceAccentList(newAccents); } return normalizedAccents; }  @Override int weightNonMatchNoNeighbours(List<String> referenceAccents, List<String> accents); @Override int weightNonMatchNonMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override int weightNonMatchWithMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override int weightMatchNoNeighbours(List<String> referenceAccents, List<String> accents); @Override int weightMatchNonMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override int weightMatchWithMatchingNeighour(List<String> referenceAccents, List<String> accents); @Override WeightClass calculateRhythmicWeight(IRhythmicLoop referenceLoop, IRhythmicLoop loop); @Override NormalizedAccents normalizeAccentLengths(IRhythmicLoop referenceLoop, IRhythmicLoop loop);  }