private void runRecording() {
final byte buf[] = new byte[mBufSize];
mTimer.schedule(new TimerTask() {
@Override
public void run() {
// stop recording
if (!mIsRecording) {
mAudioRecord.stop();
return;
}
mAudioRecord.read(buf, 0, mBufSize);
vr.readBuffer(buf);
if(save)
{
try {
fos.write(buf); <------ this is a FileOutputStream
} catch (IOException e) {
e.printStackTrace();
}
}
int decibel = calculateDecibel(buf);
// callback for return input value
if (mVolumeListener != null) {
mVolumeListener.onCalculateVolume(decibel);
}
}
}, 0, mSamplingInterval);
}