Merge branch 'dev' of https://github.com/Tonejs/Tone.js into dev

This commit is contained in:
Yotam Mann 2015-09-18 15:41:29 -07:00
commit 0045c6ee28
3 changed files with 25644 additions and 18755 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,47 @@
//UMD
if ( typeof define === "function" && define.amd ) {
define( "Tone", [], function() {
return Tone;
});
} else if (typeof module === "object") {
module.exports = Tone;
} else {
root.Tone = Tone;
}
///////////////////////////////////////////////////////////////////////////
// P5 SHIM
///////////////////////////////////////////////////////////////////////////
Tone.registeredPreload = function(callback){
return function(){
callback();
}
};
//overwrite load function
Tone.Buffer.load = function (url, callback) {
var handle = Tone.registeredPreload();
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.responseType = 'arraybuffer';
// decode asynchronously
request.onload = function () {
Tone.context.decodeAudioData(request.response, function (buff) {
if (!buff) {
throw new Error('could not decode audio data:' + url);
}
callback(buff);
handle();
});
};
//send the request
request.send();
return request;
};
p5.prototype.registerPreloadMethod("registeredPreload", Tone);
} (this));

View file

@ -72,19 +72,35 @@ gulp.task("buildrequire", ["makerequire"], function(done){
.pipe(tap(function(file){
var fileAsString = file.contents.toString();
file.contents = new Buffer(fileAsString.substr(0, fileAsString.indexOf("require([") - 1));
fs.writeFile("toneMain.js", file.contents, function(err){
if (err){
console.log(err);
}
});
}))
//surround the file with the header/footer
.pipe(insert.prepend(fs.readFileSync("./fragments/before.frag").toString()))
.pipe(insert.append(fs.readFileSync("./fragments/after.frag").toString()))
//clean up the files
.pipe(gulp.dest("../build/"));
stream.on("end", done);
});
gulp.task("buildp5Tone", ["buildrequire"], function(done){
var stream = gulp.src("./toneMain.js")
.pipe(rename("p5.Tone.js"))
//surround the file with the header/footer
.pipe(insert.prepend(fs.readFileSync("./fragments/before.frag").toString()))
.pipe(insert.append(fs.readFileSync("./fragments/p5-after.frag").toString()))
//clean up the files
.pipe(gulp.dest("../build/"));
stream.on("end", function(){
del(["./toneMain.js"], done);
});
});
gulp.task("build", ["buildrequire"], function(){
gulp.src("../build/Tone.js")
gulp.task("build", ["buildp5Tone"], function(){
gulp.src("../build/{p5.Tone,Tone}.js")
.pipe(uglify({
preserveComments : "some",
compress: {
@ -102,7 +118,9 @@ gulp.task("build", ["buildrequire"], function(){
cascade : true,
},
}))
.pipe(rename("Tone.min.js"))
.pipe(rename(function(path) {
path.basename += ".min";
}))
.pipe(gulp.dest("../build/"));
});