Exemplo n.º 1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
      AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
      String s1 = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
      String s2 = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);

      if (s1 != null && s2 != null) {
        World.freq = Integer.parseInt(s1);
        World.samples = Integer.parseInt(s2);
        System.out.println(
            "AudioManager suggested fs=" + World.freq + ", samples=" + World.samples);
      }

    } catch (Throwable t) {
      System.err.println("Could not get device defaults: " + t.toString());
    }

    AndroidService.setInstance(new AndroidService(this));

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    cfg.useAccelerometer = false;
    cfg.useCompass = false;
    cfg.useWakelock = true;
    initialize(new DrumApp(), cfg);
  }
Exemplo n.º 2
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    androidGlue = new AndroidGlue();

    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    String srs = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
    String fpbs = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);

    int sampleRate = Integer.parseInt(srs);
    int bufferSize = Integer.parseInt(fpbs);
    androidGlue.synthInit(false, sampleRate, bufferSize, 90);

    waveView = (WaveView) this.findViewById(R.id.waveView1);
    MIDIKeysView = (MIDIKeys) this.findViewById(R.id.mIDIKeys1);
    MIDIKeysView.setSynthGlue(androidGlue);
    updateWaveView();
    handler = new Handler();
    handler.postDelayed(updater, interval);
  }