OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 args = "..., " + String::number(event.time(), 16) + ", " + String::numbe
r(event.duration(), 16); | 102 args = "..., " + String::number(event.time(), 16) + ", " + String::numbe
r(event.duration(), 16); |
103 break; | 103 break; |
104 case ParamEvent::LastType: | 104 case ParamEvent::LastType: |
105 ASSERT_NOT_REACHED(); | 105 ASSERT_NOT_REACHED(); |
106 break; | 106 break; |
107 }; | 107 }; |
108 | 108 |
109 return s + "(" + args + ")"; | 109 return s + "(" + args + ")"; |
110 } | 110 } |
111 | 111 |
| 112 AudioParamTimeline::ParamEvent::ParamEvent( |
| 113 Type type, float value, double time, |
| 114 double timeConstant, double duration, const DOMFloat32Array* curve, |
| 115 float initialValue, double callTime) |
| 116 : m_type(type) |
| 117 , m_value(value) |
| 118 , m_time(time) |
| 119 , m_timeConstant(timeConstant) |
| 120 , m_duration(duration) |
| 121 , m_initialValue(initialValue) |
| 122 , m_callTime(callTime) |
| 123 { |
| 124 if (curve) { |
| 125 // Copy the curve data |
| 126 unsigned curveLength = curve->length(); |
| 127 m_curve.resize(curveLength); |
| 128 memcpy(m_curve.data(), curve->data(), curveLength * sizeof(float)); |
| 129 } |
| 130 } |
| 131 |
112 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetValueEve
nt(float value, double time) | 132 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetValueEve
nt(float value, double time) |
113 { | 133 { |
114 return ParamEvent(ParamEvent::SetValue, value, time, 0, 0, nullptr); | 134 return ParamEvent(ParamEvent::SetValue, value, time, 0, 0, nullptr); |
115 } | 135 } |
116 | 136 |
117 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createLinearRampE
vent(float value, double time, float initialValue, double callTime) | 137 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createLinearRampE
vent(float value, double time, float initialValue, double callTime) |
118 { | 138 { |
119 return ParamEvent(ParamEvent::LinearRampToValue, value, time, 0, 0, nullptr,
initialValue, callTime); | 139 return ParamEvent(ParamEvent::LinearRampToValue, value, time, 0, 0, nullptr,
initialValue, callTime); |
120 } | 140 } |
121 | 141 |
122 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createExponential
RampEvent(float value, double time, float initialValue, double callTime) | 142 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createExponential
RampEvent(float value, double time, float initialValue, double callTime) |
123 { | 143 { |
124 return ParamEvent(ParamEvent::ExponentialRampToValue, value, time, 0, 0, nul
lptr, initialValue, callTime); | 144 return ParamEvent(ParamEvent::ExponentialRampToValue, value, time, 0, 0, nul
lptr, initialValue, callTime); |
125 } | 145 } |
126 | 146 |
127 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetTargetEv
ent(float value, double time, double timeConstant) | 147 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetTargetEv
ent(float value, double time, double timeConstant) |
128 { | 148 { |
129 return ParamEvent(ParamEvent::SetTarget, value, time, timeConstant, 0, nullp
tr); | 149 return ParamEvent(ParamEvent::SetTarget, value, time, timeConstant, 0, nullp
tr); |
130 } | 150 } |
131 | 151 |
132 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetValueCur
veEvent(DOMFloat32Array* curve, double time, double duration) | 152 AudioParamTimeline::ParamEvent AudioParamTimeline::ParamEvent::createSetValueCur
veEvent(const DOMFloat32Array* curve, double time, double duration) |
133 { | 153 { |
134 return ParamEvent(ParamEvent::SetValueCurve, 0, time, 0, duration, curve); | 154 return ParamEvent(ParamEvent::SetValueCurve, 0, time, 0, duration, curve); |
135 } | 155 } |
136 | 156 |
137 void AudioParamTimeline::setValueAtTime(float value, double time, ExceptionState
& exceptionState) | 157 void AudioParamTimeline::setValueAtTime(float value, double time, ExceptionState
& exceptionState) |
138 { | 158 { |
139 ASSERT(isMainThread()); | 159 ASSERT(isMainThread()); |
140 | 160 |
141 if (!isNonNegativeAudioParamTime(time, exceptionState)) | 161 if (!isNonNegativeAudioParamTime(time, exceptionState)) |
142 return; | 162 return; |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // the last computed value. | 712 // the last computed value. |
693 if (writeIndex >= 1) | 713 if (writeIndex >= 1) |
694 value = values[writeIndex - 1]; | 714 value = values[writeIndex - 1]; |
695 currentFrame = fillToEndFrame; | 715 currentFrame = fillToEndFrame; |
696 } | 716 } |
697 break; | 717 break; |
698 } | 718 } |
699 | 719 |
700 case ParamEvent::SetValueCurve: | 720 case ParamEvent::SetValueCurve: |
701 { | 721 { |
702 DOMFloat32Array* curve = event.curve(); | 722 Vector<float> curve = event.curve(); |
703 float* curveData = curve ? curve->data() : 0; | 723 float* curveData = curve.data(); |
704 unsigned numberOfCurvePoints = curve ? curve->length() : 0; | 724 unsigned numberOfCurvePoints = curve.size(); |
705 | 725 |
706 // Curve events have duration, so don't just use next event
time. | 726 // Curve events have duration, so don't just use next event
time. |
707 double duration = event.duration(); | 727 double duration = event.duration(); |
708 // How much to step the curve index for each frame. This is
basically the term | 728 // How much to step the curve index for each frame. This is
basically the term |
709 // (N - 1)/Td in the specification. | 729 // (N - 1)/Td in the specification. |
710 double curvePointsPerFrame = (numberOfCurvePoints - 1) / dur
ation / sampleRate; | 730 double curvePointsPerFrame = (numberOfCurvePoints - 1) / dur
ation / sampleRate; |
711 | 731 |
712 if (!curve || !curveData || !numberOfCurvePoints || duration
<= 0 || sampleRate <= 0) { | 732 if (!numberOfCurvePoints || duration <= 0 || sampleRate <= 0
) { |
713 // Error condition - simply propagate previous value. | 733 // Error condition - simply propagate previous value. |
714 currentFrame = fillToEndFrame; | 734 currentFrame = fillToEndFrame; |
715 for (; writeIndex < fillToFrame; ++writeIndex) | 735 for (; writeIndex < fillToFrame; ++writeIndex) |
716 values[writeIndex] = value; | 736 values[writeIndex] = value; |
717 break; | 737 break; |
718 } | 738 } |
719 | 739 |
720 // Save old values and recalculate information based on the
curve's duration | 740 // Save old values and recalculate information based on the
curve's duration |
721 // instead of the next event time. | 741 // instead of the next event time. |
722 size_t nextEventFillToFrame = fillToFrame; | 742 size_t nextEventFillToFrame = fillToFrame; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 for (; writeIndex < numberOfValues; ++writeIndex) | 876 for (; writeIndex < numberOfValues; ++writeIndex) |
857 values[writeIndex] = value; | 877 values[writeIndex] = value; |
858 | 878 |
859 // This value is used to set the .value attribute of the AudioParam. it sho
uld be the last | 879 // This value is used to set the .value attribute of the AudioParam. it sho
uld be the last |
860 // computed value. | 880 // computed value. |
861 return values[numberOfValues - 1]; | 881 return values[numberOfValues - 1]; |
862 } | 882 } |
863 | 883 |
864 } // namespace blink | 884 } // namespace blink |
865 | 885 |
OLD | NEW |