Skip to content

Commit f482282

Browse files
authored
Release of Resonate 0.7.0-beta
1 parent a3817e1 commit f482282

29 files changed

+4281
-11
lines changed

0.7.0-beta/Resonate.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0.7.0-beta/Resonate.wasm

5.09 MB
Binary file not shown.

0.7.0-beta/ResonateInstallWPA.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// VV WPA support
2+
const CACHE_NAME = `Resonate`;
3+
4+
// Use the install event to pre-cache all initial resources.
5+
self.addEventListener('install', event => {
6+
event.waitUntil((async () => {
7+
const cache = await caches.open(CACHE_NAME);
8+
cache.addAll([
9+
'./Resonate.js',
10+
'./Resonate.wasm',
11+
'./index.html',
12+
'./icons/ResonateIcon.png',
13+
'./icons/ResonateIconLarge.png',
14+
'./icons/ResonateIconUnsaved.png',
15+
'./plugins/audiostretchworker.js',
16+
'./plugins/zip.js',
17+
'./plugins/LoadingScreenWorker.js',
18+
'./plugins/timestretch.js',
19+
'./plugins/RubberBand.js',
20+
'./plugins/RubberBand.js.mem',
21+
'./plugins/paulstretch.js',
22+
'./plugins/VexWarp/tools.js',
23+
'./plugins/VexWarp/stretch.js',
24+
'./plugins/VexWarp/require.js',
25+
'./plugins/VexWarp/main.js',
26+
'./plugins/VexWarp/jquery-2.0.3.js',
27+
'./plugins/VexWarp/dsp.js',
28+
]);
29+
})());
30+
});
31+
32+
self.addEventListener('fetch', event => {
33+
event.respondWith((async () => {
34+
const cache = await caches.open(CACHE_NAME);
35+
36+
//const injectHeaders = (request)=>{
37+
// const headers = new Headers(request.headers);
38+
// headers.set('Cross-Origin-Embedder-Policy', 'require-corp');
39+
// headers.set('Cross-Origin-Opener-Policy', 'same-origin');
40+
// const newRequest = new Request(request, {
41+
// mode: request.mode,
42+
// credentials: request.credentials,
43+
// headers: headers
44+
// });
45+
// return newRequest;
46+
//};
47+
48+
// Get the resource from the cache.
49+
//const cachedResponse = await cache.match(event.request);
50+
//if (cachedResponse) {
51+
// return cachedResponse;
52+
//} else {
53+
try {
54+
// If the resource was not in the cache, try the network.
55+
//const fetchResponse = await fetch(injectHeaders(event.request));
56+
const fetchResponse = await fetch(event.request);
57+
58+
if(event.request.method != 'POST'){
59+
// Save the resource in the cache and return it.
60+
cache.put(event.request, fetchResponse.clone());
61+
}
62+
return fetchResponse;
63+
} catch (e) {
64+
// The network failed.
65+
const cachedResponse = await cache.match(event.request);
66+
if (cachedResponse) {
67+
return cachedResponse;
68+
}
69+
}
70+
//}
71+
})());
72+
});

0.7.0-beta/icons/ResonateIcon.png

8.73 KB
Loading
96.2 KB
Loading
257 KB
Loading
8.73 KB
Loading

0.7.0-beta/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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>

0.7.0-beta/manifest.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"lang": "en-us",
3+
"name": "Resonate",
4+
"short_name": "Resonate",
5+
"description": "A timing tool for ECHO",
6+
"start_url": "./",
7+
"background_color": "#5e5966",
8+
"theme_color": "#17141f",
9+
"orientation": "any",
10+
"display": "standalone",
11+
"icons": [
12+
{
13+
"src": "./icons/ResonateIconLarge.png",
14+
"sizes": "256x256"
15+
},
16+
{
17+
"src": "./icons/ResonateIconLarger.png",
18+
"sizes": "512x512"
19+
}
20+
]
21+
}

0.7.0-beta/plugins/Dropbox-sdk.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// 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>)
2+
// <Copyright (C) 2024 98ahni> Original file author
3+
4+
const default_console_log = console.log;
5+
const default_console_warn = console.warn;
6+
const default_console_error = console.error;
7+
(()=>{
8+
self.onerror = function (event, source, lineno, colno, error) {
9+
console.error("onerror: " + event.name + ": " + event.message +
10+
"\n\t/bin/public/" + source.split('/').slice(-1) + ":" + lineno + ":" + colno);
11+
console.error(error.stack);
12+
//if(window.matchMedia('(any-pointer: coarse)').matches) // Enable if alert should be for touch only.
13+
alert("OnError: \n" + event.name + ": " + event.message);
14+
};
15+
fetch("/console", {
16+
method: "POST",
17+
headers: {'Content-Type': 'application/json'},
18+
body: JSON.stringify({type: 'log', data: ['Log server open']})
19+
}).then(
20+
/*resolve*/(response)=>{
21+
if(response.status == 405){
22+
return;
23+
}
24+
console.log = (...data) => {
25+
fetch("/console", {
26+
method: "POST",
27+
headers: {'Content-Type': 'application/json'},
28+
body: JSON.stringify({type: 'log', data})
29+
}).then(
30+
/*resolve*/()=>{},
31+
/*reject*/()=>{
32+
// No server, restore functions
33+
console.log = default_console_log;
34+
console.warn = default_console_warn;
35+
console.error = default_console_error;
36+
});
37+
default_console_log.apply(console, data);
38+
};
39+
console.warn = (...data) => {
40+
fetch("/console", {
41+
method: "POST",
42+
headers: {'Content-Type': 'application/json'},
43+
body: JSON.stringify({type: 'warn', data})
44+
}).then(
45+
/*resolve*/()=>{},
46+
/*reject*/()=>{
47+
// No server, restore functions
48+
console.log = default_console_log;
49+
console.warn = default_console_warn;
50+
console.error = default_console_error;
51+
});
52+
default_console_warn.apply(console, data);
53+
};
54+
console.error = (...data) => {
55+
fetch("/console", {
56+
method: "POST",
57+
headers: {'Content-Type': 'application/json'},
58+
body: JSON.stringify({type: 'error', data})
59+
}).then(
60+
/*resolve*/()=>{},
61+
/*reject*/()=>{
62+
// No server, restore functions
63+
console.log = default_console_log;
64+
console.warn = default_console_warn;
65+
console.error = default_console_error;
66+
});
67+
default_console_error.apply(console, data);
68+
};
69+
});
70+
})();
71+
function remap(value, l1, h1, l2, h2) {
72+
return l2 + (h2 - l2) * (value - l1) / (h1 - l1);
73+
}
74+
75+
const animMaxDuration = 250;
76+
77+
var canvas = null;
78+
var context;
79+
var bgColor = 0;
80+
var decorColor = 0;
81+
var isShowing = false;
82+
var animIn = false;
83+
var animOut = false;
84+
var animStartTime = 0;
85+
function render(time){
86+
if(!isShowing){
87+
requestAnimationFrame(render);
88+
return;
89+
}
90+
let width = canvas.width;
91+
let height = canvas.height;
92+
let size = (width < height ? width : height) * .4;
93+
let sizeMult = ((Math.sin(time * .001) + 1) * .25) + .5;
94+
let alphaMult = (1 - sizeMult) + .5;
95+
96+
context.clearRect(0, 0, width, height);
97+
if(animIn){
98+
if(animStartTime == 0){animStartTime = time;}
99+
let duration = time - animStartTime;
100+
if(duration >= animMaxDuration){
101+
duration = animMaxDuration;
102+
animIn = false;
103+
animStartTime = 0;
104+
}
105+
sizeMult = remap(Math.sqrt(Math.sqrt(duration)), 0, Math.sqrt(Math.sqrt(animMaxDuration)), 5, sizeMult);
106+
alphaMult = remap(duration, 0, animMaxDuration, 0, alphaMult);
107+
context.globalAlpha = remap(duration, 0, animMaxDuration, 0, 1);
108+
}
109+
if(animOut){
110+
if(animStartTime == 0){animStartTime = time; console.log("animOut start");}
111+
let duration = time - animStartTime;
112+
if(duration >= animMaxDuration){
113+
duration = animMaxDuration;
114+
animOut = false;
115+
isShowing = false;
116+
animStartTime = 0;
117+
console.log("animOut end");
118+
this.postMessage({cmd: 'resetZ'});
119+
}
120+
sizeMult = remap(duration * duration * duration, 0, animMaxDuration * animMaxDuration * animMaxDuration, sizeMult, 5);
121+
alphaMult = remap(duration, 0, animMaxDuration, alphaMult, 0);
122+
context.globalAlpha = remap(duration, 0, animMaxDuration, 1, 0);
123+
}
124+
125+
context.fillStyle = `rgba(
126+
${bgColor&0xff},
127+
${(bgColor>>>8)&0xff},
128+
${(bgColor>>>16)&0xff},
129+
${(bgColor>>>24)/0xff}
130+
)`;
131+
context.fillRect(0, 0, width, height);
132+
133+
context.fillStyle = "white";
134+
context.fillStyle = `rgba(
135+
${decorColor&0xff},
136+
${(decorColor>>>8)&0xff},
137+
${(decorColor>>>16)&0xff},
138+
1
139+
)`;
140+
context.globalAlpha = .1 * alphaMult;
141+
context.beginPath();
142+
context.arc(width * .5, height * .5, size * sizeMult, 0, Math.PI * 2, true);
143+
context.fill();
144+
context.globalAlpha = .3 * alphaMult;
145+
context.beginPath();
146+
context.arc(width * .5, height * .5, size * .8 * sizeMult, 0, Math.PI * 2, true);
147+
context.fill();
148+
context.globalAlpha = .5 * alphaMult;
149+
context.beginPath();
150+
context.arc(width * .5, height * .5, size * .6 * sizeMult, 0, Math.PI * 2, true);
151+
context.fill();
152+
context.globalAlpha = .7 * alphaMult;
153+
context.beginPath();
154+
context.arc(width * .5, height * .5, size * .4 * sizeMult, 0, Math.PI * 2, true);
155+
context.fill();
156+
context.globalAlpha = .9 * alphaMult;
157+
context.beginPath();
158+
context.arc(width * .5, height * .5, size * .2 * sizeMult, 0, Math.PI * 2, true);
159+
context.fill();
160+
context.globalAlpha = 1;
161+
requestAnimationFrame(render);
162+
}
163+
164+
onmessage = async function (msg)
165+
{
166+
if(msg.data.cmd == 'init'){
167+
canvas = msg.data.canvas;
168+
context = canvas.getContext('2d');
169+
requestAnimationFrame(render);
170+
}
171+
else if(msg.data.cmd == 'show'){
172+
bgColor = msg.data.bgColor;
173+
decorColor = msg.data.decorColor;
174+
canvas.width = msg.data.width;
175+
canvas.height = msg.data.height;
176+
animIn = msg.data.animIn;
177+
isShowing = true;
178+
}
179+
else if(msg.data.cmd == 'hide'){
180+
canvas.width = msg.data.width;
181+
canvas.height = msg.data.height;
182+
animOut = true;
183+
}
184+
}

0 commit comments

Comments
 (0)