| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class AudioChannel; | 44 class AudioChannel; |
| 45 class WebThread; | 45 class WebThread; |
| 46 | 46 |
| 47 class PLATFORM_EXPORT ReverbConvolver { | 47 class PLATFORM_EXPORT ReverbConvolver { |
| 48 USING_FAST_MALLOC(ReverbConvolver); | 48 USING_FAST_MALLOC(ReverbConvolver); |
| 49 WTF_MAKE_NONCOPYABLE(ReverbConvolver); | 49 WTF_MAKE_NONCOPYABLE(ReverbConvolver); |
| 50 | 50 |
| 51 public: | 51 public: |
| 52 // maxFFTSize can be adjusted (from say 2048 to 32768) depending on how much p
recision is necessary. | 52 // maxFFTSize can be adjusted (from say 2048 to 32768) depending on how much |
| 53 // For certain tweaky de-convolving applications the phase errors add up quick
ly and lead to non-sensical results with | 53 // precision is necessary. For certain tweaky de-convolving applications the |
| 54 // larger FFT sizes and single-precision floats. In these cases 2048 is a goo
d size. | 54 // phase errors add up quickly and lead to non-sensical results with larger |
| 55 // If not doing multi-threaded convolution, then should not go > 8192. | 55 // FFT sizes and single-precision floats. In these cases 2048 is a good |
| 56 // size. If not doing multi-threaded convolution, then should not go > 8192. |
| 56 ReverbConvolver(AudioChannel* impulseResponse, | 57 ReverbConvolver(AudioChannel* impulseResponse, |
| 57 size_t renderSliceSize, | 58 size_t renderSliceSize, |
| 58 size_t maxFFTSize, | 59 size_t maxFFTSize, |
| 59 size_t convolverRenderPhase, | 60 size_t convolverRenderPhase, |
| 60 bool useBackgroundThreads); | 61 bool useBackgroundThreads); |
| 61 ~ReverbConvolver(); | 62 ~ReverbConvolver(); |
| 62 | 63 |
| 63 void process(const AudioChannel* sourceChannel, | 64 void process(const AudioChannel* sourceChannel, |
| 64 AudioChannel* destinationChannel, | 65 AudioChannel* destinationChannel, |
| 65 size_t framesToProcess); | 66 size_t framesToProcess); |
| 66 void reset(); | 67 void reset(); |
| 67 | 68 |
| 68 ReverbInputBuffer* inputBuffer() { return &m_inputBuffer; } | 69 ReverbInputBuffer* inputBuffer() { return &m_inputBuffer; } |
| 69 | 70 |
| 70 size_t latencyFrames() const; | 71 size_t latencyFrames() const; |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 void processInBackground(); | 74 void processInBackground(); |
| 74 | 75 |
| 75 Vector<std::unique_ptr<ReverbConvolverStage>> m_stages; | 76 Vector<std::unique_ptr<ReverbConvolverStage>> m_stages; |
| 76 Vector<std::unique_ptr<ReverbConvolverStage>> m_backgroundStages; | 77 Vector<std::unique_ptr<ReverbConvolverStage>> m_backgroundStages; |
| 77 size_t m_impulseResponseLength; | 78 size_t m_impulseResponseLength; |
| 78 | 79 |
| 79 ReverbAccumulationBuffer m_accumulationBuffer; | 80 ReverbAccumulationBuffer m_accumulationBuffer; |
| 80 | 81 |
| 81 // One or more background threads read from this input buffer which is fed fro
m the realtime thread. | 82 // One or more background threads read from this input buffer which is fed |
| 83 // from the realtime thread. |
| 82 ReverbInputBuffer m_inputBuffer; | 84 ReverbInputBuffer m_inputBuffer; |
| 83 | 85 |
| 84 // First stage will be of size m_minFFTSize. Each next stage will be twice as
big until we hit m_maxFFTSize. | 86 // First stage will be of size m_minFFTSize. Each next stage will be twice as |
| 87 // big until we hit m_maxFFTSize. |
| 85 size_t m_minFFTSize; | 88 size_t m_minFFTSize; |
| 86 size_t m_maxFFTSize; | 89 size_t m_maxFFTSize; |
| 87 | 90 |
| 88 // But don't exceed this size in the real-time thread (if we're doing backgrou
nd processing). | 91 // But don't exceed this size in the real-time thread (if we're doing |
| 92 // background processing). |
| 89 size_t m_maxRealtimeFFTSize; | 93 size_t m_maxRealtimeFFTSize; |
| 90 | 94 |
| 91 // Background thread and synchronization | 95 // Background thread and synchronization |
| 92 std::unique_ptr<WebThread> m_backgroundThread; | 96 std::unique_ptr<WebThread> m_backgroundThread; |
| 93 }; | 97 }; |
| 94 | 98 |
| 95 } // namespace blink | 99 } // namespace blink |
| 96 | 100 |
| 97 #endif // ReverbConvolver_h | 101 #endif // ReverbConvolver_h |
| OLD | NEW |