mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1324659 - AudioParam.minValue/maxValue, r=padenot
This commit is contained in:
parent
60364b27c9
commit
7d3342df6b
@ -597,8 +597,8 @@ AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* aContext)
|
|||||||
, mLoopStart(0.0)
|
, mLoopStart(0.0)
|
||||||
, mLoopEnd(0.0)
|
, mLoopEnd(0.0)
|
||||||
// mOffset and mDuration are initialized in Start().
|
// mOffset and mDuration are initialized in Start().
|
||||||
, mPlaybackRate(new AudioParam(this, PLAYBACKRATE, 1.0f, "playbackRate"))
|
, mPlaybackRate(new AudioParam(this, PLAYBACKRATE, "playbackRate", 1.0f))
|
||||||
, mDetune(new AudioParam(this, DETUNE, 0.0f, "detune"))
|
, mDetune(new AudioParam(this, DETUNE, "detune", 0.0f))
|
||||||
, mLoop(false)
|
, mLoop(false)
|
||||||
, mStartCalled(false)
|
, mStartCalled(false)
|
||||||
{
|
{
|
||||||
|
@ -35,13 +35,17 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AudioParam, Release)
|
|||||||
|
|
||||||
AudioParam::AudioParam(AudioNode* aNode,
|
AudioParam::AudioParam(AudioNode* aNode,
|
||||||
uint32_t aIndex,
|
uint32_t aIndex,
|
||||||
|
const char* aName,
|
||||||
float aDefaultValue,
|
float aDefaultValue,
|
||||||
const char* aName)
|
float aMinValue,
|
||||||
|
float aMaxValue)
|
||||||
: AudioParamTimeline(aDefaultValue)
|
: AudioParamTimeline(aDefaultValue)
|
||||||
, mNode(aNode)
|
, mNode(aNode)
|
||||||
, mName(aName)
|
, mName(aName)
|
||||||
, mIndex(aIndex)
|
, mIndex(aIndex)
|
||||||
, mDefaultValue(aDefaultValue)
|
, mDefaultValue(aDefaultValue)
|
||||||
|
, mMinValue(aMinValue)
|
||||||
|
, mMaxValue(aMaxValue)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,10 @@ class AudioParam final : public nsWrapperCache,
|
|||||||
public:
|
public:
|
||||||
AudioParam(AudioNode* aNode,
|
AudioParam(AudioNode* aNode,
|
||||||
uint32_t aIndex,
|
uint32_t aIndex,
|
||||||
|
const char* aName,
|
||||||
float aDefaultValue,
|
float aDefaultValue,
|
||||||
const char* aName);
|
float aMinValue = -std::numeric_limits<float>::infinity(),
|
||||||
|
float aMaxValue = std::numeric_limits<float>::infinity());
|
||||||
|
|
||||||
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
|
||||||
NS_IMETHOD_(MozExternalRefCountType) Release(void);
|
NS_IMETHOD_(MozExternalRefCountType) Release(void);
|
||||||
@ -165,6 +167,16 @@ public:
|
|||||||
return mDefaultValue;
|
return mDefaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MinValue() const
|
||||||
|
{
|
||||||
|
return mMinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float MaxValue() const
|
||||||
|
{
|
||||||
|
return mMaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
const nsTArray<AudioNode::InputNode>& InputNodes() const
|
const nsTArray<AudioNode::InputNode>& InputNodes() const
|
||||||
{
|
{
|
||||||
return mInputNodes;
|
return mInputNodes;
|
||||||
@ -244,6 +256,8 @@ private:
|
|||||||
RefPtr<MediaInputPort> mNodeStreamPort;
|
RefPtr<MediaInputPort> mNodeStreamPort;
|
||||||
const uint32_t mIndex;
|
const uint32_t mIndex;
|
||||||
const float mDefaultValue;
|
const float mDefaultValue;
|
||||||
|
const float mMinValue;
|
||||||
|
const float mMaxValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
@ -251,10 +251,12 @@ BiquadFilterNode::BiquadFilterNode(AudioContext* aContext)
|
|||||||
ChannelInterpretation::Speakers)
|
ChannelInterpretation::Speakers)
|
||||||
, mType(BiquadFilterType::Lowpass)
|
, mType(BiquadFilterType::Lowpass)
|
||||||
, mFrequency(new AudioParam(this, BiquadFilterNodeEngine::FREQUENCY,
|
, mFrequency(new AudioParam(this, BiquadFilterNodeEngine::FREQUENCY,
|
||||||
350.f, "frequency"))
|
"frequency", 350.f,
|
||||||
, mDetune(new AudioParam(this, BiquadFilterNodeEngine::DETUNE, 0.f, "detune"))
|
-(aContext->SampleRate() / 2),
|
||||||
, mQ(new AudioParam(this, BiquadFilterNodeEngine::Q, 1.f, "Q"))
|
aContext->SampleRate() / 2))
|
||||||
, mGain(new AudioParam(this, BiquadFilterNodeEngine::GAIN, 0.f, "gain"))
|
, mDetune(new AudioParam(this, BiquadFilterNodeEngine::DETUNE, "detune", 0.f))
|
||||||
|
, mQ(new AudioParam(this, BiquadFilterNodeEngine::Q, "Q", 1.f))
|
||||||
|
, mGain(new AudioParam(this, BiquadFilterNodeEngine::GAIN, "gain", 0.f))
|
||||||
{
|
{
|
||||||
uint64_t windowID = aContext->GetParentObject()->WindowID();
|
uint64_t windowID = aContext->GetParentObject()->WindowID();
|
||||||
BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination(), windowID);
|
BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination(), windowID);
|
||||||
|
@ -147,7 +147,7 @@ ConstantSourceNode::ConstantSourceNode(AudioContext* aContext)
|
|||||||
ChannelCountMode::Max,
|
ChannelCountMode::Max,
|
||||||
ChannelInterpretation::Speakers)
|
ChannelInterpretation::Speakers)
|
||||||
, mOffset(new AudioParam(this, ConstantSourceNodeEngine::OFFSET,
|
, mOffset(new AudioParam(this, ConstantSourceNodeEngine::OFFSET,
|
||||||
1.0, "offset"))
|
"offset", 1.0f))
|
||||||
, mStartCalled(false)
|
, mStartCalled(false)
|
||||||
{
|
{
|
||||||
ConstantSourceNodeEngine* engine = new ConstantSourceNodeEngine(this, aContext->Destination());
|
ConstantSourceNodeEngine* engine = new ConstantSourceNodeEngine(this, aContext->Destination());
|
||||||
|
@ -196,7 +196,8 @@ DelayNode::DelayNode(AudioContext* aContext, double aMaxDelay)
|
|||||||
2,
|
2,
|
||||||
ChannelCountMode::Max,
|
ChannelCountMode::Max,
|
||||||
ChannelInterpretation::Speakers)
|
ChannelInterpretation::Speakers)
|
||||||
, mDelay(new AudioParam(this, DelayNodeEngine::DELAY, 0.0f, "delayTime"))
|
, mDelay(new AudioParam(this, DelayNodeEngine::DELAY, "delayTime", 0.0f,
|
||||||
|
0.f, aMaxDelay))
|
||||||
{
|
{
|
||||||
DelayNodeEngine* engine =
|
DelayNodeEngine* engine =
|
||||||
new DelayNodeEngine(this, aContext->Destination(),
|
new DelayNodeEngine(this, aContext->Destination(),
|
||||||
|
@ -188,16 +188,16 @@ DynamicsCompressorNode::DynamicsCompressorNode(AudioContext* aContext)
|
|||||||
ChannelCountMode::Explicit,
|
ChannelCountMode::Explicit,
|
||||||
ChannelInterpretation::Speakers)
|
ChannelInterpretation::Speakers)
|
||||||
, mThreshold(new AudioParam(this, DynamicsCompressorNodeEngine::THRESHOLD,
|
, mThreshold(new AudioParam(this, DynamicsCompressorNodeEngine::THRESHOLD,
|
||||||
-24.f, "threshold"))
|
"threshold", -24.f, -100.f, 0.f))
|
||||||
, mKnee(new AudioParam(this, DynamicsCompressorNodeEngine::KNEE,
|
, mKnee(new AudioParam(this, DynamicsCompressorNodeEngine::KNEE,
|
||||||
30.f, "knee"))
|
"knee", 30.f, 0.f, 40.f))
|
||||||
, mRatio(new AudioParam(this, DynamicsCompressorNodeEngine::RATIO,
|
, mRatio(new AudioParam(this, DynamicsCompressorNodeEngine::RATIO,
|
||||||
12.f, "ratio"))
|
"ratio", 12.f, 1.f, 20.f))
|
||||||
, mReduction(0)
|
, mReduction(0)
|
||||||
, mAttack(new AudioParam(this, DynamicsCompressorNodeEngine::ATTACK,
|
, mAttack(new AudioParam(this, DynamicsCompressorNodeEngine::ATTACK,
|
||||||
0.003f, "attack"))
|
"attack", 0.003f, 0.f, 1.f))
|
||||||
, mRelease(new AudioParam(this, DynamicsCompressorNodeEngine::RELEASE,
|
, mRelease(new AudioParam(this, DynamicsCompressorNodeEngine::RELEASE,
|
||||||
0.25f, "release"))
|
"release", 0.25f, 0.f, 1.f))
|
||||||
{
|
{
|
||||||
DynamicsCompressorNodeEngine* engine = new DynamicsCompressorNodeEngine(this, aContext->Destination());
|
DynamicsCompressorNodeEngine* engine = new DynamicsCompressorNodeEngine(this, aContext->Destination());
|
||||||
mStream = AudioNodeStream::Create(aContext, engine,
|
mStream = AudioNodeStream::Create(aContext, engine,
|
||||||
|
@ -120,7 +120,7 @@ GainNode::GainNode(AudioContext* aContext)
|
|||||||
2,
|
2,
|
||||||
ChannelCountMode::Max,
|
ChannelCountMode::Max,
|
||||||
ChannelInterpretation::Speakers)
|
ChannelInterpretation::Speakers)
|
||||||
, mGain(new AudioParam(this, GainNodeEngine::GAIN, 1.0f, "gain"))
|
, mGain(new AudioParam(this, GainNodeEngine::GAIN, "gain", 1.0f))
|
||||||
{
|
{
|
||||||
GainNodeEngine* engine = new GainNodeEngine(this, aContext->Destination());
|
GainNodeEngine* engine = new GainNodeEngine(this, aContext->Destination());
|
||||||
mStream = AudioNodeStream::Create(aContext, engine,
|
mStream = AudioNodeStream::Create(aContext, engine,
|
||||||
|
@ -413,11 +413,13 @@ OscillatorNode::OscillatorNode(AudioContext* aContext)
|
|||||||
ChannelCountMode::Max,
|
ChannelCountMode::Max,
|
||||||
ChannelInterpretation::Speakers)
|
ChannelInterpretation::Speakers)
|
||||||
, mType(OscillatorType::Sine)
|
, mType(OscillatorType::Sine)
|
||||||
, mFrequency(new AudioParam(this, OscillatorNodeEngine::FREQUENCY,
|
, mFrequency(
|
||||||
440.0f, "frequency"))
|
new AudioParam(this, OscillatorNodeEngine::FREQUENCY, "frequency", 440.0f,
|
||||||
, mDetune(new AudioParam(this, OscillatorNodeEngine::DETUNE, 0.0f, "detune"))
|
-(aContext->SampleRate() / 2), aContext->SampleRate() / 2))
|
||||||
|
, mDetune(new AudioParam(this, OscillatorNodeEngine::DETUNE, "detune", 0.0f))
|
||||||
, mStartCalled(false)
|
, mStartCalled(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
OscillatorNodeEngine* engine = new OscillatorNodeEngine(this, aContext->Destination());
|
OscillatorNodeEngine* engine = new OscillatorNodeEngine(this, aContext->Destination());
|
||||||
mStream = AudioNodeStream::Create(aContext, engine,
|
mStream = AudioNodeStream::Create(aContext, engine,
|
||||||
AudioNodeStream::NEED_MAIN_THREAD_FINISHED,
|
AudioNodeStream::NEED_MAIN_THREAD_FINISHED,
|
||||||
|
@ -301,12 +301,12 @@ PannerNode::PannerNode(AudioContext* aContext)
|
|||||||
// Please keep these default values consistent with PannerNodeEngine::PannerNodeEngine above.
|
// Please keep these default values consistent with PannerNodeEngine::PannerNodeEngine above.
|
||||||
, mPanningModel(PanningModelType::Equalpower)
|
, mPanningModel(PanningModelType::Equalpower)
|
||||||
, mDistanceModel(DistanceModelType::Inverse)
|
, mDistanceModel(DistanceModelType::Inverse)
|
||||||
, mPositionX(new AudioParam(this, PannerNode::POSITIONX, 0., this->NodeType()))
|
, mPositionX(new AudioParam(this, PannerNode::POSITIONX, this->NodeType(), 0.f))
|
||||||
, mPositionY(new AudioParam(this, PannerNode::POSITIONY, 0., this->NodeType()))
|
, mPositionY(new AudioParam(this, PannerNode::POSITIONY, this->NodeType(), 0.f))
|
||||||
, mPositionZ(new AudioParam(this, PannerNode::POSITIONZ, 0., this->NodeType()))
|
, mPositionZ(new AudioParam(this, PannerNode::POSITIONZ, this->NodeType(), 0.f))
|
||||||
, mOrientationX(new AudioParam(this, PannerNode::ORIENTATIONX, 1., this->NodeType()))
|
, mOrientationX(new AudioParam(this, PannerNode::ORIENTATIONX, this->NodeType(), 1.0f))
|
||||||
, mOrientationY(new AudioParam(this, PannerNode::ORIENTATIONY, 0., this->NodeType()))
|
, mOrientationY(new AudioParam(this, PannerNode::ORIENTATIONY, this->NodeType(), 0.f))
|
||||||
, mOrientationZ(new AudioParam(this, PannerNode::ORIENTATIONZ, 0., this->NodeType()))
|
, mOrientationZ(new AudioParam(this, PannerNode::ORIENTATIONZ, this->NodeType(), 0.f))
|
||||||
, mVelocity()
|
, mVelocity()
|
||||||
, mRefDistance(1.)
|
, mRefDistance(1.)
|
||||||
, mMaxDistance(10000.)
|
, mMaxDistance(10000.)
|
||||||
|
@ -175,7 +175,7 @@ StereoPannerNode::StereoPannerNode(AudioContext* aContext)
|
|||||||
2,
|
2,
|
||||||
ChannelCountMode::Clamped_max,
|
ChannelCountMode::Clamped_max,
|
||||||
ChannelInterpretation::Speakers)
|
ChannelInterpretation::Speakers)
|
||||||
, mPan(new AudioParam(this, StereoPannerNodeEngine::PAN, 0.f, "pan"))
|
, mPan(new AudioParam(this, StereoPannerNodeEngine::PAN, "pan", 0.f, -1.f, 1.f))
|
||||||
{
|
{
|
||||||
StereoPannerNodeEngine* engine = new StereoPannerNodeEngine(this, aContext->Destination());
|
StereoPannerNodeEngine* engine = new StereoPannerNodeEngine(this, aContext->Destination());
|
||||||
mStream = AudioNodeStream::Create(aContext, engine,
|
mStream = AudioNodeStream::Create(aContext, engine,
|
||||||
|
@ -13,8 +13,10 @@
|
|||||||
[Pref="dom.webaudio.enabled"]
|
[Pref="dom.webaudio.enabled"]
|
||||||
interface AudioParam {
|
interface AudioParam {
|
||||||
|
|
||||||
attribute float value;
|
attribute float value;
|
||||||
readonly attribute float defaultValue;
|
readonly attribute float defaultValue;
|
||||||
|
readonly attribute float minValue;
|
||||||
|
readonly attribute float maxValue;
|
||||||
|
|
||||||
// Parameter automation.
|
// Parameter automation.
|
||||||
[Throws]
|
[Throws]
|
||||||
|
@ -32193,6 +32193,10 @@
|
|||||||
"path": "webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html",
|
"path": "webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html",
|
||||||
"url": "/webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html"
|
"url": "/webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "webaudio/the-audio-api/the-audioparam-interface/idl-test.html",
|
||||||
|
"url": "/webaudio/the-audio-api/the-audioparam-interface/idl-test.html"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html",
|
"path": "webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html",
|
||||||
"url": "/webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html"
|
"url": "/webaudio/the-audio-api/the-audioparam-interface/retrospective-setValueAtTime.html"
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="a">
|
||||||
|
<head>
|
||||||
|
<title>AudioParam IDL Test</title>
|
||||||
|
<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script><script src="/resources/idlharness.js"></script><script src="/resources/WebIDLParser.js"></script><script src="/webaudio/js/lodash.js"></script><script src="/webaudio/js/vendor-prefixes.js"></script><script src="/webaudio/js/helpers.js"></script><style type="text/css">
|
||||||
|
#audio-param-idl
|
||||||
|
{ visibility:hidden; height: 0px;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="a">
|
||||||
|
|
||||||
|
<pre id="audio-param-idl">interface AudioParam {
|
||||||
|
|
||||||
|
attribute float value;
|
||||||
|
readonly attribute float defaultValue;
|
||||||
|
readonly attribute float minValue;
|
||||||
|
readonly attribute float maxValue;
|
||||||
|
|
||||||
|
// Parameter automation.
|
||||||
|
void setValueAtTime(float value, double startTime);
|
||||||
|
void linearRampToValueAtTime(float value, double endTime);
|
||||||
|
void exponentialRampToValueAtTime(float value, double endTime);
|
||||||
|
|
||||||
|
// Exponentially approach the target value with a rate having the given time constant.
|
||||||
|
void setTargetAtTime(float target, double startTime, double timeConstant);
|
||||||
|
|
||||||
|
// Sets an array of arbitrary parameter values starting at time for the given duration.
|
||||||
|
// The number of values will be scaled to fit into the desired duration.
|
||||||
|
void setValueCurveAtTime(Float32Array values, double startTime, double duration);
|
||||||
|
|
||||||
|
// Cancels all scheduled parameter changes with times greater than or equal to startTime.
|
||||||
|
void cancelScheduledValues(double startTime);
|
||||||
|
|
||||||
|
};</pre>
|
||||||
|
|
||||||
|
<div id="log"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var idl_array = new IdlArray();
|
||||||
|
idl_array.add_untested_idls(document.getElementById("audio-param-idl").textContent);
|
||||||
|
|
||||||
|
delay_time = (new AudioContext).createDelay().delayTime;
|
||||||
|
|
||||||
|
idl_array.add_objects({AudioParam: ["delay_time"]});
|
||||||
|
idl_array.test();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -96,8 +96,10 @@ interface AudioNode : EventTarget {
|
|||||||
|
|
||||||
<pre id="audio-param-idl">interface AudioParam {
|
<pre id="audio-param-idl">interface AudioParam {
|
||||||
|
|
||||||
attribute float value;
|
attribute float value;
|
||||||
readonly attribute float defaultValue;
|
readonly attribute float defaultValue;
|
||||||
|
readonly attribute float minValue;
|
||||||
|
readonly attribute float maxValue;
|
||||||
|
|
||||||
// Parameter automation.
|
// Parameter automation.
|
||||||
void setValueAtTime(float value, double startTime);
|
void setValueAtTime(float value, double startTime);
|
||||||
|
@ -95,8 +95,10 @@ interface AudioNode : EventTarget {
|
|||||||
|
|
||||||
<pre id="audio-param-idl">interface AudioParam {
|
<pre id="audio-param-idl">interface AudioParam {
|
||||||
|
|
||||||
attribute float value;
|
attribute float value;
|
||||||
readonly attribute float defaultValue;
|
readonly attribute float defaultValue;
|
||||||
|
readonly attribute float minValue;
|
||||||
|
readonly attribute float maxValue;
|
||||||
|
|
||||||
// Parameter automation.
|
// Parameter automation.
|
||||||
void setValueAtTime(float value, double startTime);
|
void setValueAtTime(float value, double startTime);
|
||||||
|
Loading…
Reference in New Issue
Block a user