Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: Source/modules/webaudio/AudioBufferSourceNode.h

Issue 190973010: Remove unnecessary attribute "gain" in AudioBuffer and AudioBufferSourceNode interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Combine with removing gains from AudioBuffer and AudioBufferSourceNode Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // The old attribute is kept for backwards compatibility. 72 // The old attribute is kept for backwards compatibility.
73 bool loop() const { return m_isLooping; } 73 bool loop() const { return m_isLooping; }
74 void setLoop(bool looping) { m_isLooping = looping; } 74 void setLoop(bool looping) { m_isLooping = looping; }
75 75
76 // Loop times in seconds. 76 // Loop times in seconds.
77 double loopStart() const { return m_loopStart; } 77 double loopStart() const { return m_loopStart; }
78 double loopEnd() const { return m_loopEnd; } 78 double loopEnd() const { return m_loopEnd; }
79 void setLoopStart(double loopStart) { m_loopStart = loopStart; } 79 void setLoopStart(double loopStart) { m_loopStart = loopStart; }
80 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } 80 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; }
81 81
82 AudioParam* gain() { return m_gain.get(); }
83 AudioParam* playbackRate() { return m_playbackRate.get(); } 82 AudioParam* playbackRate() { return m_playbackRate.get(); }
84 83
85 // If a panner node is set, then we can incorporate doppler shift into the p layback pitch rate. 84 // If a panner node is set, then we can incorporate doppler shift into the p layback pitch rate.
86 void setPannerNode(PannerNode*); 85 void setPannerNode(PannerNode*);
87 void clearPannerNode(); 86 void clearPannerNode();
88 87
89 // If we are no longer playing, propogate silence ahead to downstream nodes. 88 // If we are no longer playing, propogate silence ahead to downstream nodes.
90 virtual bool propagatesSilence() const OVERRIDE; 89 virtual bool propagatesSilence() const OVERRIDE;
91 90
92 // AudioScheduledSourceNode 91 // AudioScheduledSourceNode
93 virtual void finish() OVERRIDE; 92 virtual void finish() OVERRIDE;
94 93
95 private: 94 private:
96 AudioBufferSourceNode(AudioContext*, float sampleRate); 95 AudioBufferSourceNode(AudioContext*, float sampleRate);
97 96
98 // Returns true on success. 97 // Returns true on success.
99 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num berOfFrames); 98 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num berOfFrames);
100 99
101 // Render silence starting from "index" frame in AudioBus. 100 // Render silence starting from "index" frame in AudioBus.
102 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si ze_t framesToProcess); 101 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si ze_t framesToProcess);
103 102
104 // m_buffer holds the sample data which this node outputs. 103 // m_buffer holds the sample data which this node outputs.
105 RefPtr<AudioBuffer> m_buffer; 104 RefPtr<AudioBuffer> m_buffer;
106 105
107 // Pointers for the buffer and destination. 106 // Pointers for the buffer and destination.
108 OwnPtr<const float*[]> m_sourceChannels; 107 OwnPtr<const float*[]> m_sourceChannels;
109 OwnPtr<float*[]> m_destinationChannels; 108 OwnPtr<float*[]> m_destinationChannels;
110 109
111 // Used for the "gain" and "playbackRate" attributes. 110 // Used for the "playbackRate" attributes.
112 RefPtr<AudioParam> m_gain;
113 RefPtr<AudioParam> m_playbackRate; 111 RefPtr<AudioParam> m_playbackRate;
114 112
115 // If m_isLooping is false, then this node will be done playing and become i nactive after it reaches the end of the sample data in the buffer. 113 // If m_isLooping is false, then this node will be done playing and become i nactive after it reaches the end of the sample data in the buffer.
116 // If true, it will wrap around to the start of the buffer each time it reac hes the end. 114 // If true, it will wrap around to the start of the buffer each time it reac hes the end.
117 bool m_isLooping; 115 bool m_isLooping;
118 116
119 double m_loopStart; 117 double m_loopStart;
120 double m_loopEnd; 118 double m_loopEnd;
121 119
122 // m_virtualReadIndex is a sample-frame index into our buffer representing t he current playback position. 120 // m_virtualReadIndex is a sample-frame index into our buffer representing t he current playback position.
123 // Since it's floating-point, it has sub-sample accuracy. 121 // Since it's floating-point, it has sub-sample accuracy.
124 double m_virtualReadIndex; 122 double m_virtualReadIndex;
125 123
126 // Granular playback 124 // Granular playback
127 bool m_isGrain; 125 bool m_isGrain;
128 double m_grainOffset; // in seconds 126 double m_grainOffset; // in seconds
129 double m_grainDuration; // in seconds 127 double m_grainDuration; // in seconds
130 128
131 // totalPitchRate() returns the instantaneous pitch rate (non-time preservin g). 129 // totalPitchRate() returns the instantaneous pitch rate (non-time preservin g).
132 // It incorporates the base pitch rate, any sample-rate conversion factor fr om the buffer, and any doppler shift from an associated panner node. 130 // It incorporates the base pitch rate, any sample-rate conversion factor fr om the buffer, and any doppler shift from an associated panner node.
133 double totalPitchRate(); 131 double totalPitchRate();
134 132
135 // m_lastGain provides continuity when we dynamically adjust the gain.
136 float m_lastGain;
137
138 // We optionally keep track of a panner node which has a doppler shift that is incorporated into 133 // We optionally keep track of a panner node which has a doppler shift that is incorporated into
139 // the pitch rate. We manually manage ref-counting because we want to use Re fTypeConnection. 134 // the pitch rate. We manually manage ref-counting because we want to use Re fTypeConnection.
140 PannerNode* m_pannerNode; 135 PannerNode* m_pannerNode;
141 136
142 // This synchronizes process() with setBuffer() which can cause dynamic chan nel count changes. 137 // This synchronizes process() with setBuffer() which can cause dynamic chan nel count changes.
143 mutable Mutex m_processLock; 138 mutable Mutex m_processLock;
144 }; 139 };
145 140
146 } // namespace WebCore 141 } // namespace WebCore
147 142
148 #endif // AudioBufferSourceNode_h 143 #endif // AudioBufferSourceNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698