Bug 976471 - Implement AnalyserNode.getFloatTimeDomainData(). r=karlt
authorPaul Adenot <paul@paul.cx>
Tue, 25 Feb 2014 11:30:48 +0100
changeset 170929 9b0bf77d6f244185cff30fcfe2a3ba2718df9cf9
parent 170928 7a8e0a49b3f67f1d5a4dce0bbacadcd476d2d40e
child 170962 8c7cf76ab17da5da3928c3a7d134141c617fd4ea
push id40350
push userpaul@paul.cx
push dateThu, 27 Feb 2014 14:04:34 +0000
treeherdermozilla-inbound@9b0bf77d6f24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs976471
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 976471 - Implement AnalyserNode.getFloatTimeDomainData(). r=karlt
content/media/webaudio/AnalyserNode.cpp
content/media/webaudio/AnalyserNode.h
dom/webidl/AnalyserNode.webidl
--- a/content/media/webaudio/AnalyserNode.cpp
+++ b/content/media/webaudio/AnalyserNode.cpp
@@ -176,16 +176,27 @@ AnalyserNode::GetByteFrequencyData(const
     // scale down the value to the range of [0, UCHAR_MAX]
     const double scaled = std::max(0.0, std::min(double(UCHAR_MAX),
                                                  UCHAR_MAX * (decibels - mMinDecibels) * rangeScaleFactor));
     buffer[i] = static_cast<unsigned char>(scaled);
   }
 }
 
 void
+AnalyserNode::GetFloatTimeDomainData(const Float32Array& aArray)
+{
+  float* buffer = aArray.Data();
+  uint32_t length = std::min(aArray.Length(), mBuffer.Length());
+
+  for (uint32_t i = 0; i < length; ++i) {
+    buffer[i] = mBuffer[(i + mWriteIndex) % mBuffer.Length()];;
+  }
+}
+
+void
 AnalyserNode::GetByteTimeDomainData(const Uint8Array& aArray)
 {
   unsigned char* buffer = aArray.Data();
   uint32_t length = std::min(aArray.Length(), mBuffer.Length());
 
   for (uint32_t i = 0; i < length; ++i) {
     const float value = mBuffer[(i + mWriteIndex) % mBuffer.Length()];
     // scale the value to the range of [0, UCHAR_MAX]
--- a/content/media/webaudio/AnalyserNode.h
+++ b/content/media/webaudio/AnalyserNode.h
@@ -22,16 +22,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void GetFloatFrequencyData(const Float32Array& aArray);
   void GetByteFrequencyData(const Uint8Array& aArray);
+  void GetFloatTimeDomainData(const Float32Array& aArray);
   void GetByteTimeDomainData(const Uint8Array& aArray);
   uint32_t FftSize() const
   {
     return mAnalysisBlock.FFTSize();
   }
   void SetFftSize(uint32_t aValue, ErrorResult& aRv);
   uint32_t FrequencyBinCount() const
   {
--- a/dom/webidl/AnalyserNode.webidl
+++ b/dom/webidl/AnalyserNode.webidl
@@ -7,21 +7,22 @@
  * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 interface AnalyserNode : AudioNode {
 
-    // Real-time frequency-domain data 
+    // Real-time frequency-domain data
     void getFloatFrequencyData(Float32Array array);
     void getByteFrequencyData(Uint8Array array);
 
-    // Real-time waveform data 
+    // Real-time waveform data
+    void getFloatTimeDomainData(Float32Array array);
     void getByteTimeDomainData(Uint8Array array);
 
     [SetterThrows, Pure]
     attribute unsigned long fftSize;
     [Pure]
     readonly attribute unsigned long frequencyBinCount;
 
     [SetterThrows, Pure]