| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 47 // other messages need to be printed. It's useful to know what the AudioParam re
presents. The | 47 // other messages need to be printed. It's useful to know what the AudioParam re
presents. The |
| 48 // name should include the node type and the name of the AudioParam. | 48 // name should include the node type and the name of the AudioParam. |
| 49 enum AudioParamType { | 49 enum AudioParamType { |
| 50 ParamTypeAudioBufferSourcePlaybackRate, | 50 ParamTypeAudioBufferSourcePlaybackRate, |
| 51 ParamTypeAudioBufferSourceDetune, | 51 ParamTypeAudioBufferSourceDetune, |
| 52 ParamTypeBiquadFilterFrequency, | 52 ParamTypeBiquadFilterFrequency, |
| 53 ParamTypeBiquadFilterQ, | 53 ParamTypeBiquadFilterQ, |
| 54 ParamTypeBiquadFilterQLowpass, |
| 55 ParamTypeBiquadFilterQHighpass, |
| 54 ParamTypeBiquadFilterGain, | 56 ParamTypeBiquadFilterGain, |
| 55 ParamTypeBiquadFilterDetune, | 57 ParamTypeBiquadFilterDetune, |
| 56 ParamTypeDelayDelayTime, | 58 ParamTypeDelayDelayTime, |
| 57 ParamTypeDynamicsCompressorThreshold, | 59 ParamTypeDynamicsCompressorThreshold, |
| 58 ParamTypeDynamicsCompressorKnee, | 60 ParamTypeDynamicsCompressorKnee, |
| 59 ParamTypeDynamicsCompressorRatio, | 61 ParamTypeDynamicsCompressorRatio, |
| 60 ParamTypeDynamicsCompressorAttack, | 62 ParamTypeDynamicsCompressorAttack, |
| 61 ParamTypeDynamicsCompressorRelease, | 63 ParamTypeDynamicsCompressorRelease, |
| 62 ParamTypeGainGain, | 64 ParamTypeGainGain, |
| 63 ParamTypeOscillatorFrequency, | 65 ParamTypeOscillatorFrequency, |
| 64 ParamTypeOscillatorDetune, | 66 ParamTypeOscillatorDetune, |
| 65 ParamTypeStereoPannerPan | 67 ParamTypeStereoPannerPan |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 // AudioParamHandler is an actual implementation of web-exposed AudioParam | 70 // AudioParamHandler is an actual implementation of web-exposed AudioParam |
| 69 // interface. Each of AudioParam object creates and owns an AudioParamHandler, | 71 // interface. Each of AudioParam object creates and owns an AudioParamHandler, |
| 70 // and it is responsible for all of AudioParam tasks. An AudioParamHandler | 72 // and it is responsible for all of AudioParam tasks. An AudioParamHandler |
| 71 // object is owned by the originator AudioParam object, and some audio | 73 // object is owned by the originator AudioParam object, and some audio |
| 72 // processing classes have additional references. An AudioParamHandler can | 74 // processing classes have additional references. An AudioParamHandler can |
| 73 // outlive the owner AudioParam, and it never dies before the owner AudioParam | 75 // outlive the owner AudioParam, and it never dies before the owner AudioParam |
| 74 // dies. | 76 // dies. |
| 75 class AudioParamHandler final : public ThreadSafeRefCounted<AudioParamHandler>,
public AudioSummingJunction { | 77 class AudioParamHandler final : public ThreadSafeRefCounted<AudioParamHandler>,
public AudioSummingJunction { |
| 76 public: | 78 public: |
| 77 AudioParamType getParamType() const { return m_paramType; } | 79 AudioParamType getParamType() const { return m_paramType; } |
| 80 void setParamType(AudioParamType); |
| 78 // Return a nice name for the AudioParam. | 81 // Return a nice name for the AudioParam. |
| 79 String getParamName() const; | 82 String getParamName() const; |
| 80 | 83 |
| 81 static const double DefaultSmoothingConstant; | 84 static const double DefaultSmoothingConstant; |
| 82 static const double SnapThreshold; | 85 static const double SnapThreshold; |
| 83 | 86 |
| 84 static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, A
udioParamType paramType, double defaultValue) | 87 static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, A
udioParamType paramType, double defaultValue) |
| 85 { | 88 { |
| 86 return adoptRef(new AudioParamHandler(context, paramType, defaultValue))
; | 89 return adoptRef(new AudioParamHandler(context, paramType, defaultValue))
; |
| 87 } | 90 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 123 |
| 121 // Calculates numberOfValues parameter values starting at the context's curr
ent time. | 124 // Calculates numberOfValues parameter values starting at the context's curr
ent time. |
| 122 // Must be called in the context's render thread. | 125 // Must be called in the context's render thread. |
| 123 void calculateSampleAccurateValues(float* values, unsigned numberOfValues); | 126 void calculateSampleAccurateValues(float* values, unsigned numberOfValues); |
| 124 | 127 |
| 125 // Connect an audio-rate signal to control this parameter. | 128 // Connect an audio-rate signal to control this parameter. |
| 126 void connect(AudioNodeOutput&); | 129 void connect(AudioNodeOutput&); |
| 127 void disconnect(AudioNodeOutput&); | 130 void disconnect(AudioNodeOutput&); |
| 128 | 131 |
| 129 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); } | 132 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); } |
| 133 |
| 134 // Update any histograms with the given value. |
| 135 void updateHistograms(float newValue); |
| 136 |
| 130 private: | 137 private: |
| 131 AudioParamHandler(AbstractAudioContext& context, AudioParamType paramType, d
ouble defaultValue) | 138 AudioParamHandler(AbstractAudioContext& context, AudioParamType paramType, d
ouble defaultValue) |
| 132 : AudioSummingJunction(context.deferredTaskHandler()) | 139 : AudioSummingJunction(context.deferredTaskHandler()) |
| 133 , m_paramType(paramType) | 140 , m_paramType(paramType) |
| 134 , m_intrinsicValue(defaultValue) | 141 , m_intrinsicValue(defaultValue) |
| 135 , m_defaultValue(defaultValue) | 142 , m_defaultValue(defaultValue) |
| 136 , m_smoothedValue(defaultValue) | 143 , m_smoothedValue(defaultValue) |
| 137 , m_destinationHandler(context.destination()->audioDestinationHandler()) | 144 , m_destinationHandler(context.destination()->audioDestinationHandler()) |
| 138 { } | 145 { } |
| 139 | 146 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 165 DEFINE_WRAPPERTYPEINFO(); | 172 DEFINE_WRAPPERTYPEINFO(); |
| 166 public: | 173 public: |
| 167 static AudioParam* create(AbstractAudioContext&, AudioParamType, double defa
ultValue); | 174 static AudioParam* create(AbstractAudioContext&, AudioParamType, double defa
ultValue); |
| 168 DECLARE_TRACE(); | 175 DECLARE_TRACE(); |
| 169 // |handler| always returns a valid object. | 176 // |handler| always returns a valid object. |
| 170 AudioParamHandler& handler() const { return *m_handler; } | 177 AudioParamHandler& handler() const { return *m_handler; } |
| 171 // |context| always returns a valid object. | 178 // |context| always returns a valid object. |
| 172 AbstractAudioContext* context() const { return m_context; } | 179 AbstractAudioContext* context() const { return m_context; } |
| 173 | 180 |
| 174 AudioParamType getParamType() const { return handler().getParamType(); } | 181 AudioParamType getParamType() const { return handler().getParamType(); } |
| 182 void setParamType(AudioParamType); |
| 175 String getParamName() const; | 183 String getParamName() const; |
| 176 | 184 |
| 177 float value() const; | 185 float value() const; |
| 178 void setValue(float); | 186 void setValue(float); |
| 179 float defaultValue() const; | 187 float defaultValue() const; |
| 180 AudioParam* setValueAtTime(float value, double time, ExceptionState&); | 188 AudioParam* setValueAtTime(float value, double time, ExceptionState&); |
| 181 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState
&); | 189 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState
&); |
| 182 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception
State&); | 190 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception
State&); |
| 183 AudioParam* setTargetAtTime(float target, double time, double timeConstant,
ExceptionState&); | 191 AudioParam* setTargetAtTime(float target, double time, double timeConstant,
ExceptionState&); |
| 184 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double
duration, ExceptionState&); | 192 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double
duration, ExceptionState&); |
| 185 AudioParam* cancelScheduledValues(double startTime, ExceptionState&); | 193 AudioParam* cancelScheduledValues(double startTime, ExceptionState&); |
| 186 | 194 |
| 187 private: | 195 private: |
| 188 AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue); | 196 AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue); |
| 189 | 197 |
| 190 RefPtr<AudioParamHandler> m_handler; | 198 RefPtr<AudioParamHandler> m_handler; |
| 191 Member<AbstractAudioContext> m_context; | 199 Member<AbstractAudioContext> m_context; |
| 192 }; | 200 }; |
| 193 | 201 |
| 194 } // namespace blink | 202 } // namespace blink |
| 195 | 203 |
| 196 #endif // AudioParam_h | 204 #endif // AudioParam_h |
| OLD | NEW |