mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 865256 - Part 3a: Add AudioBufferPeakValue utility. r=ehsan
From 6c057c02970c79d620527d08bc3755491c99b1d3 Mon Sep 17 00:00:00 2001 This is an equivalent, C-only implementation of blink's VectorMath::maxmgv or Apple's vDSP_maxmgv. It finds the maximum absolute value of the elements in a float buffer. Used by blink's PeriodicWave implementation for normalization.
This commit is contained in:
parent
cafa3e5a01
commit
0608685cbf
@ -125,6 +125,19 @@ BufferComplexMultiply(const float* aInput,
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
AudioBufferPeakValue(const float *aInput, uint32_t aSize)
|
||||
{
|
||||
float max = 0.0f;
|
||||
for (uint32_t i = 0; i < aSize; i++) {
|
||||
float mag = fabs(aInput[i]);
|
||||
if (mag > max) {
|
||||
max = mag;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
void
|
||||
AudioBlockCopyChannelWithScale(const float aInput[WEBAUDIO_BLOCK_SIZE],
|
||||
const float aScale[WEBAUDIO_BLOCK_SIZE],
|
||||
|
@ -134,6 +134,11 @@ void BufferComplexMultiply(const float* aInput,
|
||||
float* aOutput,
|
||||
uint32_t aSize);
|
||||
|
||||
/**
|
||||
* Vector maximum element magnitude ( max(abs(aInput)) ).
|
||||
*/
|
||||
float AudioBufferPeakValue(const float* aInput, uint32_t aSize);
|
||||
|
||||
/**
|
||||
* In place gain. aScale == 1.0f should be optimized.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user