| 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 processCurve4x(source, destination, framesToProcess); | 63 processCurve4x(source, destination, framesToProcess); |
| 64 break; | 64 break; |
| 65 | 65 |
| 66 default: | 66 default: |
| 67 ASSERT_NOT_REACHED(); | 67 ASSERT_NOT_REACHED(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void WaveShaperDSPKernel::processCurve(const float* source, float* destination,
size_t framesToProcess) | 71 void WaveShaperDSPKernel::processCurve(const float* source, float* destination,
size_t framesToProcess) |
| 72 { | 72 { |
| 73 ASSERT(source); | 73 DCHECK(source); |
| 74 ASSERT(destination); | 74 DCHECK(destination); |
| 75 ASSERT(getWaveShaperProcessor()); | 75 DCHECK(getWaveShaperProcessor()); |
| 76 | 76 |
| 77 DOMFloat32Array* curve = getWaveShaperProcessor()->curve(); | 77 DOMFloat32Array* curve = getWaveShaperProcessor()->curve(); |
| 78 if (!curve) { | 78 if (!curve) { |
| 79 // Act as "straight wire" pass-through if no curve is set. | 79 // Act as "straight wire" pass-through if no curve is set. |
| 80 memcpy(destination, source, sizeof(float) * framesToProcess); | 80 memcpy(destination, source, sizeof(float) * framesToProcess); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 | 83 |
| 84 float* curveData = curve->data(); | 84 float* curveData = curve->data(); |
| 85 int curveLength = curve->length(); | 85 int curveLength = curve->length(); |
| 86 | 86 |
| 87 ASSERT(curveData); | 87 DCHECK(curveData); |
| 88 | 88 |
| 89 if (!curveData || !curveLength) { | 89 if (!curveData || !curveLength) { |
| 90 memcpy(destination, source, sizeof(float) * framesToProcess); | 90 memcpy(destination, source, sizeof(float) * framesToProcess); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Apply waveshaping curve. | 94 // Apply waveshaping curve. |
| 95 for (unsigned i = 0; i < framesToProcess; ++i) { | 95 for (unsigned i = 0; i < framesToProcess; ++i) { |
| 96 const float input = source[i]; | 96 const float input = source[i]; |
| 97 | 97 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 119 | 119 |
| 120 output = (1.0 - interpolationFactor) * value1 + interpolationFactor
* value2; | 120 output = (1.0 - interpolationFactor) * value1 + interpolationFactor
* value2; |
| 121 } | 121 } |
| 122 destination[i] = output; | 122 destination[i] = output; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 void WaveShaperDSPKernel::processCurve2x(const float* source, float* destination
, size_t framesToProcess) | 126 void WaveShaperDSPKernel::processCurve2x(const float* source, float* destination
, size_t framesToProcess) |
| 127 { | 127 { |
| 128 bool isSafe = framesToProcess == RenderingQuantum; | 128 bool isSafe = framesToProcess == RenderingQuantum; |
| 129 ASSERT(isSafe); | 129 DCHECK(isSafe); |
| 130 if (!isSafe) | 130 if (!isSafe) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 float* tempP = m_tempBuffer->data(); | 133 float* tempP = m_tempBuffer->data(); |
| 134 | 134 |
| 135 m_upSampler->process(source, tempP, framesToProcess); | 135 m_upSampler->process(source, tempP, framesToProcess); |
| 136 | 136 |
| 137 // Process at 2x up-sampled rate. | 137 // Process at 2x up-sampled rate. |
| 138 processCurve(tempP, tempP, framesToProcess * 2); | 138 processCurve(tempP, tempP, framesToProcess * 2); |
| 139 | 139 |
| 140 m_downSampler->process(tempP, destination, framesToProcess * 2); | 140 m_downSampler->process(tempP, destination, framesToProcess * 2); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void WaveShaperDSPKernel::processCurve4x(const float* source, float* destination
, size_t framesToProcess) | 143 void WaveShaperDSPKernel::processCurve4x(const float* source, float* destination
, size_t framesToProcess) |
| 144 { | 144 { |
| 145 bool isSafe = framesToProcess == RenderingQuantum; | 145 bool isSafe = framesToProcess == RenderingQuantum; |
| 146 ASSERT(isSafe); | 146 DCHECK(isSafe); |
| 147 if (!isSafe) | 147 if (!isSafe) |
| 148 return; | 148 return; |
| 149 | 149 |
| 150 float* tempP = m_tempBuffer->data(); | 150 float* tempP = m_tempBuffer->data(); |
| 151 float* tempP2 = m_tempBuffer2->data(); | 151 float* tempP2 = m_tempBuffer2->data(); |
| 152 | 152 |
| 153 m_upSampler->process(source, tempP, framesToProcess); | 153 m_upSampler->process(source, tempP, framesToProcess); |
| 154 m_upSampler2->process(tempP, tempP2, framesToProcess * 2); | 154 m_upSampler2->process(tempP, tempP2, framesToProcess * 2); |
| 155 | 155 |
| 156 // Process at 4x up-sampled rate. | 156 // Process at 4x up-sampled rate. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 default: | 197 default: |
| 198 ASSERT_NOT_REACHED(); | 198 ASSERT_NOT_REACHED(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 return static_cast<double>(latencyFrames) / sampleRate(); | 201 return static_cast<double>(latencyFrames) / sampleRate(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace blink | 204 } // namespace blink |
| 205 | 205 |
| OLD | NEW |