| 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; |
| 40 |
| 39 // PannerNode is an AudioNode with one input and one output. | 41 // PannerNode is an AudioNode with one input and one output. |
| 40 // 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. |
| 41 // 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. |
| 42 // 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. |
| 43 // 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. |
| 44 // All of these effects follow the OpenAL specification very closely. | 46 // All of these effects follow the OpenAL specification very closely. |
| 45 | 47 |
| 46 class PannerHandler final : public AudioHandler { | 48 class PannerHandler final : public AudioHandler { |
| 47 public: | 49 public: |
| 48 // These enums are used to distinguish what cached values of panner are dirt
y. | 50 // These enums are used to distinguish what cached values of panner are dirt
y. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 double dopplerRate(); | 100 double dopplerRate(); |
| 99 | 101 |
| 100 double tailTime() const override { return m_panner ? m_panner->tailTime() :
0; } | 102 double tailTime() const override { return m_panner ? m_panner->tailTime() :
0; } |
| 101 double latencyTime() const override { return m_panner ? m_panner->latencyTim
e() : 0; } | 103 double latencyTime() const override { return m_panner ? m_panner->latencyTim
e() : 0; } |
| 102 | 104 |
| 103 void setChannelCount(unsigned long, ExceptionState&) final; | 105 void setChannelCount(unsigned long, ExceptionState&) final; |
| 104 void setChannelCountMode(const String&, ExceptionState&) final; | 106 void setChannelCountMode(const String&, ExceptionState&) final; |
| 105 | 107 |
| 106 private: | 108 private: |
| 107 PannerHandler(AudioNode&, float sampleRate); | 109 PannerHandler(AudioNode&, float sampleRate); |
| 108 // AudioContext's listener | 110 // AbstractAudioContext's listener |
| 109 AudioListener* listener(); | 111 AudioListener* listener(); |
| 110 | 112 |
| 111 bool setPanningModel(unsigned); // Returns true on success. | 113 bool setPanningModel(unsigned); // Returns true on success. |
| 112 bool setDistanceModel(unsigned); // Returns true on success. | 114 bool setDistanceModel(unsigned); // Returns true on success. |
| 113 | 115 |
| 114 void calculateAzimuthElevation(double* outAzimuth, double* outElevation); | 116 void calculateAzimuthElevation(double* outAzimuth, double* outElevation); |
| 115 float calculateDistanceConeGain(); // Returns the combined distance and cone
gain attenuation. | 117 float calculateDistanceConeGain(); // Returns the combined distance and cone
gain attenuation. |
| 116 double calculateDopplerRate(); | 118 double calculateDopplerRate(); |
| 117 | 119 |
| 118 void azimuthElevation(double* outAzimuth, double* outElevation); | 120 void azimuthElevation(double* outAzimuth, double* outElevation); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 149 float m_cachedDistanceConeGain; | 151 float m_cachedDistanceConeGain; |
| 150 double m_cachedDopplerRate; | 152 double m_cachedDopplerRate; |
| 151 | 153 |
| 152 // Synchronize process() with setting of the panning model, source's locatio
n information, listener, distance parameters and sound cones. | 154 // Synchronize process() with setting of the panning model, source's locatio
n information, listener, distance parameters and sound cones. |
| 153 mutable Mutex m_processLock; | 155 mutable Mutex m_processLock; |
| 154 }; | 156 }; |
| 155 | 157 |
| 156 class PannerNode final : public AudioNode { | 158 class PannerNode final : public AudioNode { |
| 157 DEFINE_WRAPPERTYPEINFO(); | 159 DEFINE_WRAPPERTYPEINFO(); |
| 158 public: | 160 public: |
| 159 static PannerNode* create(AudioContext&, float sampleRate); | 161 static PannerNode* create(AbstractAudioContext&, float sampleRate); |
| 160 PannerHandler& pannerHandler() const; | 162 PannerHandler& pannerHandler() const; |
| 161 | 163 |
| 162 String panningModel() const; | 164 String panningModel() const; |
| 163 void setPanningModel(const String&); | 165 void setPanningModel(const String&); |
| 164 void setPosition(float x, float y, float z); | 166 void setPosition(float x, float y, float z); |
| 165 void setOrientation(float x, float y, float z); | 167 void setOrientation(float x, float y, float z); |
| 166 void setVelocity(float x, float y, float z); | 168 void setVelocity(float x, float y, float z); |
| 167 String distanceModel() const; | 169 String distanceModel() const; |
| 168 void setDistanceModel(const String&); | 170 void setDistanceModel(const String&); |
| 169 double refDistance() const; | 171 double refDistance() const; |
| 170 void setRefDistance(double); | 172 void setRefDistance(double); |
| 171 double maxDistance() const; | 173 double maxDistance() const; |
| 172 void setMaxDistance(double); | 174 void setMaxDistance(double); |
| 173 double rolloffFactor() const; | 175 double rolloffFactor() const; |
| 174 void setRolloffFactor(double); | 176 void setRolloffFactor(double); |
| 175 double coneInnerAngle() const; | 177 double coneInnerAngle() const; |
| 176 void setConeInnerAngle(double); | 178 void setConeInnerAngle(double); |
| 177 double coneOuterAngle() const; | 179 double coneOuterAngle() const; |
| 178 void setConeOuterAngle(double); | 180 void setConeOuterAngle(double); |
| 179 double coneOuterGain() const; | 181 double coneOuterGain() const; |
| 180 void setConeOuterGain(double); | 182 void setConeOuterGain(double); |
| 181 | 183 |
| 182 private: | 184 private: |
| 183 PannerNode(AudioContext&, float sampleRate); | 185 PannerNode(AbstractAudioContext&, float sampleRate); |
| 184 }; | 186 }; |
| 185 | 187 |
| 186 } // namespace blink | 188 } // namespace blink |
| 187 | 189 |
| 188 #endif // PannerNode_h | 190 #endif // PannerNode_h |
| OLD | NEW |