From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/scriptprocessornode/index.html | 151 +++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 files/zh-cn/web/api/scriptprocessornode/index.html (limited to 'files/zh-cn/web/api/scriptprocessornode') diff --git a/files/zh-cn/web/api/scriptprocessornode/index.html b/files/zh-cn/web/api/scriptprocessornode/index.html new file mode 100644 index 0000000000..d53e09691e --- /dev/null +++ b/files/zh-cn/web/api/scriptprocessornode/index.html @@ -0,0 +1,151 @@ +--- +title: ScriptProcessorNode +slug: Web/API/ScriptProcessorNode +translation_of: Web/API/ScriptProcessorNode +--- +

{{APIRef("Web Audio API")}}

+ +
+

注意:这个特性在2014年8月29日发布的Web Audio API规范中已经标记为不推荐,将很快会被Audio Workers代替.

+
+ +
+

ScriptProcessorNode 接口允许使用JavaScript生成、处理、分析音频. 它是一个 {{domxref("AudioNode")}}, 连接着两个缓冲区音频处理模块, 其中一个缓冲区包含输入音频数据,另外一个包含处理后的输出音频数据. 实现了 {{domxref("AudioProcessingEvent")}} 接口的一个事件,每当输入缓冲区有新的数据时,事件将被发送到该对象,并且事件将在数据填充到输出缓冲区后结束.

+
+ +

The ScriptProcessorNode stores the input in a buffer, send the audioprocess event. The EventHandler takes the input buffer and fill the output buffer which is sent to the output by the ScriptProcessorNode.

+ +

输入和输出缓冲区大小在创建时定义, 当 {{domxref("AudioContext.createScriptProcessor()")}} 方法被调用时 (都是由 {{domxref("AudioContext.createScriptProcessor()")}}的 bufferSize 参数定义). 缓冲区大小必须是在 256 到 16384 之间的 2 的次幂, 为 256, 512, 1024, 2048, 4096, 8192 或者 16384. Small numbers lower the latency, but large number may be necessary to avoid audio breakup and glitches.

+ +

If the buffer size is not defined, which is recommended, the browser will pick one that its heuristic deems appropriate.

+ + + + + + + + + + + + + + + + + + + + + + + + +
Number of inputs1
Number of outputs1
Channel count mode"max"
Channel count2 (not used in the default count mode)
Channel interpretation"speakers"
+ +

属性

+ +

从上一级继承属性, {{domxref("AudioNode")}}.

+ +
+
{{domxref("ScriptProcessorNode.bufferSize")}} {{readonlyInline}}
+
返回一个表示输入和输出缓冲区大小的整数. 它的值可以是在25616384 之间的 2 的次幂.
+
+ +

事件句柄

+ +
+
{{domxref("ScriptProcessorNode.onaudioprocess")}}
+
Represents the {{domxref("EventHandler")}} to be called.
+
+ +

方法

+ +

No specific methods; inherits methods from its parent, {{domxref("AudioNode")}}.

+ +

示例

+ +

{{page("/en-US/docs/Web/API/AudioContext.createScriptProcessor","Example")}}

+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-scriptprocessornode-interface---deprecated', 'ScriptProcessorNode')}}{{Spec2('Web Audio API')}} 
+ +

浏览器兼容性

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support14 {{property_prefix("webkit")}}{{CompatVersionUnknown}}{{CompatGeckoDesktop(25)}}{{CompatNo}}15 {{property_prefix("webkit")}}
+ 22 (unprefixed)
6 {{property_prefix("webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeEdgeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}28 {{property_prefix("webkit")}}{{CompatVersionUnknown}}{{CompatGeckoMobile(25)}}1.2{{CompatNo}}{{CompatNo}}6 {{property_prefix("webkit")}}
+
+ +

See also

+ + -- cgit v1.2.3-54-g00ecf