| 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #ifndef AudioParam_h | 29 #ifndef AudioParam_h |
| 30 #define AudioParam_h | 30 #define AudioParam_h |
| 31 | 31 |
| 32 #include "bindings/core/v8/ScriptWrappable.h" | 32 #include "bindings/core/v8/ScriptWrappable.h" |
| 33 #include "core/dom/DOMTypedArray.h" | 33 #include "core/dom/DOMTypedArray.h" |
| 34 #include "modules/webaudio/AbstractAudioContext.h" | |
| 35 #include "modules/webaudio/AudioParamTimeline.h" | 34 #include "modules/webaudio/AudioParamTimeline.h" |
| 36 #include "modules/webaudio/AudioSummingJunction.h" | 35 #include "modules/webaudio/AudioSummingJunction.h" |
| 36 #include "modules/webaudio/BaseAudioContext.h" |
| 37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 38 #include "wtf/ThreadSafeRefCounted.h" | 38 #include "wtf/ThreadSafeRefCounted.h" |
| 39 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
| 40 #include <sys/types.h> | 40 #include <sys/types.h> |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class AudioNodeOutput; | 44 class AudioNodeOutput; |
| 45 | 45 |
| 46 // Each AudioParam gets an identifier here. This is mostly for instrospection i
f warnings or | 46 // Each AudioParam gets an identifier here. This is mostly for instrospection i
f warnings or |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 public: | 93 public: |
| 94 AudioParamType getParamType() const { return m_paramType; } | 94 AudioParamType getParamType() const { return m_paramType; } |
| 95 void setParamType(AudioParamType); | 95 void setParamType(AudioParamType); |
| 96 // Return a nice name for the AudioParam. | 96 // Return a nice name for the AudioParam. |
| 97 String getParamName() const; | 97 String getParamName() const; |
| 98 | 98 |
| 99 static const double DefaultSmoothingConstant; | 99 static const double DefaultSmoothingConstant; |
| 100 static const double SnapThreshold; | 100 static const double SnapThreshold; |
| 101 | 101 |
| 102 static PassRefPtr<AudioParamHandler> create( | 102 static PassRefPtr<AudioParamHandler> create( |
| 103 AbstractAudioContext& context, | 103 BaseAudioContext& context, |
| 104 AudioParamType paramType, | 104 AudioParamType paramType, |
| 105 double defaultValue, | 105 double defaultValue, |
| 106 float minValue, | 106 float minValue, |
| 107 float maxValue) | 107 float maxValue) |
| 108 { | 108 { |
| 109 return adoptRef(new AudioParamHandler(context, paramType, defaultValue,
minValue, maxValue)); | 109 return adoptRef(new AudioParamHandler(context, paramType, defaultValue,
minValue, maxValue)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // This should be used only in audio rendering thread. | 112 // This should be used only in audio rendering thread. |
| 113 AudioDestinationHandler& destinationHandler() const; | 113 AudioDestinationHandler& destinationHandler() const; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // Connect an audio-rate signal to control this parameter. | 150 // Connect an audio-rate signal to control this parameter. |
| 151 void connect(AudioNodeOutput&); | 151 void connect(AudioNodeOutput&); |
| 152 void disconnect(AudioNodeOutput&); | 152 void disconnect(AudioNodeOutput&); |
| 153 | 153 |
| 154 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); } | 154 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); } |
| 155 | 155 |
| 156 // Update any histograms with the given value. | 156 // Update any histograms with the given value. |
| 157 void updateHistograms(float newValue); | 157 void updateHistograms(float newValue); |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 AudioParamHandler(AbstractAudioContext&, AudioParamType, double defaultValue
, float min, float max); | 160 AudioParamHandler(BaseAudioContext&, AudioParamType, double defaultValue, fl
oat min, float max); |
| 161 | 161 |
| 162 void warnIfOutsideRange(float value, float minValue, float maxValue); | 162 void warnIfOutsideRange(float value, float minValue, float maxValue); |
| 163 | 163 |
| 164 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A
udio specification. | 164 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A
udio specification. |
| 165 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl
eAccurate); | 165 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl
eAccurate); |
| 166 void calculateTimelineValues(float* values, unsigned numberOfValues); | 166 void calculateTimelineValues(float* values, unsigned numberOfValues); |
| 167 | 167 |
| 168 int computeQHistogramValue(float) const; | 168 int computeQHistogramValue(float) const; |
| 169 | 169 |
| 170 // The type of AudioParam, indicating what this AudioParam represents and wh
at node it belongs | 170 // The type of AudioParam, indicating what this AudioParam represents and wh
at node it belongs |
| (...skipping 13 matching lines...) Expand all Loading... |
| 184 AudioParamTimeline m_timeline; | 184 AudioParamTimeline m_timeline; |
| 185 | 185 |
| 186 // The destination node used to get necessary information like the smaple ra
te and context time. | 186 // The destination node used to get necessary information like the smaple ra
te and context time. |
| 187 RefPtr<AudioDestinationHandler> m_destinationHandler; | 187 RefPtr<AudioDestinationHandler> m_destinationHandler; |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 // AudioParam class represents web-exposed AudioParam interface. | 190 // AudioParam class represents web-exposed AudioParam interface. |
| 191 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc
riptWrappable { | 191 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc
riptWrappable { |
| 192 DEFINE_WRAPPERTYPEINFO(); | 192 DEFINE_WRAPPERTYPEINFO(); |
| 193 public: | 193 public: |
| 194 static AudioParam* create(AbstractAudioContext&, AudioParamType, double defa
ultValue); | 194 static AudioParam* create(BaseAudioContext&, AudioParamType, double defaultV
alue); |
| 195 static AudioParam* create(AbstractAudioContext&, AudioParamType, double defa
ultValue, float minValue, float maxValue); | 195 static AudioParam* create(BaseAudioContext&, AudioParamType, double defaultV
alue, float minValue, float maxValue); |
| 196 | 196 |
| 197 DECLARE_TRACE(); | 197 DECLARE_TRACE(); |
| 198 // |handler| always returns a valid object. | 198 // |handler| always returns a valid object. |
| 199 AudioParamHandler& handler() const { return *m_handler; } | 199 AudioParamHandler& handler() const { return *m_handler; } |
| 200 // |context| always returns a valid object. | 200 // |context| always returns a valid object. |
| 201 AbstractAudioContext* context() const { return m_context; } | 201 BaseAudioContext* context() const { return m_context; } |
| 202 | 202 |
| 203 AudioParamType getParamType() const { return handler().getParamType(); } | 203 AudioParamType getParamType() const { return handler().getParamType(); } |
| 204 void setParamType(AudioParamType); | 204 void setParamType(AudioParamType); |
| 205 String getParamName() const; | 205 String getParamName() const; |
| 206 | 206 |
| 207 float value() const; | 207 float value() const; |
| 208 void setValue(float); | 208 void setValue(float); |
| 209 float defaultValue() const; | 209 float defaultValue() const; |
| 210 | 210 |
| 211 float minValue() const; | 211 float minValue() const; |
| 212 float maxValue() const; | 212 float maxValue() const; |
| 213 | 213 |
| 214 AudioParam* setValueAtTime(float value, double time, ExceptionState&); | 214 AudioParam* setValueAtTime(float value, double time, ExceptionState&); |
| 215 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState
&); | 215 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState
&); |
| 216 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception
State&); | 216 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception
State&); |
| 217 AudioParam* setTargetAtTime(float target, double time, double timeConstant,
ExceptionState&); | 217 AudioParam* setTargetAtTime(float target, double time, double timeConstant,
ExceptionState&); |
| 218 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double
duration, ExceptionState&); | 218 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double
duration, ExceptionState&); |
| 219 AudioParam* cancelScheduledValues(double startTime, ExceptionState&); | 219 AudioParam* cancelScheduledValues(double startTime, ExceptionState&); |
| 220 | 220 |
| 221 private: | 221 private: |
| 222 AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue, float
min, float max); | 222 AudioParam(BaseAudioContext&, AudioParamType, double defaultValue, float min
, float max); |
| 223 | 223 |
| 224 void warnIfOutsideRange(const String& paramMethd, float value); | 224 void warnIfOutsideRange(const String& paramMethd, float value); |
| 225 | 225 |
| 226 RefPtr<AudioParamHandler> m_handler; | 226 RefPtr<AudioParamHandler> m_handler; |
| 227 Member<AbstractAudioContext> m_context; | 227 Member<BaseAudioContext> m_context; |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 } // namespace blink | 230 } // namespace blink |
| 231 | 231 |
| 232 #endif // AudioParam_h | 232 #endif // AudioParam_h |
| OLD | NEW |