egonelbre/jsfx — pull request #7 by greggman (2014-05-06 07:21:40+00:00)
Title: Add support for Web Audio API

I'm not sure you want this or not given that it's pretty simple.

I did test it though by editing jsfxgui with the following patch

diff --git a/lib/jsfxgui.js b/lib/jsfxgui.js
index d32d798..966b081 100644
--- a/lib/jsfxgui.js
+++ b/lib/jsfxgui.js
@@ -3,6 +3,9 @@ var jsfxgui = {};
var Parameters = [];
var logDiv = undefined;

+ var webAudioAPI = window.AudioContext || window.webkitAudioContext || window.mozAudioContext;
+ var ctx = new webAudioAPI();
+
function log(txt){
if(logDiv === undefined){
return;
@@ -384,18 +387,24 @@ var jsfxgui = {};
var data = jsfx.generate(params);
if(typeof(wave) !== undefined)
delete wave;
- var wave = audio.make(data);
+// var wave = audio.make(data);
+ var buffer = audio.makeAudioBuffer(ctx, data)
+ var src = ctx.createBufferSource();
+ src.buffer = buffer;
+ src.connect(ctx.destination);
+ src.start();
+
delete data;

var stop = millis();
log("generate: " + (stop - start) + "ms");
- wave.play();
+// wave.play();

if(typeof(this.onplay) !== undefined){
this.onplay();
}
-
- return wave;
+ console.log("pla");
+// return wave;
};

this.reset = function () {