minor fixing
This commit is contained in:
parent
acf92dd51d
commit
f366841c2c
@ -97,12 +97,12 @@ struct templateApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
|
||||
audioPause()
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
||||
audioResume()
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
|
||||
audioPause()
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
||||
audioResume()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,15 @@
|
||||
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<title>{{=it.product.name}}</title>
|
||||
<script type="text/javascript">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<title>{{=it.product.name}}</title>
|
||||
<script type="text/javascript">
|
||||
|
||||
function request(data) {
|
||||
return window.webkit.messageHandlers.listener.postMessage(data);
|
||||
}
|
||||
|
||||
|
||||
function needAudioPermission() {
|
||||
return request({ name: "needAudioPermission" });
|
||||
}
|
||||
@ -40,15 +41,15 @@ function requestAudioPermission() {
|
||||
function audioStart() {
|
||||
return request({ name: "audioStart" });
|
||||
}
|
||||
|
||||
|
||||
function audioStop() {
|
||||
return request({ name: "audioStop" });
|
||||
}
|
||||
|
||||
|
||||
function setParameter(index, value) {
|
||||
return request({ name: "setParameter", index: index, value: value });
|
||||
}
|
||||
|
||||
|
||||
function getParameter(index) {
|
||||
return request({ name: "getParameter", index: index });
|
||||
}
|
||||
@ -75,125 +76,126 @@ var outParamInterval;
|
||||
|
||||
window.onload = async function () {
|
||||
topButtonElem = document.getElementById("topButton");
|
||||
var paramsElem = document.getElementById("params");
|
||||
var paramsElem = document.getElementById("params");
|
||||
|
||||
for (var i = 0; i < data.buses.length; i++)
|
||||
if (data.buses[i].type == "audio" && data.buses[i].direction == "input") {
|
||||
hasAudioPermission = !await needAudioPermission();
|
||||
break;
|
||||
}
|
||||
for (var i = 0; i < data.buses.length; i++) {
|
||||
if (data.buses[i].type == "audio" && data.buses[i].direction == "input") {
|
||||
hasAudioPermission = !await needAudioPermission();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
topButtonElem.value = hasAudioPermission ? "START" : "INIT";
|
||||
topButtonElem.addEventListener("click", async function () {
|
||||
if (hasAudioPermission) {
|
||||
if (audioStarted) {
|
||||
clearInterval(outParamInterval);
|
||||
await audioStop();
|
||||
topButtonElem.value = hasAudioPermission ? "START" : "INIT";
|
||||
topButtonElem.addEventListener("click", async function () {
|
||||
if (hasAudioPermission) {
|
||||
if (audioStarted) {
|
||||
clearInterval(outParamInterval);
|
||||
await audioStop();
|
||||
|
||||
paramsElem.innerHTML = "";
|
||||
paramsElem.innerHTML = "";
|
||||
|
||||
topButtonElem.value = "START";
|
||||
audioStarted = false;
|
||||
} else {
|
||||
if (await audioStart()) {
|
||||
for (var i = 0; i < data.parameters.length; i++) {
|
||||
var div = document.createElement("div");
|
||||
topButtonElem.value = "START";
|
||||
audioStarted = false;
|
||||
} else {
|
||||
if (await audioStart()) {
|
||||
for (var i = 0; i < data.parameters.length; i++) {
|
||||
var div = document.createElement("div");
|
||||
|
||||
var label = document.createElement("label");
|
||||
label.setAttribute("for", "p" + i);
|
||||
label.innerText = data.parameters[i].name;
|
||||
var label = document.createElement("label");
|
||||
label.setAttribute("for", "p" + i);
|
||||
label.innerText = data.parameters[i].name;
|
||||
|
||||
var range = document.createElement("input");
|
||||
range.classList.add("range");
|
||||
range.setAttribute("type", "range");
|
||||
range.setAttribute("id", "p" + i);
|
||||
range.setAttribute("name", "p" + i);
|
||||
if (data.parameters[i].isBypass || data.parameters[i].toggled) {
|
||||
range.setAttribute("min", 0);
|
||||
range.setAttribute("max", 1);
|
||||
range.setAttribute("step", 1);
|
||||
} else {
|
||||
range.setAttribute("min", 0);
|
||||
range.setAttribute("max", 1);
|
||||
range.setAttribute("step", data.parameters[i].integer ? 1 / (data.parameters[i].maximum - data.parameters[i].minimum) : "any");
|
||||
}
|
||||
range.value = unmap(i, data.parameters[i].defaultValue);
|
||||
if (data.parameters[i].direction == "output")
|
||||
range.setAttribute("readonly", "true");
|
||||
else {
|
||||
let index = i;
|
||||
range.addEventListener("input",
|
||||
async function (ev) {
|
||||
await setParameter(index, map(index, parseFloat(ev.target.value)));
|
||||
});
|
||||
}
|
||||
var range = document.createElement("input");
|
||||
range.classList.add("range");
|
||||
range.setAttribute("type", "range");
|
||||
range.setAttribute("id", "p" + i);
|
||||
range.setAttribute("name", "p" + i);
|
||||
if (data.parameters[i].isBypass || data.parameters[i].toggled) {
|
||||
range.setAttribute("min", 0);
|
||||
range.setAttribute("max", 1);
|
||||
range.setAttribute("step", 1);
|
||||
} else {
|
||||
range.setAttribute("min", 0);
|
||||
range.setAttribute("max", 1);
|
||||
range.setAttribute("step", data.parameters[i].integer ? 1 / (data.parameters[i].maximum - data.parameters[i].minimum) : "any");
|
||||
}
|
||||
range.value = unmap(i, data.parameters[i].defaultValue);
|
||||
if (data.parameters[i].direction == "output")
|
||||
range.setAttribute("readonly", "true");
|
||||
else {
|
||||
let index = i;
|
||||
range.addEventListener("input",
|
||||
async function (ev) {
|
||||
await setParameter(index, map(index, parseFloat(ev.target.value)));
|
||||
});
|
||||
}
|
||||
|
||||
div.appendChild(label);
|
||||
div.appendChild(document.createElement("br"));
|
||||
div.appendChild(range);
|
||||
paramsElem.appendChild(div);
|
||||
}
|
||||
div.appendChild(label);
|
||||
div.appendChild(document.createElement("br"));
|
||||
div.appendChild(range);
|
||||
paramsElem.appendChild(div);
|
||||
}
|
||||
|
||||
outParamInterval = setInterval(
|
||||
async function () {
|
||||
for (var i = 0; i < data.parameters.length; i++)
|
||||
if (data.parameters[i].direction == "output") {
|
||||
document.getElementById("p" + i).value = unmap(i, await getParameter(i));
|
||||
}
|
||||
}, 50);
|
||||
|
||||
topButtonElem.value = "STOP";
|
||||
audioStarted = true;
|
||||
} else
|
||||
alert("Could not start audio");
|
||||
}
|
||||
} else {
|
||||
await requestAudioPermission();
|
||||
var interval = setInterval(
|
||||
async function () {
|
||||
if (!await needAudioPermission()) {
|
||||
gotAudioPermission();
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
outParamInterval = setInterval(
|
||||
async function () {
|
||||
for (var i = 0; i < data.parameters.length; i++)
|
||||
if (data.parameters[i].direction == "output") {
|
||||
document.getElementById("p" + i).value = unmap(i, await getParameter(i));
|
||||
}
|
||||
}, 50);
|
||||
|
||||
topButtonElem.value = "STOP";
|
||||
audioStarted = true;
|
||||
} else
|
||||
alert("Could not start audio");
|
||||
}
|
||||
} else {
|
||||
await requestAudioPermission();
|
||||
var interval = setInterval(
|
||||
async function () {
|
||||
if (!await needAudioPermission()) {
|
||||
gotAudioPermission();
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function gotAudioPermission() {
|
||||
hasAudioPermission = true;
|
||||
topButtonElem.value = "START";
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
user-select: none;
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 1em;
|
||||
}
|
||||
body {
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
#topButton {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
background-color: #04aa6d;
|
||||
color: white;
|
||||
padding: 0.5em;
|
||||
text-align: center;
|
||||
margin-bottom: 1em;
|
||||
padding: 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>
|
||||
.range {
|
||||
width: 90%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<input id="topButton" type="button">
|
||||
<div id="params"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -109,16 +109,16 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
|
||||
if (mutex.try_lock()) {
|
||||
# if PARAMETERS_N > 0
|
||||
for (size_t i = 0; i < PARAMETERS_N; i++) {
|
||||
if (param_data[i].out) {
|
||||
if (param_data[i].out) {
|
||||
# ifdef PARAM_OUT_CPU_INDEX
|
||||
if (i == PARAM_OUT_CPU_INDEX) {
|
||||
param_values_prev[i] = param_values[i] = cpu_meter;
|
||||
continue;
|
||||
}
|
||||
if (i == PARAM_OUT_CPU_INDEX) {
|
||||
param_values_prev[i] = param_values[i] = cpu_meter;
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i);
|
||||
}
|
||||
else if (param_values_prev[i] != param_values[i]) {
|
||||
param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i);
|
||||
}
|
||||
else if (param_values_prev[i] != param_values[i]) {
|
||||
plugin_set_parameter(&instance, i, param_values[i]);
|
||||
param_values_prev[i] = param_values[i];
|
||||
}
|
||||
@ -178,10 +178,10 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
|
||||
#endif
|
||||
|
||||
#ifdef PARAM_OUT_CPU_INDEX
|
||||
const unsigned long long processTimeEnd = fatica_time_process();
|
||||
const unsigned long long processTime100n = processTimeEnd - processTimeStart;
|
||||
const double processTimeS = ((double) processTime100n) * 1.0e-7;
|
||||
cpu_meter = cpu_meter * 0.9f + ((float) (processTimeS * sample_rate)) * 0.1f;
|
||||
const unsigned long long processTimeEnd = fatica_time_process();
|
||||
const unsigned long long processTime100n = processTimeEnd - processTimeStart;
|
||||
const double processTimeS = ((double) processTime100n) * 1.0e-7;
|
||||
cpu_meter = cpu_meter * 0.9f + ((float) (processTimeS * sample_rate)) * 0.1f;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -301,8 +301,8 @@ char audioStart() {
|
||||
#endif
|
||||
|
||||
plugin_set_sample_rate(&instance, (float)device.sampleRate);
|
||||
sample_rate = (float)device.sampleRate;
|
||||
|
||||
sample_rate = (float)device.sampleRate;
|
||||
|
||||
size_t req = plugin_mem_req(&instance);
|
||||
if (req != 0) {
|
||||
mem = malloc(req);
|
||||
|
Loading…
Reference in New Issue
Block a user