AVAudioPlayer 仪表值仍然 - 160

发布于 2024-11-09 12:26:14 字数 448 浏览 0 评论 0原文

尝试实现 AVAudioplayer 并获取播放音乐的一些计量数据,但仍然获得值 -160。 看起来很容易使用,只需启用 Meter,然后在计时器下拾取数据,但到目前为止还没有结果。

playerAV = [[AVAudioPlayer alloc] initWithContentsOfURL:outURL error:nil];
        playerAV.delegate = self;


        playerAV.meteringEnabled = YES;

        [playerAV prepareToPlay];
        [playerAV play];

NSLog(@"Peak left: %f Avg right: %f", [playerAV peakPowerForChannel:0],[playerAV averagePowerForChannel:1]);

欢迎任何想法。

Trying to implement AVAudioplayer and get some metering data of the played music, but still getting value -160.
It looks easy to use, just enable Meter and then pickup data under a timer, but no results so far.

playerAV = [[AVAudioPlayer alloc] initWithContentsOfURL:outURL error:nil];
        playerAV.delegate = self;


        playerAV.meteringEnabled = YES;

        [playerAV prepareToPlay];
        [playerAV play];

NSLog(@"Peak left: %f Avg right: %f", [playerAV peakPowerForChannel:0],[playerAV averagePowerForChannel:1]);

any thoughts are welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

耳根太软 2024-11-16 12:26:14

您是否正在拨打 updateMeters?两者的文档 peakPowerForChannel:averagePowerForChannel: 说:

要获取当前 [...] 值,您必须在调用此方法之前调用 updateMeters 方法。

Are you calling updateMeters? The docs for both peakPowerForChannel: and averagePowerForChannel: say:

To obtain a current [...] value, you must call the updateMeters method before calling this method.

完美的未来在梦里 2024-11-16 12:26:14

您如何知道网址有效,并且其末尾的数据格式正确?你能听到扬声器发出的声音吗?

你是否以某种方式制作了两个playerAV对象,一个具有可以播放的正确URL,另一个具有不播放任何内容的错误URL,并且是计时器在调用NSLog()时看到的对象?

How do you know the url works, and the data at the end of it is the right format? Can you hear stuff coming from the speakers?

Are you somehow making two playerAV objects, one with the correct URL which plays, the other with a bad url which plays nothing, and is the one that the timer sees when it calls NSLog()?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文