0

我想编写一个 Web 应用程序,允许我将 MP3 的音频播放同步到大约 50 毫秒,或者足够接近人耳无法检测到差异。

这个想法是两个或更多的智能手机可以分别与一个蓝牙扬声器配对,两个或更多的扬声器可以同时播放相同的音频。

您如何建议我在客户端和服务器端进行设置?我打算将 Rails/Ruby 用于后端,将 iOS/obj c 用于移动开发。

我有过同步到服务器上的全局/原子时钟的想法,并让服务器向客户端提供关于何时开始播放/跳转到已经播放的曲目的说明。我担心的是,如果我想流式传输音频,就不可能将一首歌曲加载到内存中并在毫秒级别准确地开始播放。

想法?

4

2 回答 2

1

The jitter in internet packet delivery will be too large, so forget about syncing over the internet. However you could check the accuracy of NTP which is still used (I guess, I know that older UNIX's used it) by the OS when you switch on automatic date/time in Settings, but my guess is that it won't be good enough either. But perhaps the OS may also use other time sources like GPS; I'm don't know how iOS does it but accuracy within 20ms is not to be expected. You could create experimental app to check it out.

So, what's left is a sync closer to home, meaning between the devices directly. Of course you need to make sure that all devices haves loaded (enough of) the song, and have preloaded it in AVAudioPlayer or whatever you're using, to be able to start playing immediately. (It may actually not be the best idea to use higher level 'AVAudioPlayer` API's as it may give higher delays, and what more important higher jitter, than lower level API's.)

Here are three ideas (one device needs to be master triggering the start play, the others are slaves that are waiting for the trigger):

  • Use an audio trigger pulse, like a high tone of a defined length and frequency. Then use FFT to recognise this tone.
  • Connect the devices via GameKit Bluetooth and transmit the trigger on these connections.
  • Use the iPhone 4+ flash as trigger: flash in a certain pattern. This would require you to sample the video data which is quite doable and can be very fast.
于 2013-04-29T22:43:38.387 回答
0

我将使用一个使用原子钟进行同步的解决方案,以及一个允许服务器指令/消息以紧密同步的方式发送到所有设备的外部服务。

于 2013-06-13T18:52:25.190 回答