|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef BiquadFilterNode_h_ |
|
8 #define BiquadFilterNode_h_ |
|
9 |
|
10 #include "AudioNode.h" |
|
11 #include "AudioParam.h" |
|
12 #include "mozilla/dom/BiquadFilterNodeBinding.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace dom { |
|
16 |
|
17 class AudioContext; |
|
18 |
|
19 class BiquadFilterNode : public AudioNode |
|
20 { |
|
21 public: |
|
22 explicit BiquadFilterNode(AudioContext* aContext); |
|
23 |
|
24 NS_DECL_ISUPPORTS_INHERITED |
|
25 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BiquadFilterNode, AudioNode) |
|
26 |
|
27 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
28 |
|
29 BiquadFilterType Type() const |
|
30 { |
|
31 return mType; |
|
32 } |
|
33 void SetType(BiquadFilterType aType); |
|
34 |
|
35 AudioParam* Frequency() const |
|
36 { |
|
37 return mFrequency; |
|
38 } |
|
39 |
|
40 AudioParam* Detune() const |
|
41 { |
|
42 return mDetune; |
|
43 } |
|
44 |
|
45 AudioParam* Q() const |
|
46 { |
|
47 return mQ; |
|
48 } |
|
49 |
|
50 AudioParam* Gain() const |
|
51 { |
|
52 return mGain; |
|
53 } |
|
54 |
|
55 void GetFrequencyResponse(const Float32Array& aFrequencyHz, |
|
56 const Float32Array& aMagResponse, |
|
57 const Float32Array& aPhaseResponse); |
|
58 |
|
59 virtual const char* NodeType() const |
|
60 { |
|
61 return "BiquadFilterNode"; |
|
62 } |
|
63 |
|
64 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
|
65 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
|
66 |
|
67 private: |
|
68 static void SendFrequencyToStream(AudioNode* aNode); |
|
69 static void SendDetuneToStream(AudioNode* aNode); |
|
70 static void SendQToStream(AudioNode* aNode); |
|
71 static void SendGainToStream(AudioNode* aNode); |
|
72 |
|
73 private: |
|
74 BiquadFilterType mType; |
|
75 nsRefPtr<AudioParam> mFrequency; |
|
76 nsRefPtr<AudioParam> mDetune; |
|
77 nsRefPtr<AudioParam> mQ; |
|
78 nsRefPtr<AudioParam> mGain; |
|
79 }; |
|
80 |
|
81 } |
|
82 } |
|
83 |
|
84 #endif |
|
85 |