-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
4,148 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// VV WPA support | ||
const CACHE_NAME = `Resonate`; | ||
|
||
// Use the install event to pre-cache all initial resources. | ||
self.addEventListener('install', event => { | ||
event.waitUntil((async () => { | ||
const cache = await caches.open(CACHE_NAME); | ||
cache.addAll([ | ||
'./Resonate.js', | ||
'./Resonate.wasm', | ||
'./index.html', | ||
'./icons/ResonateIcon.png', | ||
'./icons/ResonateIconLarge.png', | ||
'./icons/ResonateIconUnsaved.png', | ||
'./plugins/audiostretchworker.js', | ||
'./plugins/zip.js', | ||
'./plugins/LoadingScreenWorker.js', | ||
'./plugins/timestretch.js', | ||
'./plugins/RubberBand.js', | ||
'./plugins/RubberBand.js.mem', | ||
'./plugins/paulstretch.js', | ||
'./plugins/VexWarp/tools.js', | ||
'./plugins/VexWarp/stretch.js', | ||
'./plugins/VexWarp/require.js', | ||
'./plugins/VexWarp/main.js', | ||
'./plugins/VexWarp/jquery-2.0.3.js', | ||
'./plugins/VexWarp/dsp.js', | ||
]); | ||
})()); | ||
}); | ||
|
||
self.addEventListener('fetch', event => { | ||
event.respondWith((async () => { | ||
const cache = await caches.open(CACHE_NAME); | ||
|
||
//const injectHeaders = (request)=>{ | ||
// const headers = new Headers(request.headers); | ||
// headers.set('Cross-Origin-Embedder-Policy', 'require-corp'); | ||
// headers.set('Cross-Origin-Opener-Policy', 'same-origin'); | ||
// const newRequest = new Request(request, { | ||
// mode: request.mode, | ||
// credentials: request.credentials, | ||
// headers: headers | ||
// }); | ||
// return newRequest; | ||
//}; | ||
|
||
// Get the resource from the cache. | ||
//const cachedResponse = await cache.match(event.request); | ||
//if (cachedResponse) { | ||
// return cachedResponse; | ||
//} else { | ||
try { | ||
// If the resource was not in the cache, try the network. | ||
//const fetchResponse = await fetch(injectHeaders(event.request)); | ||
const fetchResponse = await fetch(event.request); | ||
|
||
if(event.request.method != 'POST'){ | ||
// Save the resource in the cache and return it. | ||
cache.put(event.request, fetchResponse.clone()); | ||
} | ||
return fetchResponse; | ||
} catch (e) { | ||
// The network failed. | ||
const cachedResponse = await cache.match(event.request); | ||
if (cachedResponse) { | ||
return cachedResponse; | ||
} | ||
} | ||
//} | ||
})()); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!doctypehtml><html lang=en-us><head><meta charset=utf-8><meta content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"name=viewport><link crossorigin=use-credentials href=./manifest.json rel=manifest><title>Resonate</title><style>body{margin:0;background-color:#000}.emscripten{position:absolute;top:0;left:0;margin:0;border:0;width:100%;height:100%;overflow:hidden;display:block;image-rendering:optimizeSpeed;image-rendering:-moz-crisp-edges;image-rendering:-o-crisp-edges;image-rendering:-webkit-optimize-contrast;image-rendering:optimize-contrast;image-rendering:crisp-edges;image-rendering:pixelated;-ms-interpolation-mode:nearest-neighbor}</style><script>const default_console_log=console.log,default_console_warn=console.warn,default_console_error=console.error;fetch("/console",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"log",data:["Log server open"]})}).then((o=>{405!=o.status&&(console.log=(...o)=>{fetch("/console",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"log",data:o})}).then((()=>{}),(()=>{console.log=default_console_log,console.warn=default_console_warn,console.error=default_console_error})),default_console_log.apply(console,o)},console.warn=(...o)=>{fetch("/console",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"warn",data:o})}).then((()=>{}),(()=>{console.log=default_console_log,console.warn=default_console_warn,console.error=default_console_error})),default_console_warn.apply(console,o)},console.error=(...o)=>{fetch("/console",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"error",data:o})}).then((()=>{}),(()=>{console.log=default_console_log,console.warn=default_console_warn,console.error=default_console_error})),default_console_error.apply(console,o)})}))</script></head><body><canvas class=emscripten id=canvas oncontextmenu=event.preventDefault() onclick=_jsPrepPlayback()></canvas><canvas class=emscripten id=loadingCanvas oncontextmenu=event.preventDefault()></canvas><script>var Module;(async()=>{Module={preRun:[],postRun:[],print:function(e){e=Array.prototype.slice.call(arguments).join(" "),console.log(e)},printErr:function(e){e=Array.prototype.slice.call(arguments).join(" "),console.error(e)},canvas:document.getElementById("canvas"),setStatus:function(e){console.log("status: "+e)},monitorRunDependencies:function(e){}},window.onerror=function(e,n,o,i,t){console.error("onerror: "+e.name+": "+e.message+"\n\t/bin/public/"+n.split("/").slice(-1)+":"+o+":"+i),console.error(t.stack),alert("OnError: \n"+e.name+": "+e.message)};{const e=new Worker("plugins/LoadingScreenWorker.js");Module.loadingScreenWorker=e;const n=document.getElementById("loadingCanvas");n.style.zIndex=-1,document.getElementById("canvas").style.zIndex=0;const o=n.transferControlToOffscreen();e.postMessage({cmd:"init",canvas:o},[o]),Module.show_loading_screen=(e,n,o)=>{document.getElementById("loadingCanvas").style.zIndex=1,Module.loadingScreenWorker.postMessage({cmd:"show",bgColor:e,decorColor:n,width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio,animIn:o})},Module.hide_loading_screen=()=>{document.getElementById("loadingCanvas");Module.loadingScreenWorker.postMessage({cmd:"hide",width:window.innerWidth*window.devicePixelRatio,height:window.innerHeight*window.devicePixelRatio})},e.addEventListener("message",(e=>{"resetZ"==e.data.cmd&&(document.getElementById("loadingCanvas").style.zIndex=-1)}))}{const e=await navigator.gpu.requestAdapter(),n=await e.requestDevice();Module.preinitializedWebGPUDevice=n}"serviceWorker"in navigator&&navigator.serviceWorker.register("./ResonateInstallWPA.js",{scope:"./"})})()</script><script src=plugins/timestretch.js></script><script src=plugins/zip.js></script><script src=https://apis.google.com/js/api.js async defer onload=""></script><script src=https://accounts.google.com/gsi/client async defer onload=""></script><script src=plugins/Dropbox-sdk.min.js></script><script src=https://www.dropbox.com/static/api/2/dropins.js data-app-key=pzgv8lp5thkigx4 id=dropboxjs></script><script src=Resonate.js async></script></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"lang": "en-us", | ||
"name": "Resonate", | ||
"short_name": "Resonate", | ||
"description": "A timing tool for ECHO", | ||
"start_url": "./", | ||
"background_color": "#5e5966", | ||
"theme_color": "#17141f", | ||
"orientation": "any", | ||
"display": "standalone", | ||
"icons": [ | ||
{ | ||
"src": "./icons/ResonateIconLarge.png", | ||
"sizes": "256x256" | ||
}, | ||
{ | ||
"src": "./icons/ResonateIconLarger.png", | ||
"sizes": "512x512" | ||
} | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
// This file is licenced under the GNU Affero General Public License and the Resonate Supplemental Terms. (See file LICENSE and LICENSE-SUPPLEMENT or <https://github.com/98ahni/Resonate>) | ||
// <Copyright (C) 2024 98ahni> Original file author | ||
|
||
const default_console_log = console.log; | ||
const default_console_warn = console.warn; | ||
const default_console_error = console.error; | ||
(()=>{ | ||
self.onerror = function (event, source, lineno, colno, error) { | ||
console.error("onerror: " + event.name + ": " + event.message + | ||
"\n\t/bin/public/" + source.split('/').slice(-1) + ":" + lineno + ":" + colno); | ||
console.error(error.stack); | ||
//if(window.matchMedia('(any-pointer: coarse)').matches) // Enable if alert should be for touch only. | ||
alert("OnError: \n" + event.name + ": " + event.message); | ||
}; | ||
fetch("/console", { | ||
method: "POST", | ||
headers: {'Content-Type': 'application/json'}, | ||
body: JSON.stringify({type: 'log', data: ['Log server open']}) | ||
}).then( | ||
/*resolve*/(response)=>{ | ||
if(response.status == 405){ | ||
return; | ||
} | ||
console.log = (...data) => { | ||
fetch("/console", { | ||
method: "POST", | ||
headers: {'Content-Type': 'application/json'}, | ||
body: JSON.stringify({type: 'log', data}) | ||
}).then( | ||
/*resolve*/()=>{}, | ||
/*reject*/()=>{ | ||
// No server, restore functions | ||
console.log = default_console_log; | ||
console.warn = default_console_warn; | ||
console.error = default_console_error; | ||
}); | ||
default_console_log.apply(console, data); | ||
}; | ||
console.warn = (...data) => { | ||
fetch("/console", { | ||
method: "POST", | ||
headers: {'Content-Type': 'application/json'}, | ||
body: JSON.stringify({type: 'warn', data}) | ||
}).then( | ||
/*resolve*/()=>{}, | ||
/*reject*/()=>{ | ||
// No server, restore functions | ||
console.log = default_console_log; | ||
console.warn = default_console_warn; | ||
console.error = default_console_error; | ||
}); | ||
default_console_warn.apply(console, data); | ||
}; | ||
console.error = (...data) => { | ||
fetch("/console", { | ||
method: "POST", | ||
headers: {'Content-Type': 'application/json'}, | ||
body: JSON.stringify({type: 'error', data}) | ||
}).then( | ||
/*resolve*/()=>{}, | ||
/*reject*/()=>{ | ||
// No server, restore functions | ||
console.log = default_console_log; | ||
console.warn = default_console_warn; | ||
console.error = default_console_error; | ||
}); | ||
default_console_error.apply(console, data); | ||
}; | ||
}); | ||
})(); | ||
function remap(value, l1, h1, l2, h2) { | ||
return l2 + (h2 - l2) * (value - l1) / (h1 - l1); | ||
} | ||
|
||
const animMaxDuration = 250; | ||
|
||
var canvas = null; | ||
var context; | ||
var bgColor = 0; | ||
var decorColor = 0; | ||
var isShowing = false; | ||
var animIn = false; | ||
var animOut = false; | ||
var animStartTime = 0; | ||
function render(time){ | ||
if(!isShowing){ | ||
requestAnimationFrame(render); | ||
return; | ||
} | ||
let width = canvas.width; | ||
let height = canvas.height; | ||
let size = (width < height ? width : height) * .4; | ||
let sizeMult = ((Math.sin(time * .001) + 1) * .25) + .5; | ||
let alphaMult = (1 - sizeMult) + .5; | ||
|
||
context.clearRect(0, 0, width, height); | ||
if(animIn){ | ||
if(animStartTime == 0){animStartTime = time;} | ||
let duration = time - animStartTime; | ||
if(duration >= animMaxDuration){ | ||
duration = animMaxDuration; | ||
animIn = false; | ||
animStartTime = 0; | ||
} | ||
sizeMult = remap(Math.sqrt(Math.sqrt(duration)), 0, Math.sqrt(Math.sqrt(animMaxDuration)), 5, sizeMult); | ||
alphaMult = remap(duration, 0, animMaxDuration, 0, alphaMult); | ||
context.globalAlpha = remap(duration, 0, animMaxDuration, 0, 1); | ||
} | ||
if(animOut){ | ||
if(animStartTime == 0){animStartTime = time; console.log("animOut start");} | ||
let duration = time - animStartTime; | ||
if(duration >= animMaxDuration){ | ||
duration = animMaxDuration; | ||
animOut = false; | ||
isShowing = false; | ||
animStartTime = 0; | ||
console.log("animOut end"); | ||
this.postMessage({cmd: 'resetZ'}); | ||
} | ||
sizeMult = remap(duration * duration * duration, 0, animMaxDuration * animMaxDuration * animMaxDuration, sizeMult, 5); | ||
alphaMult = remap(duration, 0, animMaxDuration, alphaMult, 0); | ||
context.globalAlpha = remap(duration, 0, animMaxDuration, 1, 0); | ||
} | ||
|
||
context.fillStyle = `rgba( | ||
${bgColor&0xff}, | ||
${(bgColor>>>8)&0xff}, | ||
${(bgColor>>>16)&0xff}, | ||
${(bgColor>>>24)/0xff} | ||
)`; | ||
context.fillRect(0, 0, width, height); | ||
|
||
context.fillStyle = "white"; | ||
context.fillStyle = `rgba( | ||
${decorColor&0xff}, | ||
${(decorColor>>>8)&0xff}, | ||
${(decorColor>>>16)&0xff}, | ||
1 | ||
)`; | ||
context.globalAlpha = .1 * alphaMult; | ||
context.beginPath(); | ||
context.arc(width * .5, height * .5, size * sizeMult, 0, Math.PI * 2, true); | ||
context.fill(); | ||
context.globalAlpha = .3 * alphaMult; | ||
context.beginPath(); | ||
context.arc(width * .5, height * .5, size * .8 * sizeMult, 0, Math.PI * 2, true); | ||
context.fill(); | ||
context.globalAlpha = .5 * alphaMult; | ||
context.beginPath(); | ||
context.arc(width * .5, height * .5, size * .6 * sizeMult, 0, Math.PI * 2, true); | ||
context.fill(); | ||
context.globalAlpha = .7 * alphaMult; | ||
context.beginPath(); | ||
context.arc(width * .5, height * .5, size * .4 * sizeMult, 0, Math.PI * 2, true); | ||
context.fill(); | ||
context.globalAlpha = .9 * alphaMult; | ||
context.beginPath(); | ||
context.arc(width * .5, height * .5, size * .2 * sizeMult, 0, Math.PI * 2, true); | ||
context.fill(); | ||
context.globalAlpha = 1; | ||
requestAnimationFrame(render); | ||
} | ||
|
||
onmessage = async function (msg) | ||
{ | ||
if(msg.data.cmd == 'init'){ | ||
canvas = msg.data.canvas; | ||
context = canvas.getContext('2d'); | ||
requestAnimationFrame(render); | ||
} | ||
else if(msg.data.cmd == 'show'){ | ||
bgColor = msg.data.bgColor; | ||
decorColor = msg.data.decorColor; | ||
canvas.width = msg.data.width; | ||
canvas.height = msg.data.height; | ||
animIn = msg.data.animIn; | ||
isShowing = true; | ||
} | ||
else if(msg.data.cmd == 'hide'){ | ||
canvas.width = msg.data.width; | ||
canvas.height = msg.data.height; | ||
animOut = true; | ||
} | ||
} |
Oops, something went wrong.