@Test public void shouldExtractChordsToArray(){ ChordMelodyDecoder decoder = new ChordMelodyDecoder(null); String chordPrediction = "#31:313-313%125*415*713*713"; List<String> chords = decoder.extractChordPredictionToArray(chordPrediction); List<String> expected = Arrays.asList("a#dom7", "ddom7", "gmaj7", "gmaj7"); assertThat(chords).isEqualTo(expected); }
public List<String> extractChordPredictionToArray(String chordPrediction){ String[] prefixAndChords = chordPrediction.split("%"); String[] chords = prefixAndChords[1].split("\\*"); List<String> chordStrings = new ArrayList<>(); for(String chord : chords){ ChordMelodyDecoder decoder = new ChordMelodyDecoder(null); String chordRoot = chord.substring(0, 2); chordRoot = decoder.getKey(chordRoot); String chordType = chord.substring(2, chord.length()); chordType = decoder.getChordType(chordType); String fullChordName = chordRoot + chordType; chordStrings.add(fullChordName); } return chordStrings; }
ChordMelodyDecoder { public List<String> extractChordPredictionToArray(String chordPrediction){ String[] prefixAndChords = chordPrediction.split("%"); String[] chords = prefixAndChords[1].split("\\*"); List<String> chordStrings = new ArrayList<>(); for(String chord : chords){ ChordMelodyDecoder decoder = new ChordMelodyDecoder(null); String chordRoot = chord.substring(0, 2); chordRoot = decoder.getKey(chordRoot); String chordType = chord.substring(2, chord.length()); chordType = decoder.getChordType(chordType); String fullChordName = chordRoot + chordType; chordStrings.add(fullChordName); } return chordStrings; } }
ChordMelodyDecoder { public List<String> extractChordPredictionToArray(String chordPrediction){ String[] prefixAndChords = chordPrediction.split("%"); String[] chords = prefixAndChords[1].split("\\*"); List<String> chordStrings = new ArrayList<>(); for(String chord : chords){ ChordMelodyDecoder decoder = new ChordMelodyDecoder(null); String chordRoot = chord.substring(0, 2); chordRoot = decoder.getKey(chordRoot); String chordType = chord.substring(2, chord.length()); chordType = decoder.getChordType(chordType); String fullChordName = chordRoot + chordType; chordStrings.add(fullChordName); } return chordStrings; } ChordMelodyDecoder(Config config); }
ChordMelodyDecoder { public List<String> extractChordPredictionToArray(String chordPrediction){ String[] prefixAndChords = chordPrediction.split("%"); String[] chords = prefixAndChords[1].split("\\*"); List<String> chordStrings = new ArrayList<>(); for(String chord : chords){ ChordMelodyDecoder decoder = new ChordMelodyDecoder(null); String chordRoot = chord.substring(0, 2); chordRoot = decoder.getKey(chordRoot); String chordType = chord.substring(2, chord.length()); chordType = decoder.getChordType(chordType); String fullChordName = chordRoot + chordType; chordStrings.add(fullChordName); } return chordStrings; } ChordMelodyDecoder(Config config); String extractValidChords(String seq); List<String> extractChordPredictionToArray(String chordPrediction); String extractValidMelody(String seq); String decodeChords(String encoded); String decodeBassline(String encoded); String getJChordName(String encodedChord); String getChordType(String chordCode); String decodeMelody(String encoded, String key); String extractDuration(int duration); String getNoteName(String encoded); String encodeNoteName(String encoded); String encodeChordType(String chordType); String getKey(String encoded); }
ChordMelodyDecoder { public List<String> extractChordPredictionToArray(String chordPrediction){ String[] prefixAndChords = chordPrediction.split("%"); String[] chords = prefixAndChords[1].split("\\*"); List<String> chordStrings = new ArrayList<>(); for(String chord : chords){ ChordMelodyDecoder decoder = new ChordMelodyDecoder(null); String chordRoot = chord.substring(0, 2); chordRoot = decoder.getKey(chordRoot); String chordType = chord.substring(2, chord.length()); chordType = decoder.getChordType(chordType); String fullChordName = chordRoot + chordType; chordStrings.add(fullChordName); } return chordStrings; } ChordMelodyDecoder(Config config); String extractValidChords(String seq); List<String> extractChordPredictionToArray(String chordPrediction); String extractValidMelody(String seq); String decodeChords(String encoded); String decodeBassline(String encoded); String getJChordName(String encodedChord); String getChordType(String chordCode); String decodeMelody(String encoded, String key); String extractDuration(int duration); String getNoteName(String encoded); String encodeNoteName(String encoded); String encodeChordType(String chordType); String getKey(String encoded); static String INVALID; }