【发布时间】:2014-03-01 19:42:22
【问题描述】:
我最近发现了很棒的 baudio NodeJS 库。
我有以下代码:
var baudio = require("baudio")
, b = baudio()
, tau = 2 * Math.PI
;
function playSound (f, duration) {
console.log(f, duration);
b.push(function (t) {
return (square (f) + square (f + 1)) * (t < duration);
function square (freq) {
return Math.sin(tau * t * freq) < 0 ? -1 : 1;
}
});
b.play();
}
playSound(440, 2) 将播放 A 键 2 秒。这是对的。如果我再次调用playSound 函数,则不会播放其他声音。
为什么?在播放完第一个或正在播放后,如何播放其他声音?
【问题讨论】:
-
上面的
tau是什么? -
@Andbdrew 不错。
tau是2 * Math.PI