improved android code + fixes in bw_ppm and bw_rand

This commit is contained in:
Stefano D'Angelo 2023-08-04 07:30:57 +02:00
parent 13659d9aad
commit 6d92e83b57
6 changed files with 11 additions and 5 deletions

1
TODO
View File

@ -101,6 +101,7 @@ build system:
* single header(s) * single header(s)
* cross compile (rpi etc.) * cross compile (rpi etc.)
* consider tuist (https://tuist.io/), bazel (https://bazel.build/), pants (https://www.pantsbuild.org/), buck (https://buck2.build/), please (https://please.build/index.html) for mobile apps * consider tuist (https://tuist.io/), bazel (https://bazel.build/), pants (https://www.pantsbuild.org/), buck (https://buck2.build/), please (https://please.build/index.html) for mobile apps
* homogenize android and ios common code (e.g., same index)
-- --

View File

@ -71,7 +71,7 @@ public class MainActivity extends Activity {
@JavascriptInterface @JavascriptInterface
public void setParameter(int i, float v) { public void setParameter(int i, float v) {
nativeSetParameter(i, v * 0.001f); nativeSetParameter(i, v);
} }
} }

View File

@ -154,7 +154,7 @@ public class MainActivity extends Activity {
@JavascriptInterface @JavascriptInterface
public void setParameter(int i, float v) { public void setParameter(int i, float v) {
nativeSetParameter(i, v * 0.001f); nativeSetParameter(i, v);
} }
} }

View File

@ -22,6 +22,7 @@
--> -->
<html> <html>
<head> <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" src="config.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var hasAudioPermission = true; var hasAudioPermission = true;
@ -75,7 +76,7 @@ window.onload = function () {
let index = i; let index = i;
range.addEventListener("input", range.addEventListener("input",
function (ev) { function (ev) {
Android.setParameter(index, ev.target.value * 1000); Android.setParameter(index, parseFloat(ev.target.value));
}); });
} }
div.appendChild(range); div.appendChild(range);
@ -108,6 +109,7 @@ function gotAudioPermission() {
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
user-select: none;
} }
body { body {

View File

@ -33,6 +33,8 @@
* <li>Version <strong>0.6.0</strong>: * <li>Version <strong>0.6.0</strong>:
* <ul> * <ul>
* <li>Removed dependency on bw_config.</li> * <li>Removed dependency on bw_config.</li>
* <li>Fixed bug by forcing <code>-INFINITY</code> output when signal
* level is below -600 dB.</li>
* </ul> * </ul>
* </li> * </li>
* <li>Version <strong>0.5.0</strong>: * <li>Version <strong>0.5.0</strong>:
@ -200,7 +202,7 @@ static inline void bw_ppm_update_coeffs_audio(bw_ppm_coeffs *BW_RESTRICT coeffs)
static inline float bw_ppm_process1(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, float x) { static inline float bw_ppm_process1(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, float x) {
const float yl = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x); const float yl = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x);
const float y = yl > 0.f ? bw_lin2dBf_3(yl) : -INFINITY; const float y = yl >= 1e-30f ? bw_lin2dBf_3(yl) : -INFINITY; // -600 dB is quiet enough
state->y_z1 = y; state->y_z1 = y;
return y; return y;
} }

View File

@ -38,6 +38,7 @@
* <ul> * <ul>
* <li>Added debugging code.</li> * <li>Added debugging code.</li>
* <li>Removed dependency on bw_config.</li> * <li>Removed dependency on bw_config.</li>
* <li>Fixed harmless warning in <code>bw_randu32()</code>.</li>
* </ul> * </ul>
* </li> * </li>
* <li>Version <strong>0.2.0</strong>: * <li>Version <strong>0.2.0</strong>:
@ -95,7 +96,7 @@ static inline uint32_t bw_randu32(uint64_t *BW_RESTRICT state) {
// Permuted Congruential Generator, // Permuted Congruential Generator,
// taken from https://nullprogram.com/blog/2017/09/21/ // taken from https://nullprogram.com/blog/2017/09/21/
*state = *state * 0x9b60933458e17d7d + 0xd737232eeccdf7ed; *state = *state * 0x9b60933458e17d7d + 0xd737232eeccdf7ed;
return *state >> (29 - (*state >> 61)); return (uint32_t)(*state >> (29 - (*state >> 61)));
} }
static inline float bw_randf(uint64_t *BW_RESTRICT state) { static inline float bw_randf(uint64_t *BW_RESTRICT state) {