OLD | NEW |
1 // Copyright (C) 2013 Google Inc. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * 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 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
11 // in the documentation and/or other materials provided with the | 11 // in the documentation and/or other materials provided with the |
12 // distribution. | 12 // distribution. |
13 // * Neither the name of Google Inc. nor the names of its | 13 // * Neither the name of Google Inc. nor the names of its |
14 // contributors may be used to endorse or promote products derived from | 14 // contributors may be used to endorse or promote products derived from |
15 // this software without specific prior written permission. | 15 // this software without specific prior written permission. |
16 // | 16 // |
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 #ifndef TextRunIterator_h | 29 #ifndef StereoPannerNode_h |
30 #define TextRunIterator_h | 30 #define StereoPannerNode_h |
31 | 31 |
32 #include "platform/text/TextRun.h" | 32 #include "modules/webaudio/AudioNode.h" |
| 33 #include "modules/webaudio/AudioParam.h" |
| 34 #include "platform/audio/AudioBus.h" |
| 35 #include "platform/audio/Spatializer.h" |
33 | 36 |
34 namespace blink { | 37 namespace blink { |
35 | 38 |
36 class TextRunIterator { | 39 // StereoPannerNode is an AudioNode with one input and one output. It is |
| 40 // specifically designed for equal-power stereo panning. |
| 41 class StereoPannerNode final : public AudioNode { |
| 42 DEFINE_WRAPPERTYPEINFO(); |
37 public: | 43 public: |
38 TextRunIterator() | 44 static StereoPannerNode* create(AudioContext* context, float sampleRate) |
39 : m_textRun(0) | |
40 , m_offset(0) | |
41 { | 45 { |
| 46 return new StereoPannerNode(context, sampleRate); |
42 } | 47 } |
43 | 48 |
44 TextRunIterator(const TextRun* textRun, unsigned offset) | 49 virtual ~StereoPannerNode(); |
45 : m_textRun(textRun) | |
46 , m_offset(offset) | |
47 { | |
48 } | |
49 | 50 |
50 TextRunIterator(const TextRunIterator& other) | 51 virtual void dispose() override; |
51 : m_textRun(other.m_textRun) | 52 virtual void process(size_t framesToProcess) override; |
52 , m_offset(other.m_offset) | 53 virtual void initialize() override; |
53 { | 54 virtual void uninitialize() override; |
54 } | |
55 | 55 |
56 unsigned offset() const { return m_offset; } | 56 virtual double tailTime() const override { return 0; } |
57 void increment() { m_offset++; } | 57 virtual double latencyTime() const override { return 0; } |
58 bool atEnd() const { return !m_textRun || m_offset >= m_textRun->length(); } | |
59 UChar current() const { return (*m_textRun)[m_offset]; } | |
60 WTF::Unicode::Direction direction() const { return atEnd() ? WTF::Unicode::O
therNeutral : WTF::Unicode::direction(current()); } | |
61 bool atParagraphSeparator() const { return current() == '\n'; } | |
62 | 58 |
63 bool operator==(const TextRunIterator& other) | 59 virtual void setChannelCount(unsigned long, ExceptionState&) final; |
64 { | 60 virtual void setChannelCountMode(const String&, ExceptionState&) final; |
65 return m_offset == other.m_offset && m_textRun == other.m_textRun; | |
66 } | |
67 | 61 |
68 bool operator!=(const TextRunIterator& other) { return !operator==(other); } | 62 virtual void trace(Visitor*) override; |
| 63 |
| 64 AudioParam* pan() { return m_pan.get(); } |
69 | 65 |
70 private: | 66 private: |
71 const TextRun* m_textRun; | 67 StereoPannerNode(AudioContext*, float sampleRate); |
72 int m_offset; | 68 |
| 69 Member<Spatializer> m_stereoPanner; |
| 70 Member<AudioParam> m_pan; |
| 71 |
| 72 AudioFloatArray m_sampleAccuratePanValues; |
73 }; | 73 }; |
74 | 74 |
75 | |
76 } // namespace blink | 75 } // namespace blink |
77 | 76 |
78 #endif // TextRunIterator_h | 77 #endif // StereoPannerNode_h |
OLD | NEW |