OscillatorNode::OscillatorNode(BaseAudioContext& context) : AudioScheduledSourceNode(context), // Use musical pitch standard A440 as a default. m_frequency(AudioParam::create(context, ParamTypeOscillatorFrequency, 440, -context.sampleRate() / 2, context.sampleRate() / 2)), // Default to no detuning. m_detune(AudioParam::create(context, ParamTypeOscillatorDetune, 0)) { setHandler(OscillatorHandler::create(*this, context.sampleRate(), m_frequency->handler(), m_detune->handler())); }
TEST_F(BaseAudioContextTest, AutoplayMetrics_NodeStartNoGesture) { HistogramTester histogramTester; createChildFrame(); childDocument().settings()->setMediaPlaybackRequiresUserGesture(true); BaseAudioContext* audioContext = BaseAudioContext::create(childDocument(), ASSERT_NO_EXCEPTION); audioContext->maybeRecordStartAttempt(); recordAutoplayStatus(audioContext); histogramTester.expectBucketCount(kCrossOriginMetric, AutoplayStatus::AutoplayStatusFailed, 1); histogramTester.expectTotalCount(kCrossOriginMetric, 1); }
IIRFilterNode::IIRFilterNode(BaseAudioContext& context, const Vector<double> feedforwardCoef, const Vector<double> feedbackCoef) : AudioNode(context) { setHandler(AudioBasicProcessorHandler::create( AudioHandler::NodeTypeIIRFilter, *this, context.sampleRate(), wrapUnique(new IIRProcessor(context.sampleRate(), 1, feedforwardCoef, feedbackCoef)))); // Histogram of the IIRFilter order. createIIRFilter ensures that the length // of |feedbackCoef| is in the range [1, IIRFilter::kMaxOrder + 1]. The order // is one less than the length of this vector. DEFINE_STATIC_LOCAL(SparseHistogram, filterOrderHistogram, ("WebAudio.IIRFilterNode.Order")); filterOrderHistogram.sample(feedbackCoef.size() - 1); }
TEST_F(BaseAudioContextTest, AutoplayMetrics_CallResumeNoGesture) { HistogramTester histogramTester; createChildFrame(); childDocument().settings()->setMediaPlaybackRequiresUserGesture(true); ScriptState::Scope scope(getScriptStateFrom(childDocument())); BaseAudioContext* audioContext = BaseAudioContext::create(childDocument(), ASSERT_NO_EXCEPTION); audioContext->resumeContext(getScriptStateFrom(childDocument())); rejectPendingResolvers(audioContext); recordAutoplayStatus(audioContext); histogramTester.expectBucketCount(kCrossOriginMetric, AutoplayStatus::AutoplayStatusFailed, 1); histogramTester.expectTotalCount(kCrossOriginMetric, 1); }
TEST_F(BaseAudioContextTest, AutoplayMetrics_NodeStartGestureThenSucces) { HistogramTester histogramTester; createChildFrame(); childDocument().settings()->setMediaPlaybackRequiresUserGesture(true); ScriptState::Scope scope(getScriptStateFrom(childDocument())); BaseAudioContext* audioContext = BaseAudioContext::create(childDocument(), ASSERT_NO_EXCEPTION); UserGestureIndicator userGestureScope(DocumentUserGestureToken::create( &childDocument(), UserGestureToken::NewGesture)); audioContext->maybeRecordStartAttempt(); audioContext->resumeContext(getScriptStateFrom(childDocument())); rejectPendingResolvers(audioContext); recordAutoplayStatus(audioContext); histogramTester.expectBucketCount(kCrossOriginMetric, AutoplayStatus::AutoplayStatusSucceeded, 1); histogramTester.expectTotalCount(kCrossOriginMetric, 1); }
ChannelMergerNode::ChannelMergerNode(BaseAudioContext& context, unsigned numberOfInputs) : AudioNode(context) { setHandler(ChannelMergerHandler::create(*this, context.sampleRate(), numberOfInputs)); }
StereoPannerNode::StereoPannerNode(BaseAudioContext& context) : AudioNode(context), m_pan(AudioParam::create(context, ParamTypeStereoPannerPan, 0, -1, 1)) { setHandler(StereoPannerHandler::create(*this, context.sampleRate(), m_pan->handler())); }
ConvolverNode::ConvolverNode(BaseAudioContext& context) : AudioNode(context) { setHandler(ConvolverHandler::create(*this, context.sampleRate())); }