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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 m_tempBuffer2 = adoptPtr(new AudioFloatArray(RenderingQuantum * 4)); | 45 m_tempBuffer2 = adoptPtr(new AudioFloatArray(RenderingQuantum * 4)); |
46 m_upSampler = adoptPtr(new UpSampler(RenderingQuantum)); | 46 m_upSampler = adoptPtr(new UpSampler(RenderingQuantum)); |
47 m_downSampler = adoptPtr(new DownSampler(RenderingQuantum * 2)); | 47 m_downSampler = adoptPtr(new DownSampler(RenderingQuantum * 2)); |
48 m_upSampler2 = adoptPtr(new UpSampler(RenderingQuantum * 2)); | 48 m_upSampler2 = adoptPtr(new UpSampler(RenderingQuantum * 2)); |
49 m_downSampler2 = adoptPtr(new DownSampler(RenderingQuantum * 4)); | 49 m_downSampler2 = adoptPtr(new DownSampler(RenderingQuantum * 4)); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 void WaveShaperDSPKernel::process(const float* source, float* destination, size_
t framesToProcess) | 53 void WaveShaperDSPKernel::process(const float* source, float* destination, size_
t framesToProcess) |
54 { | 54 { |
55 switch (waveShaperProcessor()->oversample()) { | 55 switch (getWaveShaperProcessor()->oversample()) { |
56 case WaveShaperProcessor::OverSampleNone: | 56 case WaveShaperProcessor::OverSampleNone: |
57 processCurve(source, destination, framesToProcess); | 57 processCurve(source, destination, framesToProcess); |
58 break; | 58 break; |
59 case WaveShaperProcessor::OverSample2x: | 59 case WaveShaperProcessor::OverSample2x: |
60 processCurve2x(source, destination, framesToProcess); | 60 processCurve2x(source, destination, framesToProcess); |
61 break; | 61 break; |
62 case WaveShaperProcessor::OverSample4x: | 62 case WaveShaperProcessor::OverSample4x: |
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 ASSERT(source); |
74 ASSERT(destination); | 74 ASSERT(destination); |
75 ASSERT(waveShaperProcessor()); | 75 ASSERT(getWaveShaperProcessor()); |
76 | 76 |
77 DOMFloat32Array* curve = waveShaperProcessor()->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 ASSERT(curveData); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 m_upSampler2->reset(); | 168 m_upSampler2->reset(); |
169 m_downSampler2->reset(); | 169 m_downSampler2->reset(); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 double WaveShaperDSPKernel::latencyTime() const | 173 double WaveShaperDSPKernel::latencyTime() const |
174 { | 174 { |
175 size_t latencyFrames = 0; | 175 size_t latencyFrames = 0; |
176 WaveShaperDSPKernel* kernel = const_cast<WaveShaperDSPKernel*>(this); | 176 WaveShaperDSPKernel* kernel = const_cast<WaveShaperDSPKernel*>(this); |
177 | 177 |
178 switch (kernel->waveShaperProcessor()->oversample()) { | 178 switch (kernel->getWaveShaperProcessor()->oversample()) { |
179 case WaveShaperProcessor::OverSampleNone: | 179 case WaveShaperProcessor::OverSampleNone: |
180 break; | 180 break; |
181 case WaveShaperProcessor::OverSample2x: | 181 case WaveShaperProcessor::OverSample2x: |
182 latencyFrames += m_upSampler->latencyFrames(); | 182 latencyFrames += m_upSampler->latencyFrames(); |
183 latencyFrames += m_downSampler->latencyFrames(); | 183 latencyFrames += m_downSampler->latencyFrames(); |
184 break; | 184 break; |
185 case WaveShaperProcessor::OverSample4x: | 185 case WaveShaperProcessor::OverSample4x: |
186 { | 186 { |
187 // Account for first stage upsampling. | 187 // Account for first stage upsampling. |
188 latencyFrames += m_upSampler->latencyFrames(); | 188 latencyFrames += m_upSampler->latencyFrames(); |
189 latencyFrames += m_downSampler->latencyFrames(); | 189 latencyFrames += m_downSampler->latencyFrames(); |
190 | 190 |
191 // Account for second stage upsampling. | 191 // Account for second stage upsampling. |
192 // and divide by 2 to get back down to the regular sample-rate. | 192 // and divide by 2 to get back down to the regular sample-rate. |
193 size_t latencyFrames2 = (m_upSampler2->latencyFrames() + m_downSampl
er2->latencyFrames()) / 2; | 193 size_t latencyFrames2 = (m_upSampler2->latencyFrames() + m_downSampl
er2->latencyFrames()) / 2; |
194 latencyFrames += latencyFrames2; | 194 latencyFrames += latencyFrames2; |
195 break; | 195 break; |
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 |