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 * 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 15 matching lines...) Expand all Loading... |
26 #define GainNode_h | 26 #define GainNode_h |
27 | 27 |
28 #include "modules/webaudio/AudioNode.h" | 28 #include "modules/webaudio/AudioNode.h" |
29 #include "modules/webaudio/AudioParam.h" | 29 #include "modules/webaudio/AudioParam.h" |
30 #include "wtf/PassRefPtr.h" | 30 #include "wtf/PassRefPtr.h" |
31 #include "wtf/Threading.h" | 31 #include "wtf/Threading.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 class BaseAudioContext; | 35 class BaseAudioContext; |
| 36 class GainOptions; |
36 | 37 |
37 // GainNode is an AudioNode with one input and one output which applies a gain (
volume) change to the audio signal. | 38 // GainNode is an AudioNode with one input and one output which applies a gain (
volume) change to the audio signal. |
38 // De-zippering (smoothing) is applied when the gain value is changed dynamicall
y. | 39 // De-zippering (smoothing) is applied when the gain value is changed dynamicall
y. |
39 | 40 |
40 class GainHandler final : public AudioHandler { | 41 class GainHandler final : public AudioHandler { |
41 public: | 42 public: |
42 static PassRefPtr<GainHandler> create(AudioNode&, float sampleRate, AudioPar
amHandler& gain); | 43 static PassRefPtr<GainHandler> create(AudioNode&, float sampleRate, AudioPar
amHandler& gain); |
43 | 44 |
44 // AudioHandler | 45 // AudioHandler |
45 void process(size_t framesToProcess) override; | 46 void process(size_t framesToProcess) override; |
46 | 47 |
47 // Called in the main thread when the number of channels for the input may h
ave changed. | 48 // Called in the main thread when the number of channels for the input may h
ave changed. |
48 void checkNumberOfChannelsForInput(AudioNodeInput*) override; | 49 void checkNumberOfChannelsForInput(AudioNodeInput*) override; |
49 | 50 |
50 private: | 51 private: |
51 GainHandler(AudioNode&, float sampleRate, AudioParamHandler& gain); | 52 GainHandler(AudioNode&, float sampleRate, AudioParamHandler& gain); |
52 | 53 |
53 float m_lastGain; // for de-zippering | 54 float m_lastGain; // for de-zippering |
54 RefPtr<AudioParamHandler> m_gain; | 55 RefPtr<AudioParamHandler> m_gain; |
55 | 56 |
56 AudioFloatArray m_sampleAccurateGainValues; | 57 AudioFloatArray m_sampleAccurateGainValues; |
57 }; | 58 }; |
58 | 59 |
59 class GainNode final : public AudioNode { | 60 class GainNode final : public AudioNode { |
60 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
61 public: | 62 public: |
62 static GainNode* create(BaseAudioContext&, ExceptionState&); | 63 static GainNode* create(BaseAudioContext&, ExceptionState&); |
| 64 static GainNode* create(BaseAudioContext*, const GainOptions&, ExceptionStat
e&); |
63 DECLARE_VIRTUAL_TRACE(); | 65 DECLARE_VIRTUAL_TRACE(); |
64 | 66 |
65 AudioParam* gain() const; | 67 AudioParam* gain() const; |
66 | 68 |
67 private: | 69 private: |
68 GainNode(BaseAudioContext&); | 70 GainNode(BaseAudioContext&); |
69 | 71 |
70 Member<AudioParam> m_gain; | 72 Member<AudioParam> m_gain; |
71 }; | 73 }; |
72 | 74 |
73 } // namespace blink | 75 } // namespace blink |
74 | 76 |
75 #endif // GainNode_h | 77 #endif // GainNode_h |
OLD | NEW |