[英]How can I receive the Hardware Timestamp of Audiorecord in Android?
I need to retrieve the timestamp of when the AudioRecord class
does a read of a buffer. 我需要检索AudioRecord class
读取缓冲区的时间戳。 I need to keep track of the time in milliseconds. 我需要以毫秒为单位跟踪时间。 I have tried to add a timestamp retrieve after I read the buffer, however when I receive the next buffer, the amount of time it takes to retrieve it can fluctuate a lot. 我尝试在读取缓冲区后添加时间戳检索,但是当我收到下一个缓冲区时,检索它所需的时间可能会波动很多。 Is there a way from a callback to receive the time that the audio was recorded? 回调是否有办法接收录制音频的时间?
int bufferReadResult = audioRecord.read(buffer, 0,blockSize);
long startTime = System.nanoTime()/ 1000;
is what I am currently trying. 是我目前正在尝试的。
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, but i think that you can't get the absolute time of the aquired signal. 我不确定,但我认为你无法获得获得信号的绝对时间。 What you can do is to 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. 您可以做的是对记录的音频信号上的2个事件之间的样本进行计数,并通过计算样本并了解采样频率来获得精确的经过时间。 Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.