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 24 matching lines...) Expand all Loading... |
35 #include "modules/webaudio/AudioParamTimeline.h" | 35 #include "modules/webaudio/AudioParamTimeline.h" |
36 #include "modules/webaudio/AudioSummingJunction.h" | 36 #include "modules/webaudio/AudioSummingJunction.h" |
37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
38 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
39 #include <sys/types.h> | 39 #include <sys/types.h> |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 class AudioNodeOutput; | 43 class AudioNodeOutput; |
44 | 44 |
45 class AudioParamHandler final : public AudioSummingJunction, public ScriptWrappa
ble { | 45 class AudioParamHandler final : public GarbageCollectedFinalized<AudioParamHandl
er>, public AudioSummingJunction, public ScriptWrappable { |
46 DEFINE_WRAPPERTYPEINFO(); | 46 DEFINE_WRAPPERTYPEINFO(); |
47 public: | 47 public: |
48 static const double DefaultSmoothingConstant; | 48 static const double DefaultSmoothingConstant; |
49 static const double SnapThreshold; | 49 static const double SnapThreshold; |
50 | 50 |
51 static AudioParamHandler* create(AudioContext* context, double defaultValue) | 51 static AudioParamHandler* create(AudioContext* context, double defaultValue) |
52 { | 52 { |
53 return new AudioParamHandler(context, defaultValue); | 53 return new AudioParamHandler(context, defaultValue); |
54 } | 54 } |
| 55 DECLARE_TRACE(); |
| 56 AudioContext* context() const { return m_context; } |
55 | 57 |
56 // AudioSummingJunction | 58 // AudioSummingJunction |
57 virtual void didUpdate() override { } | 59 virtual void didUpdate() override { } |
58 | 60 |
59 // Intrinsic value. | 61 // Intrinsic value. |
60 float value(); | 62 float value(); |
61 void setValue(float); | 63 void setValue(float); |
62 | 64 |
63 // Final value for k-rate parameters, otherwise use calculateSampleAccurateV
alues() for a-rate. | 65 // Final value for k-rate parameters, otherwise use calculateSampleAccurateV
alues() for a-rate. |
64 // Must be called in the audio thread. | 66 // Must be called in the audio thread. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // Calculates numberOfValues parameter values starting at the context's curr
ent time. | 111 // Calculates numberOfValues parameter values starting at the context's curr
ent time. |
110 // Must be called in the context's render thread. | 112 // Must be called in the context's render thread. |
111 void calculateSampleAccurateValues(float* values, unsigned numberOfValues); | 113 void calculateSampleAccurateValues(float* values, unsigned numberOfValues); |
112 | 114 |
113 // Connect an audio-rate signal to control this parameter. | 115 // Connect an audio-rate signal to control this parameter. |
114 void connect(AudioNodeOutput&); | 116 void connect(AudioNodeOutput&); |
115 void disconnect(AudioNodeOutput&); | 117 void disconnect(AudioNodeOutput&); |
116 | 118 |
117 private: | 119 private: |
118 AudioParamHandler(AudioContext* context, double defaultValue) | 120 AudioParamHandler(AudioContext* context, double defaultValue) |
119 : AudioSummingJunction(context) | 121 : AudioSummingJunction(context->handler()) |
120 , m_value(defaultValue) | 122 , m_value(defaultValue) |
121 , m_defaultValue(defaultValue) | 123 , m_defaultValue(defaultValue) |
122 , m_smoothedValue(defaultValue) { } | 124 , m_smoothedValue(defaultValue) |
| 125 , m_context(context) { } |
123 | 126 |
124 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A
udio specification. | 127 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A
udio specification. |
125 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl
eAccurate); | 128 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl
eAccurate); |
126 void calculateTimelineValues(float* values, unsigned numberOfValues); | 129 void calculateTimelineValues(float* values, unsigned numberOfValues); |
127 | 130 |
128 double m_value; | 131 double m_value; |
129 double m_defaultValue; | 132 double m_defaultValue; |
130 | 133 |
131 // Smoothing (de-zippering) | 134 // Smoothing (de-zippering) |
132 double m_smoothedValue; | 135 double m_smoothedValue; |
133 | 136 |
134 AudioParamTimeline m_timeline; | 137 AudioParamTimeline m_timeline; |
| 138 Member<AudioContext> m_context; |
135 }; | 139 }; |
136 | 140 |
137 // TODO(tkent): remove the type alias, and introduce a real AudioParam class to | 141 // TODO(tkent): remove the type alias, and introduce a real AudioParam class to |
138 // wrap AudioParamHandler. | 142 // wrap AudioParamHandler. |
139 using AudioParam = AudioParamHandler; | 143 using AudioParam = AudioParamHandler; |
140 | 144 |
141 } // namespace blink | 145 } // namespace blink |
142 | 146 |
143 #endif // AudioParam_h | 147 #endif // AudioParam_h |
OLD | NEW |