Hello, I apologize for my English first.
I am developing an android piano.
I wonder how I can record the sounds that occurs when i touch the keys of
the piano.
I explain it:
I load the sounds:
private void chargeSounds() {
this.soundPool = new SoundPool(12, AudioManager.STREAM_MUSIC, 0);
this.soundPool.
setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId,
int status) {
MainActivity.this.loaded = true;
}
});
this.soundID[0] = soundPool.load(this, R.raw.dob, 1);
this.soundID[1] = soundPool.load(this, R.raw.rebbem, 1);
this.soundID[2] = soundPool.load(this, R.raw.reb, 1);
this.soundID[3] = soundPool.load(this, R.raw.mibbem, 1);
......
.....
Then, to record audio i have a button that launches myRecord:
public void myRecord(View view) {
mediaRecorder = new MediaRecorder();
// Create folder if no exists
File file = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/folder");
if (!file.exists())
file.mkdirs();
mediaRecorder.setOutputFile(file + "/audio1.3gp");
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mediaRecorder.prepare();
} catch (IOException e) {
Log.e("Record", "Fail to record:" + e.getMessage());
Toast toast = Toast.makeText(getApplicationContext(),
e.getMessage(), Toast.LENGTH_LONG);
toast.show();
}
mediaRecorder.start();
this.btnGrabar.setBackgroundResource(R.drawable.record_on);
}
}
With this code i can record the piano music and my voice, but i only what
to record piano audio.
Is there any way to record only the sound of the piano without voice?
I have tried to set grabar function like:
mediaRecorder.setAudioSource(AudioManager.STREAM_MUSIC); instead of:
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); but it blocks
the app.
Any suggestions?
Thank you and Again apologies for my English.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en