import jp.crestmuse.cmx.inference.MusicRepresentation;
import jp.crestmuse.cmx.inference.MusicRepresentation.MusicElement;

public class CMXTutorial5 {

  public static void main(String[] args) {
    // MusicRepresentationの初期化
    MusicRepresentation musRep = new MusicRepresentation(8, 8);

    // レイヤーを登録する
    musRep.addMusicLayer("melody", 12);
    musRep.addMusicLayer("chord", new String[]{ "C", "Dm", "Em", "F", "G", "Am", "Bm(b5)" }, 8);

    // Calculatorを登録する
    musRep.addCalculator("melody", new ChordCalculator());

    // melodyレイヤーを一つ決定する
    musRep.getMusicElement("melody", 0).setEvidence(62);
    musRep.update("melody", 0);

    // chordが更新されたかどうか確認する
    MusicElement nextChord = musRep.getMusicElement("chord", 8);
    int highestIndex = nextChord.getHighestProbIndex();
    System.out.println(nextChord.getLabel(highestIndex));
  }

}

