| 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 27 matching lines...) Expand all Loading... |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class AudioContext; | 40 class AudioContext; |
| 41 | 41 |
| 42 // AudioBufferSourceNode is an AudioNode representing an audio source from an in
-memory audio asset represented by an AudioBuffer. | 42 // AudioBufferSourceNode is an AudioNode representing an audio source from an in
-memory audio asset represented by an AudioBuffer. |
| 43 // It generally will be used for short sounds which require a high degree of sch
eduling flexibility (can playback in rhythmically perfect ways). | 43 // It generally will be used for short sounds which require a high degree of sch
eduling flexibility (can playback in rhythmically perfect ways). |
| 44 | 44 |
| 45 class AudioBufferSourceHandler final : public AudioScheduledSourceHandler { | 45 class AudioBufferSourceHandler final : public AudioScheduledSourceHandler { |
| 46 public: | 46 public: |
| 47 static PassRefPtr<AudioBufferSourceHandler> create(AudioNode&, float sampleR
ate, AudioParamHandler& playbackRate, AudioParamHandler& detune); | 47 static PassRefPtr<AudioBufferSourceHandler> create(AudioNode&, float sampleR
ate, AudioParamHandler& playbackRate, AudioParamHandler& detune); |
| 48 virtual ~AudioBufferSourceHandler(); | 48 ~AudioBufferSourceHandler() override; |
| 49 | 49 |
| 50 // AudioHandler | 50 // AudioHandler |
| 51 virtual void process(size_t framesToProcess) override; | 51 void process(size_t framesToProcess) override; |
| 52 | 52 |
| 53 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. | 53 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. |
| 54 void setBuffer(AudioBuffer*, ExceptionState&); | 54 void setBuffer(AudioBuffer*, ExceptionState&); |
| 55 AudioBuffer* buffer() { return m_buffer.get(); } | 55 AudioBuffer* buffer() { return m_buffer.get(); } |
| 56 | 56 |
| 57 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. | 57 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. |
| 58 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. | 58 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. |
| 59 unsigned numberOfChannels(); | 59 unsigned numberOfChannels(); |
| 60 | 60 |
| 61 // Play-state | 61 // Play-state |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 double loopStart() const { return m_loopStart; } | 73 double loopStart() const { return m_loopStart; } |
| 74 double loopEnd() const { return m_loopEnd; } | 74 double loopEnd() const { return m_loopEnd; } |
| 75 void setLoopStart(double loopStart) { m_loopStart = loopStart; } | 75 void setLoopStart(double loopStart) { m_loopStart = loopStart; } |
| 76 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } | 76 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } |
| 77 | 77 |
| 78 // If a panner node is set, then we can incorporate doppler shift into the p
layback pitch rate. | 78 // If a panner node is set, then we can incorporate doppler shift into the p
layback pitch rate. |
| 79 void setPannerNode(PannerHandler*); | 79 void setPannerNode(PannerHandler*); |
| 80 void clearPannerNode(); | 80 void clearPannerNode(); |
| 81 | 81 |
| 82 // If we are no longer playing, propogate silence ahead to downstream nodes. | 82 // If we are no longer playing, propogate silence ahead to downstream nodes. |
| 83 virtual bool propagatesSilence() const override; | 83 bool propagatesSilence() const override; |
| 84 | 84 |
| 85 // AudioScheduledSourceNode | 85 // AudioScheduledSourceNode |
| 86 virtual void finish() override; | 86 void finish() override; |
| 87 | 87 |
| 88 void handleStoppableSourceNode(); | 88 void handleStoppableSourceNode(); |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 AudioBufferSourceHandler(AudioNode&, float sampleRate, AudioParamHandler& pl
aybackRate, AudioParamHandler& detune); | 91 AudioBufferSourceHandler(AudioNode&, float sampleRate, AudioParamHandler& pl
aybackRate, AudioParamHandler& detune); |
| 92 void startSource(double when, double grainOffset, double grainDuration, bool
isDurationGiven, ExceptionState&); | 92 void startSource(double when, double grainOffset, double grainDuration, bool
isDurationGiven, ExceptionState&); |
| 93 | 93 |
| 94 // Returns true on success. | 94 // Returns true on success. |
| 95 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); | 95 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); |
| 96 | 96 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 private: | 179 private: |
| 180 AudioBufferSourceNode(AudioContext&, float sampleRate); | 180 AudioBufferSourceNode(AudioContext&, float sampleRate); |
| 181 | 181 |
| 182 Member<AudioParam> m_playbackRate; | 182 Member<AudioParam> m_playbackRate; |
| 183 Member<AudioParam> m_detune; | 183 Member<AudioParam> m_detune; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 } // namespace blink | 186 } // namespace blink |
| 187 | 187 |
| 188 #endif // AudioBufferSourceNode_h | 188 #endif // AudioBufferSourceNode_h |
| OLD | NEW |