OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 unsigned log2size = static_cast<unsigned>(log2(size)); | 83 unsigned log2size = static_cast<unsigned>(log2(size)); |
84 bool isPOT(1UL << log2size == size); | 84 bool isPOT(1UL << log2size == size); |
85 | 85 |
86 if (!isPOT || size > MaxFFTSize) { | 86 if (!isPOT || size > MaxFFTSize) { |
87 // FIXME: It would be good to also set an exception. | 87 // FIXME: It would be good to also set an exception. |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 if (m_fftSize != size) { | 91 if (m_fftSize != size) { |
92 m_analysisFrame = adoptPtr(new FFTFrame(m_fftSize)); | 92 m_analysisFrame = adoptPtr(new FFTFrame(m_fftSize)); |
93 m_magnitudeBuffer.resize(size); | 93 m_magnitudeBuffer.allocate(size); |
94 m_fftSize = size; | 94 m_fftSize = size; |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 void RealtimeAnalyser::writeInput(AudioBus* bus, size_t framesToProcess) | 98 void RealtimeAnalyser::writeInput(AudioBus* bus, size_t framesToProcess) |
99 { | 99 { |
100 bool isBusGood = bus && bus->numberOfChannels() > 0 && bus->channel(0)->leng
th() >= framesToProcess; | 100 bool isBusGood = bus && bus->numberOfChannels() > 0 && bus->channel(0)->leng
th() >= framesToProcess; |
101 ASSERT(isBusGood); | 101 ASSERT(isBusGood); |
102 if (!isBusGood) | 102 if (!isBusGood) |
103 return; | 103 return; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 scaledValue = UCHAR_MAX; | 285 scaledValue = UCHAR_MAX; |
286 | 286 |
287 destination[i] = static_cast<unsigned char>(scaledValue); | 287 destination[i] = static_cast<unsigned char>(scaledValue); |
288 } | 288 } |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 } // namespace WebCore | 292 } // namespace WebCore |
293 | 293 |
294 #endif // ENABLE(WEB_AUDIO) | 294 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |