Example #1
1
  // called when other activities end
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    // if the activity that ended what the settings activity
    if (requestCode == SET_PROBABILITY_SETTINGS) {
      if (resultCode == RESULT_OK) {
        rightHand.setDegreeProbability(data.getIntArrayExtra(SingActivity.DEGREE_PROBABILITY));
        rightHand.setRhythmProbability(data.getIntArrayExtra(SingActivity.RHYTHM_PROBABILITY));
      }
    }
  }
Example #2
0
  public void onSettingsButtonClick(View view) {

    // create an intent to start the settings activity
    Intent intent = new Intent(this, SettingsActivity.class);

    intent.putExtra(DEGREE_PROBABILITY, rightHand.getDegreeProbability());
    intent.putExtra(RHYTHM_PROBABILITY, rightHand.getRhythmProbability());

    // create the activity, asking for a result
    // startActivity(intent);
    startActivityForResult(intent, SET_PROBABILITY_SETTINGS);
  }
Example #3
0
  public void onMainButtonClick(View v) {

    try {
      switch (cur_state) {
        case INIT:
          // create and display root note

          // get new root note
          curRootNote = rightHand.getNewRootNote();

          // display note in javascript
          notationWebView.loadUrl("javascript:createRoot()");

          // send note for PD to play
          PdBase.sendFloat("midinote1", curRootNote);
          PdBase.sendBang("rootTrigger");

          // prepare for next state, ask for guess note
          cur_state = states.GIVE_GUESS;
          // rename the android main button
          ((Button) v).setText(R.string.mainButtonGiveGuess);

          break;

        case GIVE_GUESS:
          curGuessNote = rightHand.getNewGuessNote();
          // create and display guess note
          // notationWebView.loadUrl("javascript:createGuessNote(" +
          // rightHand.getCurrentMidiGuessNote() + ")");
          notationWebView.loadUrl("javascript:createGuessNote()");

          // start recording
          pitchView.setCenterPitch(curGuessNote % 12);

          // prepare for next state, ask for answer
          cur_state = states.PLAY_ANSWER;
          // rename the android main button
          ((Button) v).setText(R.string.mainButtonPlayAnswer);

          break;
        case PLAY_ANSWER:

          // play answer
          PdBase.sendFloat("midinote1", curGuessNote);
          PdBase.sendBang("rootTrigger");

          // prepare for next state, ask for answer
          cur_state = states.START_OVER;
          ((Button) v).setText(R.string.mainButtonStartOver);
          break;

        case START_OVER:

          // reset webview
          rightHand.resetNotes();
          notationWebView.loadUrl("javascript:reset()");

          // prepare for next state
          cur_state = states.INIT;
          ((Button) v).setText(R.string.mainButtonGiveRoot);

          // reset pitch to max
          pitchView.setCenterPitch(127);

          break;
        default:
          Log.e(LOG_TAG, "ERROR-WRONGSTATE");
          break;
      }
    } catch (Exception e) {
      Log.e(LOG_TAG, e.toString());
      finish();
    }
  }