如何用web audio api测量压缩?

Oli*_*ond 3 javascript html5 meter web-audio-api

我想创建一个HTML计量器来显示压缩器节点的减少量.

我使用了这段代码,但它没有改变metter

compressor = context.createDynamicsCompressor();
compressor.threshold = -50;
compressor.ratio = 12;
compressor.attack = 0.003;
compressor.reduction.onchange = function () {
  var gainReduction = pluginSlot1.reduction;
  document.getElementById("meter").value = gainReduction.value;
};
Run Code Online (Sandbox Code Playgroud)

这与此HTML相关联

<meter id ="meter"min ="0"max ="100">

为了让它起作用,我需要做什么?

Kev*_*nis 6

这是一个快速而又脏的jsbin示例:http://jsbin.com/ahocUt/1/edit

除非我在规范中遗漏了某些内容,否则reductionparam不会触发任何事件.您只需按需阅读即可.在我的例子中,这只是一个requestAnimationFrame循环.

你缺少的另一件事是你需要设置params compressor.threshold.value,因为compressor.threshold它实际上是一个对象.

希望有所帮助.