Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioParam.h

Issue 1934683002: Add histograms for Biquad lowpass and highpass Q values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove variables used only once. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/AudioParam.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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&, AudioParamType, double defaultValue ); 138 AudioParamHandler(AbstractAudioContext&, AudioParamType, double defaultValue );
132 139
133 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A udio specification. 140 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A udio specification.
134 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl eAccurate); 141 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl eAccurate);
135 void calculateTimelineValues(float* values, unsigned numberOfValues); 142 void calculateTimelineValues(float* values, unsigned numberOfValues);
136 143
144 int computeQHistogramValue(float) const;
145
137 // The type of AudioParam, indicating what this AudioParam represents and wh at node it belongs 146 // The type of AudioParam, indicating what this AudioParam represents and wh at node it belongs
138 // to. Mostly for informational purposes and doesn't affect implementation. 147 // to. Mostly for informational purposes and doesn't affect implementation.
139 AudioParamType m_paramType; 148 AudioParamType m_paramType;
140 149
141 // Intrinsic value 150 // Intrinsic value
142 float m_intrinsicValue; 151 float m_intrinsicValue;
143 void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, n ewValue); } 152 void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, n ewValue); }
144 153
145 float m_defaultValue; 154 float m_defaultValue;
146 155
(...skipping 11 matching lines...) Expand all
158 DEFINE_WRAPPERTYPEINFO(); 167 DEFINE_WRAPPERTYPEINFO();
159 public: 168 public:
160 static AudioParam* create(AbstractAudioContext&, AudioParamType, double defa ultValue); 169 static AudioParam* create(AbstractAudioContext&, AudioParamType, double defa ultValue);
161 DECLARE_TRACE(); 170 DECLARE_TRACE();
162 // |handler| always returns a valid object. 171 // |handler| always returns a valid object.
163 AudioParamHandler& handler() const { return *m_handler; } 172 AudioParamHandler& handler() const { return *m_handler; }
164 // |context| always returns a valid object. 173 // |context| always returns a valid object.
165 AbstractAudioContext* context() const { return m_context; } 174 AbstractAudioContext* context() const { return m_context; }
166 175
167 AudioParamType getParamType() const { return handler().getParamType(); } 176 AudioParamType getParamType() const { return handler().getParamType(); }
177 void setParamType(AudioParamType);
168 String getParamName() const; 178 String getParamName() const;
169 179
170 float value() const; 180 float value() const;
171 void setValue(float); 181 void setValue(float);
172 float defaultValue() const; 182 float defaultValue() const;
173 AudioParam* setValueAtTime(float value, double time, ExceptionState&); 183 AudioParam* setValueAtTime(float value, double time, ExceptionState&);
174 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState &); 184 AudioParam* linearRampToValueAtTime(float value, double time, ExceptionState &);
175 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception State&); 185 AudioParam* exponentialRampToValueAtTime(float value, double time, Exception State&);
176 AudioParam* setTargetAtTime(float target, double time, double timeConstant, ExceptionState&); 186 AudioParam* setTargetAtTime(float target, double time, double timeConstant, ExceptionState&);
177 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double duration, ExceptionState&); 187 AudioParam* setValueCurveAtTime(DOMFloat32Array* curve, double time, double duration, ExceptionState&);
178 AudioParam* cancelScheduledValues(double startTime, ExceptionState&); 188 AudioParam* cancelScheduledValues(double startTime, ExceptionState&);
179 189
180 private: 190 private:
181 AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue); 191 AudioParam(AbstractAudioContext&, AudioParamType, double defaultValue);
182 192
183 RefPtr<AudioParamHandler> m_handler; 193 RefPtr<AudioParamHandler> m_handler;
184 Member<AbstractAudioContext> m_context; 194 Member<AbstractAudioContext> m_context;
185 }; 195 };
186 196
187 } // namespace blink 197 } // namespace blink
188 198
189 #endif // AudioParam_h 199 #endif // AudioParam_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/AudioParam.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698