content/media/webaudio/AnalyserNode.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef AnalyserNode_h_
michael@0 8 #define AnalyserNode_h_
michael@0 9
michael@0 10 #include "AudioNode.h"
michael@0 11 #include "FFTBlock.h"
michael@0 12
michael@0 13 namespace mozilla {
michael@0 14 namespace dom {
michael@0 15
michael@0 16 class AudioContext;
michael@0 17
michael@0 18 class AnalyserNode : public AudioNode
michael@0 19 {
michael@0 20 public:
michael@0 21 explicit AnalyserNode(AudioContext* aContext);
michael@0 22
michael@0 23 NS_DECL_ISUPPORTS_INHERITED
michael@0 24
michael@0 25 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 26
michael@0 27 void GetFloatFrequencyData(const Float32Array& aArray);
michael@0 28 void GetByteFrequencyData(const Uint8Array& aArray);
michael@0 29 void GetFloatTimeDomainData(const Float32Array& aArray);
michael@0 30 void GetByteTimeDomainData(const Uint8Array& aArray);
michael@0 31 uint32_t FftSize() const
michael@0 32 {
michael@0 33 return mAnalysisBlock.FFTSize();
michael@0 34 }
michael@0 35 void SetFftSize(uint32_t aValue, ErrorResult& aRv);
michael@0 36 uint32_t FrequencyBinCount() const
michael@0 37 {
michael@0 38 return FftSize() / 2;
michael@0 39 }
michael@0 40 double MinDecibels() const
michael@0 41 {
michael@0 42 return mMinDecibels;
michael@0 43 }
michael@0 44 void SetMinDecibels(double aValue, ErrorResult& aRv);
michael@0 45 double MaxDecibels() const
michael@0 46 {
michael@0 47 return mMaxDecibels;
michael@0 48 }
michael@0 49 void SetMaxDecibels(double aValue, ErrorResult& aRv);
michael@0 50 double SmoothingTimeConstant() const
michael@0 51 {
michael@0 52 return mSmoothingTimeConstant;
michael@0 53 }
michael@0 54 void SetSmoothingTimeConstant(double aValue, ErrorResult& aRv);
michael@0 55
michael@0 56 virtual const char* NodeType() const
michael@0 57 {
michael@0 58 return "AnalyserNode";
michael@0 59 }
michael@0 60
michael@0 61 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
michael@0 62 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
michael@0 63
michael@0 64 private:
michael@0 65 friend class AnalyserNodeEngine;
michael@0 66 void AppendChunk(const AudioChunk& aChunk);
michael@0 67 bool AllocateBuffer();
michael@0 68 bool FFTAnalysis();
michael@0 69 void ApplyBlackmanWindow(float* aBuffer, uint32_t aSize);
michael@0 70
michael@0 71 private:
michael@0 72 FFTBlock mAnalysisBlock;
michael@0 73 double mMinDecibels;
michael@0 74 double mMaxDecibels;
michael@0 75 double mSmoothingTimeConstant;
michael@0 76 uint32_t mWriteIndex;
michael@0 77 FallibleTArray<float> mBuffer;
michael@0 78 FallibleTArray<float> mOutputBuffer;
michael@0 79 };
michael@0 80
michael@0 81 }
michael@0 82 }
michael@0 83
michael@0 84 #endif
michael@0 85

mercurial