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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 20 matching lines...) Expand all Loading... |
31 #ifndef AudioProcessor_h | 31 #ifndef AudioProcessor_h |
32 #define AudioProcessor_h | 32 #define AudioProcessor_h |
33 | 33 |
34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
35 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class AudioBus; | 39 class AudioBus; |
40 | 40 |
41 // AudioProcessor is an abstract base class representing an audio signal process
ing object with a single input and a single output, | 41 // AudioProcessor is an abstract base class representing an audio signal |
42 // where the number of input channels equals the number of output channels. It
can be used as one part of a complex DSP algorithm, | 42 // processing object with a single input and a single output, where the number |
43 // or as the processor for a basic (one input - one output) AudioNode. | 43 // of input channels equals the number of output channels. It can be used as |
| 44 // one part of a complex DSP algorithm, or as the processor for a basic (one |
| 45 // input - one output) AudioNode. |
44 | 46 |
45 class PLATFORM_EXPORT AudioProcessor { | 47 class PLATFORM_EXPORT AudioProcessor { |
46 USING_FAST_MALLOC(AudioProcessor); | 48 USING_FAST_MALLOC(AudioProcessor); |
47 | 49 |
48 public: | 50 public: |
49 AudioProcessor(float sampleRate, unsigned numberOfChannels) | 51 AudioProcessor(float sampleRate, unsigned numberOfChannels) |
50 : m_initialized(false), | 52 : m_initialized(false), |
51 m_numberOfChannels(numberOfChannels), | 53 m_numberOfChannels(numberOfChannels), |
52 m_sampleRate(sampleRate) {} | 54 m_sampleRate(sampleRate) {} |
53 | 55 |
54 virtual ~AudioProcessor(); | 56 virtual ~AudioProcessor(); |
55 | 57 |
56 // Full initialization can be done here instead of in the constructor. | 58 // Full initialization can be done here instead of in the constructor. |
57 virtual void initialize() = 0; | 59 virtual void initialize() = 0; |
58 virtual void uninitialize() = 0; | 60 virtual void uninitialize() = 0; |
59 | 61 |
60 // Processes the source to destination bus. The number of channels must match
in source and destination. | 62 // Processes the source to destination bus. The number of channels must match |
| 63 // in source and destination. |
61 virtual void process(const AudioBus* source, | 64 virtual void process(const AudioBus* source, |
62 AudioBus* destination, | 65 AudioBus* destination, |
63 size_t framesToProcess) = 0; | 66 size_t framesToProcess) = 0; |
64 | 67 |
65 // Resets filter state | 68 // Resets filter state |
66 virtual void reset() = 0; | 69 virtual void reset() = 0; |
67 | 70 |
68 virtual void setNumberOfChannels(unsigned) = 0; | 71 virtual void setNumberOfChannels(unsigned) = 0; |
69 virtual unsigned numberOfChannels() const = 0; | 72 virtual unsigned numberOfChannels() const = 0; |
70 | 73 |
71 bool isInitialized() const { return m_initialized; } | 74 bool isInitialized() const { return m_initialized; } |
72 | 75 |
73 float sampleRate() const { return m_sampleRate; } | 76 float sampleRate() const { return m_sampleRate; } |
74 | 77 |
75 virtual double tailTime() const = 0; | 78 virtual double tailTime() const = 0; |
76 virtual double latencyTime() const = 0; | 79 virtual double latencyTime() const = 0; |
77 | 80 |
78 protected: | 81 protected: |
79 bool m_initialized; | 82 bool m_initialized; |
80 unsigned m_numberOfChannels; | 83 unsigned m_numberOfChannels; |
81 float m_sampleRate; | 84 float m_sampleRate; |
82 }; | 85 }; |
83 | 86 |
84 } // namespace blink | 87 } // namespace blink |
85 | 88 |
86 #endif // AudioProcessor_h | 89 #endif // AudioProcessor_h |
OLD | NEW |