简体   繁体   English

Android音频-计算两个设备之间的距离

[英]android audio - calculating the distance between two devices

I'm having a real hard time calculating the distance between two android phones using sound. 我真的很难用声音计算两个Android手机之间的距离。

-the main idea is having 2 phones sync'ed on same time, making mobile A send a msg to mobile B to let him know he is playing sound soon. -主要想法是同时同步2部电话,从而使移动设备A向移动设备B发送消息,让他知道他即将播放声音。 note that mobile A save this time. 请注意,手机A可以节省时间。

-then mobile B sends "ok, u can go ahead" to mobile A while it starts recording the next 1 second or so. -然后,移动设备B向移动设备A发送“好,你可以继续前进”,同时开始记录下1秒钟左右的时间。

-Then mobile A gets the "ok" and start playing a 1000Hz sound. -然后,移动设备A获得“确定”,并开始播放1000Hz声音。

-Mobile B detect that freq and send its current time to mobileA -移动设备B检测到该频率并将其当前时间发送到移动设备A

now we have all the info to calculate the distance. 现在我们有了所有信息来计算距离。 problem is that at theory this is all good, but when i implement this i have lots of random time added into the equation. 问题是,从理论上讲,这一切都很好,但是当我实现这一点时,我在方程中增加了很多随机时间。

the main problem is that I cant point at the ABSOLUTE time when mobile B got the good freq. 主要问题是我无法指出移动台B获得良好频率的绝对时间。

I tried not recording the whole 1000 ms but lots of "mini" chunks of (12~24ms) but the time the mobile spend on the recorder_.startRecording()/recorder_.read()/recorder_.stop() commands is too much, and im missing the freq by lots of ms (each ms is equal to 30cm so i cant effort much errors...) 我尝试不记录整个1000毫秒,而是记录许多“小”块(12到24毫秒),但是移动设备花费在recorder_.startRecording()/ recorder_.read()/ recorder_.stop()命令上的时间太多了,而且我错过了很多ms的频率(每个ms等于30cm,所以我无法付出很多错误...)

can any one tell me what im doing wrong or guiding me to better ways of doing that?? 谁能告诉我我做错了什么或指导我采取更好的方法呢?

The main issue is the recording device cant point on the actual time he recorded the wanted freq..... 主要问题是录音设备无法准确记录他想要的频率.....

thanks in advanced, 提前致谢,

Ofer. 没错

请查看API 19中引入的新音频功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM