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 18 matching lines...) Expand all Loading... |
29 #ifndef ReverbConvolver_h | 29 #ifndef ReverbConvolver_h |
30 #define ReverbConvolver_h | 30 #define ReverbConvolver_h |
31 | 31 |
32 #include "platform/audio/AudioArray.h" | 32 #include "platform/audio/AudioArray.h" |
33 #include "platform/audio/DirectConvolver.h" | 33 #include "platform/audio/DirectConvolver.h" |
34 #include "platform/audio/FFTConvolver.h" | 34 #include "platform/audio/FFTConvolver.h" |
35 #include "platform/audio/ReverbAccumulationBuffer.h" | 35 #include "platform/audio/ReverbAccumulationBuffer.h" |
36 #include "platform/audio/ReverbConvolverStage.h" | 36 #include "platform/audio/ReverbConvolverStage.h" |
37 #include "platform/audio/ReverbInputBuffer.h" | 37 #include "platform/audio/ReverbInputBuffer.h" |
38 #include "wtf/Allocator.h" | 38 #include "wtf/Allocator.h" |
39 #include "wtf/OwnPtr.h" | |
40 #include "wtf/Vector.h" | 39 #include "wtf/Vector.h" |
| 40 #include <memory> |
41 | 41 |
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 public: | 50 public: |
51 // maxFFTSize can be adjusted (from say 2048 to 32768) depending on how much
precision is necessary. | 51 // maxFFTSize can be adjusted (from say 2048 to 32768) depending on how much
precision is necessary. |
52 // For certain tweaky de-convolving applications the phase errors add up qui
ckly and lead to non-sensical results with | 52 // For certain tweaky de-convolving applications the phase errors add up qui
ckly and lead to non-sensical results with |
53 // larger FFT sizes and single-precision floats. In these cases 2048 is a g
ood size. | 53 // larger FFT sizes and single-precision floats. In these cases 2048 is a g
ood size. |
54 // If not doing multi-threaded convolution, then should not go > 8192. | 54 // If not doing multi-threaded convolution, then should not go > 8192. |
55 ReverbConvolver(AudioChannel* impulseResponse, size_t renderSliceSize, size_
t maxFFTSize, size_t convolverRenderPhase, bool useBackgroundThreads); | 55 ReverbConvolver(AudioChannel* impulseResponse, size_t renderSliceSize, size_
t maxFFTSize, size_t convolverRenderPhase, bool useBackgroundThreads); |
56 ~ReverbConvolver(); | 56 ~ReverbConvolver(); |
57 | 57 |
58 void process(const AudioChannel* sourceChannel, AudioChannel* destinationCha
nnel, size_t framesToProcess); | 58 void process(const AudioChannel* sourceChannel, AudioChannel* destinationCha
nnel, size_t framesToProcess); |
59 void reset(); | 59 void reset(); |
60 | 60 |
61 ReverbInputBuffer* inputBuffer() { return &m_inputBuffer; } | 61 ReverbInputBuffer* inputBuffer() { return &m_inputBuffer; } |
62 | 62 |
63 size_t latencyFrames() const; | 63 size_t latencyFrames() const; |
64 private: | 64 private: |
65 void processInBackground(); | 65 void processInBackground(); |
66 | 66 |
67 Vector<OwnPtr<ReverbConvolverStage>> m_stages; | 67 Vector<std::unique_ptr<ReverbConvolverStage>> m_stages; |
68 Vector<OwnPtr<ReverbConvolverStage>> m_backgroundStages; | 68 Vector<std::unique_ptr<ReverbConvolverStage>> m_backgroundStages; |
69 size_t m_impulseResponseLength; | 69 size_t m_impulseResponseLength; |
70 | 70 |
71 ReverbAccumulationBuffer m_accumulationBuffer; | 71 ReverbAccumulationBuffer m_accumulationBuffer; |
72 | 72 |
73 // One or more background threads read from this input buffer which is fed f
rom the realtime thread. | 73 // One or more background threads read from this input buffer which is fed f
rom the realtime thread. |
74 ReverbInputBuffer m_inputBuffer; | 74 ReverbInputBuffer m_inputBuffer; |
75 | 75 |
76 // First stage will be of size m_minFFTSize. Each next stage will be twice
as big until we hit m_maxFFTSize. | 76 // First stage will be of size m_minFFTSize. Each next stage will be twice
as big until we hit m_maxFFTSize. |
77 size_t m_minFFTSize; | 77 size_t m_minFFTSize; |
78 size_t m_maxFFTSize; | 78 size_t m_maxFFTSize; |
79 | 79 |
80 // But don't exceed this size in the real-time thread (if we're doing backgr
ound processing). | 80 // But don't exceed this size in the real-time thread (if we're doing backgr
ound processing). |
81 size_t m_maxRealtimeFFTSize; | 81 size_t m_maxRealtimeFFTSize; |
82 | 82 |
83 // Background thread and synchronization | 83 // Background thread and synchronization |
84 OwnPtr<WebThread> m_backgroundThread; | 84 std::unique_ptr<WebThread> m_backgroundThread; |
85 }; | 85 }; |
86 | 86 |
87 } // namespace blink | 87 } // namespace blink |
88 | 88 |
89 #endif // ReverbConvolver_h | 89 #endif // ReverbConvolver_h |
OLD | NEW |