summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/webaudio/StereoPannerNode.h
blob: 16283e62c584fc34d3d582fc519dea200824d255 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef StereoPannerNode_h
#define StereoPannerNode_h

#include "base/gtest_prod_util.h"
#include "modules/webaudio/AudioNode.h"
#include "modules/webaudio/AudioParam.h"
#include "platform/audio/AudioBus.h"
#include "platform/audio/Spatializer.h"

namespace blink {

class AbstractAudioContext;

// StereoPannerNode is an AudioNode with one input and one output. It is
// specifically designed for equal-power stereo panning.
class StereoPannerHandler final : public AudioHandler {
public:
    static PassRefPtr<StereoPannerHandler> create(AudioNode&, float sampleRate, AudioParamHandler& pan);
    ~StereoPannerHandler() override;

    void process(size_t framesToProcess) override;
    void initialize() override;

    void setChannelCount(unsigned long, ExceptionState&) final;
    void setChannelCountMode(const String&, ExceptionState&) final;

private:
    StereoPannerHandler(AudioNode&, float sampleRate, AudioParamHandler& pan);

    OwnPtr<Spatializer> m_stereoPanner;
    RefPtr<AudioParamHandler> m_pan;

    AudioFloatArray m_sampleAccuratePanValues;

    FRIEND_TEST_ALL_PREFIXES(StereoPannerNodeTest, StereoPannerLifetime);
};

class StereoPannerNode final : public AudioNode {
    DEFINE_WRAPPERTYPEINFO();
public:
    static StereoPannerNode* create(AbstractAudioContext&, float sampleRate);
    DECLARE_VIRTUAL_TRACE();

    AudioParam* pan() const;

private:
    StereoPannerNode(AbstractAudioContext&, float sampleRate);

    Member<AudioParam> m_pan;
};

} // namespace blink

#endif // StereoPannerNode_h