V10.22: the audio's cost as before (CI target budget)

The target-cost check refused V10.22: analog_ext +35 % (PLS3 in its loop),
mod_begin +57 % and mod_voice +17 % (ENV2 in the source switch and the
per-voice pick). Now PLS3 is a loop of its own (analog_pls3, dispatched before
analog_ext: SAW3 SYNC RING exactly as before), ENV2 out of mod_tsrc's switch
(its default), MS_VOICE a bit mask, and mod_voice reads its per-voice sources
from a table by number (cost 19, was 30). analog_ext 750 (750), mod_begin 177
(175), mod_voice 19 (30). mod_test: PLS3 its own sound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
Claude committed 2026-11-01 11:44:19 +00:00
1 parent 2588773d7d
commit 17eff83290
4 files changed
+1748 -1709

No files matched your search

+36 -7
View File
@@ -116,6 +116,37 @@ static uint32_t an_pw(const track_t *t, const vmod_t *m)
/* SYNC RING SAW3 (see the top): a render of their own (the other WAVEs' loop untouched), the same noise, drive and
* filter */
/* (V10.22) PLS3: three pulses as SAW3's saws (osc 2 DTN cents up at INT, osc 3 down), SHAPE (MORPH too) their width;
* a loop of its own (analog_ext's as it was), the same noise, drive and filter */
static __attribute__((noinline)) void analog_pls3(track_t *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
{
const int16_t *p = t->p;
uint32_t i, inc1 = m->inc, ph0 = v->ph[0], ph1 = v->ph[1], ph2 = v->ph[2], ft = ft_voice(p), pw = an_pw(t, m);
uint32_t inc2 = cents_inc(m->pitch16 + p[P_E7] * 16, p[P_E1], 0), inc3 = cents_inc(m->pitch16, -p[P_E1], 0);
int32_t m2 = p[P_E2] * 258, m1 = 32767 - m2, nz = p[P_E3] * 200, drv = p[P_E6], kd = 8192 - p[P_E5] * 7600 / 127;
int32_t drive = 32768 + drv * 512, cut = (p[P_E4] << 8) + m->cutoff + ((v->pitch16 - 60 * 16) << 2);
int32_t ic1 = v->s[0], ic2 = v->s[1], nst = v->s[2];
tsvf_t flt;
tsvf_coef(&flt, cut, p[P_E5]);
for (i = 0; i < n; i++) {
int32_t a = osc_pulse(ph0, inc1, pw), b = (osc_pulse(ph1, inc2, pw) + osc_pulse(ph2, inc3, pw)) >> 1, s;
ph0 += inc1;
ph1 += inc2;
ph2 += inc3;
s = mulq15(a, m1) + mulq15(b, m2);
if (nz)
s += mulq15((int32_t)(noise32(&nst) >> 17) - 16384, nz);
if (drv)
s = softclip(((s >> 2) * (drive >> 2)) >> 11);
out[i] += voice_amp(soft_knee(svf_mode(&flt, s >> 1, &ic1, &ic2, ft, kd), 16000) << 1, m, i) << 1;
}
v->ph[0] = ph0;
v->ph[1] = ph1;
v->ph[2] = ph2;
v->s[0] = ic1;
v->s[1] = ic2;
v->s[2] = nst;
}
static __attribute__((noinline)) void analog_ext(track_t *t, voice_t *v, int32_t *out, uint32_t n, const vmod_t *m)
{
const int16_t *p = t->p;
@@ -129,13 +160,13 @@ static __attribute__((noinline)) void analog_ext(track_t *t, voice_t *v, int32_t
tsvf_coef(&flt, cut, p[P_E5]);
r = 16u + (uint32_t)det + (wave != AW_SAW3 ? (uint32_t)(mx * 64 / (127 << 8)) : 0u); /* SYNC / RING: osc 2 at r / 16
* of osc 1 (1 .. 8.9; 0.6.81: MORPH up to 4 more) */
inc2 = wave >= AW_SAW3 ? cents_inc(m->pitch16 + p[P_E7] * 16, det, 0) : (inc1 >> 4) * r; /* (SAW3, PLS3: osc 2 at INT) */
if (wave < AW_SAW3 && p[P_E7]) { /* (JIANT 0.5) SYNC / RING: INT moves osc 2 too, semitones */
inc2 = wave == AW_SAW3 ? cents_inc(m->pitch16 + p[P_E7] * 16, det, 0) : (inc1 >> 4) * r; /* (SAW3: osc 2 at INT) */
if (wave != AW_SAW3 && p[P_E7]) { /* (JIANT 0.5) SYNC / RING: INT moves osc 2 too, semitones */
inc2 = (cents_inc(m->pitch16 + p[P_E7] * 16, 0, 0) >> 4) * r;
r = inc1 >> 8 ? (inc2 / (inc1 >> 8)) >> 4 : r; /* (its ratio to osc 1, x16: the restart below) */
if (r < 1u) r = 1u;
}
inc3 = wave >= AW_SAW3 ? cents_inc(m->pitch16, -det, 0) : 0u;
inc3 = wave == AW_SAW3 ? cents_inc(m->pitch16, -det, 0) : 0u;
if (wave < AW_SYNC) /* (JIANT 0.5: HP BP COMB) the plain WAVEs: osc 2 as analog_render */
inc2 = det || p[P_E7] ? cents_inc(m->pitch16 + p[P_E7] * 16, det, 0) : inc1;
for (i = 0; i < n; i++) {
@@ -151,10 +182,6 @@ static __attribute__((noinline)) void analog_ext(track_t *t, voice_t *v, int32_t
} else if (wave == AW_SAW3) {
b = (osc_saw(ph1, inc2) + osc_saw(ph2, inc3)) >> 1;
ph2 += inc3;
} else if (wave == AW_PLS3) { /* (V10.22) three pulses, SHAPE their width */
a = osc_pulse(ph0, inc1, pw);
b = (osc_pulse(ph1, inc2, pw) + osc_pulse(ph2, inc3, pw)) >> 1;
ph2 += inc3;
} else if (wave == AW_SYNC) {
b = osc_saw(ph1, inc2);
} else {
@@ -254,6 +281,8 @@ static void analog_dispatch(track_t *t, voice_t *v, int32_t *out, uint32_t n, co
int32_t base = (int32_t)t->p[P_E0] * 256; /* (as it leaves or comes: the plain WAVE) */
analog_morph(t, v, out, n, m, m0 < 0 ? base : m0, m1 < 0 ? base : m1);
}
else if (t->p[P_E0] == AW_PLS3) /* (V10.22) */
analog_pls3(t, v, out, n, m);
else if ((uint32_t)t->p[P_E0] >= AW_SYNC || t->p[P_FTYPE])
analog_ext(t, v, out, n, m);
else
+14 -8
View File
@@ -65,7 +65,8 @@ static uint8_t macro_v[4]; /* (JIANT) the macros M1..M4, 0..127: the proje
_Static_assert(NELEM(N_MSRC) == MS_N && NELEM(N_MDST) == MD_N, "N_MSRC / N_MDST == MS_* / MD_*");
_Static_assert(P_M2SRC == P_M1SRC + 3 && P_M4AMT == P_M1SRC + 11 && P_M4AMT + 1 == P_FM1_ATK, "matrix slots: 3 ids each");
#define NMSLOT 4u
#define MS_VOICE(s) (((s) >= MS_ENV && (s) <= MS_RAND) || (s) == MS_ENV2) /* a value per voice */
#define MS_VMASK ((1u << MS_ENV) | (1u << MS_VEL) | (1u << MS_KEY) | (1u << MS_RAND) | (1u << MS_ENV2))
#define MS_VOICE(s) ((MS_VMASK >> ((s) & 31u)) & 1u) /* a value per voice: ENV VEL KEY RAND, (V10.22) ENV2 */
#define MS_BIPOLAR(s) ((s) == MS_LFO || (s) == MS_KEY || (s) == MS_RAND || (s) == MS_NOISE)
/* the track parameter of a per-block destination */
@@ -124,8 +125,6 @@ static int32_t mod_tsrc(const track_t *t, uint32_t s, int32_t lfo)
return lfo;
case MS_ENV:
return t->m_env;
case MS_ENV2:
return t->m_env2;
case MS_VEL:
return t->m_vel * 258;
case MS_KEY:
@@ -145,7 +144,7 @@ static int32_t mod_tsrc(const track_t *t, uint32_t s, int32_t lfo)
case MS_NOISE: /* (0.7.8) a random wander, a new point every ~46 ms, eased */
return drift_noise((uint32_t)(t - trk) * 7919u + 0x1234u, mns_clk, 6u - (CTL_LOG2 - 5u));
default:
return macro_v[(s - MS_M1) & 3u] * 258;
return s == MS_ENV2 ? t->m_env2 : macro_v[(s - MS_M1) & 3u] * 258; /* (V10.22 ENV2: out of the switch's run) */
}
}
@@ -304,10 +303,17 @@ static __attribute__((noinline)) void mod_voice(track_t *t, voice_t *v, vmod_t *
t->m_env = env; /* ENV of the latest note, for per-block destinations */
t->m_env2 = m->env2q15; /* (V10.22) and its ENV 2 */
}
for (k = 0; k < mp->nv; k++) {
uint32_t s = mp->vsrc[k];
int32_t x = s == MS_ENV ? env : s == MS_ENV2 ? m->env2q15 : s == MS_VEL ? v->mvel * 258 : s == MS_KEY ? mod_key(v->note) : v->mrnd;
mod_voice_add(s, mp->vdst[k], x, mp->vamt[k], &pit, &cut, &shp, &gain);
{
int32_t xv[MS_N]; /* (V10.22) the per-voice sources by number, read in the loop */
xv[MS_ENV] = env;
xv[MS_VEL] = v->mvel * 258;
xv[MS_KEY] = mod_key(v->note);
xv[MS_RAND] = v->mrnd;
xv[MS_ENV2] = m->env2q15;
for (k = 0; k < mp->nv; k++) {
uint32_t s = mp->vsrc[k];
mod_voice_add(s, mp->vdst[k], xv[s], mp->vamt[k], &pit, &cut, &shp, &gain);
}
}
if (pit) {
m->pitch16 = clamp(m->pitch16 + pit, 0, 2047);
+3
View File
@@ -700,6 +700,9 @@ static void test_jiant_078(void)
blocks(FS / 2u / CTL);
down = trk[0].m_env2;
check("V10.22: ENV2 rises with the note, to the top, then down after it", up < top && top > 30000 && down < top / 4);
check("V10.22: ANALOG WAVE PLS3 sounds its own (not PWM's, not SAW3's), SHAPE's width moves it",
phrase_on(ea, P_E0, 8) != phrase_on(ea, P_E0, 4) && phrase_on(ea, P_E0, 8) != phrase_on(ea, P_E0, 7) &&
phrase_on(ea, P_E0, 8) != a0);
}
}
+1695 -1694
View File
File diff suppressed because it is too large. Load diff