Bug 48810

Summary: Add RealtimeAnalyser files
Product: WebKit Reporter: Chris Rogers <crogers>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarrin, commit-queue, dglazkov, eric.carlson, jamesr, jer.noble, kbr, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
Patch
none
Patch none

Chris Rogers
Reported 2010-11-01 17:24:00 PDT
Add RealtimeAnalyser files
Attachments
Patch (15.65 KB, patch)
2010-11-01 17:25 PDT, Chris Rogers
no flags
Patch (15.58 KB, patch)
2010-11-02 12:23 PDT, Chris Rogers
no flags
Chris Rogers
Comment 1 2010-11-01 17:25:51 PDT
Kenneth Russell
Comment 2 2010-11-01 19:26:48 PDT
Comment on attachment 72606 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=72606&action=review A few relatively minor issues. > WebCore/webaudio/RealtimeAnalyser.cpp:53 > +const unsigned RealtimeAnalyser::InputBufferSize = RealtimeAnalyser::MaxFFTSize * 2; I recall that you may have compilation problems on Windows with static constants. I think the MSVC compiler wants the definition in the header and none in the .cpp file. However I guess we'll cross that bridge when we come to it. > WebCore/webaudio/RealtimeAnalyser.cpp:109 > + return; This check is redundant with the second half of the isDestinationGood check below, and has the disadvantage that it uses the InputBufferSize constant instead of m_inputBuffer.size(). It should be removed and the isDestinationGood check hoisted up to here. > WebCore/webaudio/RealtimeAnalyser.cpp:129 > +static void ApplyWindow(float* p, size_t n) WebKit style is lower case for first letter. Also, consider using an anonymous namespace rather than a static function. > WebCore/webaudio/RealtimeAnalyser.cpp:153 > + AudioFloatArray temporaryBuffer(fftSize); Isn't the reallocation of this array expensive? If so consider caching it and only reallocating if fftSize changes. > WebCore/webaudio/RealtimeAnalyser.cpp:158 > + // FIXME : optimize with memcpy() Add period at end of sentence. > WebCore/webaudio/RealtimeAnalyser.cpp:215 > + double dbMag = !linearValue ? MinDecibels : 20.0 * log10(linearValue); What's this 20.0 constant? Can it be defined somewhere? > WebCore/webaudio/RealtimeAnalyser.cpp:241 > + double dbMag = !linearValue ? m_minDecibels : 20.0 * log10(linearValue); Same comment about the 20.0 constant. > WebCore/webaudio/RealtimeAnalyser.cpp:244 > + double scaledValue = 255.0 * (dbMag - m_minDecibels) * RangeScaleFactor; Please #include <limits.h> and use UCHAR_MAX rather than 255.0 sprinkled everywhere. > WebCore/webaudio/RealtimeAnalyser.cpp:282 > + double scaledValue = 128.0 * (value + 1.0); Unfortunately SCHAR_MAX is 127 and not 128, but if there is a reasonable way to express this scaling in terms of predefined constants please do so. > WebCore/webaudio/RealtimeAnalyser.cpp:288 > + if (scaledValue > 255.0) > + scaledValue = 255.0; These should use UCHAR_MAX.
Chris Rogers
Comment 3 2010-11-02 12:16:40 PDT
Comment on attachment 72606 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=72606&action=review >> WebCore/webaudio/RealtimeAnalyser.cpp:53 >> +const unsigned RealtimeAnalyser::InputBufferSize = RealtimeAnalyser::MaxFFTSize * 2; > > I recall that you may have compilation problems on Windows with static constants. I think the MSVC compiler wants the definition in the header and none in the .cpp file. However I guess we'll cross that bridge when we come to it. Actually jamesr thought the problem was the other way where MSVC didn't like the definition in the header, but required it in the .cpp >> WebCore/webaudio/RealtimeAnalyser.cpp:109 >> + return; > > This check is redundant with the second half of the isDestinationGood check below, and has the disadvantage that it uses the InputBufferSize constant instead of m_inputBuffer.size(). It should be removed and the isDestinationGood check hoisted up to here. FIXED >> WebCore/webaudio/RealtimeAnalyser.cpp:129 >> +static void ApplyWindow(float* p, size_t n) > > WebKit style is lower case for first letter. Also, consider using an anonymous namespace rather than a static function. FIXED >> WebCore/webaudio/RealtimeAnalyser.cpp:153 >> + AudioFloatArray temporaryBuffer(fftSize); > > Isn't the reallocation of this array expensive? If so consider caching it and only reallocating if fftSize changes. In this situation, compared with the cost of doing the windowing and the FFT, the cost of malloc() is extremely small. >> WebCore/webaudio/RealtimeAnalyser.cpp:158 >> + // FIXME : optimize with memcpy() > > Add period at end of sentence. FIXED >> WebCore/webaudio/RealtimeAnalyser.cpp:215 >> + double dbMag = !linearValue ? MinDecibels : 20.0 * log10(linearValue); > > What's this 20.0 constant? Can it be defined somewhere? Sorry, I forgot I had defined a function for this: AudioUtilities::linearToDecibels() FIXED >> WebCore/webaudio/RealtimeAnalyser.cpp:241 >> + double dbMag = !linearValue ? m_minDecibels : 20.0 * log10(linearValue); > > Same comment about the 20.0 constant. FIXED: switched to AudioUtilities::linearToDecibels() >> WebCore/webaudio/RealtimeAnalyser.cpp:244 >> + double scaledValue = 255.0 * (dbMag - m_minDecibels) * RangeScaleFactor; > > Please #include <limits.h> and use UCHAR_MAX rather than 255.0 sprinkled everywhere. FIXED >> WebCore/webaudio/RealtimeAnalyser.cpp:288 >> + scaledValue = 255.0; > > These should use UCHAR_MAX. FIXED
Chris Rogers
Comment 4 2010-11-02 12:23:20 PDT
Kenneth Russell
Comment 5 2010-11-02 12:50:15 PDT
Comment on attachment 72713 [details] Patch Looks good.
WebKit Commit Bot
Comment 6 2010-11-02 17:44:48 PDT
Comment on attachment 72713 [details] Patch Clearing flags on attachment: 72713 Committed r71193: <http://trac.webkit.org/changeset/71193>
WebKit Commit Bot
Comment 7 2010-11-02 17:44:54 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.