samedi 18 avril 2015

to record audio and then to playback with AudioRecord, AudioTrack.trouble

i made a audio-recording in real-time and then playback, but when i get started it sounded very noisy sounds and my voice. so i want to get my voice only with clean tone


im implementing this app with reverb, bass boost, equalizer and visualizer effects


i just wanna clean sounds without those effects


Q : how do i have to modify this substantial code part? (for audioRecord.startRecording, audioTrack.record, audioTrack.write)


here is my code snippet as below :


////////////////////////////////////



private void main() {

for (;;) {

Log.d("AFX", "Starting audio thread");
this.audioRecord.startRecording();
this.audioTrack.play();

int i;

if (!this.running) {
this.audioRecord.stop();
this.audioTrack.stop();
this.audioRecord.release();
return;
}

i = this.audioRecord.read(this.buffer, 0, this.chunkSize);
Log.v("AudioRecord", "read " + this.chunkSize + "bytes");

try {

// Log.d("AFX", "Starting audio thread");
this.audioRecord.startRecording();
this.audioTrack.play();
Log.d("AFX", "Starting audio thread");

boolean flag = this.running; // df value : false

if (!flag) {
this.audioRecord.stop();
this.audioTrack.stop();
// this.audioRecord.release(); // added
// this.audioTrack.release(); // added
Log.d("AFX", "Exiting audio thread");
return;
}

i = this.audioRecord.read(this.buffer, 0, this.chunkSize);
Log.v("AudioRecord", "read " + this.chunkSize + "bytes");

if (i < 0) {
Log.e("AFX", "Record error: " + i);
this.running = false;
continue;
// break;
}
if (!this.running) {
continue;
// break;
}

} finally {
this.audioRecord.stop();
// this.audioRecord.release(); // added
this.audioTrack.stop();
// this.audioTrack.release(); // added
}

this.audioTrack.write(this.buffer, 0, i);
// Log.d("AFX", "Starting audio thread");
// this.audioRecord.startRecording();
// this.audioTrack.play();
}
}


any idea'll be appreciated


thank you much


Aucun commentaire:

Enregistrer un commentaire