@Test public void shouldTransposeToCorrectOctave(){ int bassOctave = 2; List<String> chords = Arrays.asList("gmaj7", "f#dom7", "dbmin7", "c5maj7", "c#5maj", "cb4min"); assertThat(synthBassGenerator.transposeChord(chords.get(0), bassOctave)).isEqualTo("g2maj7"); assertThat(synthBassGenerator.transposeChord(chords.get(1), bassOctave)).isEqualTo("f#2dom7"); assertThat(synthBassGenerator.transposeChord(chords.get(2), bassOctave)).isEqualTo("db2min7"); assertThat(synthBassGenerator.transposeChord(chords.get(3), bassOctave)).isEqualTo("c2maj7"); assertThat(synthBassGenerator.transposeChord(chords.get(4), bassOctave)).isEqualTo( "c#2maj"); assertThat(synthBassGenerator.transposeChord(chords.get(5), bassOctave)).isEqualTo("cb2min"); }
@Override public String transposeChord(String chord, int bassOctave) { if ((Character.isDigit(chord.charAt(2)) && chord.charAt(1) == '#') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'b') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'B')) { char[] charArray = chord.toCharArray(); charArray[2] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } else if (chord.charAt(1) == '#' || chord.charAt(1) == 'b' || chord.charAt(1) == 'B') { return new StringBuffer(chord).insert(2, bassOctave).toString(); } else if (!Character.isDigit(chord.charAt(1))) { return new StringBuffer(chord).insert(1, bassOctave).toString(); } else if (Character.isDigit(chord.charAt(1))) { char[] charArray = chord.toCharArray(); charArray[1] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } throw new RuntimeException("UNABLE TO TRANSPOSE CHORD"); }
SynthBassOptions implements ISynthBassGenerator { @Override public String transposeChord(String chord, int bassOctave) { if ((Character.isDigit(chord.charAt(2)) && chord.charAt(1) == '#') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'b') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'B')) { char[] charArray = chord.toCharArray(); charArray[2] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } else if (chord.charAt(1) == '#' || chord.charAt(1) == 'b' || chord.charAt(1) == 'B') { return new StringBuffer(chord).insert(2, bassOctave).toString(); } else if (!Character.isDigit(chord.charAt(1))) { return new StringBuffer(chord).insert(1, bassOctave).toString(); } else if (Character.isDigit(chord.charAt(1))) { char[] charArray = chord.toCharArray(); charArray[1] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } throw new RuntimeException("UNABLE TO TRANSPOSE CHORD"); } }
SynthBassOptions implements ISynthBassGenerator { @Override public String transposeChord(String chord, int bassOctave) { if ((Character.isDigit(chord.charAt(2)) && chord.charAt(1) == '#') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'b') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'B')) { char[] charArray = chord.toCharArray(); charArray[2] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } else if (chord.charAt(1) == '#' || chord.charAt(1) == 'b' || chord.charAt(1) == 'B') { return new StringBuffer(chord).insert(2, bassOctave).toString(); } else if (!Character.isDigit(chord.charAt(1))) { return new StringBuffer(chord).insert(1, bassOctave).toString(); } else if (Character.isDigit(chord.charAt(1))) { char[] charArray = chord.toCharArray(); charArray[1] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } throw new RuntimeException("UNABLE TO TRANSPOSE CHORD"); } @Autowired  SynthBassOptions(IBasslineWeighter basslineWeighter,
                            @Value("${bypass_bassline_vertical_rating}") boolean bypassBasslineVerticalRating,
                            @Value("${num_of_generated_mixes}") Integer numOfGeneratedMixes
    ); }
SynthBassOptions implements ISynthBassGenerator { @Override public String transposeChord(String chord, int bassOctave) { if ((Character.isDigit(chord.charAt(2)) && chord.charAt(1) == '#') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'b') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'B')) { char[] charArray = chord.toCharArray(); charArray[2] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } else if (chord.charAt(1) == '#' || chord.charAt(1) == 'b' || chord.charAt(1) == 'B') { return new StringBuffer(chord).insert(2, bassOctave).toString(); } else if (!Character.isDigit(chord.charAt(1))) { return new StringBuffer(chord).insert(1, bassOctave).toString(); } else if (Character.isDigit(chord.charAt(1))) { char[] charArray = chord.toCharArray(); charArray[1] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } throw new RuntimeException("UNABLE TO TRANSPOSE CHORD"); } @Autowired  SynthBassOptions(IBasslineWeighter basslineWeighter,
                            @Value("${bypass_bassline_vertical_rating}") boolean bypassBasslineVerticalRating,
                            @Value("${num_of_generated_mixes}") Integer numOfGeneratedMixes
    ); void generateSynthBassOptions(ProgressionUnit progressionUnit, List<Bassline> basslines, HashMap<Integer, List<BasslineWithRating>> basslineMap); @Override List<BasslineWithRating> distributeByWeights(List<BasslineWithRating> basslineWithRatings); @Override void setSynthBassOptions(ProgressionUnit progressionUnit, List<Bassline> basslines, HashMap<Integer, List<BasslineWithRating>> basslineMap, Integer bpm); int getBassCode(Chord chordOne, Chord chordTwo, int bassOctave); void populateBasslinesByCode(List<Bassline> basslineSource, int bassCode, HashMap<Integer, List<BasslineWithRating>> basslineMap); int[] generateBeatArrayFromBassline(Bassline bassline); Pattern generateBasslinePattern(Intervals intervalsA, Intervals intervalsB, int[] beats, int bassOctave, Integer bpm); List<String> convertToNoteMap(int[] arpeggioList, Intervals intervalsA, Intervals intervalsB); @Override String transposeChord(String chord, int bassOctave); }
SynthBassOptions implements ISynthBassGenerator { @Override public String transposeChord(String chord, int bassOctave) { if ((Character.isDigit(chord.charAt(2)) && chord.charAt(1) == '#') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'b') || (Character.isDigit(chord.charAt(2)) && chord.charAt(1) == 'B')) { char[] charArray = chord.toCharArray(); charArray[2] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } else if (chord.charAt(1) == '#' || chord.charAt(1) == 'b' || chord.charAt(1) == 'B') { return new StringBuffer(chord).insert(2, bassOctave).toString(); } else if (!Character.isDigit(chord.charAt(1))) { return new StringBuffer(chord).insert(1, bassOctave).toString(); } else if (Character.isDigit(chord.charAt(1))) { char[] charArray = chord.toCharArray(); charArray[1] = Integer.toString(bassOctave).charAt(0); return new String(charArray); } throw new RuntimeException("UNABLE TO TRANSPOSE CHORD"); } @Autowired  SynthBassOptions(IBasslineWeighter basslineWeighter,
                            @Value("${bypass_bassline_vertical_rating}") boolean bypassBasslineVerticalRating,
                            @Value("${num_of_generated_mixes}") Integer numOfGeneratedMixes
    ); void generateSynthBassOptions(ProgressionUnit progressionUnit, List<Bassline> basslines, HashMap<Integer, List<BasslineWithRating>> basslineMap); @Override List<BasslineWithRating> distributeByWeights(List<BasslineWithRating> basslineWithRatings); @Override void setSynthBassOptions(ProgressionUnit progressionUnit, List<Bassline> basslines, HashMap<Integer, List<BasslineWithRating>> basslineMap, Integer bpm); int getBassCode(Chord chordOne, Chord chordTwo, int bassOctave); void populateBasslinesByCode(List<Bassline> basslineSource, int bassCode, HashMap<Integer, List<BasslineWithRating>> basslineMap); int[] generateBeatArrayFromBassline(Bassline bassline); Pattern generateBasslinePattern(Intervals intervalsA, Intervals intervalsB, int[] beats, int bassOctave, Integer bpm); List<String> convertToNoteMap(int[] arpeggioList, Intervals intervalsA, Intervals intervalsB); @Override String transposeChord(String chord, int bassOctave); static final int BASS_OCTAVE; }