// An AudioBus represents a collection of one or more AudioChannels.
// The data layout is "planar" as opposed to "interleaved".
// An AudioBus with one channel is mono, an AudioBus with two channels is stereo, etc.
-class AudioBus : public Noncopyable {
+class AudioBus {
+ WTF_MAKE_NONCOPYABLE(AudioBus);
public:
enum {
ChannelLeft = 0,
// 0 may be returned if the range does not fit in the sourceBuffer
static PassOwnPtr<AudioBus> createBufferFromRange(AudioBus* sourceBuffer, unsigned startFrame, unsigned endFrame);
+
+#if !PLATFORM(MAC)
+ // Creates a new AudioBus by sample-rate converting sourceBus to the newSampleRate.
+ // setSampleRate() must have been previously called on sourceBus.
+ // Note: sample-rate conversion is already handled in the file-reading code for the mac port, so we don't need this.
+ static PassOwnPtr<AudioBus> createBySampleRateConverting(AudioBus* sourceBus, bool mixToMono, double newSampleRate);
+#endif
+
+ // Creates a new AudioBus by mixing all the channels down to mono.
+ // If sourceBus is already mono, then the returned AudioBus will simply be a copy.
+ static PassOwnPtr<AudioBus> createByMixingToMono(AudioBus* sourceBus);
+
// Scales all samples by the same amount.
void scale(double scale);
void copyWithGainFrom(const AudioBus &sourceBus, double* lastMixGain, double targetGain);
void sumWithGainFrom(const AudioBus &sourceBus, double* lastMixGain, double targetGain);
+ // Copies the sourceBus by scaling with sample-accurate gain values.
+ void copyWithSampleAccurateGainValuesFrom(const AudioBus &sourceBus, float* gainValues, unsigned numberOfGainValues);
+
// Returns maximum absolute value across all channels (useful for normalization).
float maxAbsValue() const;