1

I'm developing an app like Talking Tom

I tried to record audio, save to file then play with Mediaplayer in android but there is a bit delay to save the file then play. It is not smooth like Talking Tom

I saw that both MediaRecorder & MediaPlayer accept argument FileDescriptor in setOutputFile & setDataSource.

Is there any way to record then play without save to file ?

Do SoundPool & Mediaplayer can sound with byte array like byte [] buffer ?

Please help!

LongLT
  • 411
  • 6
  • 19
  • It seems must exist the way to do this without read-write to file system. because `Talking Tom` looks so smooth including `human voice recognition` – LongLT Jan 02 '16 at 09:16

1 Answers1

1

AudioRecord has the ability to record to a buffer, which can be played without saving to a file. MediaRecorder, which can also record videos, cannot. http://developer.android.com/reference/android/media/AudioRecord.html

Two previous related questions answered on stackoverflow:

AudioRecord - how to get data in to buffer?

Android AudioRecord to File then use AudioTrack for Playback

I don't know if soundpool can be used with an array. The samples I seen and follow create multiple soundpools:

soundPool1 = new SoundPool(3, AudioManager.STREAM_MUSIC,0); 
sound1 = soundPool1.load(getApplication(), R.raw.basskickdrum,1);
soundPoolA = new SoundPool(3, AudioManager.STREAM_MUSIC,0);
soundA = soundPoolA.load(getApplication(),R.raw.closedhighhat,1);
soundPool2 = new SoundPool(3, AudioManager.STREAM_MUSIC,0);
sound2 = soundPool2.load(getApplication(),R.raw.snare2,1);
Community
  • 1
  • 1
Greg Marsh
  • 209
  • 1
  • 2
  • 9