class 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){
//            if(accentsLength % refAccentsLength != 0){
//                //TODO throw exception ..
//                //NOT DIVISIBLE THROUGH EXCEPTION ..
//            }

            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;
    }

}