Skip to content

Commit

Permalink
include patches to freesound and audio-encoder dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarcosfer committed Jan 27, 2022
1 parent 584b134 commit 1b8c9e7
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/demos/onsets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress"
"build": "cross-env NODE_ENV=production webpack --progress",
"postinstall": "npx patch-package"
},
"browserslist": [
"> 1%",
Expand Down
20 changes: 20 additions & 0 deletions examples/demos/onsets/patches/audio-encoder+1.0.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/node_modules/audio-encoder/src/encodeWav.js b/node_modules/audio-encoder/src/encodeWav.js
index 51a531c..3b96798 100644
--- a/node_modules/audio-encoder/src/encodeWav.js
+++ b/node_modules/audio-encoder/src/encodeWav.js
@@ -82,9 +82,12 @@ function encodeWav(audioBuffer, cb) {

var blob = new Blob([uint8], { type: 'audio/x-wav' })

- setTimeout(function () {
- return cb(blob);
- }, 30);
+ // return new Promise((resolve, _) => {
+ // setTimeout(function () {
+ // resolve(blob);
+ // }, 30);
+ // });
+ return blob;
}

module.exports = encodeWav;
69 changes: 69 additions & 0 deletions examples/demos/onsets/patches/freesound+0.0.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff --git a/node_modules/freesound/freesound.js b/node_modules/freesound/freesound.js
index 879d67a..25a1ca1 100644
--- a/node_modules/freesound/freesound.js
+++ b/node_modules/freesound/freesound.js
@@ -57,46 +57,24 @@
uri = uri +"?"+ paramStr;
}

- if (typeof module !== 'undefined'){ // node.js
- var http = require("http");
- var options = {
- host: host,
- path: uri.substring(uri.indexOf("/",8),uri.length), // first '/' after 'http://'
- port: '80',
- method: method,
- headers: {'Authorization': authHeader}
- };
- var req = http.request(options,function(res){
- res.setEncoding('utf8');
- res.on('data', function (data){
- if([200,201,202].indexOf(res.statusCode)>=0)
- success(wrapper?wrapper(data):data);
- else
- error(data);
- });
- });
- req.on('error', error).end();
- }
- else{ // browser
- var xhr;
- try {xhr = new XMLHttpRequest();}
- catch (e) {xhr = new ActiveXObject('Microsoft.XMLHTTP');}
-
- xhr.onreadystatechange = function(){
- if (xhr.readyState === 4 && [200,201,202].indexOf(xhr.status)>=0){
- var data = eval("(" + xhr.responseText + ")");
- if(success) success(wrapper?wrapper(data):data);
- }
- else if (xhr.readyState === 4 && xhr.status !== 200){
- if(error) error(xhr.statusText);
- }
- };
- xhr.open(method, uri);
- xhr.setRequestHeader('Authorization',authHeader);
- if(content_type!==undefined)
- xhr.setRequestHeader('Content-Type',content_type);
- xhr.send(data);
- }
+ var xhr;
+ try {xhr = new XMLHttpRequest();}
+ catch (e) {xhr = new ActiveXObject('Microsoft.XMLHTTP');}
+
+ xhr.onreadystatechange = function(){
+ if (xhr.readyState === 4 && [200,201,202].indexOf(xhr.status)>=0){
+ var data = eval("(" + xhr.responseText + ")");
+ if(success) success(wrapper?wrapper(data):data);
+ }
+ else if (xhr.readyState === 4 && xhr.status !== 200){
+ if(error) error(xhr.statusText);
+ }
+ };
+ xhr.open(method, uri);
+ xhr.setRequestHeader('Authorization',authHeader);
+ if(content_type!==undefined)
+ xhr.setRequestHeader('Content-Type',content_type);
+ xhr.send(data);
};
var checkOauth = function(){
if(authHeader.indexOf("Bearer")==-1)

0 comments on commit 1b8c9e7

Please sign in to comment.