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 30 matching lines...) Expand all Loading... |
41 context.sampleRate() / 2)), | 41 context.sampleRate() / 2)), |
42 m_q(AudioParam::create(context, ParamTypeBiquadFilterQ, 1.0)), | 42 m_q(AudioParam::create(context, ParamTypeBiquadFilterQ, 1.0)), |
43 m_gain(AudioParam::create(context, ParamTypeBiquadFilterGain, 0.0)), | 43 m_gain(AudioParam::create(context, ParamTypeBiquadFilterGain, 0.0)), |
44 m_detune(AudioParam::create(context, ParamTypeBiquadFilterDetune, 0.0)) { | 44 m_detune(AudioParam::create(context, ParamTypeBiquadFilterDetune, 0.0)) { |
45 setHandler(AudioBasicProcessorHandler::create( | 45 setHandler(AudioBasicProcessorHandler::create( |
46 AudioHandler::NodeTypeBiquadFilter, *this, context.sampleRate(), | 46 AudioHandler::NodeTypeBiquadFilter, *this, context.sampleRate(), |
47 wrapUnique(new BiquadProcessor(context.sampleRate(), 1, | 47 wrapUnique(new BiquadProcessor(context.sampleRate(), 1, |
48 m_frequency->handler(), m_q->handler(), | 48 m_frequency->handler(), m_q->handler(), |
49 m_gain->handler(), m_detune->handler())))); | 49 m_gain->handler(), m_detune->handler())))); |
50 | 50 |
51 // Explicitly set the filter type so that any histograms get updated with the
default value. | 51 // Explicitly set the filter type so that any histograms get updated with the |
52 // Otherwise, the histogram won't ever show it. | 52 // default value. Otherwise, the histogram won't ever show it. |
53 setType("lowpass"); | 53 setType("lowpass"); |
54 } | 54 } |
55 | 55 |
56 BiquadFilterNode* BiquadFilterNode::create(BaseAudioContext& context, | 56 BiquadFilterNode* BiquadFilterNode::create(BaseAudioContext& context, |
57 ExceptionState& exceptionState) { | 57 ExceptionState& exceptionState) { |
58 DCHECK(isMainThread()); | 58 DCHECK(isMainThread()); |
59 | 59 |
60 if (context.isContextClosed()) { | 60 if (context.isContextClosed()) { |
61 context.throwExceptionForClosedState(exceptionState); | 61 context.throwExceptionForClosedState(exceptionState); |
62 return nullptr; | 62 return nullptr; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return "notch"; | 120 return "notch"; |
121 case BiquadProcessor::Allpass: | 121 case BiquadProcessor::Allpass: |
122 return "allpass"; | 122 return "allpass"; |
123 default: | 123 default: |
124 ASSERT_NOT_REACHED(); | 124 ASSERT_NOT_REACHED(); |
125 return "lowpass"; | 125 return "lowpass"; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 void BiquadFilterNode::setType(const String& type) { | 129 void BiquadFilterNode::setType(const String& type) { |
130 // For the Q histogram, we need to change the name of the AudioParam for the l
owpass and | 130 // For the Q histogram, we need to change the name of the AudioParam for the |
131 // highpass filters so we know to count the Q value when it is set. And explic
itly set the value | 131 // lowpass and highpass filters so we know to count the Q value when it is |
132 // to itself so the histograms know the initial value. | 132 // set. And explicitly set the value to itself so the histograms know the |
| 133 // initial value. |
133 | 134 |
134 if (type == "lowpass") { | 135 if (type == "lowpass") { |
135 setType(BiquadProcessor::LowPass); | 136 setType(BiquadProcessor::LowPass); |
136 m_q->setParamType(ParamTypeBiquadFilterQLowpass); | 137 m_q->setParamType(ParamTypeBiquadFilterQLowpass); |
137 m_q->setValue(m_q->value()); | 138 m_q->setValue(m_q->value()); |
138 } else if (type == "highpass") { | 139 } else if (type == "highpass") { |
139 setType(BiquadProcessor::HighPass); | 140 setType(BiquadProcessor::HighPass); |
140 m_q->setParamType(ParamTypeBiquadFilterQHighpass); | 141 m_q->setParamType(ParamTypeBiquadFilterQHighpass); |
141 m_q->setValue(m_q->value()); | 142 m_q->setValue(m_q->value()); |
142 } else if (type == "bandpass") { | 143 } else if (type == "bandpass") { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 DCHECK(phaseResponse); | 176 DCHECK(phaseResponse); |
176 | 177 |
177 int n = std::min(frequencyHz->length(), | 178 int n = std::min(frequencyHz->length(), |
178 std::min(magResponse->length(), phaseResponse->length())); | 179 std::min(magResponse->length(), phaseResponse->length())); |
179 if (n) | 180 if (n) |
180 getBiquadProcessor()->getFrequencyResponse( | 181 getBiquadProcessor()->getFrequencyResponse( |
181 n, frequencyHz->data(), magResponse->data(), phaseResponse->data()); | 182 n, frequencyHz->data(), magResponse->data(), phaseResponse->data()); |
182 } | 183 } |
183 | 184 |
184 } // namespace blink | 185 } // namespace blink |
OLD | NEW |