| 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 18 matching lines...) Expand all Loading... |
| 29 #include "modules/webaudio/AudioNode.h" | 29 #include "modules/webaudio/AudioNode.h" |
| 30 #include "platform/audio/AudioBus.h" | 30 #include "platform/audio/AudioBus.h" |
| 31 #include "platform/audio/Cone.h" | 31 #include "platform/audio/Cone.h" |
| 32 #include "platform/audio/Distance.h" | 32 #include "platform/audio/Distance.h" |
| 33 #include "platform/audio/Panner.h" | 33 #include "platform/audio/Panner.h" |
| 34 #include "platform/geometry/FloatPoint3D.h" | 34 #include "platform/geometry/FloatPoint3D.h" |
| 35 #include "wtf/HashMap.h" | 35 #include "wtf/HashMap.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class AbstractAudioContext; | 39 class BaseAudioContext; |
| 40 | 40 |
| 41 // PannerNode is an AudioNode with one input and one output. | 41 // PannerNode is an AudioNode with one input and one output. |
| 42 // It positions a sound in 3D space, with the exact effect dependent on the pann
ing model. | 42 // It positions a sound in 3D space, with the exact effect dependent on the pann
ing model. |
| 43 // It has a position and an orientation in 3D space which is relative to the pos
ition and orientation of the context's AudioListener. | 43 // It has a position and an orientation in 3D space which is relative to the pos
ition and orientation of the context's AudioListener. |
| 44 // A distance effect will attenuate the gain as the position moves away from the
listener. | 44 // A distance effect will attenuate the gain as the position moves away from the
listener. |
| 45 // A cone effect will attenuate the gain as the orientation moves away from the
listener. | 45 // A cone effect will attenuate the gain as the orientation moves away from the
listener. |
| 46 // All of these effects follow the OpenAL specification very closely. | 46 // All of these effects follow the OpenAL specification very closely. |
| 47 | 47 |
| 48 class PannerHandler final : public AudioHandler { | 48 class PannerHandler final : public AudioHandler { |
| 49 public: | 49 public: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void markPannerAsDirty(unsigned); | 95 void markPannerAsDirty(unsigned); |
| 96 | 96 |
| 97 double tailTime() const override { return m_panner ? m_panner->tailTime() :
0; } | 97 double tailTime() const override { return m_panner ? m_panner->tailTime() :
0; } |
| 98 double latencyTime() const override { return m_panner ? m_panner->latencyTim
e() : 0; } | 98 double latencyTime() const override { return m_panner ? m_panner->latencyTim
e() : 0; } |
| 99 | 99 |
| 100 void setChannelCount(unsigned long, ExceptionState&) final; | 100 void setChannelCount(unsigned long, ExceptionState&) final; |
| 101 void setChannelCountMode(const String&, ExceptionState&) final; | 101 void setChannelCountMode(const String&, ExceptionState&) final; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 PannerHandler(AudioNode&, float sampleRate); | 104 PannerHandler(AudioNode&, float sampleRate); |
| 105 // AbstractAudioContext's listener | 105 // BaseAudioContext's listener |
| 106 AudioListener* listener(); | 106 AudioListener* listener(); |
| 107 | 107 |
| 108 bool setPanningModel(unsigned); // Returns true on success. | 108 bool setPanningModel(unsigned); // Returns true on success. |
| 109 bool setDistanceModel(unsigned); // Returns true on success. | 109 bool setDistanceModel(unsigned); // Returns true on success. |
| 110 | 110 |
| 111 void calculateAzimuthElevation(double* outAzimuth, double* outElevation); | 111 void calculateAzimuthElevation(double* outAzimuth, double* outElevation); |
| 112 float calculateDistanceConeGain(); // Returns the combined distance and cone
gain attenuation. | 112 float calculateDistanceConeGain(); // Returns the combined distance and cone
gain attenuation. |
| 113 | 113 |
| 114 void azimuthElevation(double* outAzimuth, double* outElevation); | 114 void azimuthElevation(double* outAzimuth, double* outElevation); |
| 115 float distanceConeGain(); | 115 float distanceConeGain(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 141 double m_cachedElevation; | 141 double m_cachedElevation; |
| 142 float m_cachedDistanceConeGain; | 142 float m_cachedDistanceConeGain; |
| 143 | 143 |
| 144 // Synchronize process() with setting of the panning model, source's locatio
n information, listener, distance parameters and sound cones. | 144 // Synchronize process() with setting of the panning model, source's locatio
n information, listener, distance parameters and sound cones. |
| 145 mutable Mutex m_processLock; | 145 mutable Mutex m_processLock; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 class PannerNode final : public AudioNode { | 148 class PannerNode final : public AudioNode { |
| 149 DEFINE_WRAPPERTYPEINFO(); | 149 DEFINE_WRAPPERTYPEINFO(); |
| 150 public: | 150 public: |
| 151 static PannerNode* create(AbstractAudioContext&, float sampleRate); | 151 static PannerNode* create(BaseAudioContext&, float sampleRate); |
| 152 PannerHandler& pannerHandler() const; | 152 PannerHandler& pannerHandler() const; |
| 153 | 153 |
| 154 String panningModel() const; | 154 String panningModel() const; |
| 155 void setPanningModel(const String&); | 155 void setPanningModel(const String&); |
| 156 void setPosition(float x, float y, float z); | 156 void setPosition(float x, float y, float z); |
| 157 void setOrientation(float x, float y, float z); | 157 void setOrientation(float x, float y, float z); |
| 158 void setVelocity(float x, float y, float z); | 158 void setVelocity(float x, float y, float z); |
| 159 String distanceModel() const; | 159 String distanceModel() const; |
| 160 void setDistanceModel(const String&); | 160 void setDistanceModel(const String&); |
| 161 double refDistance() const; | 161 double refDistance() const; |
| 162 void setRefDistance(double); | 162 void setRefDistance(double); |
| 163 double maxDistance() const; | 163 double maxDistance() const; |
| 164 void setMaxDistance(double); | 164 void setMaxDistance(double); |
| 165 double rolloffFactor() const; | 165 double rolloffFactor() const; |
| 166 void setRolloffFactor(double); | 166 void setRolloffFactor(double); |
| 167 double coneInnerAngle() const; | 167 double coneInnerAngle() const; |
| 168 void setConeInnerAngle(double); | 168 void setConeInnerAngle(double); |
| 169 double coneOuterAngle() const; | 169 double coneOuterAngle() const; |
| 170 void setConeOuterAngle(double); | 170 void setConeOuterAngle(double); |
| 171 double coneOuterGain() const; | 171 double coneOuterGain() const; |
| 172 void setConeOuterGain(double); | 172 void setConeOuterGain(double); |
| 173 | 173 |
| 174 private: | 174 private: |
| 175 PannerNode(AbstractAudioContext&, float sampleRate); | 175 PannerNode(BaseAudioContext&, float sampleRate); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace blink | 178 } // namespace blink |
| 179 | 179 |
| 180 #endif // PannerNode_h | 180 #endif // PannerNode_h |
| OLD | NEW |