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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 26 matching lines...) Expand all Loading... |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class PLATFORM_EXPORT FFTConvolver { | 39 class PLATFORM_EXPORT FFTConvolver { |
40 USING_FAST_MALLOC(FFTConvolver); | 40 USING_FAST_MALLOC(FFTConvolver); |
41 WTF_MAKE_NONCOPYABLE(FFTConvolver); | 41 WTF_MAKE_NONCOPYABLE(FFTConvolver); |
42 | 42 |
43 public: | 43 public: |
44 // fftSize must be a power of two | 44 // fftSize must be a power of two |
45 FFTConvolver(size_t fftSize); | 45 FFTConvolver(size_t fftSize); |
46 | 46 |
47 // For now, with multiple calls to Process(), framesToProcess MUST add up EXAC
TLY to fftSize / 2 | 47 // For now, with multiple calls to Process(), framesToProcess MUST add up |
| 48 // EXACTLY to fftSize / 2 |
48 // | 49 // |
49 // FIXME: Later, we can do more sophisticated buffering to relax this requirem
ent... | 50 // FIXME: Later, we can do more sophisticated buffering to relax this |
| 51 // requirement... |
50 // | 52 // |
51 // The input to output latency is equal to fftSize / 2 | 53 // The input to output latency is equal to fftSize / 2 |
52 // | 54 // |
53 // Processing in-place is allowed... | 55 // Processing in-place is allowed... |
54 void process(FFTFrame* fftKernel, | 56 void process(FFTFrame* fftKernel, |
55 const float* sourceP, | 57 const float* sourceP, |
56 float* destP, | 58 float* destP, |
57 size_t framesToProcess); | 59 size_t framesToProcess); |
58 | 60 |
59 void reset(); | 61 void reset(); |
60 | 62 |
61 size_t fftSize() const { return m_frame.fftSize(); } | 63 size_t fftSize() const { return m_frame.fftSize(); } |
62 | 64 |
63 private: | 65 private: |
64 FFTFrame m_frame; | 66 FFTFrame m_frame; |
65 | 67 |
66 // Buffer input until we get fftSize / 2 samples then do an FFT | 68 // Buffer input until we get fftSize / 2 samples then do an FFT |
67 size_t m_readWriteIndex; | 69 size_t m_readWriteIndex; |
68 AudioFloatArray m_inputBuffer; | 70 AudioFloatArray m_inputBuffer; |
69 | 71 |
70 // Stores output which we read a little at a time | 72 // Stores output which we read a little at a time |
71 AudioFloatArray m_outputBuffer; | 73 AudioFloatArray m_outputBuffer; |
72 | 74 |
73 // Saves the 2nd half of the FFT buffer, so we can do an overlap-add with the
1st half of the next one | 75 // Saves the 2nd half of the FFT buffer, so we can do an overlap-add with the |
| 76 // 1st half of the next one |
74 AudioFloatArray m_lastOverlapBuffer; | 77 AudioFloatArray m_lastOverlapBuffer; |
75 }; | 78 }; |
76 | 79 |
77 } // namespace blink | 80 } // namespace blink |
78 | 81 |
79 #endif // FFTConvolver_h | 82 #endif // FFTConvolver_h |
OLD | NEW |