简体   繁体   中英

android audio - calculating the distance between two devices

I'm having a real hard time calculating the distance between two android phones using sound.

-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. note that mobile A save this time.

-then mobile B sends "ok, u can go ahead" to mobile A while it starts recording the next 1 second or so.

-Then mobile A gets the "ok" and start playing a 1000Hz sound.

-Mobile B detect that freq and send its current time to mobileA

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.

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...)

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中引入的新音频功能。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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