@Test public void shouldDetermineIfValidChords(){ String validA = "#61:310-610%310*610*310*610"; String validB = "#31:110-610%310*610*310*510"; String invalidA = "#31:310-610%310:610*310*610"; String invalidB = "#31:310-610%310%610*310*610"; String invalidC = "#31:310-610%310*610*310-610"; ChordMelodyDecoder chordMelodyDecoder = new ChordMelodyDecoder(new Config(false)); Assert.assertFalse(chordMelodyDecoder.INVALID.equalsIgnoreCase(chordMelodyDecoder.extractValidChords(validA))); Assert.assertFalse(chordMelodyDecoder.INVALID.equalsIgnoreCase(chordMelodyDecoder.extractValidChords(validB))); Assert.assertTrue(chordMelodyDecoder.INVALID.equalsIgnoreCase(chordMelodyDecoder.extractValidChords(invalidA))); Assert.assertTrue(chordMelodyDecoder.INVALID.equalsIgnoreCase(chordMelodyDecoder.extractValidChords(invalidB))); Assert.assertTrue(chordMelodyDecoder.INVALID.equalsIgnoreCase(chordMelodyDecoder.extractValidChords(invalidC))); }
public String extractValidChords(String seq) { if(count(seq, "*") != 3) { return INVALID; } if(count(seq, "#") != 1) { return INVALID; } if(count(seq, "-") != 1) { return INVALID; } if(count(seq, "%") != 1) { return INVALID; } try { extractChordPredictionToArray(seq); }catch (Exception e){ System.out.println(e); return INVALID; } return seq; }
ChordMelodyDecoder { public String extractValidChords(String seq) { if(count(seq, "*") != 3) { return INVALID; } if(count(seq, "#") != 1) { return INVALID; } if(count(seq, "-") != 1) { return INVALID; } if(count(seq, "%") != 1) { return INVALID; } try { extractChordPredictionToArray(seq); }catch (Exception e){ System.out.println(e); return INVALID; } return seq; } }
ChordMelodyDecoder { public String extractValidChords(String seq) { if(count(seq, "*") != 3) { return INVALID; } if(count(seq, "#") != 1) { return INVALID; } if(count(seq, "-") != 1) { return INVALID; } if(count(seq, "%") != 1) { return INVALID; } try { extractChordPredictionToArray(seq); }catch (Exception e){ System.out.println(e); return INVALID; } return seq; } ChordMelodyDecoder(Config config); }
ChordMelodyDecoder { public String extractValidChords(String seq) { if(count(seq, "*") != 3) { return INVALID; } if(count(seq, "#") != 1) { return INVALID; } if(count(seq, "-") != 1) { return INVALID; } if(count(seq, "%") != 1) { return INVALID; } try { extractChordPredictionToArray(seq); }catch (Exception e){ System.out.println(e); return INVALID; } return seq; } 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 String extractValidChords(String seq) { if(count(seq, "*") != 3) { return INVALID; } if(count(seq, "#") != 1) { return INVALID; } if(count(seq, "-") != 1) { return INVALID; } if(count(seq, "%") != 1) { return INVALID; } try { extractChordPredictionToArray(seq); }catch (Exception e){ System.out.println(e); return INVALID; } return seq; } 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; }