2012-11-05 18:14:13 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef PannerNode_h_
|
|
|
|
#define PannerNode_h_
|
|
|
|
|
|
|
|
#include "AudioNode.h"
|
|
|
|
#include "AudioParam.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
2013-01-28 16:33:17 -08:00
|
|
|
#include "mozilla/TypedEnum.h"
|
2013-03-11 16:09:27 -07:00
|
|
|
#include "mozilla/dom/PannerNodeBinding.h"
|
2012-11-05 18:14:13 -08:00
|
|
|
#include "ThreeDPoint.h"
|
2013-03-12 16:28:30 -07:00
|
|
|
#include "mozilla/WeakPtr.h"
|
2012-11-05 18:14:13 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class AudioContext;
|
|
|
|
|
2013-03-12 16:28:30 -07:00
|
|
|
class PannerNode : public AudioNode,
|
|
|
|
public SupportsWeakPtr<PannerNode>
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit PannerNode(AudioContext* aContext);
|
2013-03-12 11:34:55 -07:00
|
|
|
virtual ~PannerNode();
|
2012-11-05 18:14:13 -08:00
|
|
|
|
2013-01-23 16:50:18 -08:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
|
2012-11-05 18:14:13 -08:00
|
|
|
|
2013-03-12 11:34:55 -07:00
|
|
|
virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
PanningModelType PanningModel() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
2013-03-11 16:09:27 -07:00
|
|
|
return mPanningModel;
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetPanningModel(PanningModelType aPanningModel)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
2013-03-11 16:09:27 -07:00
|
|
|
mPanningModel = aPanningModel;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendInt32ParameterToStream(PANNING_MODEL, int32_t(mPanningModel));
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
DistanceModelType DistanceModel() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
2013-03-11 16:09:27 -07:00
|
|
|
return mDistanceModel;
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetDistanceModel(DistanceModelType aDistanceModel)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
2013-03-11 16:09:27 -07:00
|
|
|
mDistanceModel = aDistanceModel;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendInt32ParameterToStream(DISTANCE_MODEL, int32_t(mDistanceModel));
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetPosition(double aX, double aY, double aZ)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mPosition.x = aX;
|
|
|
|
mPosition.y = aY;
|
|
|
|
mPosition.z = aZ;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendThreeDPointParameterToStream(POSITION, mPosition);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetOrientation(double aX, double aY, double aZ)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mOrientation.x = aX;
|
|
|
|
mOrientation.y = aY;
|
|
|
|
mOrientation.z = aZ;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendThreeDPointParameterToStream(ORIENTATION, mOrientation);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetVelocity(double aX, double aY, double aZ)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mVelocity.x = aX;
|
|
|
|
mVelocity.y = aY;
|
|
|
|
mVelocity.z = aZ;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendThreeDPointParameterToStream(VELOCITY, mVelocity);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
double RefDistance() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
return mRefDistance;
|
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetRefDistance(double aRefDistance)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mRefDistance = aRefDistance;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendDoubleParameterToStream(REF_DISTANCE, mRefDistance);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
double MaxDistance() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
return mMaxDistance;
|
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetMaxDistance(double aMaxDistance)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mMaxDistance = aMaxDistance;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendDoubleParameterToStream(MAX_DISTANCE, mMaxDistance);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
double RolloffFactor() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
return mRolloffFactor;
|
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetRolloffFactor(double aRolloffFactor)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mRolloffFactor = aRolloffFactor;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendDoubleParameterToStream(ROLLOFF_FACTOR, mRolloffFactor);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
double ConeInnerAngle() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
return mConeInnerAngle;
|
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetConeInnerAngle(double aConeInnerAngle)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mConeInnerAngle = aConeInnerAngle;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendDoubleParameterToStream(CONE_INNER_ANGLE, mConeInnerAngle);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
double ConeOuterAngle() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
return mConeOuterAngle;
|
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetConeOuterAngle(double aConeOuterAngle)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mConeOuterAngle = aConeOuterAngle;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendDoubleParameterToStream(CONE_OUTER_ANGLE, mConeOuterAngle);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:09:27 -07:00
|
|
|
double ConeOuterGain() const
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
return mConeOuterGain;
|
|
|
|
}
|
2013-03-11 16:09:27 -07:00
|
|
|
void SetConeOuterGain(double aConeOuterGain)
|
2012-11-05 18:14:13 -08:00
|
|
|
{
|
|
|
|
mConeOuterGain = aConeOuterGain;
|
2013-03-12 11:34:55 -07:00
|
|
|
SendDoubleParameterToStream(CONE_OUTER_GAIN, mConeOuterGain);
|
2012-11-05 18:14:13 -08:00
|
|
|
}
|
|
|
|
|
2013-03-12 11:34:55 -07:00
|
|
|
private:
|
|
|
|
friend class AudioListener;
|
|
|
|
friend class PannerNodeEngine;
|
|
|
|
enum EngineParameters {
|
|
|
|
LISTENER_POSITION,
|
|
|
|
LISTENER_ORIENTATION,
|
|
|
|
LISTENER_UPVECTOR,
|
|
|
|
LISTENER_VELOCITY,
|
|
|
|
LISTENER_DOPPLER_FACTOR,
|
|
|
|
LISTENER_SPEED_OF_SOUND,
|
|
|
|
PANNING_MODEL,
|
|
|
|
DISTANCE_MODEL,
|
|
|
|
POSITION,
|
|
|
|
ORIENTATION,
|
|
|
|
VELOCITY,
|
|
|
|
REF_DISTANCE,
|
|
|
|
MAX_DISTANCE,
|
|
|
|
ROLLOFF_FACTOR,
|
|
|
|
CONE_INNER_ANGLE,
|
|
|
|
CONE_OUTER_ANGLE,
|
|
|
|
CONE_OUTER_GAIN
|
|
|
|
};
|
|
|
|
|
2012-11-05 18:14:13 -08:00
|
|
|
private:
|
2013-03-11 16:09:27 -07:00
|
|
|
PanningModelType mPanningModel;
|
|
|
|
DistanceModelType mDistanceModel;
|
2012-11-05 18:14:13 -08:00
|
|
|
ThreeDPoint mPosition;
|
|
|
|
ThreeDPoint mOrientation;
|
|
|
|
ThreeDPoint mVelocity;
|
2013-03-11 16:09:27 -07:00
|
|
|
double mRefDistance;
|
|
|
|
double mMaxDistance;
|
|
|
|
double mRolloffFactor;
|
|
|
|
double mConeInnerAngle;
|
|
|
|
double mConeOuterAngle;
|
|
|
|
double mConeOuterGain;
|
2012-11-05 18:14:13 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|