| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #ifndef AnalyserNode_h | 25 #ifndef AnalyserNode_h |
| 26 #define AnalyserNode_h | 26 #define AnalyserNode_h |
| 27 | 27 |
| 28 #include "core/dom/DOMTypedArray.h" | 28 #include "core/dom/DOMTypedArray.h" |
| 29 #include "modules/webaudio/AudioBasicInspectorNode.h" | 29 #include "modules/webaudio/AudioBasicInspectorNode.h" |
| 30 #include "modules/webaudio/RealtimeAnalyser.h" | 30 #include "modules/webaudio/RealtimeAnalyser.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 class BaseAudioContext; | 34 class BaseAudioContext; |
| 35 class AnalyserOptions; |
| 35 class ExceptionState; | 36 class ExceptionState; |
| 36 | 37 |
| 37 class AnalyserHandler final : public AudioBasicInspectorHandler { | 38 class AnalyserHandler final : public AudioBasicInspectorHandler { |
| 38 public: | 39 public: |
| 39 static PassRefPtr<AnalyserHandler> create(AudioNode&, float sampleRate); | 40 static PassRefPtr<AnalyserHandler> create(AudioNode&, float sampleRate); |
| 40 ~AnalyserHandler() override; | 41 ~AnalyserHandler() override; |
| 41 | 42 |
| 42 // AudioHandler | 43 // AudioHandler |
| 43 void process(size_t framesToProcess) override; | 44 void process(size_t framesToProcess) override; |
| 44 | 45 |
| 45 unsigned fftSize() const { return m_analyser.fftSize(); } | 46 unsigned fftSize() const { return m_analyser.fftSize(); } |
| 46 void setFftSize(unsigned size, ExceptionState&); | 47 void setFftSize(unsigned size, ExceptionState&); |
| 47 | 48 |
| 48 unsigned frequencyBinCount() const { return m_analyser.frequencyBinCount();
} | 49 unsigned frequencyBinCount() const { return m_analyser.frequencyBinCount();
} |
| 49 | 50 |
| 50 void setMinDecibels(double k, ExceptionState&); | 51 void setMinDecibels(double k, ExceptionState&); |
| 51 double minDecibels() const { return m_analyser.minDecibels(); } | 52 double minDecibels() const { return m_analyser.minDecibels(); } |
| 52 | 53 |
| 53 void setMaxDecibels(double k, ExceptionState&); | 54 void setMaxDecibels(double k, ExceptionState&); |
| 54 double maxDecibels() const { return m_analyser.maxDecibels(); } | 55 double maxDecibels() const { return m_analyser.maxDecibels(); } |
| 55 | 56 |
| 57 void setMinMaxDecibels(double min, double max, ExceptionState&); |
| 58 |
| 56 void setSmoothingTimeConstant(double k, ExceptionState&); | 59 void setSmoothingTimeConstant(double k, ExceptionState&); |
| 57 double smoothingTimeConstant() const { return m_analyser.smoothingTimeConsta
nt(); } | 60 double smoothingTimeConstant() const { return m_analyser.smoothingTimeConsta
nt(); } |
| 58 | 61 |
| 59 void getFloatFrequencyData(DOMFloat32Array* array, double currentTime) | 62 void getFloatFrequencyData(DOMFloat32Array* array, double currentTime) |
| 60 { | 63 { |
| 61 m_analyser.getFloatFrequencyData(array, currentTime); | 64 m_analyser.getFloatFrequencyData(array, currentTime); |
| 62 } | 65 } |
| 63 void getByteFrequencyData(DOMUint8Array* array, double currentTime) | 66 void getByteFrequencyData(DOMUint8Array* array, double currentTime) |
| 64 { | 67 { |
| 65 m_analyser.getByteFrequencyData(array, currentTime); | 68 m_analyser.getByteFrequencyData(array, currentTime); |
| 66 } | 69 } |
| 67 void getFloatTimeDomainData(DOMFloat32Array* array) { m_analyser.getFloatTim
eDomainData(array); } | 70 void getFloatTimeDomainData(DOMFloat32Array* array) { m_analyser.getFloatTim
eDomainData(array); } |
| 68 void getByteTimeDomainData(DOMUint8Array* array) { m_analyser.getByteTimeDom
ainData(array); } | 71 void getByteTimeDomainData(DOMUint8Array* array) { m_analyser.getByteTimeDom
ainData(array); } |
| 69 | 72 |
| 70 private: | 73 private: |
| 71 AnalyserHandler(AudioNode&, float sampleRate); | 74 AnalyserHandler(AudioNode&, float sampleRate); |
| 72 | 75 |
| 73 RealtimeAnalyser m_analyser; | 76 RealtimeAnalyser m_analyser; |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 class AnalyserNode final : public AudioBasicInspectorNode { | 79 class AnalyserNode final : public AudioBasicInspectorNode { |
| 77 DEFINE_WRAPPERTYPEINFO(); | 80 DEFINE_WRAPPERTYPEINFO(); |
| 78 public: | 81 public: |
| 79 static AnalyserNode* create(BaseAudioContext&, ExceptionState&); | 82 static AnalyserNode* create(BaseAudioContext&, ExceptionState&); |
| 83 static AnalyserNode* create(BaseAudioContext*, const AnalyserOptions&, Excep
tionState&); |
| 80 | 84 |
| 81 unsigned fftSize() const; | 85 unsigned fftSize() const; |
| 82 void setFftSize(unsigned size, ExceptionState&); | 86 void setFftSize(unsigned size, ExceptionState&); |
| 83 unsigned frequencyBinCount() const; | 87 unsigned frequencyBinCount() const; |
| 84 void setMinDecibels(double, ExceptionState&); | 88 void setMinDecibels(double, ExceptionState&); |
| 85 double minDecibels() const; | 89 double minDecibels() const; |
| 86 void setMaxDecibels(double, ExceptionState&); | 90 void setMaxDecibels(double, ExceptionState&); |
| 87 double maxDecibels() const; | 91 double maxDecibels() const; |
| 88 void setSmoothingTimeConstant(double, ExceptionState&); | 92 void setSmoothingTimeConstant(double, ExceptionState&); |
| 89 double smoothingTimeConstant() const; | 93 double smoothingTimeConstant() const; |
| 90 void getFloatFrequencyData(DOMFloat32Array*); | 94 void getFloatFrequencyData(DOMFloat32Array*); |
| 91 void getByteFrequencyData(DOMUint8Array*); | 95 void getByteFrequencyData(DOMUint8Array*); |
| 92 void getFloatTimeDomainData(DOMFloat32Array*); | 96 void getFloatTimeDomainData(DOMFloat32Array*); |
| 93 void getByteTimeDomainData(DOMUint8Array*); | 97 void getByteTimeDomainData(DOMUint8Array*); |
| 94 | 98 |
| 95 private: | 99 private: |
| 96 AnalyserNode(BaseAudioContext&); | 100 AnalyserNode(BaseAudioContext&); |
| 97 AnalyserHandler& analyserHandler() const; | 101 AnalyserHandler& analyserHandler() const; |
| 102 |
| 103 void setMinMaxDecibels(double min, double max, ExceptionState&); |
| 98 }; | 104 }; |
| 99 | 105 |
| 100 } // namespace blink | 106 } // namespace blink |
| 101 | 107 |
| 102 #endif // AnalyserNode_h | 108 #endif // AnalyserNode_h |
| OLD | NEW |