[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

crogers at google.com crogers at google.com
Wed Dec 22 14:11:11 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7a8b3074baa79fb270de1e4152e846f4aa3eae05
Author: crogers at google.com <crogers at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 5 08:13:18 2010 +0000

    2010-10-05  Chris Rogers  <crogers at google.com>
    
            Reviewed by Kenneth Russell.
    
            Add AudioPannerNode files
            https://bugs.webkit.org/show_bug.cgi?id=46505
    
            No new tests since audio API is not yet implemented.
    
            * webaudio/AudioPannerNode.cpp: Added.
            (WebCore::fixNANs):
            (WebCore::AudioPannerNode::AudioPannerNode):
            (WebCore::AudioPannerNode::~AudioPannerNode):
            (WebCore::AudioPannerNode::pullInputs):
            (WebCore::AudioPannerNode::process):
            (WebCore::AudioPannerNode::reset):
            (WebCore::AudioPannerNode::initialize):
            (WebCore::AudioPannerNode::uninitialize):
            (WebCore::AudioPannerNode::listener):
            (WebCore::AudioPannerNode::setPanningModel):
            (WebCore::AudioPannerNode::getAzimuthElevation):
            (WebCore::AudioPannerNode::dopplerRate):
            (WebCore::AudioPannerNode::distanceConeGain):
            (WebCore::AudioPannerNode::notifyAudioSourcesConnectedToNode):
            * webaudio/AudioPannerNode.h: Added.
            (WebCore::AudioPannerNode::create):
            (WebCore::AudioPannerNode::panningModel):
            (WebCore::AudioPannerNode::position):
            (WebCore::AudioPannerNode::setPosition):
            (WebCore::AudioPannerNode::orientation):
            (WebCore::AudioPannerNode::setOrientation):
            (WebCore::AudioPannerNode::velocity):
            (WebCore::AudioPannerNode::setVelocity):
            (WebCore::AudioPannerNode::distanceModel):
            (WebCore::AudioPannerNode::setDistanceModel):
            (WebCore::AudioPannerNode::refDistance):
            (WebCore::AudioPannerNode::setRefDistance):
            (WebCore::AudioPannerNode::maxDistance):
            (WebCore::AudioPannerNode::setMaxDistance):
            (WebCore::AudioPannerNode::rolloffFactor):
            (WebCore::AudioPannerNode::setRolloffFactor):
            (WebCore::AudioPannerNode::coneInnerAngle):
            (WebCore::AudioPannerNode::setConeInnerAngle):
            (WebCore::AudioPannerNode::coneOuterAngle):
            (WebCore::AudioPannerNode::setConeOuterAngle):
            (WebCore::AudioPannerNode::coneOuterGain):
            (WebCore::AudioPannerNode::setConeOuterGain):
            (WebCore::AudioPannerNode::distanceGain):
            (WebCore::AudioPannerNode::coneGain):
            * webaudio/AudioPannerNode.idl: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69093 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2cf3a58..ee5f11d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,54 @@
+2010-10-05  Chris Rogers  <crogers at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        Add AudioPannerNode files
+        https://bugs.webkit.org/show_bug.cgi?id=46505
+
+        No new tests since audio API is not yet implemented.
+
+        * webaudio/AudioPannerNode.cpp: Added.
+        (WebCore::fixNANs):
+        (WebCore::AudioPannerNode::AudioPannerNode):
+        (WebCore::AudioPannerNode::~AudioPannerNode):
+        (WebCore::AudioPannerNode::pullInputs):
+        (WebCore::AudioPannerNode::process):
+        (WebCore::AudioPannerNode::reset):
+        (WebCore::AudioPannerNode::initialize):
+        (WebCore::AudioPannerNode::uninitialize):
+        (WebCore::AudioPannerNode::listener):
+        (WebCore::AudioPannerNode::setPanningModel):
+        (WebCore::AudioPannerNode::getAzimuthElevation):
+        (WebCore::AudioPannerNode::dopplerRate):
+        (WebCore::AudioPannerNode::distanceConeGain):
+        (WebCore::AudioPannerNode::notifyAudioSourcesConnectedToNode):
+        * webaudio/AudioPannerNode.h: Added.
+        (WebCore::AudioPannerNode::create):
+        (WebCore::AudioPannerNode::panningModel):
+        (WebCore::AudioPannerNode::position):
+        (WebCore::AudioPannerNode::setPosition):
+        (WebCore::AudioPannerNode::orientation):
+        (WebCore::AudioPannerNode::setOrientation):
+        (WebCore::AudioPannerNode::velocity):
+        (WebCore::AudioPannerNode::setVelocity):
+        (WebCore::AudioPannerNode::distanceModel):
+        (WebCore::AudioPannerNode::setDistanceModel):
+        (WebCore::AudioPannerNode::refDistance):
+        (WebCore::AudioPannerNode::setRefDistance):
+        (WebCore::AudioPannerNode::maxDistance):
+        (WebCore::AudioPannerNode::setMaxDistance):
+        (WebCore::AudioPannerNode::rolloffFactor):
+        (WebCore::AudioPannerNode::setRolloffFactor):
+        (WebCore::AudioPannerNode::coneInnerAngle):
+        (WebCore::AudioPannerNode::setConeInnerAngle):
+        (WebCore::AudioPannerNode::coneOuterAngle):
+        (WebCore::AudioPannerNode::setConeOuterAngle):
+        (WebCore::AudioPannerNode::coneOuterGain):
+        (WebCore::AudioPannerNode::setConeOuterGain):
+        (WebCore::AudioPannerNode::distanceGain):
+        (WebCore::AudioPannerNode::coneGain):
+        * webaudio/AudioPannerNode.idl: Added.
+
 2010-10-04  Alejandro G. Castro  <alex at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebCore/webaudio/AudioPannerNode.cpp b/WebCore/webaudio/AudioPannerNode.cpp
new file mode 100644
index 0000000..b7282e3
--- /dev/null
+++ b/WebCore/webaudio/AudioPannerNode.cpp
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "AudioPannerNode.h"
+
+#include "AudioBufferSourceNode.h"
+#include "AudioBus.h"
+#include "AudioContext.h"
+#include "AudioNodeInput.h"
+#include "AudioNodeOutput.h"
+#include "HRTFPanner.h"
+#include <wtf/MathExtras.h>
+
+using namespace std;
+
+namespace WebCore {
+
+static void fixNANs(double &x)
+{
+    if (isnan(x) || isinf(x))
+        x = 0.0;
+}
+
+AudioPannerNode::AudioPannerNode(AudioContext* context, double sampleRate)
+    : AudioNode(context, sampleRate)
+    , m_panningModel(Panner::PanningModelHRTF)
+    , m_lastGain(-1.0)
+    , m_connectionCount(0)
+{
+    addInput(adoptPtr(new AudioNodeInput(this)));
+    addOutput(adoptPtr(new AudioNodeOutput(this, 2)));
+    
+    m_distanceGain = AudioGain::create("distanceGain", 1.0, 0.0, 1.0);
+    m_coneGain = AudioGain::create("coneGain", 1.0, 0.0, 1.0);
+
+    m_position = Vector3(0, 0, 0);
+    m_orientation = Vector3(1, 0, 0);
+    m_velocity = Vector3(0, 0, 0);
+    
+    setType(NodeTypePanner);
+
+    initialize();
+}
+
+AudioPannerNode::~AudioPannerNode()
+{
+    uninitialize();
+}
+
+void AudioPannerNode::pullInputs(size_t framesToProcess)
+{
+    // We override pullInputs(), so we can detect new AudioSourceNodes which have connected to us when new connections are made.
+    // These AudioSourceNodes need to be made aware of our existence in order to handle doppler shift pitch changes.
+    if (m_connectionCount != context()->connectionCount()) {
+        m_connectionCount = context()->connectionCount();
+
+        // Recursively go through all nodes connected to us.
+        notifyAudioSourcesConnectedToNode(this);
+    }
+    
+    AudioNode::pullInputs(framesToProcess);
+}
+
+void AudioPannerNode::process(size_t framesToProcess)
+{
+    AudioBus* destination = output(0)->bus();
+
+    if (!isInitialized() || !input(0)->isConnected() || !m_panner.get()) {
+        destination->zero();
+        return;
+    }
+
+    AudioBus* source = input(0)->bus();
+
+    if (!source) {
+        destination->zero();
+        return;
+    }
+
+    // Apply the panning effect.
+    double azimuth;
+    double elevation;
+    getAzimuthElevation(&azimuth, &elevation);
+    m_panner->pan(azimuth, elevation, source, destination, framesToProcess);
+
+    // Get the distance and cone gain.
+    double totalGain = distanceConeGain();
+
+    // Snap to desired gain at the beginning.
+    if (m_lastGain == -1.0)
+        m_lastGain = totalGain;
+        
+    // Apply gain in-place with de-zippering.
+    destination->copyWithGainFrom(*destination, &m_lastGain, totalGain);
+}
+
+void AudioPannerNode::reset()
+{
+    m_lastGain = -1.0; // force to snap to initial gain
+    if (m_panner.get())
+        m_panner->reset();
+}
+
+void AudioPannerNode::initialize()
+{
+    if (isInitialized())
+        return;
+        
+    m_panner = Panner::create(m_panningModel, sampleRate());
+
+    AudioNode::initialize();
+}
+
+void AudioPannerNode::uninitialize()
+{
+    if (!isInitialized())
+        return;
+        
+    m_panner.clear();
+    AudioNode::uninitialize();
+}
+
+AudioListener* AudioPannerNode::listener()
+{
+    return context()->listener();
+}
+
+void AudioPannerNode::setPanningModel(unsigned short model)
+{
+    if (!m_panner.get() || model != m_panningModel) {
+        OwnPtr<Panner> newPanner = Panner::create(model, sampleRate());
+        m_panner = newPanner.release();
+    }
+}
+
+void AudioPannerNode::getAzimuthElevation(double* outAzimuth, double* outElevation)
+{
+    // FIXME: we should cache azimuth and elevation (if possible), so we only re-calculate if a change has been made.
+
+    double azimuth = 0.0;
+
+    // Calculate the source-listener vector
+    Vector3 listenerPosition = listener()->position();
+    Vector3 sourceListener = m_position - listenerPosition;
+
+    if (sourceListener.isZero()) {
+        // degenerate case if source and listener are at the same point
+        *outAzimuth = 0.0;
+        *outElevation = 0.0;
+        return;
+    }
+
+    sourceListener.normalize();
+
+    // Align axes
+    Vector3 listenerFront = listener()->orientation();
+    Vector3 listenerUp = listener()->upVector();
+    Vector3 listenerRight = cross(listenerFront, listenerUp);
+    listenerRight.normalize();
+
+    Vector3 listenerFrontNorm = listenerFront;
+    listenerFrontNorm.normalize();
+
+    Vector3 up = cross(listenerRight, listenerFrontNorm);
+
+    double upProjection = dot(sourceListener, up);
+
+    Vector3 projectedSource = sourceListener - upProjection * up;
+    projectedSource.normalize();
+
+    azimuth = 180.0 * acos(dot(projectedSource, listenerRight)) / M_PI;
+    fixNANs(azimuth); // avoid illegal values
+
+    // Source  in front or behind the listener
+    double frontBack = dot(projectedSource, listenerFrontNorm);
+    if (frontBack < 0.0)
+        azimuth = 360.0 - azimuth;
+
+    // Make azimuth relative to "front" and not "right" listener vector
+    if ((azimuth >= 0.0) && (azimuth <= 270.0))
+        azimuth = 90.0 - azimuth;
+    else
+        azimuth = 450.0 - azimuth;
+
+    // Elevation
+    double elevation = 90.0 - 180.0 * acos(dot(sourceListener, up)) / M_PI;
+    fixNANs(azimuth); // avoid illegal values
+
+    if (elevation > 90.0)
+        elevation = 180.0 - elevation;
+    else if (elevation < -90.0)
+        elevation = -180.0 - elevation;
+
+    if (outAzimuth)
+        *outAzimuth = azimuth;
+    if (outElevation)
+        *outElevation = elevation;
+}
+
+float AudioPannerNode::dopplerRate()
+{
+    double dopplerShift = 1.0;
+
+    // FIXME: optimize for case when neither source nor listener has changed...
+    double dopplerFactor = listener()->dopplerFactor();
+
+    if (dopplerFactor > 0.0) {
+        double speedOfSound = listener()->speedOfSound();
+
+        const Vector3 &sourceVelocity = m_velocity;
+        const Vector3 &listenerVelocity = listener()->velocity();
+
+        // Don't bother if both source and listener have no velocity
+        bool sourceHasVelocity = !sourceVelocity.isZero();
+        bool listenerHasVelocity = !listenerVelocity.isZero();
+
+        if (sourceHasVelocity || listenerHasVelocity) {
+            // Calculate the source to listener vector
+            Vector3 listenerPosition = listener()->position();
+            Vector3 sourceToListener = m_position - listenerPosition;
+
+            double sourceListenerMagnitude = sourceToListener.abs();
+
+            double listenerProjection = dot(sourceToListener, listenerVelocity) / sourceListenerMagnitude;
+            double sourceProjection = dot(sourceToListener, sourceVelocity) / sourceListenerMagnitude;
+
+            listenerProjection = -listenerProjection;
+            sourceProjection = -sourceProjection;
+
+            double scaledSpeedOfSound = speedOfSound / dopplerFactor;
+            listenerProjection = min(listenerProjection, scaledSpeedOfSound);
+            sourceProjection = min(sourceProjection, scaledSpeedOfSound);
+
+            dopplerShift = ((speedOfSound - dopplerFactor * listenerProjection) / (speedOfSound - dopplerFactor * sourceProjection));
+            fixNANs(dopplerShift); // avoid illegal values
+
+            // Limit the pitch shifting to 4 octaves up and 3 octaves down.
+            if (dopplerShift > 16.0)
+                dopplerShift = 16.0;
+            else if (dopplerShift < 0.125)
+                dopplerShift = 0.125;   
+        }
+    }
+
+    return static_cast<float>(dopplerShift);
+}
+
+float AudioPannerNode::distanceConeGain()
+{
+    Vector3 listenerPosition = listener()->position();
+
+    double listenerDistance = distance(m_position, listenerPosition);
+    double distanceGain = m_distanceEffect.gain(listenerDistance);
+    
+    m_distanceGain->setValue(static_cast<float>(distanceGain));
+
+    // FIXME: could optimize by caching coneGain
+    double coneGain = m_coneEffect.gain(m_position, m_orientation, listenerPosition);
+    
+    m_coneGain->setValue(static_cast<float>(coneGain));
+
+    return float(distanceGain * coneGain);
+}
+
+void AudioPannerNode::notifyAudioSourcesConnectedToNode(AudioNode* node)
+{
+    ASSERT(node);
+    if (!node)
+        return;
+        
+    // First check if this node is an AudioBufferSourceNode.  If so, let it know about us so that doppler shift pitch can be taken into account.
+    if (node->type() == NodeTypeAudioBufferSource) {
+        AudioBufferSourceNode* bufferSourceNode = reinterpret_cast<AudioBufferSourceNode*>(node);
+        bufferSourceNode->setPannerNode(this);
+    } else {    
+        // Go through all inputs to this node.
+        for (unsigned i = 0; i < node->numberOfInputs(); ++i) {
+            AudioNodeInput* input = node->input(i);
+
+            // For each input, go through all of its connections, looking for AudioBufferSourceNodes.
+            for (unsigned j = 0; j < input->numberOfConnections(); ++j) {
+                AudioNodeOutput* connectedOutput = input->output(j);
+                AudioNode* connectedNode = connectedOutput->node();
+                notifyAudioSourcesConnectedToNode(connectedNode); // recurse
+            }
+        }
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
diff --git a/WebCore/webaudio/AudioPannerNode.h b/WebCore/webaudio/AudioPannerNode.h
new file mode 100644
index 0000000..144b61b
--- /dev/null
+++ b/WebCore/webaudio/AudioPannerNode.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AudioPannerNode_h
+#define AudioPannerNode_h
+
+#include "AudioBus.h"
+#include "AudioGain.h"
+#include "AudioListener.h"
+#include "AudioNode.h"
+#include "Cone.h"
+#include "Distance.h"
+#include "Panner.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/Vector3.h>
+
+namespace WebCore {
+
+// AudioPannerNode is an AudioNode with one input and one output.
+// It positions a sound in 3D space, with the exact effect dependent on the panning model.
+// It has a position and an orientation in 3D space which is relative to the position and orientation of the context's AudioListener.
+// A distance effect will attenuate the gain as the position moves away from the listener.
+// A cone effect will attenuate the gain as the orientation moves away from the listener.
+// All of these effects follow the OpenAL specification very closely.
+
+class AudioPannerNode : public AudioNode {
+public:
+    enum {
+        PASSTHROUGH = 0,
+        EQUALPOWER = 1,
+        HRTF = 2,
+        SOUNDFIELD = 3,
+        MATRIXMIX = 4
+    };
+
+    static PassRefPtr<AudioPannerNode> create(AudioContext* context, double sampleRate)
+    {
+        return adoptRef(new AudioPannerNode(context, sampleRate));
+    }
+
+    virtual ~AudioPannerNode();
+
+    // AudioNode
+    virtual void process(size_t framesToProcess);
+    virtual void pullInputs(size_t framesToProcess);
+    virtual void reset();
+    virtual void initialize();
+    virtual void uninitialize();
+
+    // Listener
+    AudioListener* listener();
+
+    // Panning model
+    unsigned short panningModel() const { return m_panningModel; }
+    void setPanningModel(unsigned short);
+
+    // Position
+    Vector3 position() const { return m_position; }
+    void setPosition(float x, float y, float z) { m_position = Vector3(x, y, z); }
+
+    // Orientation
+    Vector3 orientation() const { return m_position; }
+    void setOrientation(float x, float y, float z) { m_orientation = Vector3(x, y, z); }
+
+    // Velocity
+    Vector3 velocity() const { return m_velocity; }
+    void setVelocity(float x, float y, float z) { m_velocity = Vector3(x, y, z); }
+
+    // Distance parameters
+    unsigned short distanceModel() { return m_distanceEffect.model(); }
+    void setDistanceModel(unsigned short model) { m_distanceEffect.setModel(static_cast<DistanceEffect::ModelType>(model), true); }
+    
+    float refDistance() { return static_cast<float>(m_distanceEffect.refDistance()); }
+    void setRefDistance(float refDistance) { m_distanceEffect.setRefDistance(refDistance); }
+
+    float maxDistance() { return static_cast<float>(m_distanceEffect.maxDistance()); }
+    void setMaxDistance(float maxDistance) { m_distanceEffect.setMaxDistance(maxDistance); }
+
+    float rolloffFactor() { return static_cast<float>(m_distanceEffect.rolloffFactor()); }
+    void setRolloffFactor(float rolloffFactor) { m_distanceEffect.setRolloffFactor(rolloffFactor); }
+
+    // Sound cones - angles in degrees
+    float coneInnerAngle() const { return static_cast<float>(m_coneEffect.innerAngle()); }
+    void setConeInnerAngle(float angle) { m_coneEffect.setInnerAngle(angle); }
+
+    float coneOuterAngle() const { return static_cast<float>(m_coneEffect.outerAngle()); }
+    void setConeOuterAngle(float angle) { m_coneEffect.setOuterAngle(angle); }
+
+    float coneOuterGain() const { return static_cast<float>(m_coneEffect.outerGain()); }
+    void setConeOuterGain(float angle) { m_coneEffect.setOuterGain(angle); }
+
+    void getAzimuthElevation(double* outAzimuth, double* outElevation);
+    float dopplerRate();
+
+    // Accessors for dynamically calculated gain values.
+    AudioGain* distanceGain() { return m_distanceGain.get(); }                                        
+    AudioGain* coneGain() { return m_coneGain.get(); }                                        
+
+private:
+    AudioPannerNode(AudioContext*, double sampleRate);
+
+    // Returns the combined distance and cone gain attenuation.
+    float distanceConeGain();
+
+    // Notifies any AudioBufferSourceNodes connected to us either directly or indirectly about our existence.
+    // This is in order to handle the pitch change necessary for the doppler shift.
+    void notifyAudioSourcesConnectedToNode(AudioNode*);
+
+    OwnPtr<Panner> m_panner;
+    unsigned m_panningModel;
+
+    // FIXME: upgrade to FloatPoint3D from Vector3.
+    Vector3 m_position;
+    Vector3 m_orientation;
+    Vector3 m_velocity;
+
+    // Gain
+    RefPtr<AudioGain> m_distanceGain;
+    RefPtr<AudioGain> m_coneGain;
+    DistanceEffect m_distanceEffect;
+    ConeEffect m_coneEffect;
+    double m_lastGain;
+
+    unsigned m_connectionCount;
+};
+
+} // namespace WebCore
+
+#endif // AudioPannerNode_h
diff --git a/WebCore/webaudio/AudioPannerNode.idl b/WebCore/webaudio/AudioPannerNode.idl
new file mode 100644
index 0000000..eb6db40
--- /dev/null
+++ b/WebCore/webaudio/AudioPannerNode.idl
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module audio {
+    interface [
+        Conditional=WEB_AUDIO,
+        GenerateConstructor,
+        GenerateToJS
+    ] AudioPannerNode : AudioNode {
+        // Panning model
+        const unsigned short PASSTHROUGH = 0;
+        const unsigned short EQUALPOWER = 1;
+        const unsigned short HRTF = 2;
+        const unsigned short SOUNDFIELD = 3;
+
+        // Default model for stereo is HRTF 
+        attribute unsigned long panningModel; // FIXME: use unsigned short when glue generation supports it
+
+        // Uses a 3D cartesian coordinate system 
+        void setPosition(in float x, in float y, in float z);
+        void setOrientation(in float x, in float y, in float z);
+        void setVelocity(in float x, in float y, in float z);
+
+        // Distance model
+        attribute unsigned long distanceModel; // FIXME: use unsigned short when glue generation supports it
+        attribute float refDistance;
+        attribute float maxDistance;
+        attribute float rolloffFactor;
+
+        // Directional sound cone
+        attribute float coneInnerAngle;
+        attribute float coneOuterAngle;
+        attribute float coneOuterGain;
+
+        // Dynamically calculated gain values          
+        readonly attribute AudioGain coneGain;
+        readonly attribute AudioGain distanceGain;
+    };
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list