Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Unified Diff: Source/core/platform/audio/DownSampler.h

Issue 15619003: Add support for WaveShaperNode.oversample (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: change TestExpectations in middle of file Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/audio/DownSampler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/audio/DownSampler.h
diff --git a/Source/core/animation/Animation.h b/Source/core/platform/audio/DownSampler.h
similarity index 60%
copy from Source/core/animation/Animation.h
copy to Source/core/platform/audio/DownSampler.h
index f72d57ac5e5fd993ea4f360163ee7e351343b920..afd5d98cf2de7d7220f22ce5bee1421961dcdf70 100644
--- a/Source/core/animation/Animation.h
+++ b/Source/core/platform/audio/DownSampler.h
@@ -28,43 +28,47 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef Animation_h
-#define Animation_h
+#ifndef DownSampler_h
+#define DownSampler_h
-#include "core/animation/AnimationEffect.h"
-#include "core/animation/TimedItem.h"
-#include "wtf/RefPtr.h"
+#include "core/platform/audio/AudioArray.h"
+#include "core/platform/audio/DirectConvolver.h"
namespace WebCore {
-class Element;
-
-class Animation FINAL : public TimedItem {
+// DownSampler down-samples the source stream by a factor of 2x.
+class DownSampler {
public:
- static PassRefPtr<Animation> create(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&);
- virtual ~Animation();
+ DownSampler(size_t inputBlockSize);
+
+ // The destination buffer |destP| is of size sourceFramesToProcess / 2.
+ void process(const float* sourceP, float* destP, size_t sourceFramesToProcess);
- const AnimationEffect::CompositableValueMap* compositableValues() const
- {
- ASSERT(m_compositableValues);
- return m_compositableValues.get();
- }
+ void reset();
-protected:
- virtual void applyEffects(bool previouslyActiveOrInEffect);
- virtual void clearEffects();
- virtual void updateChildrenAndEffects(bool) const OVERRIDE FINAL;
+ // Latency based on the destination sample-rate.
+ size_t latencyFrames() const;
private:
- Animation(PassRefPtr<Element>, PassRefPtr<AnimationEffect>, const Timing&);
+ enum { DefaultKernelSize = 256 };
+
+ size_t m_inputBlockSize;
+
+ // Computes ideal band-limited half-band filter coefficients.
+ // In other words, filter out all frequencies higher than 0.25 * Nyquist.
+ void initializeKernel();
+ AudioFloatArray m_reducedKernel;
+
+ // Half-band filter.
+ DirectConvolver m_convolver;
+
+ AudioFloatArray m_tempBuffer;
- RefPtr<Element> m_target;
- RefPtr<AnimationEffect> m_effect;
- bool m_isInTargetActiveAnimationsList;
- OwnPtr<AnimationEffect::CompositableValueMap> m_compositableValues;
+ // Used as delay-line (FIR filter history) for the input samples to account for the 0.5 term right in the middle of the kernel.
+ AudioFloatArray m_inputBuffer;
};
} // namespace WebCore
-#endif
+#endif // DownSampler_h
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/platform/audio/DownSampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698