Note that there are some explanatory texts on larger screens.

plurals
  1. POLow Pass Audio Filter, calculating RMS on iOS
    primarykey
    data
    text
    <p>I am working on an App for the iPad, and I want to analyze the Audio from a Video that I am playing. This is all going well, using the MTAudioProcessingTap. Currently I have some test code to test/measure the volume of the left and right channel. This is all going pretty well:</p> <pre><code>void process(MTAudioProcessingTapRef tap, CMItemCount numberFrames, MTAudioProcessingTapFlags flags, AudioBufferList *bufferListInOut, CMItemCount *numberFramesOut, MTAudioProcessingTapFlags *flagsOut) { OSStatus err = MTAudioProcessingTapGetSourceAudio(tap, numberFrames, bufferListInOut, flagsOut, NULL, numberFramesOut); if (err) NSLog(@"Error from GetSourceAudio: %ld", err); float leftVolume, rightVolume; for (CMItemCount i = 0; i &lt; bufferListInOut-&gt;mNumberBuffers; i++) { AudioBuffer *pBuffer = &amp;bufferListInOut-&gt;mBuffers[i]; int cSamples = numberFrames * pBuffer-&gt;mNumberChannels; float *pData = (float *)pBuffer-&gt;mData; float rms = 0.0f; for (int j = 0; j &lt; cSamples; j++) { rms += pData[j] * pData[j]; } if (cSamples &gt; 0) { rms = sqrtf(rms / cSamples); } if (0 == i) { leftVolume = rms; } if (1 == i || (0 == i &amp;&amp; 1 == bufferListInOut-&gt;mNumberBuffers)) { rightVolume = rms; } } NSLog(@"Left / Right Volume: %f / %f", leftVolume, rightVolume); } </code></pre> <p>But for the purpose of this App, I want it to just measure the RMS ("intensity") of the range of 0-80Hz (as example). Therefore, I need a Low-Pass filter.</p> <p>I have been Googling for a long time now, but my problem is that I can't find any clear post, tutorial or solution that is obvious. Almost every problem that sounds somewhat like mine has a random piece of code underneath it with crappy or lack of comments so I can't figure out what all the magic numbers are doing there, and what they mean.. </p> <p>Could someone push me in the right direction here? Note that in my case I <strong>do</strong> want to understand the code and not just run off with a working sample.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload