pyglet 中的无缝播放

Gapless playback in pyglet

我理解 this 页面的意思是在 pyglet 中排队提供了音轨之间的无缝过渡。但是当我测试它时,有一个明显的差距。这里有人在 pyglet 中使用过无缝音频吗?

示例:

player = pyglet.media.Player()

source1 = pyglet.media.load([file1]) # adding streaming=False doesn't fix the issue

source2 = pyglet.media.load([file2])

player.queue(source1)

player.queue(source2)

player.play()

player.seek([time]) # to avoid having to wait until the end of the track. removing this doesn't fix the gap issue

pyglet.app.run()

我建议您将 url1url2 编辑为在本地缓存它们(如果它们是外部来源)。然后使用 Player().time to identify when you're about to reach the end. And then call player.next_source.

或者,如果它是本地文件并且您不想以编程方式解决问题,您可以将音频文件分割成 Audacity 之类的内容,使它们在 start/stop.[=15 上无缝播放=]

您也可以尝试让多个玩家叠加在一起。但如果您只对音频播放感兴趣,还有 other 个选择。

原来有2个问题。

第一个:我应该用过

source_group = pyglet.media.SourceGroup()

source_group.add(source1)
source_group.add(source2)

player.queue(source_group)

第二个:mp3 文件的开头和结尾明显略有填充,这就是差距的来源。但是,这似乎不是任何其他文件类型的问题。