mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 04:44:33 +01:00
Juan: "¿Se puede llevar el OTT más al extremo? Quiero que me permita hacer
bajos y sonidos ultra comprimidos y saturados tipo dubstep."
FX > OTT (fx.c ott_block), DEPTH alone (DEPTH, TIME, UP/DN and X-OVER are
all taken):
- DEPTH 0 .. 80 exactly as V10.8.72, every sample. GEN uses at most 78, so
its pieces render as they did.
- DEPTH 85 .. 100 the extreme zone, a smoothstep from 80 (ex: 85 0.16,
90 0.5, 95 0.84, 100 1):
- both thresholds up to 9 dB higher at 100 (up toward -9 dBFS, down over
-13). They move together so the law keeps its shape: widening the two
apart (up higher, down lower) was tried and inverts a wobble's dynamics
(its quiet half came out 4 dB over its loud half);
- the drive into dsp.c's soft clip up to +18 dB (V10.8.72: +9);
- the half under 0 driven 3 dB less: asymmetric, even harmonics, a growl
rather than a fizz (a fold was not used: on a bass it fizzes). A fourth
gain (ott_t g[3], in the struct's padding: no RAM) ramps like the drive
and equals it to DEPTH 80;
- the release a quarter of TIME faster (TIME 48 reads as 36).
- Still never past -0.3 dBFS: the soft clip's ceiling is 31597 << 2 of
2^17. The drive's top (2 x OT_DRV) on the clamp's 262143 stays inside
32 bits (2.13e9). Never a hard clip.
- The overload guard halves the extreme zone along with the weight.
ott_test 11 (new): a 55 Hz bass, its level wobbling 2 Hz between full and a
quarter, at TIME 48 and X-OVER 26 (GEN's bass). Crest dB / THD % / peak dBFS:
sine DEPTH 0 6.4 / 0.0 / -6.03
DEPTH 60 5.5 / 1.3 / -7.41
DEPTH 80 4.8 / 4.0 / -7.59
DEPTH 90 4.1 / 6.2 / -0.67
DEPTH 100 1.1 / 23.7 / -0.32
saw DEPTH 80 6.7 dB crest, harmonics 2 .. 40 at 35.7 % of the
fundamental
DEPTH 100 1.2 dB, 31.0 % (the saturation squares the saw, and the
pulled-up low band weighs more against the fundamental)
- DEPTH 1 .. 80: a hash of ott_block's output (TIME, UP/DN and X-OVER
moving, a wobble and noise bursts) equals V10.8.72's build (0x4e930819).
- The drive's top within 32 bits, the negative side's lower; to 80 both
equal.
- Section 1's DEPTH 100 bounds are the new ones: a quiet band +41 dB, a loud
one held at the ceiling, the drive alone +16.7 dB.
- DEPTH 0 bit-exact and the rest as before.
GEN unchanged: gen_test, gen_entry (MID byte for byte) and gen_peak (270
pieces, 0 over -1 dBFS, loudest stem -2.5, mix -1.1) give logs identical to
V10.8.72's. A WEST FOLD BASS riff rendered at OTT 80 is byte-identical in
both builds.
WAVE (JIANT BYTE 87f9122 / ba68749): FM has no WAVE engine (no formula
frames drawn in the main loop, no fvm compiler), so it has no such click.
BYTE 32428a5d itself is DIST's formula TONE stage in 32 bits, which
V10.8.72 already does here. Nothing to port.
Flash (V10.8.72: 12 B free; this work ~150 B):
- 12 more once-an-event sound functions built for size: WEST's and SWARM's
note, JAM's next sequence, CLAY's key, SCENE's follower, an automation's
id, the FX fault, a MIDI message queued, a fitted step, a step's lanes,
the ratchets.
- PHASE's WAVE / WAVE2 and ANALOG's WAVE names packed in PNE (str_nth).
Image 84 B free, BT 36 B free (73692 of 73728), RAM .data+.bss 1048 B free,
pool spare 8224 B, RAM code 40384 of 42496 B. audio.c is V23's.
REPIN=keep; a plain build passes.
CPU (tests/cpu_lines_test.py), each scene's worst block, core 0/core 1,
V10.8.72 -> V10.8.73:
101 78/44 -> 78/44 102 62/28 -> 62/28 103 85/14 -> 86/14
104 50/14 -> 51/14 105 66/41 -> 66/41 106 52/36 -> 52/36
107 62/11 -> 63/11 108 51/29 -> 51/29 0c 70/58 -> 70/58
0c, T2 (FM6, sounding) at OTT 100 (CL_OTTB, new): 76/55 -> 76/56
0c, every track at OTT 100 (CL_OTT, the worst case): 75/64 -> 80/64.
The total is +1.8 k instructions a block (+0.35 % of a block), but
mc_split moved a track to core 0 in the model.
The GEN scenes' +1 is the OTT tracks' per-sample select.
The A/B: a dubstep riff (WEST FOLD BASS, FOLD and RES wobbling 1/4 .. 1/16,
DRUM half time, 140 BPM) at OTT 0, 60, 80, 100, and V10.8.72's 100. The
bass alone: crest 12.9, 9.0, 5.7 and 2.9 dB at 0, 60, 80 and 100.
Tests:
- ott_test: the extreme zone, DEPTH 1 .. 80's hash, the new bounds;
- cpu_lines_test.c: CL_OTTB;
- the local workflow: steps 1 .. 27 pass. Step 28's wasm build needs
emcc, which this machine lacks; its native-check, gen-web and
resound-web pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
422 lines
25 KiB
C
422 lines
25 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only
|
|
* Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
|
|
/* (V10.8.71, JIANT BYTE 43923fd4's tests/ott_test.c, GPL, on FM; V10.8.72: BYTE d9feaf71's final law) FX > OTT, a track's two-band upward / downward
|
|
* compressor (fx.c ott_block; params.c ott_v): a quiet band comes up, a loud one goes down, each band on its own; DEPTH 0
|
|
* the track's sound bit for bit (not run), and back to it after DEPTH goes down; silence stays silence; no value out of
|
|
* range on any input; the overload's guard eases it (never cuts the sound); kept with a project ('O' 'T', its TIME
|
|
* UP/DN X-OVER at DEPTH 0 too) and a user preset, an older one loading with it off; the page (FX > TRACK's fourth).
|
|
* cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/ott_test.c -lm */
|
|
#define UI_TEST_NO_MAIN 1
|
|
#include "ui_test.c"
|
|
#include <math.h>
|
|
static int bad;
|
|
static void ck(const char *what, int ok) { printf("ott: %-100s %s\n", what, ok ? "ok" : "FAIL"); bad += !ok; }
|
|
static double run_sine(uint32_t ti, double amp, double hz, uint32_t nblk, double *out_rms, int32_t *mx)
|
|
{
|
|
static int32_t b[CTL];
|
|
double ein = 0, eout = 0;
|
|
uint32_t k, i;
|
|
*mx = 0;
|
|
for (k = 0; k < nblk; k++) {
|
|
for (i = 0; i < CTL; i++) b[i] = (int32_t)lrint(amp * sin(2 * M_PI * hz * (k * CTL + i) / 44100.0));
|
|
if (k >= nblk / 2) for (i = 0; i < CTL; i++) ein += (double)b[i] * b[i];
|
|
if (ott_on(ti)) ott_block(ti, b, CTL);
|
|
if (k >= nblk / 2) for (i = 0; i < CTL; i++) { eout += (double)b[i] * b[i]; if (abs(b[i]) > *mx) *mx = abs(b[i]); }
|
|
}
|
|
*out_rms = sqrt(eout / (nblk / 2 * CTL));
|
|
return 10 * log10((eout + 1) / (ein + 1)); /* (the gain, dB) */
|
|
}
|
|
static void ott_set(uint32_t ti, int d, int tm, int ud, int xo)
|
|
{
|
|
ott_v[ti][OT_DEPTH] = (int16_t)d; ott_v[ti][OT_TIME] = (int16_t)tm; ott_v[ti][OT_UPDN] = (int16_t)ud; ott_v[ti][OT_XO] = (int16_t)xo;
|
|
}
|
|
/* (V10.8.73) a 55 Hz bass (a sine or a naive saw, its level wobbling 2 Hz between full and a quarter: a dubstep
|
|
* wobble's) through the OTT at DEPTH d: after 1 s, a second's crest (peak over rms, dB), THD (harmonics 2 .. 40 over the
|
|
* fundamental, Goertzel, %) and peak */
|
|
static void bass55(int d, int saw, double *crest, double *thd, int32_t *mx)
|
|
{
|
|
static int32_t b[CTL];
|
|
static double y[44100 + CTL];
|
|
double e = 0, h1 = 0, hn = 0;
|
|
uint32_t k, i, n = 0, h;
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, d, 48, 0, 26);
|
|
*mx = 0;
|
|
for (k = 0; k < 2 * 44100 / CTL; k++) {
|
|
for (i = 0; i < CTL; i++) {
|
|
double t = (k * CTL + i) / 44100.0, p = fmod(55 * t, 1.0), w = 0.625 + 0.375 * cos(2 * M_PI * 2 * t);
|
|
b[i] = (int32_t)lrint(131072 * 0.5 * w * (saw ? 2 * p - 1 : sin(2 * M_PI * p)));
|
|
}
|
|
ott_block(0, b, CTL);
|
|
if (k >= 44100 / CTL)
|
|
for (i = 0; i < CTL && n < 44100; i++) { y[n++] = b[i]; e += (double)b[i] * b[i]; if (abs(b[i]) > *mx) *mx = abs(b[i]); }
|
|
}
|
|
for (h = 1; h <= 40; h++) { /* (Goertzel at h x 55 Hz: whole bins over a second) */
|
|
double c = 2 * cos(2 * M_PI * 55 * h / 44100.0), s1 = 0, s2 = 0, s0, p;
|
|
for (i = 0; i < n; i++) { s0 = y[i] + c * s1 - s2; s2 = s1; s1 = s0; }
|
|
p = s1 * s1 + s2 * s2 - c * s1 * s2;
|
|
if (h == 1) h1 = p; else hn += p;
|
|
}
|
|
*crest = 20 * log10(*mx / sqrt(e / n));
|
|
*thd = 100 * sqrt(hn / h1);
|
|
}
|
|
static uint32_t part_hash(uint32_t nblk, int depth_until)
|
|
{
|
|
track_t *t = &trk[0];
|
|
uint32_t h = 2166136261u, b, i;
|
|
ui_power_on();
|
|
host_preset(t, 0, 0);
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_defaults();
|
|
rng_state = 99;
|
|
for (b = 0; b < nblk; b++) {
|
|
if (b == 2) trk_note_on(t, 48, 110);
|
|
ott_v[0][OT_DEPTH] = (int16_t)((int)b < depth_until ? 100 : 0);
|
|
memset(mix_l, 0, sizeof mix_l); memset(mix_r, 0, sizeof mix_r);
|
|
memset(send_c, 0, sizeof send_c); memset(send_d, 0, sizeof send_d); memset(send_r, 0, sizeof send_r);
|
|
mix_part_m(t, CTL);
|
|
if (b >= 60) for (i = 0; i < CTL; i++) h = (h ^ (uint32_t)mix_l[i]) * 16777619u;
|
|
}
|
|
return h;
|
|
}
|
|
int main(void)
|
|
{
|
|
double r, g;
|
|
int32_t mx;
|
|
uint32_t i, k;
|
|
ui_power_on();
|
|
ck("power-on: every track's OTT off at its defaults (DEPTH 0, TIME 48, UP/DN 0, X-OVER 37), not run",
|
|
ott_v[0][OT_DEPTH] == 0 && ott_v[5][OT_TIME] == 48 && ott_v[3][OT_UPDN] == 0 && ott_v[2][OT_XO] == 37 && !ott_on(0) && !ott_on(5));
|
|
{ /* 1. a quiet band up, a loud one down (DEPTH 100), each band its own; UP/DN takes from one side */
|
|
double q_lo, q_hi, l_lo, l_hi, q_none, l_none, q_mix;
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 100, 50, 0, 37);
|
|
q_lo = run_sine(0, 1300, 80, 400, &r, &mx); /* -40 dB of full scale (2^17), under X-OVER */
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
q_hi = run_sine(0, 1300, 3000, 400, &r, &mx); /* .. over it */
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
l_lo = run_sine(0, 120000, 80, 400, &r, &mx); /* -0.8 dB */
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
l_hi = run_sine(0, 120000, 3000, 400, &r, &mx);
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 100, 50, 63, 37); /* UP/DN +: no downward */
|
|
l_none = run_sine(0, 120000, 3000, 400, &r, &mx);
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 100, 50, -64, 37); /* UP/DN -: no upward */
|
|
q_none = run_sine(0, 1300, 3000, 400, &r, &mx);
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 50, 50, 0, 37); /* half the DEPTH: about half the gain */
|
|
q_mix = run_sine(0, 1300, 3000, 400, &r, &mx);
|
|
printf("ott: quiet low %+.1f dB, quiet high %+.1f, loud low %+.1f, loud high %+.1f; UP/DN +63 loud %+.1f, -64 quiet %+.1f; DEPTH 50 quiet %+.1f\n",
|
|
q_lo, q_hi, l_lo, l_hi, l_none, q_none, q_mix);
|
|
ck("1. DEPTH 100 (V10.8.73's extreme zone): a quiet band up (+38 .. +45 dB with the drive), a loud one held at the ceiling (-3 .. +4 dB)",
|
|
q_lo > 38 && q_lo < 45 && q_hi > 38 && q_hi < 45 && l_lo < 4 && l_lo > -3 && l_hi < 4 && l_hi > -3);
|
|
ck(" UP/DN +63: no downward (a loud band driven into the clip: 0 .. +4 dB); -64: no upward, the drive alone (+15 .. +18 dB); DEPTH 50 a quarter (squared)",
|
|
l_none > 0 && l_none < 4 && q_none > 15 && q_none < 18 && q_mix > q_hi * 0.15 && q_mix < q_hi * 0.4);
|
|
{ /* (V10.8.72) the level pulled even: a -46 dBFS sine and a -6 dBFS one, within 3 dB of each other (full scale 2^17) */
|
|
double r46, r6;
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 100, 48, 0, 37);
|
|
(void)run_sine(0, 131072 * pow(10, -46 / 20.0), 1000, 400, &r46, &mx);
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
(void)run_sine(0, 131072 * pow(10, -6 / 20.0), 1000, 400, &r6, &mx);
|
|
printf("ott: DEPTH 100, 1 kHz: -46 dBFS in: %.1f dBFS out; -6 dBFS in: %.1f dBFS out (peaks, from the rms; peak %d)\n",
|
|
20 * log10(r46 * M_SQRT2 / 131072), 20 * log10(r6 * M_SQRT2 / 131072), mx);
|
|
ck(" DEPTH 100: -46 dBFS and -6 dBFS sines come out within 3 dB of each other, no sample past full scale (the soft clip)",
|
|
fabs(20 * log10(r46 / r6)) < 3 && mx < 131072);
|
|
}
|
|
}
|
|
{ /* 2. a quiet low under a loud high: the low comes up, the high goes down (the bands apart) */
|
|
static int32_t b[CTL];
|
|
double elo = 0, elo0 = 0;
|
|
uint32_t n;
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 100, 50, 0, 37);
|
|
for (n = 0; n < 400; n++) {
|
|
for (i = 0; i < CTL; i++) {
|
|
double tt = (n * CTL + i) / 44100.0;
|
|
b[i] = (int32_t)lrint(1300 * sin(2 * M_PI * 60 * tt) + 100000 * sin(2 * M_PI * 4000 * tt));
|
|
}
|
|
ott_block(0, b, CTL);
|
|
}
|
|
(void)elo; (void)elo0;
|
|
ck("2. a quiet low under a loud high: LOW's gain up, HIGH's down (each band its own level)",
|
|
ott_s[0].g[0] > 0 && ott_s[0].g[1] < -50);
|
|
}
|
|
{ /* 3. silence stays silence; anything in, nothing out of range (the integers' path: no NaN, no denormal) */
|
|
static int32_t b[CTL];
|
|
int ok = 1;
|
|
uint32_t n, rs = 12345u;
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(1, 100, 30, 0, 15);
|
|
for (n = 0; n < 300; n++) {
|
|
memset(b, 0, sizeof b);
|
|
ott_block(1, b, CTL);
|
|
for (i = 0; i < CTL; i++) ok &= b[i] == 0;
|
|
}
|
|
ck("3. DEPTH 100, silence in: silence out (no hiss brought up), its gain within the bounds", ok && ott_s[1].g[0] <= OT_GUP && ott_s[1].g[0] >= 0);
|
|
for (k = 0; k < 4u; k++) {
|
|
ott_set(1, 100, k ? 30 + (int)k * 23 : 30, k & 1 ? 63 : -64, k ? 100 : 15);
|
|
for (n = 0; n < 500; n++) {
|
|
for (i = 0; i < CTL; i++) {
|
|
rs ^= rs << 13; rs ^= rs >> 17; rs ^= rs << 5;
|
|
b[i] = n % 50 < 25 ? (int32_t)rs >> (n % 7 == 0 ? 8 : 14) : (int32_t)(rs & 15u) - 8; /* (bursts of noise past
|
|
* full scale, near-silence between) */
|
|
}
|
|
ott_block(1, b, CTL);
|
|
for (i = 0; i < CTL; i++) ok &= b[i] > -(1 << 25) && b[i] < (1 << 25);
|
|
ok &= ott_s[1].g[0] >= -OT_GDN - 3 && ott_s[1].g[0] <= OT_GUP + 3 && ott_s[1].g[1] >= -OT_GDN - 3 && ott_s[1].g[1] <= OT_GUP + 3 &&
|
|
ott_s[1].g[2] >= 0 && ott_s[1].g[2] <= 2 * OT_DRV + 1; /* (DEPTH's weight x 1.0014: +0.01 dB; V10.8.73: +18 dB at 100) */
|
|
ok &= ott_s[1].lv[0] >= 0 && ott_s[1].lv[1] >= 0;
|
|
}
|
|
}
|
|
ck(" noise bursts past full scale and near-silence, every setting: every sample and gain within range", ok);
|
|
}
|
|
{ /* 4. DEPTH 0: not run, bit for bit; after DEPTH 100 then 0: back to the same sound within a block, then not run */
|
|
uint32_t h0 = part_hash(160, 0), h1 = part_hash(160, 40), h2 = part_hash(160, 1000), h3 = part_hash(160, 0);
|
|
int quiet;
|
|
quiet = !ott_on(0);
|
|
ck("4. DEPTH 0 bit-exact (not run); DEPTH 100 for 40 blocks then 0: back to the dry part bit for bit", h0 == h3 && h0 == h1 && quiet);
|
|
ck(" DEPTH 100 throughout: the part changed", h2 != h0);
|
|
{ /* the fade: gains back at 1 after one block, the state cleared */
|
|
static int32_t b[CTL];
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(2, 100, 50, 0, 37);
|
|
for (k = 0; k < 100u; k++) {
|
|
for (i = 0; i < CTL; i++) b[i] = (int32_t)lrint(1300 * sin(2 * M_PI * 200 * (k * CTL + i) / 44100.0));
|
|
ott_block(2, b, CTL);
|
|
}
|
|
g = ott_s[2].g[0];
|
|
ott_v[2][OT_DEPTH] = 0;
|
|
ott_block(2, b, CTL);
|
|
ck(" DEPTH to 0: a block's ramp to unity, then out (ott_on 0, the state cleared)",
|
|
g > 0 && !ott_on(2) && !ott_s[2].lv[0] && !ott_s[2].lp);
|
|
}
|
|
}
|
|
{ /* 5. the overload's guard (voice.c): half the effect tripped, none while the load stays past OT_DEEP (the sound
|
|
* itself as it is) */
|
|
double full, half, none;
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 100, 50, 0, 37);
|
|
load_tight = 0; load_avg_q8 = 0;
|
|
full = run_sine(0, 1300, 3000, 400, &r, &mx);
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
load_tight = 1; load_avg_q8 = 80u << 8;
|
|
half = run_sine(0, 1300, 3000, 400, &r, &mx);
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
load_avg_q8 = (OT_DEEP + 5u) << 8;
|
|
none = run_sine(0, 1300, 3000, 400, &r, &mx);
|
|
load_tight = 0; load_avg_q8 = 0;
|
|
printf("ott: guard: off %+.1f dB, tripped %+.1f, past OT_DEEP %+.2f (the level the sound had: %.0f rms)\n", full, half, none, r);
|
|
ck("5. the guard: tripped half the squared DEPTH (half the gain); past OT_DEEP none (the sound as it was, never cut)",
|
|
half > full * 0.4 && half < full * 0.6 && fabs(none) < 0.01 && r > 800);
|
|
}
|
|
{ /* 6. kept with a project: 'O' 'T' when one is on; without it (every one of before): off */
|
|
static project_store_t st;
|
|
int ok;
|
|
uint32_t j, found = 0;
|
|
ui_power_on();
|
|
ott_set(2, 70, 40, -20, 60);
|
|
ott_set(4, 0, 90, 10, 20);
|
|
project_capture(&proj_scratch);
|
|
ok = proj_pack(&st, &proj_scratch);
|
|
for (j = 68; j + 1 < PROJ_STORE_SIZE; j++) found |= st.raw[j] == 'O' && st.raw[j + 1] == 'T' && st.raw[j + 2 + 2 * OT_N] == 70;
|
|
ui_power_on();
|
|
ok = ok && proj_import(&proj_scratch, &st, sizeof st) && project_restore_runtime(&proj_scratch) == 0;
|
|
ck("6. a project keeps each track's OTT ('O' 'T'): T3 70 40 -20 60, T5's knobs at DEPTH 0, the others off",
|
|
ok && found && ott_v[2][OT_DEPTH] == 70 && ott_v[2][OT_TIME] == 40 && ott_v[2][OT_UPDN] == -20 && ott_v[2][OT_XO] == 60 &&
|
|
ott_v[4][OT_DEPTH] == 0 && ott_v[4][OT_TIME] == 90 && ott_v[4][OT_UPDN] == 10 && ott_v[4][OT_XO] == 20 &&
|
|
ott_v[0][OT_DEPTH] == 0 && ott_v[0][OT_TIME] == 48 && ott_v[0][OT_XO] == 37);
|
|
ui_power_on(); /* (V10.8.71, BYTE's pending fixed) DEPTH 0 everywhere, a knob moved */
|
|
ott_set(1, 0, 80, -30, 50);
|
|
project_capture(&proj_scratch);
|
|
ok = proj_pack(&st, &proj_scratch);
|
|
ui_power_on();
|
|
ok = ok && proj_import(&proj_scratch, &st, sizeof st) && project_restore_runtime(&proj_scratch) == 0;
|
|
ck(" DEPTH 0 on every track: TIME UP/DN X-OVER kept all the same (80 -30 50)",
|
|
ok && ott_v[1][OT_DEPTH] == 0 && ott_v[1][OT_TIME] == 80 && ott_v[1][OT_UPDN] == -30 && ott_v[1][OT_XO] == 50);
|
|
ui_power_on(); /* a project of before: no 'O' 'T' */
|
|
project_capture(&proj_scratch);
|
|
ok &= proj_pack(&st, &proj_scratch);
|
|
for (j = 68, found = 0; j + 1 < PROJ_STORE_SIZE; j++) found |= st.raw[j] == 'O' && st.raw[j + 1] == 'T';
|
|
ott_set(1, 100, 40, 0, 50);
|
|
ok = ok && proj_import(&proj_scratch, &st, sizeof st) && project_restore_runtime(&proj_scratch) == 0;
|
|
ck(" a project with no OTT on writes no block; loading one (as every project of before): OTT off, the defaults",
|
|
ok && !found && ott_v[1][OT_DEPTH] == 0 && ott_v[1][OT_TIME] == 48 && ott_v[1][OT_XO] == 37);
|
|
}
|
|
{ /* 7. a user preset keeps the track's OTT; one of before loads it off */
|
|
int ok;
|
|
ui_power_on();
|
|
song.sel = 3;
|
|
ott_set(3, 55, 70, 30, 80);
|
|
ok = (up_store(9, "OTT TEST") | 3) == 3;
|
|
ott_set(3, 0, 48, 0, 37);
|
|
ok &= up_load(9) == 0 && ott_v[3][OT_DEPTH] == 55 && ott_v[3][OT_TIME] == 70 && ott_v[3][OT_UPDN] == 30 && ott_v[3][OT_XO] == 80;
|
|
{
|
|
up_rec_t rr = *up_rec(9);
|
|
rr.packed[UP_OT_AT] = 0; /* (a record of before) */
|
|
*up_rec(10) = rr;
|
|
}
|
|
ok &= up_load(10) == 0 && ott_v[3][OT_DEPTH] == 0 && ott_v[3][OT_TIME] == 48;
|
|
ck("7. a user preset keeps the track's OTT (55 70 +30 80); one of before loads with it off", ok);
|
|
memset(up_rec(9), 0, sizeof(up_rec_t)); memset(up_rec(10), 0, sizeof(up_rec_t));
|
|
song.sel = 0;
|
|
}
|
|
{ /* 8. the page: FX > TRACK's fourth, DEPTH TIME UP/DN X-OVER (their formats), drawn; HOME's tag */
|
|
int16_t *vp;
|
|
const param_desc_t *d;
|
|
char v[12];
|
|
const char *u;
|
|
int ok;
|
|
ui_power_on(); go_home(); frame(); press(B_FX); frame();
|
|
nav_put(SEC_FX, "OTT"); frame();
|
|
ok = str_eq(cur_page()->title, "OTT") && fx_level() == FXL_TRACK && fx_trk_k(ui.page) == 3;
|
|
d = page_desc(cur_page(), 0, &vp);
|
|
ok &= d && str_eq(d->label, "DEPTH") && vp == &ott_v[song.sel % NTRK][OT_DEPTH];
|
|
turn(EN_K1, 5); frame();
|
|
ok &= ott_v[song.sel % NTRK][OT_DEPTH] > 0 && ott_on(song.sel % NTRK);
|
|
d = page_desc(cur_page(), 3, &vp);
|
|
param_format(d, *vp, v, &u);
|
|
ok &= str_eq(d->label, "X-OVER") && str_eq(v, "187") && str_eq(u, "Hz");
|
|
d = page_desc(cur_page(), 1, &vp);
|
|
param_format(d, *vp, v, &u);
|
|
ok &= str_eq(d->label, "TIME") && str_eq(u, "ms");
|
|
ok &= str_eq(page_desc(cur_page(), 2, &vp)->label, "UP/DN");
|
|
ck("8. FX > TRACK's fourth page OTT: DEPTH (KNOB 1 turns it on) TIME (ms) UP/DN X-OVER (187 Hz)", ok);
|
|
ott_v[song.sel % NTRK][OT_DEPTH] = 0;
|
|
}
|
|
{ /* 9. (V10.8.72) DEPTH's curve: squared to 70 (30 .. 60 musical), then a cubic to 100 (80 .. 100 brutal) */
|
|
int ok = ot_w(0) == 0 && ot_w(30) == 900 && ot_w(60) == 3600 && ot_w(70) == 4900 && ot_w(100) == 10000 &&
|
|
ot_w(80) > 8000 && ot_w(90) > 9500, d;
|
|
for (d = 1; d <= 100; d++) ok &= ot_w(d) > ot_w(d - 1) || d == 100;
|
|
printf("ott: DEPTH's weight: 30 %d, 50 %d, 60 %d, 70 %d, 80 %d, 90 %d, 100 %d (of 10000)\n", ot_w(30), ot_w(50), ot_w(60), ot_w(70),
|
|
ot_w(80), ot_w(90), ot_w(100));
|
|
ck("9. DEPTH's weight: squared to 70, a cubic over it (80 past 0.8, 90 past 0.95), rising all the way", ok);
|
|
}
|
|
{ /* 10. (V10.8.72) GEN: the electronic genres' OTT on the drums and the bass (40 .. 60), the lead or the texture a
|
|
* throw in two (60 .. 80), three tracks at most; the acoustic genres, CALM and EXPLORE none; a seed the same twice;
|
|
* RESOUND gives the genre's or clears it */
|
|
static const char *const EL[] = {"MINIMAL TECHNO", "HARD TECHNO", "HARD BASS", "HOUSE", "TECH HOUSE", "ELECTRO",
|
|
"DRUM & BASS", "EBM", "PHONK", "DUBSTEP"};
|
|
static const char *const AC[] = {"CUMBIA", "JAZZ", "NEO CLASSIC", "DREAM POP", "SHOEGAZE", "IDM AMBIENT"};
|
|
uint32_t e, g, sd, n, hard = 0, pieces = 0, most = 0;
|
|
int ok = 1, okd = 1, oka = 1, okc = 1;
|
|
int16_t v0[NTRK][OT_N];
|
|
for (e = 0; e < sizeof EL / sizeof EL[0]; e++)
|
|
for (g = 0; g < NGENRE; g++) {
|
|
if (!str_eq(GENRE[g].name, EL[e])) continue;
|
|
for (sd = 0; sd < 4u; sd++) {
|
|
uint32_t on = 0;
|
|
ui_power_on();
|
|
gp.genre = (uint8_t)(g + 1u); gp.seed = (uint16_t)(300u + 17u * sd); gp.form = 0; grd.mood = 0;
|
|
gen_make();
|
|
for (k = 0, n = 0; k < NTRK; k++)
|
|
if (ott_v[k][OT_DEPTH]) {
|
|
n++;
|
|
on |= 1u << gs.role[k];
|
|
ok &= gs.role[k] <= RL_BASS ? ott_v[k][OT_DEPTH] >= 40 && ott_v[k][OT_DEPTH] <= 64 :
|
|
(gs.role[k] == RL_LEAD || gs.role[k] == RL_TEX) && ott_v[k][OT_DEPTH] >= 60 && ott_v[k][OT_DEPTH] <= 80;
|
|
hard += ott_v[k][OT_DEPTH] >= 60 && gs.role[k] > RL_BASS;
|
|
ok &= gs.role[k] != RL_PAD;
|
|
}
|
|
ok &= n <= 3u && n >= 1u;
|
|
most = n > most ? n : most;
|
|
pieces++;
|
|
memcpy(v0, ott_v, sizeof v0);
|
|
ui_power_on();
|
|
gen_make();
|
|
okd &= !memcmp(v0, ott_v, sizeof v0); /* (the seed: the same OTT) */
|
|
(void)on;
|
|
}
|
|
}
|
|
for (e = 0; e < sizeof AC / sizeof AC[0]; e++)
|
|
for (g = 0; g < NGENRE; g++) {
|
|
if (!str_eq(GENRE[g].name, AC[e])) continue;
|
|
for (sd = 0; sd < 3u; sd++) {
|
|
ui_power_on();
|
|
gp.genre = (uint8_t)(g + 1u); gp.seed = (uint16_t)(500u + 13u * sd); gp.form = 0; grd.mood = 0;
|
|
gen_make();
|
|
for (k = 0; k < NTRK; k++) oka &= !ott_v[k][OT_DEPTH];
|
|
}
|
|
}
|
|
for (g = 0; g < NGENRE; g++) /* (CALM: none, whatever the genre) */
|
|
if (str_eq(GENRE[g].name, "DUBSTEP")) {
|
|
ui_power_on();
|
|
gp.genre = (uint8_t)(g + 1u); gp.seed = 300; gp.form = 0; grd.mood = -40;
|
|
gen_make();
|
|
for (k = 0; k < NTRK; k++) okc &= !ott_v[k][OT_DEPTH];
|
|
grd.mood = 0;
|
|
gen_make(); /* (RESOUND, a DUBSTEP piece: the genre's again, on its tracks) */
|
|
for (k = 0; k < NTRK; k++) ott_v[k][OT_DEPTH] = 0;
|
|
ott_v[5][OT_DEPTH] = 77; /* (a track RESOUND gives no sound to keeps its own) */
|
|
song_draft = 1; /* (GEN's piece: its genre's sounds) */
|
|
{
|
|
uint32_t any = gen_rs_prep(1234u), on = 0;
|
|
if (any) gen_rs_apply();
|
|
for (k = 0; k < NTRK; k++) on += ott_v[k][OT_DEPTH] != 0 && rs_role[k] < RL_N;
|
|
okc &= any && rs_gi == (int16_t)g && on >= 1u && on <= 3u && (rs_role[5] < RL_N || ott_v[5][OT_DEPTH] == 77);
|
|
}
|
|
song_draft = 0;
|
|
}
|
|
printf("ott: GEN: %u electronic pieces, at most %u tracks with OTT, %u leads / textures hard\n", pieces, most, hard);
|
|
ck("10. GEN: the electronic genres' drums and bass at 40 .. 60, a lead or texture 60 .. 80, three tracks at most, no pads", ok && hard > 0u);
|
|
ck(" GEN: the seed's OTT the same twice; the acoustic genres none", okd && oka);
|
|
ck(" GEN: MOOD CALM none; RESOUND the genre's on the tracks it resounds (1 .. 3), the others kept", okc);
|
|
ui_power_on();
|
|
}
|
|
{ /* 11. (V10.8.73, the owner: "bajos ultra comprimidos y saturados tipo dubstep") DEPTH 85 .. 100, the extreme zone:
|
|
* DEPTH 80 as V10.8.72 (GEN's at most 78); at 100 a 55 Hz bass far denser (a lower crest) and far more saturated
|
|
* (more harmonics), never past -0.3 dBFS (the soft clip's ceiling: 31597 << 2 of 2^17) */
|
|
double c0, c60, c80, c90, c100, t0, t60, t80, t90, t100, sc80, sc100, st80, st100;
|
|
int32_t m0, m60, m80, m90, m100, ms80, ms100, ok = 1, d;
|
|
bass55(0, 0, &c0, &t0, &m0); bass55(60, 0, &c60, &t60, &m60); bass55(80, 0, &c80, &t80, &m80);
|
|
bass55(90, 0, &c90, &t90, &m90); bass55(100, 0, &c100, &t100, &m100);
|
|
bass55(80, 1, &sc80, &st80, &ms80); bass55(100, 1, &sc100, &st100, &ms100);
|
|
printf("ott: 55 Hz sine wobble, crest dB / THD %% / peak dBFS: DEPTH 0 %.1f / %.1f / %.2f, 60 %.1f / %.1f / %.2f, 80 %.1f / %.1f / %.2f, 90 %.1f / %.1f / %.2f, 100 %.1f / %.1f / %.2f\n",
|
|
c0, t0, 20 * log10(m0 / 131072.0), c60, t60, 20 * log10(m60 / 131072.0), c80, t80, 20 * log10(m80 / 131072.0),
|
|
c90, t90, 20 * log10(m90 / 131072.0), c100, t100, 20 * log10(m100 / 131072.0));
|
|
printf("ott: 55 Hz saw wobble, crest dB / harmonics over the fundamental %%: DEPTH 80 %.1f / %.1f, 100 %.1f / %.1f (peaks %.2f, %.2f dBFS)\n",
|
|
sc80, st80, sc100, st100, 20 * log10(ms80 / 131072.0), 20 * log10(ms100 / 131072.0));
|
|
ck("11. DEPTH 100 against 80, a 55 Hz bass: the crest 1.5 dB lower or more (sine and saw), the sine's THD twice or more",
|
|
c100 < c80 - 1.5 && sc100 < sc80 - 1.5 && t100 > 2 * t80);
|
|
ck(" the ceiling: never past -0.3 dBFS (126632 of 2^17) at 80, 90, 100", m80 <= 126632 && m90 <= 126632 && m100 <= 126632 && ms100 <= 126632);
|
|
{ /* the drive's top within 32 bits: the clamp's 262143 x the drive's Q12 >> 2 */
|
|
static int32_t bb[CTL];
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, 100, 48, 0, 26);
|
|
for (k = 0; k < 200u; k++) { for (i = 0; i < CTL; i++) bb[i] = (int32_t)lrint(2000 * sin(2 * M_PI * 55 * (k * CTL + i) / 44100.0)); ott_block(0, bb, CTL); }
|
|
ok &= ott_s[0].g[2] >= 2 * OT_DRV - 2 && ott_s[0].g[2] <= 2 * OT_DRV && (int64_t)262143 * (ott_lin(ott_s[0].g[2]) >> 2) < 2147483647LL;
|
|
ok &= ott_s[0].g[3] < ott_s[0].g[2] && ott_s[0].g[3] > OT_DRV;
|
|
}
|
|
for (d = 0; d <= 100; d++) { /* (the drive, the drive under 0: equal to 80, rising after) */
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, d, 48, 0, 26);
|
|
{ static int32_t bb[CTL]; for (k = 0; k < 4u; k++) { for (i = 0; i < CTL; i++) bb[i] = 3000; ott_block(0, bb, CTL); } }
|
|
ok &= d <= 80 ? ott_s[0].g[3] == ott_s[0].g[2] : ott_s[0].g[3] < ott_s[0].g[2] || d < 83;
|
|
}
|
|
ck(" the drive +18 dB at 100 (2 x OT_DRV, in 32 bits), the negative side 3 dB less; to 80 both one (as V10.8.72)", ok);
|
|
{ /* DEPTH 1 .. 80 bit for bit V10.8.72's (its build gave this hash): TIME, UP/DN, X-OVER moving, a 55 Hz wobble and
|
|
* noise bursts */
|
|
static int32_t bb[CTL];
|
|
uint32_t h = 2166136261u, rs = 7u;
|
|
for (d = 1; d <= 80; d++) {
|
|
memset(ott_s, 0, sizeof ott_s);
|
|
ott_set(0, d, 20 + d % 60, (d % 9) * 14 - 56, 10 + d);
|
|
for (k = 0; k < 120u; k++) {
|
|
for (i = 0; i < CTL; i++) {
|
|
double t = (k * CTL + i) / 44100.0;
|
|
rs ^= rs << 13; rs ^= rs >> 17; rs ^= rs << 5;
|
|
bb[i] = (int32_t)lrint(60000 * (0.6 + 0.4 * cos(2 * M_PI * 2 * t)) * sin(2 * M_PI * 55 * t)) + (k % 40 < 5 ? ((int32_t)rs >> 14) : 0);
|
|
}
|
|
ott_block(0, bb, CTL);
|
|
for (i = 0; i < CTL; i++) h = (h ^ (uint32_t)bb[i]) * 16777619u;
|
|
}
|
|
}
|
|
printf("ott: DEPTH 1 .. 80 hash 0x%08x (V10.8.72 0x4e930819)\n", h);
|
|
ck(" DEPTH 1 .. 80: V10.8.72's sound bit for bit (GEN's OTT at most 78: its pieces as they were)", h == 0x4e930819u);
|
|
}
|
|
}
|
|
printf("ott: %s\n", bad ? "FAILED" : "all ok");
|
|
return bad != 0;
|
|
}
|