| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // right in the middle at halfSize, which is 0.5 and we'll handle specially
during processing | 66 // right in the middle at halfSize, which is 0.5 and we'll handle specially
during processing |
| 67 // after doing the main convolution using m_reducedKernel. | 67 // after doing the main convolution using m_reducedKernel. |
| 68 for (int i = 1; i < n; i += 2) { | 68 for (int i = 1; i < n; i += 2) { |
| 69 // Compute the sinc() with offset. | 69 // Compute the sinc() with offset. |
| 70 double s = sincScaleFactor * piDouble * (i - halfSize); | 70 double s = sincScaleFactor * piDouble * (i - halfSize); |
| 71 double sinc = !s ? 1.0 : sin(s) / s; | 71 double sinc = !s ? 1.0 : sin(s) / s; |
| 72 sinc *= sincScaleFactor; | 72 sinc *= sincScaleFactor; |
| 73 | 73 |
| 74 // Compute Blackman window, matching the offset of the sinc(). | 74 // Compute Blackman window, matching the offset of the sinc(). |
| 75 double x = static_cast<double>(i) / n; | 75 double x = static_cast<double>(i) / n; |
| 76 double window = a0 - a1 * cos(2.0 * piDouble * x) + a2 * cos(4.0 * piDou
ble * x); | 76 double window = a0 - a1 * cos(twoPiDouble * x) + a2 * cos(twoPiDouble *
2.0 * x); |
| 77 | 77 |
| 78 // Window the sinc() function. | 78 // Window the sinc() function. |
| 79 // Then store only the odd terms in the kernel. | 79 // Then store only the odd terms in the kernel. |
| 80 // In a sense, this is shifting forward in time by one sample-frame at t
he destination sample-rate. | 80 // In a sense, this is shifting forward in time by one sample-frame at t
he destination sample-rate. |
| 81 m_reducedKernel[(i - 1) / 2] = sinc * window; | 81 m_reducedKernel[(i - 1) / 2] = sinc * window; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void DownSampler::process(const float* sourceP, float* destP, size_t sourceFrame
sToProcess) | 85 void DownSampler::process(const float* sourceP, float* destP, size_t sourceFrame
sToProcess) |
| 86 { | 86 { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 size_t DownSampler::latencyFrames() const | 143 size_t DownSampler::latencyFrames() const |
| 144 { | 144 { |
| 145 // Divide by two since this is a linear phase kernel and the delay is at the
center of the kernel. | 145 // Divide by two since this is a linear phase kernel and the delay is at the
center of the kernel. |
| 146 return m_reducedKernel.size() / 2; | 146 return m_reducedKernel.size() / 2; |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace WebCore | 149 } // namespace WebCore |
| 150 | 150 |
| 151 #endif // ENABLE(WEB_AUDIO) | 151 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |