140 lines
3.5 KiB
HTML
140 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
|
|
Brickworks
|
|
|
|
Copyright (C) 2023 Orastron Srl unipersonale
|
|
|
|
Brickworks is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, version 3 of the License.
|
|
|
|
Brickworks is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Brickworks. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
File author: Stefano D'Angelo, Paolo Marrone
|
|
|
|
-->
|
|
<html>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
|
<script type="text/javascript" src="config.js"></script>
|
|
<script type="text/javascript">
|
|
var hasAudioPermission = true;
|
|
for (var i = 0; i < buses.length; i++)
|
|
if (!buses[i].output) {
|
|
hasAudioPermission = Android.hasAudioPermission();
|
|
break;
|
|
}
|
|
var audioStarted = false;
|
|
var topButtonElem;
|
|
var outParamInterval;
|
|
|
|
window.onload = function () {
|
|
topButtonElem = document.getElementById("topButton");
|
|
var paramsElem = document.getElementById("params");
|
|
|
|
topButtonElem.value = hasAudioPermission ? "START" : "INIT";
|
|
topButtonElem.addEventListener("click", function () {
|
|
if (hasAudioPermission) {
|
|
if (audioStarted) {
|
|
clearInterval(outParamInterval);
|
|
Android.audioStop();
|
|
|
|
paramsElem.innerHTML = "";
|
|
|
|
topButtonElem.value = "START";
|
|
audioStarted = false;
|
|
} else {
|
|
if (Android.audioStart()) {
|
|
for (var i = 0; i < parameters.length; i++) {
|
|
var div = document.createElement("div");
|
|
paramsElem.appendChild(div);
|
|
|
|
var label = document.createElement("label");
|
|
label.innerText = parameters[i].name;
|
|
div.appendChild(label);
|
|
|
|
div.appendChild(document.createElement("br"));
|
|
|
|
var range = document.createElement("input");
|
|
range.classList.add("range");
|
|
range.setAttribute("type", "range");
|
|
range.setAttribute("id", "p" + i);
|
|
range.setAttribute("min", 0);
|
|
range.setAttribute("max", 1);
|
|
range.setAttribute("step", parameters[i].step ? 1 / parameters[i].step : "any");
|
|
range.value = parameters[i].defaultValue;
|
|
if (parameters[i].output)
|
|
range.setAttribute("readonly", "readonly");
|
|
else {
|
|
let index = i;
|
|
range.addEventListener("input",
|
|
function (ev) {
|
|
Android.setParameter(index, parseFloat(ev.target.value));
|
|
});
|
|
}
|
|
div.appendChild(range);
|
|
}
|
|
|
|
outParamInterval = setInterval(
|
|
function () {
|
|
for (var i = 0; i < parameters.length; i++)
|
|
if (parameters[i].output)
|
|
document.getElementById("p" + i).value = Android.getParameter(i);
|
|
}, 50);
|
|
|
|
topButtonElem.value = "STOP";
|
|
audioStarted = true;
|
|
} else
|
|
alert("Could not start audio");
|
|
}
|
|
}
|
|
else
|
|
Android.requestAudioPermission();
|
|
});
|
|
};
|
|
|
|
function gotAudioPermission() {
|
|
hasAudioPermission = true;
|
|
topButtonElem.value = "START";
|
|
}
|
|
</script>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
user-select: none;
|
|
}
|
|
|
|
body {
|
|
margin: 1em;
|
|
}
|
|
|
|
#topButton {
|
|
width: 100%;
|
|
border: 0;
|
|
background-color: #04aa6d;
|
|
color: white;
|
|
padding: 0.5em;
|
|
text-align: center;
|
|
margin-bottom: 1em;
|
|
padding: 1em;
|
|
}
|
|
|
|
.range {
|
|
width: 90%;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<input id="topButton" type="button">
|
|
<div id="params"></div>
|
|
</body>
|
|
</html>
|