ios - 如何获取手机正在播放歌曲律动节奏的能量值?
PHP中文网
PHP中文网 2017-04-18 09:54:38
0
3
627

1.问题描述:
项目需要做一个随音乐节奏律动的动效,需要获取正在播放歌曲的律动信息,也就是一个随音乐节奏变化的值。

2.尝试解决办法:

1.目前找到的结果是需要使用 AVAudioPlayer 播放该歌曲时才能获取到该音频的律动能量值,对应接口如下:

/* returns peak power in decibels for a given channel */
- (float)peakPowerForChannel:(NSUInteger)channelNumber; 

 /* returns average power in decibels for a given channel */
- (float)averagePowerForChannel:(NSUInteger)channelNumber;

2.尝试使用录音的方式,将手机播放的音频录起来,然后再获取这些音频的能量值。但是受到周围噪声干扰很大,效果很不好,不知道是不是我处理方式不对。

3.未解决问题:
项目需要的做到的效果是:无论任何播放源,例如使用酷狗播放器、QQ音乐播放器、网易云音乐等,都要能获取到手机输出音频的律动信息。

假如你有任何头绪或者建议,请务必告知我一下,非常感谢!

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
刘奇

It is not particularly convenient to answer on the mobile phone. I recommend Baidu: "websocket and audio", which should have the answer you want.

左手右手慢动作

I also encountered this problem today, have you solved it?

大家讲道理

AVAudioPlayer has a methodupdateMeters() You can try adjusting this method first and then the above two. This is how I get the sound volume when recording
And you have to pay attention to the volume~~I remember it is negative, such as peak = - 80 this kind

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template