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 19 matching lines...) Expand all Loading... |
30 #include "platform/audio/AudioArray.h" | 30 #include "platform/audio/AudioArray.h" |
31 #include "platform/audio/AudioDSPKernel.h" | 31 #include "platform/audio/AudioDSPKernel.h" |
32 #include "platform/audio/DownSampler.h" | 32 #include "platform/audio/DownSampler.h" |
33 #include "platform/audio/UpSampler.h" | 33 #include "platform/audio/UpSampler.h" |
34 #include <memory> | 34 #include <memory> |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class WaveShaperProcessor; | 38 class WaveShaperProcessor; |
39 | 39 |
40 // WaveShaperDSPKernel is an AudioDSPKernel and is responsible for non-linear di
stortion on one channel. | 40 // WaveShaperDSPKernel is an AudioDSPKernel and is responsible for non-linear |
| 41 // distortion on one channel. |
41 | 42 |
42 class WaveShaperDSPKernel final : public AudioDSPKernel { | 43 class WaveShaperDSPKernel final : public AudioDSPKernel { |
43 public: | 44 public: |
44 explicit WaveShaperDSPKernel(WaveShaperProcessor*); | 45 explicit WaveShaperDSPKernel(WaveShaperProcessor*); |
45 | 46 |
46 // AudioDSPKernel | 47 // AudioDSPKernel |
47 void process(const float* source, | 48 void process(const float* source, |
48 float* dest, | 49 float* dest, |
49 size_t framesToProcess) override; | 50 size_t framesToProcess) override; |
50 void reset() override; | 51 void reset() override; |
51 double tailTime() const override { return 0; } | 52 double tailTime() const override { return 0; } |
52 double latencyTime() const override; | 53 double latencyTime() const override; |
53 | 54 |
54 // Oversampling requires more resources, so let's only allocate them if needed
. | 55 // Oversampling requires more resources, so let's only allocate them if |
| 56 // needed. |
55 void lazyInitializeOversampling(); | 57 void lazyInitializeOversampling(); |
56 | 58 |
57 protected: | 59 protected: |
58 // Apply the shaping curve. | 60 // Apply the shaping curve. |
59 void processCurve(const float* source, float* dest, size_t framesToProcess); | 61 void processCurve(const float* source, float* dest, size_t framesToProcess); |
60 | 62 |
61 // Use up-sampling, process at the higher sample-rate, then down-sample. | 63 // Use up-sampling, process at the higher sample-rate, then down-sample. |
62 void processCurve2x(const float* source, float* dest, size_t framesToProcess); | 64 void processCurve2x(const float* source, float* dest, size_t framesToProcess); |
63 void processCurve4x(const float* source, float* dest, size_t framesToProcess); | 65 void processCurve4x(const float* source, float* dest, size_t framesToProcess); |
64 | 66 |
65 WaveShaperProcessor* getWaveShaperProcessor() { | 67 WaveShaperProcessor* getWaveShaperProcessor() { |
66 return static_cast<WaveShaperProcessor*>(processor()); | 68 return static_cast<WaveShaperProcessor*>(processor()); |
67 } | 69 } |
68 | 70 |
69 // Oversampling. | 71 // Oversampling. |
70 std::unique_ptr<AudioFloatArray> m_tempBuffer; | 72 std::unique_ptr<AudioFloatArray> m_tempBuffer; |
71 std::unique_ptr<AudioFloatArray> m_tempBuffer2; | 73 std::unique_ptr<AudioFloatArray> m_tempBuffer2; |
72 std::unique_ptr<UpSampler> m_upSampler; | 74 std::unique_ptr<UpSampler> m_upSampler; |
73 std::unique_ptr<DownSampler> m_downSampler; | 75 std::unique_ptr<DownSampler> m_downSampler; |
74 std::unique_ptr<UpSampler> m_upSampler2; | 76 std::unique_ptr<UpSampler> m_upSampler2; |
75 std::unique_ptr<DownSampler> m_downSampler2; | 77 std::unique_ptr<DownSampler> m_downSampler2; |
76 }; | 78 }; |
77 | 79 |
78 } // namespace blink | 80 } // namespace blink |
79 | 81 |
80 #endif // WaveShaperDSPKernel_h | 82 #endif // WaveShaperDSPKernel_h |
OLD | NEW |