audioWaveCanvas icon indicating copy to clipboard operation
audioWaveCanvas copied to clipboard

关于getSamplesPerFrame

Open diguagege opened this issue 6 years ago • 0 comments

// Should be removed when the app will use directly the samples instead of the frames. public int getSamplesPerFrame() { return 1024; // just a fixed value here... } 我想知道一下,如果使用自己的PerFrame,需要怎么修改。如果使用这个,我用本地的音频去加载。在ReadFile的时候,下面这部分代码会执行几十万上百万次。 for (i=0; i<mNumFrames; i++){ gain = -1; for(j=0; j<getSamplesPerFrame(); j++) { value = 0; for (int k=0; k<mChannels; k++) { if (mDecodedSamples.remaining() > 0) { value += Math.abs(mDecodedSamples.get()); } } value /= mChannels; if (gain < value) { gain = value; } } mFrameGains[i] = (int)Math.sqrt(gain); // here gain = sqrt(max value of 1st channel)... mFrameLens[i] = frameLens; // totally not accurate... mFrameOffsets[i] = (int)(i * (1000 * mAvgBitRate / 8) * // = i * frameLens ((float)getSamplesPerFrame() / mSampleRate)); }

diguagege avatar Jan 25 '19 06:01 diguagege