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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 // ScriptProcessorNode is an AudioNode which allows for arbitrary synthesis or p
rocessing directly using JavaScript. | 40 // ScriptProcessorNode is an AudioNode which allows for arbitrary synthesis or p
rocessing directly using JavaScript. |
41 // The API allows for a variable number of inputs and outputs, although it must
have at least one input or output. | 41 // The API allows for a variable number of inputs and outputs, although it must
have at least one input or output. |
42 // This basic implementation supports no more than one input and output. | 42 // This basic implementation supports no more than one input and output. |
43 // The "onaudioprocess" attribute is an event listener which will get called per
iodically with an AudioProcessingEvent which has | 43 // The "onaudioprocess" attribute is an event listener which will get called per
iodically with an AudioProcessingEvent which has |
44 // AudioBuffers for each input and output. | 44 // AudioBuffers for each input and output. |
45 | 45 |
46 class ScriptProcessorHandler final : public AudioHandler { | 46 class ScriptProcessorHandler final : public AudioHandler { |
47 public: | 47 public: |
48 static PassRefPtr<ScriptProcessorHandler> create(AudioNode&, float sampleRat
e, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputCha
nnels); | 48 static PassRefPtr<ScriptProcessorHandler> create(AudioNode&, float sampleRat
e, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputCha
nnels); |
49 virtual ~ScriptProcessorHandler(); | 49 ~ScriptProcessorHandler() override; |
50 | 50 |
51 // AudioHandler | 51 // AudioHandler |
52 virtual void process(size_t framesToProcess) override; | 52 void process(size_t framesToProcess) override; |
53 virtual void initialize() override; | 53 void initialize() override; |
54 | 54 |
55 size_t bufferSize() const { return m_bufferSize; } | 55 size_t bufferSize() const { return m_bufferSize; } |
56 | 56 |
57 virtual void setChannelCount(unsigned long, ExceptionState&) override; | 57 void setChannelCount(unsigned long, ExceptionState&) override; |
58 virtual void setChannelCountMode(const String&, ExceptionState&) override; | 58 void setChannelCountMode(const String&, ExceptionState&) override; |
59 | 59 |
60 virtual unsigned numberOfOutputChannels() const { return m_numberOfOutputCha
nnels; } | 60 virtual unsigned numberOfOutputChannels() const { return m_numberOfOutputCha
nnels; } |
61 | 61 |
62 private: | 62 private: |
63 ScriptProcessorHandler(AudioNode&, float sampleRate, size_t bufferSize, unsi
gned numberOfInputChannels, unsigned numberOfOutputChannels); | 63 ScriptProcessorHandler(AudioNode&, float sampleRate, size_t bufferSize, unsi
gned numberOfInputChannels, unsigned numberOfOutputChannels); |
64 virtual double tailTime() const override; | 64 double tailTime() const override; |
65 virtual double latencyTime() const override; | 65 double latencyTime() const override; |
66 | 66 |
67 void fireProcessEvent(); | 67 void fireProcessEvent(); |
68 | 68 |
69 // Double buffering | 69 // Double buffering |
70 unsigned doubleBufferIndex() const { return m_doubleBufferIndex; } | 70 unsigned doubleBufferIndex() const { return m_doubleBufferIndex; } |
71 void swapBuffers() { m_doubleBufferIndex = 1 - m_doubleBufferIndex; } | 71 void swapBuffers() { m_doubleBufferIndex = 1 - m_doubleBufferIndex; } |
72 unsigned m_doubleBufferIndex; | 72 unsigned m_doubleBufferIndex; |
73 unsigned m_doubleBufferIndexForEvent; | 73 unsigned m_doubleBufferIndexForEvent; |
74 // These Persistent don't make reference cycles including the owner | 74 // These Persistent don't make reference cycles including the owner |
75 // ScriptProcessorNode. | 75 // ScriptProcessorNode. |
(...skipping 30 matching lines...) Expand all Loading... |
106 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess); | 106 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioprocess); |
107 size_t bufferSize() const; | 107 size_t bufferSize() const; |
108 | 108 |
109 private: | 109 private: |
110 ScriptProcessorNode(AudioContext&, float sampleRate, size_t bufferSize, unsi
gned numberOfInputChannels, unsigned numberOfOutputChannels); | 110 ScriptProcessorNode(AudioContext&, float sampleRate, size_t bufferSize, unsi
gned numberOfInputChannels, unsigned numberOfOutputChannels); |
111 }; | 111 }; |
112 | 112 |
113 } // namespace blink | 113 } // namespace blink |
114 | 114 |
115 #endif // ScriptProcessorNode_h | 115 #endif // ScriptProcessorNode_h |
OLD | NEW |