Changeset 267361 in webkit
- Timestamp:
- Sep 21, 2020, 1:22:27 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/webaudio/AudioParam/audioparam-processing-expected.txt (modified) (2 diffs)
-
LayoutTests/webaudio/DynamicsCompressor/dynamicscompressor-clear-internal-state-expected.txt (modified) (1 diff)
-
LayoutTests/webaudio/DynamicsCompressor/dynamicscompressor-simple-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/audio/DynamicsCompressor.cpp (modified) (7 diffs)
-
Source/WebCore/platform/audio/DynamicsCompressor.h (modified) (3 diffs)
-
Source/WebCore/platform/audio/DynamicsCompressorKernel.cpp (modified) (2 diffs)
-
Source/WebCore/platform/audio/DynamicsCompressorKernel.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r267357 r267361 1 2020-09-21 Chris Dumez <cdumez@apple.com> 2 3 Remove emphasis/de-emphasis filters from DynamicsCompressor 4 https://bugs.webkit.org/show_bug.cgi?id=216796 5 6 Reviewed by Darin Adler. 7 8 Rebaseline tests that are now passing. 9 10 * webaudio/AudioParam/audioparam-processing-expected.txt: 11 * webaudio/DynamicsCompressor/dynamicscompressor-clear-internal-state-expected.txt: 12 * webaudio/DynamicsCompressor/dynamicscompressor-simple-expected.txt: 13 1 14 2020-09-21 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/LayoutTests/webaudio/AudioParam/audioparam-processing-expected.txt
r267253 r267361 25 25 PASS > [DynamicsCompressorNode] 26 26 PASS DynamicsCompressorNode.attack ramp final value is not equal to 0.003000000026077032. 27 FAIL X DynamicsCompressorNode.attack.value is not equal to 0.5. Got 0.003000000026077032. assert_true: expected true got false 27 PASS DynamicsCompressorNode.attack.value is equal to 0.5. 28 28 PASS DynamicsCompressorNode.knee ramp final value is not equal to 30. 29 FAIL X DynamicsCompressorNode.knee.value is not equal to 25. Got 30. assert_true: expected true got false 29 PASS DynamicsCompressorNode.knee.value is equal to 25. 30 30 PASS DynamicsCompressorNode.ratio ramp final value is not equal to 12. 31 FAIL X DynamicsCompressorNode.ratio.value is not equal to 15. Got 12. assert_true: expected true got false 31 PASS DynamicsCompressorNode.ratio.value is equal to 15. 32 32 PASS DynamicsCompressorNode.release ramp final value is not equal to 0.25. 33 FAIL X DynamicsCompressorNode.release.value is not equal to 0.75. Got 0.25. assert_true: expected true got false 33 PASS DynamicsCompressorNode.release.value is equal to 0.75. 34 34 PASS DynamicsCompressorNode.threshold ramp final value is not equal to -24. 35 FAIL X DynamicsCompressorNode.threshold.value is not equal to -10. Got -24. assert_true: expected true got false 36 FAIL < [DynamicsCompressorNode] 5 out of 10 assertions were failed. assert_true: expected true got false 35 PASS DynamicsCompressorNode.threshold.value is equal to -10. 36 PASS < [DynamicsCompressorNode] All assertions passed. (total 10 assertions) 37 37 PASS > [GainNode] 38 38 PASS GainNode.gain ramp final value is not equal to 1. … … 77 77 FAIL X AudioListener.upZ.value is not equal to 137. Got 0. assert_true: expected true got false 78 78 FAIL < [AudioListener] 9 out of 18 assertions were failed. assert_true: expected true got false 79 FAIL # AUDIT TASK RUNNER FINISHED: 7out of 7 tasks were failed. assert_true: expected true got false79 FAIL # AUDIT TASK RUNNER FINISHED: 6 out of 7 tasks were failed. assert_true: expected true got false 80 80 -
trunk/LayoutTests/webaudio/DynamicsCompressor/dynamicscompressor-clear-internal-state-expected.txt
r267307 r267361 4 4 PASS Audit report 5 5 PASS > [test] Validate Reduction Value of DynamicsCompressor after Disabling 6 FAIL X Math.abs(compressor.reduction) (6.09318733215332) is not less than or equal to 0.048223. Got 6.09318733215332. assert_true: expected true got false 7 FAIL < [test] 1 out of 1 assertions were failed. assert_true: expected true got false 8 FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false 6 PASS Math.abs(compressor.reduction) (0.048222921788692474) is less than or equal to 0.048223. 7 PASS < [test] All assertions passed. (total 1 assertions) 8 PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. 9 9 -
trunk/LayoutTests/webaudio/DynamicsCompressor/dynamicscompressor-simple-expected.txt
r267307 r267361 4 4 PASS Audit report 5 5 PASS > [test] Test pre-emphasis in DynamicsCompressor is removed 6 FAIL X Pre-emphasis effect not applied is not true. Got false. assert_true: expected true got false 6 PASS Pre-emphasis effect not applied is true. 7 7 PASS Reduction value changed is true. 8 FAIL < [test] 1 out of 2 assertions were failed. assert_true: expected true got false 9 FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false 8 PASS < [test] All assertions passed. (total 2 assertions) 9 PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. 10 10 -
trunk/Source/WebCore/ChangeLog
r267357 r267361 1 2020-09-21 Chris Dumez <cdumez@apple.com> 2 3 Remove emphasis/de-emphasis filters from DynamicsCompressor 4 https://bugs.webkit.org/show_bug.cgi?id=216796 5 6 Reviewed by Darin Adler. 7 8 Remove emphasis/de-emphasis filters from DynamicsCompressor as these have been removed 9 from the specification. 10 11 This is a merge of the following Blink change: 12 - https://codereview.chromium.org/152333003 13 14 No new tests, rebaselined existing tests. 15 16 * platform/audio/DynamicsCompressor.cpp: 17 (WebCore::DynamicsCompressor::DynamicsCompressor): 18 (WebCore::DynamicsCompressor::process): 19 (WebCore::DynamicsCompressor::reset): 20 (WebCore::DynamicsCompressor::setNumberOfChannels): 21 * platform/audio/DynamicsCompressor.h: 22 * platform/audio/DynamicsCompressorKernel.cpp: 23 (WebCore::DynamicsCompressorKernel::process): 24 (WebCore::DynamicsCompressorKernel::tailTime const): 25 * platform/audio/DynamicsCompressorKernel.h: 26 1 27 2020-09-21 Chris Dumez <cdumez@apple.com> 2 28 -
trunk/Source/WebCore/platform/audio/DynamicsCompressor.cpp
r248846 r267361 47 47 , m_compressor(sampleRate, numberOfChannels) 48 48 { 49 // Uninitialized state - for parameter recalculation.50 m_lastFilterStageRatio = -1;51 m_lastAnchor = -1;52 m_lastFilterStageGain = -1;53 54 49 setNumberOfChannels(numberOfChannels); 55 50 initializeParameters(); … … 79 74 m_parameters[ParamReleaseZone3] = 0.42f; 80 75 m_parameters[ParamReleaseZone4] = 0.98f; 81 82 m_parameters[ParamFilterStageGain] = 4.4f; // dB83 m_parameters[ParamFilterStageRatio] = 2;84 m_parameters[ParamFilterAnchor] = 15000 / nyquist();85 76 86 77 m_parameters[ParamPostGain] = 0; // dB … … 95 86 ASSERT(parameterID < ParamLast); 96 87 return m_parameters[parameterID]; 97 }98 99 void DynamicsCompressor::setEmphasisStageParameters(unsigned stageIndex, float gain, float normalizedFrequency /* 0 -> 1 */)100 {101 float gk = 1 - gain / 20;102 float f1 = normalizedFrequency * gk;103 float f2 = normalizedFrequency / gk;104 float r1 = expf(-f1 * piFloat);105 float r2 = expf(-f2 * piFloat);106 107 ASSERT(m_numberOfChannels == m_preFilterPacks.size());108 109 for (unsigned i = 0; i < m_numberOfChannels; ++i) {110 // Set pre-filter zero and pole to create an emphasis filter.111 ZeroPole& preFilter = m_preFilterPacks[i]->filters[stageIndex];112 preFilter.setZero(r1);113 preFilter.setPole(r2);114 115 // Set post-filter with zero and pole reversed to create the de-emphasis filter.116 // If there were no compressor kernel in between, they would cancel each other out (allpass filter).117 ZeroPole& postFilter = m_postFilterPacks[i]->filters[stageIndex];118 postFilter.setZero(r2);119 postFilter.setPole(r1);120 }121 }122 123 void DynamicsCompressor::setEmphasisParameters(float gain, float anchorFreq, float filterStageRatio)124 {125 setEmphasisStageParameters(0, gain, anchorFreq);126 setEmphasisStageParameters(1, gain, anchorFreq / filterStageRatio);127 setEmphasisStageParameters(2, gain, anchorFreq / (filterStageRatio * filterStageRatio));128 setEmphasisStageParameters(3, gain, anchorFreq / (filterStageRatio * filterStageRatio * filterStageRatio));129 88 } 130 89 … … 166 125 m_destinationChannels[i] = destinationBus->channel(i)->mutableData(); 167 126 168 float filterStageGain = parameterValue(ParamFilterStageGain);169 float filterStageRatio = parameterValue(ParamFilterStageRatio);170 float anchor = parameterValue(ParamFilterAnchor);171 172 if (filterStageGain != m_lastFilterStageGain || filterStageRatio != m_lastFilterStageRatio || anchor != m_lastAnchor) {173 m_lastFilterStageGain = filterStageGain;174 m_lastFilterStageRatio = filterStageRatio;175 m_lastAnchor = anchor;176 177 setEmphasisParameters(filterStageGain, anchor, filterStageRatio);178 }179 180 // Apply pre-emphasis filter.181 // Note that the final three stages are computed in-place in the destination buffer.182 for (unsigned i = 0; i < numberOfChannels; ++i) {183 const float* sourceData = m_sourceChannels[i];184 float* destinationData = m_destinationChannels[i];185 ZeroPole* preFilters = m_preFilterPacks[i]->filters;186 187 preFilters[0].process(sourceData, destinationData, framesToProcess);188 preFilters[1].process(destinationData, destinationData, framesToProcess);189 preFilters[2].process(destinationData, destinationData, framesToProcess);190 preFilters[3].process(destinationData, destinationData, framesToProcess);191 }192 193 127 float dbThreshold = parameterValue(ParamThreshold); 194 128 float dbKnee = parameterValue(ParamKnee); … … 211 145 float releaseZone4 = parameterValue(ParamReleaseZone4); 212 146 213 // Apply compression to the pre-filtered signal. 214 // The processing is performed in place. 215 m_compressor.process(m_destinationChannels.get(), 147 // Apply compression to the source signal. 148 m_compressor.process(m_sourceChannels.get(), 216 149 m_destinationChannels.get(), 217 150 numberOfChannels, … … 235 168 // Update the compression amount. 236 169 setParameterValue(ParamReduction, m_compressor.meteringGain()); 237 238 // Apply de-emphasis filter.239 for (unsigned i = 0; i < numberOfChannels; ++i) {240 float* destinationData = m_destinationChannels[i];241 ZeroPole* postFilters = m_postFilterPacks[i]->filters;242 243 postFilters[0].process(destinationData, destinationData, framesToProcess);244 postFilters[1].process(destinationData, destinationData, framesToProcess);245 postFilters[2].process(destinationData, destinationData, framesToProcess);246 postFilters[3].process(destinationData, destinationData, framesToProcess);247 }248 170 } 249 171 250 172 void DynamicsCompressor::reset() 251 173 { 252 m_lastFilterStageRatio = -1; // for recalc253 m_lastAnchor = -1;254 m_lastFilterStageGain = -1;255 256 for (unsigned channel = 0; channel < m_numberOfChannels; ++channel) {257 for (unsigned stageIndex = 0; stageIndex < 4; ++stageIndex) {258 m_preFilterPacks[channel]->filters[stageIndex].reset();259 m_postFilterPacks[channel]->filters[stageIndex].reset();260 }261 }262 263 174 m_compressor.reset(); 264 175 } … … 266 177 void DynamicsCompressor::setNumberOfChannels(unsigned numberOfChannels) 267 178 { 268 if (m_preFilterPacks.size() == numberOfChannels)269 return;270 271 m_preFilterPacks.clear();272 m_postFilterPacks.clear();273 for (unsigned i = 0; i < numberOfChannels; ++i) {274 m_preFilterPacks.append(makeUnique<ZeroPoleFilterPack4>());275 m_postFilterPacks.append(makeUnique<ZeroPoleFilterPack4>());276 }277 278 179 m_sourceChannels = makeUniqueArray<const float*>(numberOfChannels); 279 180 m_destinationChannels = makeUniqueArray<float*>(numberOfChannels); -
trunk/Source/WebCore/platform/audio/DynamicsCompressor.h
r266417 r267361 60 60 ParamReleaseZone4, 61 61 ParamPostGain, 62 ParamFilterStageGain,63 ParamFilterStageRatio,64 ParamFilterAnchor,65 62 ParamEffectBlend, 66 63 ParamReduction, … … 80 77 float nyquist() const { return m_sampleRate / 2; } 81 78 82 double tailTime() const { return 0; }79 double tailTime() const { return m_compressor.tailTime(); } 83 80 double latencyTime() const { return m_compressor.latencyFrames() / static_cast<double>(sampleRate()); } 84 81 bool requiresTailProcessing() const … … 97 94 float m_sampleRate; 98 95 99 // Emphasis filter controls.100 float m_lastFilterStageRatio;101 float m_lastAnchor;102 float m_lastFilterStageGain;103 104 struct ZeroPoleFilterPack4 {105 WTF_MAKE_STRUCT_FAST_ALLOCATED;106 ZeroPole filters[4];107 };108 109 // Per-channel emphasis filters.110 Vector<std::unique_ptr<ZeroPoleFilterPack4>> m_preFilterPacks;111 Vector<std::unique_ptr<ZeroPoleFilterPack4>> m_postFilterPacks;112 113 96 UniqueArray<const float*> m_sourceChannels; 114 97 UniqueArray<float*> m_destinationChannels; 115 116 void setEmphasisStageParameters(unsigned stageIndex, float gain, float normalizedFrequency /* 0 -> 1 */);117 void setEmphasisParameters(float gain, float anchorFreq, float filterStageRatio);118 98 119 99 // The core compressor. -
trunk/Source/WebCore/platform/audio/DynamicsCompressorKernel.cpp
r248846 r267361 200 200 } 201 201 202 void DynamicsCompressorKernel::process( float* sourceChannels[],202 void DynamicsCompressorKernel::process(const float* sourceChannels[], 203 203 float* destinationChannels[], 204 204 unsigned numberOfChannels, … … 473 473 } 474 474 475 double DynamicsCompressorKernel::tailTime() const 476 { 477 // The reduction value of the compressor is computed from the gain using an exponential filter 478 // with a time constant of |meteringReleaseTimeConstant|. We need to keep he compressor running 479 // for some time after the inputs go away so that the reduction value approaches 0. This is a 480 // tradeoff between how long we keep the node alive and how close we approach the final value. 481 // A value of 5 to 10 times the time constant is a reasonable trade-off. 482 return 5 * meteringReleaseTimeConstant; 483 } 484 475 485 } // namespace WebCore 476 486 -
trunk/Source/WebCore/platform/audio/DynamicsCompressorKernel.h
r248762 r267361 44 44 45 45 // Performs stereo-linked compression. 46 void process( float* sourceChannels[],46 void process(const float* sourceChannels[], 47 47 float* destinationChannels[], 48 48 unsigned numberOfChannels, … … 71 71 72 72 float meteringGain() const { return m_meteringGain; } 73 74 double tailTime() const; 73 75 74 76 protected:
Note:
See TracChangeset
for help on using the changeset viewer.