Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   handler.removeCallbacks(updater);
   androidGlue.synthDestroy();
 }
Ejemplo n.º 3
0
 protected void updateWaveView() {
   short[] buffer = androidGlue.getOutputBuffer();
   waveView.setWaveTable(buffer);
   waveView.invalidate();
 }