Reputation: 114
I am developing an Android Application which is time sensitive and I would like to record precise timestamps when a particular audio sample is recorded. I am using AudioRecord.startRecording().
I want the timestamp to be noted exactly when the audio is processed by the hardware to avoid any errors.Is it possible to achieve this kind of accuracy and if so, how should I proceed with it.
Any pointers in this regard is highly appreciated.
Upvotes: 2
Views: 1958
Reputation:
You can use System Time for timestamp like below :
int bufferReadResult = audioRecord.read(buffer, 0,blockSize);
long startTime = System.nanoTime()/ 1000;
You can count the samples between 2 events on the recorded audio signal, and get the precise elapsed time, by counting the samples and knowing the sample frequency. AFAIK, you can't get the absolute time of the aquired signal. As, audio is sampled realtime by local oscillator. A chunk is sent to you as soon as the operative system has free time to send it to you. I'm not sure about this.
Upvotes: 2