OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/webaudio/IIRProcessor.h" | 5 #include "modules/webaudio/IIRProcessor.h" |
6 | 6 |
7 #include "modules/webaudio/IIRDSPKernel.h" | 7 #include "modules/webaudio/IIRDSPKernel.h" |
8 #include "wtf/PtrUtil.h" | 8 #include "wtf/PtrUtil.h" |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 for (unsigned k = 1; k < feedbackLength; ++k) | 44 for (unsigned k = 1; k < feedbackLength; ++k) |
45 m_feedback[k] /= scale; | 45 m_feedback[k] /= scale; |
46 | 46 |
47 for (unsigned k = 0; k < feedforwardLength; ++k) | 47 for (unsigned k = 0; k < feedforwardLength; ++k) |
48 m_feedforward[k] /= scale; | 48 m_feedforward[k] /= scale; |
49 | 49 |
50 // The IIRFilter checks to make sure this coefficient is 1, so make it so. | 50 // The IIRFilter checks to make sure this coefficient is 1, so make it so. |
51 m_feedback[0] = 1; | 51 m_feedback[0] = 1; |
52 } | 52 } |
53 | 53 |
54 m_responseKernel = makeUnique<IIRDSPKernel>(this); | 54 m_responseKernel = WTF::makeUnique<IIRDSPKernel>(this); |
55 } | 55 } |
56 | 56 |
57 IIRProcessor::~IIRProcessor() { | 57 IIRProcessor::~IIRProcessor() { |
58 if (isInitialized()) | 58 if (isInitialized()) |
59 uninitialize(); | 59 uninitialize(); |
60 } | 60 } |
61 | 61 |
62 std::unique_ptr<AudioDSPKernel> IIRProcessor::createKernel() { | 62 std::unique_ptr<AudioDSPKernel> IIRProcessor::createKernel() { |
63 return makeUnique<IIRDSPKernel>(this); | 63 return WTF::makeUnique<IIRDSPKernel>(this); |
64 } | 64 } |
65 | 65 |
66 void IIRProcessor::process(const AudioBus* source, | 66 void IIRProcessor::process(const AudioBus* source, |
67 AudioBus* destination, | 67 AudioBus* destination, |
68 size_t framesToProcess) { | 68 size_t framesToProcess) { |
69 if (!isInitialized()) { | 69 if (!isInitialized()) { |
70 destination->zero(); | 70 destination->zero(); |
71 return; | 71 return; |
72 } | 72 } |
73 | 73 |
74 // For each channel of our input, process using the corresponding IIRDSPKernel | 74 // For each channel of our input, process using the corresponding IIRDSPKernel |
75 // into the output channel. | 75 // into the output channel. |
76 for (unsigned i = 0; i < m_kernels.size(); ++i) | 76 for (unsigned i = 0; i < m_kernels.size(); ++i) |
77 m_kernels[i]->process(source->channel(i)->data(), | 77 m_kernels[i]->process(source->channel(i)->data(), |
78 destination->channel(i)->mutableData(), | 78 destination->channel(i)->mutableData(), |
79 framesToProcess); | 79 framesToProcess); |
80 } | 80 } |
81 | 81 |
82 void IIRProcessor::getFrequencyResponse(int nFrequencies, | 82 void IIRProcessor::getFrequencyResponse(int nFrequencies, |
83 const float* frequencyHz, | 83 const float* frequencyHz, |
84 float* magResponse, | 84 float* magResponse, |
85 float* phaseResponse) { | 85 float* phaseResponse) { |
86 m_responseKernel->getFrequencyResponse(nFrequencies, frequencyHz, magResponse, | 86 m_responseKernel->getFrequencyResponse(nFrequencies, frequencyHz, magResponse, |
87 phaseResponse); | 87 phaseResponse); |
88 } | 88 } |
89 | 89 |
90 } // namespace blink | 90 } // namespace blink |
OLD | NEW |