Title: [108110] trunk/Source/WebCore
- Revision
- 108110
- Author
- [email protected]
- Date
- 2012-02-17 12:57:02 -0800 (Fri, 17 Feb 2012)
Log Message
RealtimeAnalyserNode does not consistently respect .minDecibels
https://bugs.webkit.org/show_bug.cgi?id=78729
Make use of m_minDecibel consistent. Clean up some style issues
with names of local variables and style issues with float
constants.
Patch by Raymond Toy <[email protected]> on 2012-02-17
Reviewed by Chris Rogers.
No new tests because the changes are cosmetic for style issues.
* webaudio/RealtimeAnalyser.cpp:
(WebCore):
(WebCore::RealtimeAnalyser::doFFTAnalysis):
(WebCore::RealtimeAnalyser::getFloatFrequencyData):
(WebCore::RealtimeAnalyser::getByteFrequencyData):
(WebCore::RealtimeAnalyser::getByteTimeDomainData):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (108109 => 108110)
--- trunk/Source/WebCore/ChangeLog 2012-02-17 20:51:45 UTC (rev 108109)
+++ trunk/Source/WebCore/ChangeLog 2012-02-17 20:57:02 UTC (rev 108110)
@@ -1,3 +1,23 @@
+2012-02-17 Raymond Toy <[email protected]>
+
+ RealtimeAnalyserNode does not consistently respect .minDecibels
+ https://bugs.webkit.org/show_bug.cgi?id=78729
+
+ Make use of m_minDecibel consistent. Clean up some style issues
+ with names of local variables and style issues with float
+ constants.
+
+ Reviewed by Chris Rogers.
+
+ No new tests because the changes are cosmetic for style issues.
+
+ * webaudio/RealtimeAnalyser.cpp:
+ (WebCore):
+ (WebCore::RealtimeAnalyser::doFFTAnalysis):
+ (WebCore::RealtimeAnalyser::getFloatFrequencyData):
+ (WebCore::RealtimeAnalyser::getByteFrequencyData):
+ (WebCore::RealtimeAnalyser::getByteTimeDomainData):
+
2012-02-17 Abhishek Arya <[email protected]>
:before content incorrectly placed in continuation
Modified: trunk/Source/WebCore/webaudio/RealtimeAnalyser.cpp (108109 => 108110)
--- trunk/Source/WebCore/webaudio/RealtimeAnalyser.cpp 2012-02-17 20:51:45 UTC (rev 108109)
+++ trunk/Source/WebCore/webaudio/RealtimeAnalyser.cpp 2012-02-17 20:57:02 UTC (rev 108110)
@@ -45,8 +45,8 @@
namespace WebCore {
const double RealtimeAnalyser::DefaultSmoothingTimeConstant = 0.8;
-const double RealtimeAnalyser::DefaultMinDecibels = -100.0;
-const double RealtimeAnalyser::DefaultMaxDecibels = -30.0;
+const double RealtimeAnalyser::DefaultMinDecibels = -100;
+const double RealtimeAnalyser::DefaultMaxDecibels = -30;
const unsigned RealtimeAnalyser::DefaultFFTSize = 2048;
// All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize.
@@ -132,13 +132,13 @@
// Blackman window
double alpha = 0.16;
- double a0 = 0.5 * (1.0 - alpha);
+ double a0 = 0.5 * (1 - alpha);
double a1 = 0.5;
double a2 = 0.5 * alpha;
for (unsigned i = 0; i < n; ++i) {
double x = static_cast<double>(i) / static_cast<double>(n);
- double window = a0 - a1 * cos(2.0 * piDouble * x) + a2 * cos(4.0 * piDouble * x);
+ double window = a0 - a1 * cos(2 * piDouble * x) + a2 * cos(4 * piDouble * x);
p[i] *= float(window);
}
}
@@ -175,10 +175,10 @@
float* imagP = m_analysisFrame->imagData();
// Blow away the packed nyquist component.
- imagP[0] = 0.0f;
+ imagP[0] = 0;
// Normalize so than an input sine wave at 0dBfs registers as 0dBfs (undo FFT scaling factor).
- const double MagnitudeScale = 1.0 / DefaultFFTSize;
+ const double magnitudeScale = 1.0 / DefaultFFTSize;
// A value of 0 does no averaging with the previous result. Larger values produce slower, but smoother changes.
double k = m_smoothingTimeConstant;
@@ -190,8 +190,8 @@
size_t n = magnitudeBuffer().size();
for (size_t i = 0; i < n; ++i) {
Complex c(realP[i], imagP[i]);
- double scalarMagnitude = abs(c) * MagnitudeScale;
- destination[i] = float(k * destination[i] + (1.0 - k) * scalarMagnitude);
+ double scalarMagnitude = abs(c) * magnitudeScale;
+ destination[i] = float(k * destination[i] + (1 - k) * scalarMagnitude);
}
}
@@ -205,7 +205,7 @@
doFFTAnalysis();
// Convert from linear magnitude to floating-point decibels.
- const double MinDecibels = m_minDecibels;
+ const double minDecibels = m_minDecibels;
unsigned sourceLength = magnitudeBuffer().size();
size_t len = min(sourceLength, destinationArray->length());
if (len > 0) {
@@ -214,7 +214,7 @@
for (unsigned i = 0; i < len; ++i) {
float linearValue = source[i];
- double dbMag = !linearValue ? MinDecibels : AudioUtilities::linearToDecibels(linearValue);
+ double dbMag = !linearValue ? minDecibels : AudioUtilities::linearToDecibels(linearValue);
destination[i] = float(dbMag);
}
}
@@ -233,21 +233,22 @@
unsigned sourceLength = magnitudeBuffer().size();
size_t len = min(sourceLength, destinationArray->length());
if (len > 0) {
- const double RangeScaleFactor = m_maxDecibels == m_minDecibels ? 1.0 : 1.0 / (m_maxDecibels - m_minDecibels);
+ const double rangeScaleFactor = m_maxDecibels == m_minDecibels ? 1 : 1 / (m_maxDecibels - m_minDecibels);
+ const double minDecibels = m_minDecibels;
const float* source = magnitudeBuffer().data();
unsigned char* destination = destinationArray->data();
for (unsigned i = 0; i < len; ++i) {
float linearValue = source[i];
- double dbMag = !linearValue ? m_minDecibels : AudioUtilities::linearToDecibels(linearValue);
+ double dbMag = !linearValue ? minDecibels : AudioUtilities::linearToDecibels(linearValue);
// The range m_minDecibels to m_maxDecibels will be scaled to byte values from 0 to UCHAR_MAX.
- double scaledValue = UCHAR_MAX * (dbMag - m_minDecibels) * RangeScaleFactor;
+ double scaledValue = UCHAR_MAX * (dbMag - minDecibels) * rangeScaleFactor;
// Clip to valid range.
- if (scaledValue < 0.0)
- scaledValue = 0.0;
+ if (scaledValue < 0)
+ scaledValue = 0;
if (scaledValue > UCHAR_MAX)
scaledValue = UCHAR_MAX;
@@ -280,12 +281,12 @@
// Buffer access is protected due to modulo operation.
float value = inputBuffer[(i + writeIndex - fftSize + InputBufferSize) % InputBufferSize];
- // Scale from nominal -1.0 -> +1.0 to unsigned byte.
- double scaledValue = 128.0 * (value + 1.0);
+ // Scale from nominal -1 -> +1 to unsigned byte.
+ double scaledValue = 128 * (value + 1);
// Clip to valid range.
- if (scaledValue < 0.0)
- scaledValue = 0.0;
+ if (scaledValue < 0)
+ scaledValue = 0;
if (scaledValue > UCHAR_MAX)
scaledValue = UCHAR_MAX;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes