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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return narrowPrecisionToFloat(m_smoothedValue); | 67 return narrowPrecisionToFloat(m_smoothedValue); |
68 } | 68 } |
69 | 69 |
70 bool AudioParam::smooth() | 70 bool AudioParam::smooth() |
71 { | 71 { |
72 // If values have been explicitly scheduled on the timeline, then use the ex
act value. | 72 // If values have been explicitly scheduled on the timeline, then use the ex
act value. |
73 // Smoothing effectively is performed by the timeline. | 73 // Smoothing effectively is performed by the timeline. |
74 bool useTimelineValue = false; | 74 bool useTimelineValue = false; |
75 if (context()) | 75 if (context()) |
76 m_value = m_timeline.valueForContextTime(context(), narrowPrecisionToFlo
at(m_value), useTimelineValue); | 76 m_value = m_timeline.valueForContextTime(context(), narrowPrecisionToFlo
at(m_value), useTimelineValue); |
77 | 77 |
78 if (m_smoothedValue == m_value) { | 78 if (m_smoothedValue == m_value) { |
79 // Smoothed value has already approached and snapped to value. | 79 // Smoothed value has already approached and snapped to value. |
80 return true; | 80 return true; |
81 } | 81 } |
82 | 82 |
83 if (useTimelineValue) | 83 if (useTimelineValue) |
84 m_smoothedValue = m_value; | 84 m_smoothedValue = m_value; |
85 else { | 85 else { |
86 // Dezipper - exponential approach. | 86 // Dezipper - exponential approach. |
87 m_smoothedValue += (m_value - m_smoothedValue) * m_smoothingConstant; | 87 m_smoothedValue += (m_value - m_smoothedValue) * m_smoothingConstant; |
88 | 88 |
89 // If we get close enough then snap to actual value. | 89 // If we get close enough then snap to actual value. |
90 if (fabs(m_smoothedValue - m_value) < SnapThreshold) // FIXME: the thres
hold needs to be adjustable depending on range - but this is OK general purpose
value. | 90 if (fabs(m_smoothedValue - m_value) < SnapThreshold) // FIXME: the thres
hold needs to be adjustable depending on range - but this is OK general purpose
value. |
91 m_smoothedValue = m_value; | 91 m_smoothedValue = m_value; |
92 } | 92 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (m_outputs.contains(output)) { | 191 if (m_outputs.contains(output)) { |
192 m_outputs.remove(output); | 192 m_outputs.remove(output); |
193 changedOutputs(); | 193 changedOutputs(); |
194 output->removeParam(this); | 194 output->removeParam(this); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 } // namespace WebCore | 198 } // namespace WebCore |
199 | 199 |
200 #endif // ENABLE(WEB_AUDIO) | 200 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |