4

Still a novice java developer, I need to build an Android app that

1 streams a single mp3 from a supplied URL and then

2 extracts volume and-or sound frequency data from the mp3 stream

3 drives a light show from the data in #2

I have a possible solution to #1 and am working on #2,

Can anyone suggest specific classes in the SDK I should be looking at?

Are there any existing Android projects on github or elsewhere that extract frequency and or volume data from streamed mp3 files I might examine and learn from?

4

3 回答 3

0

您将希望公开读取底层的缓冲区,以便获得派生的音量级别...这可能意味着使用“MediaPlayer”以外的其他 API,它可能不会公开音量的 RMS 级别。

每次在 MP3 上进行缓冲读取时,都可以从 Volume 生成 x 轴、y 轴数据,如下所示:

while (mIsPlaying) {
    double sum = 0;
    int readSize = mRecorder.read(mBuffer, 0, mBuffer.length);
    for (int i = 0; i < readSize; i++) {
        output.writeShort(mBuffer[i]);
        sum += mBuffer[i] * mBuffer[i];
    }
// PrBar needs RMS as int
//log base2 for the rms expression on the Volume from the mic
    if (readSize > 0) {
        mProgressBar.setProgress((int)Math.sqrt( sum / readSize ));
        handleRMS((Math.log(Math.sqrt( sum / readSize ))/Math.log(2))); 


    }
}

...

private void handleRMS(double rms){

    rmscnt++;
    rmssum += rms;
    if(rms > rmsmax)rmsmax=rms;
    if(rms< rmsmin)rmsmin=rms;
    double myamt=(rmsmax - rmsmin) / 10 +rmsmin;
    if (rms < myamt) decile++; 
    if(rmscnt % 5 ==0){
        if (rmssum / 5 < myamt) {                                       
        if( Long.valueOf(System.currentTimeMillis())
          - tslist.get(tslist.size()-1) - segmenttime > 0 ){
            tslist.add(Long.valueOf(System.currentTimeMillis()));
        };
    };
    rmssum = 0;
}
}
   * feature - select the TS corresponding to a 'pause' in the speech stream       *   arriving from microphone        * ''pause' in algorythm and

正弦波模式上的正常 RMS 音量水平 * 根据正弦波观察 RMS 的最后读数 * 最小值和最大值是波上的“y 轴”值 *“myamt”字段是阈值上限,即目前 10% 的 delta ( max - min ) * 在实践中,暂停必须有一系列相邻的 RMS 值,其 AVG LESS 小于 * 一些配置值。* 一旦暂停的 TS 被接受,在寻找演讲中的另一个暂停之前,还有另一个最小的时间值应该经过。* 有用的提示 - RMS vals 的 5% 到 10% 应该增加 'decile'。* 否则,雷达上没有足够的低音量事件来识别语音中的停顿。

为了公开缓冲区,而不是 'MediaPlayer' api,您可能需要使用类似'AudioTrack' 的东西来处理您的 mp3。对于示例,我认为您可以在git上访问这个项目

RMS 和处理程序在这里解释

于 2014-01-01T20:39:42.517 回答
0

Echo Nest ( http://developer.echonest.com/ ) 是一款出色的 MP3 分析工具,可为您提供音量、频率、节拍和其他数据。

有一个适用于 Android 的 java 库。

于 2013-12-21T22:36:09.280 回答
0

这是您项目的另一个好资源:http: //therandomlab.blogspot.nl/2013/05/fft-audio-frequency-analysis-with.html

祝你好运

于 2013-12-29T20:25:25.777 回答