721
edits
Line 40: | Line 40: | ||
<syntaxhighlight lang="c++"> | <syntaxhighlight lang="c++"> | ||
float getPeakOfBlock(){ | float getPeakOfBlock(){ | ||
float peak=0; | float peak=0; | ||
// imagine that the audio block and its length (n_smps) is given to you | // imagine that the audio block and its length (n_smps) is given to you | ||
for (int i=0; i<n_smps; i++) { | for (int i=0; i<n_smps; i++) { | ||
if (block[i]>peak) { | |||
// we remember every peak that | |||
// is greater then we seen so far | |||
peak = block[i]; | |||
} | |||
} | } | ||
return peak; | |||
return peak; | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |