MSEQ modulation sequencer, DIST types, delay HPF, WIDTH, reverb MOD and PRE (FUNB)

- LFO > MSEQ: per track a CV-style sequence of 16 levels with LEN, DIV and
  SLEW, running with the transport; the MOD matrix reads it as STEP.
- DIST TYPE (SOFT as before, HARD, FOLD, CRUSH, RECT) and TONE (FX > DIST).
- Delay: HPF in the feedback (COLR stays its high cut). WIDTH: the delay's
  right echo up to 1/32 later, the chorus's second tap opposite; 0 is mono
  as before.
- Reverb: PRE (pre-delay up to 100 ms); MOD and RATE modulate the ROOM's
  comb lengths (interpolated reads) and deepen the SPRING's wobble.
- Projects are FUNB (3840 bytes): 21 track parameters before P_E0
  (P_COUNT 120, P_E0 112) and 5 globals after the header's 27. FUNA and
  older load mapped by count, the new values at their defaults; the
  goldens are unchanged.

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-10-09 12:30:31 +00:00
1 parent 48cfc0f837
commit b0a07d47d0
25 files changed
+547 -121

No files matched your search

+19 -4
View File
@@ -77,6 +77,20 @@ La escena sigue vigente en las filas siguientes que no tengan una propia, y los
- **Con SONG REC**: cada fila grabada guarda su escena sola, con el estado de cuando empezó. Tocás la canción con
mutes, macros y efectos, y queda grabada así.
### Modulación secuenciada (LFO > MSEQ)
Cada track tiene un secuenciador de modulación, como un secuenciador de CV: 16 niveles, **LEN** (1–16 pasos), **DIV**
(el ritmo de los pasos) y **SLEW** (de saltos a glides). Corre con el transporte y en la matriz MOD es la fuente
**STEP**: cualquier destino (filtro, pitch, MORPH, envíos, CLIP…) sigue la secuencia. En la página MSEQ, KNOB 1 elige
el paso y KNOB 2 su nivel; los niveles también se automatizan.
### Efectos
- **DIST** por track con **TYPE** (SOFT, HARD, FOLD, CRUSH, RECT) y **TONE** (más oscuro o más brillante): página FX > DIST.
- **Delay**: además de COLR (agudos), **HPF** recorta los graves de las repeticiones (más dub, más fino).
- **WIDTH**: abre el estéreo. El eco derecho del delay llega un poco después y el chorus separa L y R. En 0 todo
suena como antes.
- **Reverb**: **PRE** (pre-delay de hasta 100 ms), y **MOD** y **RATE** modulan la red de resonancia. En ROOM se mueve
el largo de los combs: menos metálico, una cola más ancha. En SPRING, un vaivén más profundo.
### Master con carácter (FX > MASTER)
- **CLIP**: satura la mezcla antes del limiter.
- **PNCH**: bus de batería con más ataque y cola más corta.
@@ -87,9 +101,10 @@ La escena sigue vigente en las filas siguientes que no tengan una propia, y los
- **4 tracks** con 8 voces compartidas.
- **12 engines**: ANALOG, FM6 (Dexed, importa .syx), PHASE, LOFI, SAMPLE, VOICE, TRIO, WHEEL, GRAIN, NOISE, SLICE y
DRUM (DRUM-X).
- **Modulación**: 4 slots por track. Fuentes: LFO, ENV, VEL, KEY, RAND, controladores MIDI y las 4 macros.
- **Efectos**: distorsión y SLICER por track; envíos a chorus, delay y reverb (ROOM o SPRING); master con CLIP,
PNCH, DUCK y limiter.
- **Modulación**: 4 slots por track. Fuentes: LFO, ENV, VEL, KEY, RAND, controladores MIDI, las 4 macros y STEP (el
secuenciador de modulación).
- **Efectos**: distorsión de 5 tipos y SLICER por track; envíos a chorus, delay (con HPF) y reverb (ROOM o SPRING, con
pre-delay y modulación); WIDTH estéreo; master con CLIP, PNCH, DUCK y limiter.
- **Arpegiador** con 16 modos y 16 escalas con modo de teclas blancas; glide; POLY, MONO, LEGATO y UNISON.
- **Conexiones**:
- USB: MIDI class-compliant y audio (el master llega a la computadora).
@@ -110,7 +125,7 @@ La escena sigue vigente en las filas siguientes que no tengan una propia, y los
| SHIFT (OFS / PIT), ARP TRNS, SEQ + REC | ✅ |
| Paleta térmica JIANT | ✅ |
| Escenas por fila de la cadena (mutes, macros, punch-in) | ✅ |
| Más modulación y mejores efectos | ⏳ |
| Secuenciador de modulación (STEP), DIST con tipos y tono, delay HPF, WIDTH, reverb MOD y PRE | ✅ |
| Interfaz orgánica con las ilustraciones ([docs/TONIC-UI.md](docs/TONIC-UI.md)) | ⏸ después de sonido y performance |
<details>
+11
View File
@@ -65,6 +65,9 @@ enum { /* per-track parameters */
P_FM4_ATK, P_FM4_DEC, P_FM4_SUS, P_FM4_REL, P_FM4_LEVEL,
P_SOFS, P_POFS, /* (JIANT; the former chord keys) the sequence offset: OFS steps, PIT semitones */
P_LN0, P_LN1, P_LN2, P_LN3, P_LN4, P_LN5, P_LN6, P_LN7, /* DRUM lane levels (eng_drum.c, #97): KICK .. BELL */
P_DTYPE, P_DTONE, /* (JIANT, FUNB) DIST's type and tone (fx.c track_dist) */
P_MSLEN, P_MSDIV, P_MSSLW, /* (JIANT, FUNB) the modulation sequence (mod.c MS_STEP): its length, */
P_MS0, P_MS15 = P_MS0 + 15, /* rate and slew, its 16 levels */
P_E0, P_E1, P_E2, P_E3, P_E4, P_E5, P_E6, P_E7,
P_COUNT
};
@@ -85,6 +88,11 @@ enum { /* global parameters */
* Were G_DRLVL / G_DRREV, inert since 1.0 (0..0): the GM drum part's level and
* reverb send, read only by the import of a project of before 1.0
* (proj_drums_to_part, which clears them after) */
G_NSTORE, /* the 27 a project's header holds (FUN7 on: their ids kept) */
G_DHPF = G_NSTORE, /* (JIANT, FUNB: after the punch-in lane, project.c) the delay's feedback low cut, */
G_WIDTH, /* the buses' stereo width (the delay's right echo later, the chorus's taps apart), */
G_RMOD, G_RRATE, /* the reverb's modulation (ROOM: its combs' lengths; SPRING: its wobble) depth, rate, */
G_RPRE, /* its pre-delay */
G_COUNT
};
#define G_SYNC G_DREL /* (the old names, for the formats' importers and their tests) */
@@ -315,6 +323,9 @@ typedef struct track {
/* mix runtime */
int32_t peak;
int32_t dist_hp, dist_lp1, dist_lp2; /* DIST insert state (fx.c) */
int32_t dist_dc, dist_hold; /* (JIANT) RECT's DC; CRUSH's held sample */
uint8_t dist_hc; /* .. CRUSH's hold count */
int32_t ms_v; /* (JIANT) the modulation sequence's level now (mod.c MS_STEP, Q15, slewed) */
uint8_t tail; /* blocks to mix after the last voice (the DIST tail) */
int16_t armp, aholdp; /* P_AMODE / P_AHOLD as last seen by the ISR */
/* engine switch (voice.c engine_block): the old engine's voices fade out, then it switches */
+2 -1
View File
@@ -151,7 +151,8 @@ static uint32_t ed_bk_commit(void)
/* a project object's length: FUN9 (today's), FUN8 (before the DRUM lane levels, 1.0.x), FUN7 */
static int proj_store_len(uint32_t len)
{
return len == sizeof(project_store_t) || len == PROJ_STORE_V8 || len == PROJ_STORE_V7;
return len == sizeof(project_store_t) || len == PROJ_STORE_VA || len == PROJ_STORE_V9 || len == PROJ_STORE_V8 ||
len == PROJ_STORE_V7;
}
static uint32_t ed_bk_write(const uint8_t *a, uint32_t n)
{
+131 -12
View File
@@ -14,9 +14,13 @@ static union { /* ROOM's allpasses; SPRING's allpass ch
int32_t sp[(556 + 441) / 2];
} rev_u __attribute__((section(".pool")));
#define rev_ap (rev_u.ap)
#define RPRE_LEN 4096u /* (JIANT) the reverb's pre-delay line: up to 92 ms */
static int16_t rpre_buf[RPRE_LEN] __attribute__((section(".pool")));
static int32_t rpre_out[CTL]; /* .. the block out of it (the reverb's input) */
static struct {
uint32_t dly_w, cho_w, cho_ph;
int32_t dly_lp;
int32_t dly_lp, dly_hp; /* the delay's feedback: high cut (COLR), low cut (JIANT: HPF) */
uint32_t rpre_w, rm_ph; /* (JIANT) the pre-delay's write index; the reverb modulation's phase */
uint16_t comb_i[4], ap_i[2];
int32_t comb_lp[4];
uint8_t rtype; /* the reverb model running (G_RTYPE: 0 ROOM, 1 SPRING) */
@@ -47,20 +51,55 @@ _Static_assert(sizeof rev_comb / 2u >= SP_LEN && sizeof rev_u.sp / 4u >= 4u * (S
* (a little bias = even harmonics) -> tone low-pass that closes with drive ->
* make-up gain (straight into tanh over the full band, it would sound like a
* broken digital fuzz). State per part (track_t dist_*). */
/* (JIANT) DIST TYPE (P_DTYPE): SOFT the biased tanh as before; HARD a hard clip; FOLD a triangle wavefolder (the drive
* folds the wave back on itself: more partials as it rises); CRUSH fewer bits and a held sample (the drive takes both
* down); RECT full-wave rectified (an octave up, fuzz), its DC taken out. Then the two-pole low-pass, TONE (P_DTONE)
* moving it darker / brighter, and the make-up. DRIVE 0: out of the chain */
enum { DT_SOFT, DT_HARD, DT_FOLD, DT_CRUSH, DT_RECT };
static __attribute__((noinline)) int32_t dist_shape(track_t *t, uint32_t type, int32_t x, int32_t g, int32_t d)
{
int32_t v = ((x >> 2) * g) >> 10, a;
switch (type) {
case DT_HARD:
return clamp(v, -22000, 22000);
case DT_FOLD: /* folded back at +-T (T 22000), up to 5T: three folds */
v = clamp(v, -110000, 110000);
for (a = 0; a < 3; a++)
v = v > 22000 ? 44000 - v : v < -22000 ? -44000 - v : v;
return v;
case DT_CRUSH: {
uint32_t hold = 1u + (uint32_t)d / 12u, sh = 4u + (uint32_t)d / 12u; /* (up to 11x held, 4 .. 14 bits off) */
if (!t->dist_hc) {
t->dist_hold = (int32_t)((uint32_t)(clamp(x, -131072, 131068) >> sh) << sh);
t->dist_hc = (uint8_t)hold;
}
t->dist_hc--;
return t->dist_hold >> 2;
}
case DT_RECT:
a = x < 0 ? -x : x;
t->dist_dc += (a - t->dist_dc) >> 9; /* (its mean: the DC the rectifier adds) */
return softclip((((a - t->dist_dc) >> 2) * g) >> 10);
default:
return softclip(v + 2400) - softclip(2400);
}
}
static void track_dist(track_t *t, int32_t *b, uint32_t n)
{
int32_t d = t->p[P_DIST], i, g, k, mk, bias = 2400, b0;
int32_t d = t->p[P_DIST], i, g, k, mk, b0 = softclip(2400);
uint32_t type = (uint32_t)t->p[P_DTYPE];
if (!d)
return; /* states kept: switching on does not click */
g = 4096 + d * d * 2; /* Q12: 1x .. ~9x, gentle at first */
k = 32000 - d * 95; /* tone: transparent at low drive .. ~3 kHz, Q15 */
mk = 30000 - d * 120; /* make-up */
b0 = softclip(bias);
k = clamp(32000 - d * 95 + t->p[P_DTONE] * 300, 2500, 32767); /* tone: transparent at low drive .. ~3 kHz, Q15 */
mk = type == DT_HARD || type == DT_FOLD ? 30000 - d * 60 : 30000 - d * 120; /* make-up */
if (type > DT_RECT)
type = DT_SOFT;
for (i = 0; i < (int32_t)n; i++) {
int32_t x = b[i], y;
t->dist_hp += (x - t->dist_hp + 64) >> 7; /* ~55 Hz low cut: keep the bass out of the clipper */
x = clamp(x - t->dist_hp, -230000, 230000); /* (x >> 2) * g fits 32 bits; the clip is flat out there */
y = softclip((((x >> 2) * g) >> 10) + bias) - b0; /* >> 2 first: no overflow for loud poly */
y = type == DT_SOFT ? softclip((((x >> 2) * g) >> 10) + 2400) - b0 : dist_shape(t, type, x, g, d);
t->dist_lp1 += mulq15(y - t->dist_lp1, k); /* two poles: tames the fizz */
t->dist_lp2 += mulq15(t->dist_lp1 - t->dist_lp2, k);
b[i] = mulq15(t->dist_lp2, mk);
@@ -266,6 +305,49 @@ static __attribute__((noinline)) void rev_room(const int32_t *rev_in, int32_t *o
}
}
/* (JIANT) ROOM with its networks modulated (G_RMOD > 0): each comb read up to ~1.3 ms nearer (between samples),
* by a slow sine of G_RRATE a quarter apart per comb: the resonances drift, the ringing smears, a wider tail. Its own
* loop: at MOD 0 the plain one runs, unchanged */
static __attribute__((noinline)) void rev_room_mod(const int32_t *rev_in, int32_t *out, uint32_t n)
{
uint32_t i, k, off[4];
int32_t size = 25000 + song.g[G_RSIZE] * 50, damp = 32767 - song.g[G_RDAMP] * 200, fr[4];
int32_t depth = song.g[G_RMOD] * 2 + 64; /* Q8 samples: 0.25 .. ~1.3 ms */
fx.rm_ph += LFO_INC[song.g[G_RRATE] & 127];
for (k = 0; k < 4u; k++) {
int32_t m = (osc_sine(fx.rm_ph + k * 0x40000000u) + 32768) * depth >> 16; /* 0 .. depth (Q8) */
off[k] = (uint32_t)m >> 8;
fr[k] = m & 255;
}
for (i = 0; i < n; i++) {
int32_t a = 0;
int16_t *c = rev_comb;
int32_t in = mulq15(rev_in[i], 2580);
for (k = 0; k < 4u; k++) {
uint32_t L = REV_COMB[k], j0 = fx.comb_i[k] + off[k], j1 = j0 + 1u;
int32_t o0 = c[j0 >= L ? j0 - L : j0], o1 = c[j1 >= L ? j1 - L : j1];
int32_t o = o0 + (((o1 - o0) * fr[k]) >> 8); /* (a shorter delay: nearer the write) */
fx.comb_lp[k] = o + mulq15(fx.comb_lp[k] - o, 32767 - damp);
c[fx.comb_i[k]] = (int16_t)clamp(in + mulq15(fx.comb_lp[k], size), -32768, 32767);
if (++fx.comb_i[k] >= L)
fx.comb_i[k] = 0;
a += o;
c += L;
}
c = rev_ap;
for (k = 0; k < 2u; k++) {
int32_t o = c[fx.ap_i[k]];
int32_t v = a + (o >> 1);
c[fx.ap_i[k]] = (int16_t)clamp(v, -32768, 32767);
a = o - a;
if (++fx.ap_i[k] >= REV_AP[k])
fx.ap_i[k] = 0;
c += REV_AP[k];
}
out[i] += a;
}
}
/* SPRING (see the top), added to out */
static __attribute__((noinline)) void rev_spring(const int32_t *rev_in, int32_t *out, uint32_t n)
{
@@ -279,8 +361,8 @@ static __attribute__((noinline)) void rev_spring(const int32_t *rev_in, int32_t
fx.sp_size = len;
fx.sp_size += clamp(len - fx.sp_size, -256, 256); /* SIZE glides (a sample a block at most) */
L = fx.sp_size >> 8;
fx.sp_ph += 2u * LFO_INC[24]; /* the wobble: a slow sine, 1.5 samples deep */
w = (fx.sp_size >> 1) + ((osc_sine(fx.sp_ph) * 3) >> 8); /* the far end, Q8 */
fx.sp_ph += 2u * LFO_INC[song.g[G_RMOD] ? song.g[G_RRATE] & 127 : 24]; /* the wobble: a slow sine, 1.5 samples */
w = (fx.sp_size >> 1) + ((osc_sine(fx.sp_ph) * (3 + song.g[G_RMOD] / 4)) >> 8); /* deep (MOD: up to 17); the far end, Q8 */
L2 = w >> 8;
f = w & 255;
L3 = (L * 3) >> 2;
@@ -334,8 +416,21 @@ static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t
int32_t dmix = song.g[G_DMIX] * 258;
int32_t cdepth = song.g[G_CDEPTH] * 6, rt;
uint32_t cinc = LFO_INC[song.g[G_CRATE] & 127] / CTL;
int32_t hk = song.g[G_DHPF] * 44, wd = song.g[G_WIDTH]; /* (JIANT) HPF: off .. ~1.2 kHz; WIDTH */
uint32_t dr = dl + (wd ? div_samples(3) * (uint32_t)wd / 127u : 0u); /* the right echo: up to 1/32 later */
if (dr >= DLY_LEN)
dr = DLY_LEN - 1u;
if (song.g[G_RPRE]) { /* (JIANT) the reverb's pre-delay */
uint32_t pd = (uint32_t)song.g[G_RPRE] * 41u; /* (ms -> samples: 4100 at 100) */
for (i = 0; i < n; i++) {
rpre_buf[fx.rpre_w & (RPRE_LEN - 1u)] = (int16_t)clamp(rev_in[i] >> 3, -32768, 32767);
rpre_out[i] = rpre_buf[(fx.rpre_w - pd) & (RPRE_LEN - 1u)] * 8;
fx.rpre_w++;
}
rev_in = rpre_out;
}
for (i = 0; i < n; i++) {
int32_t y = 0, x, r;
int32_t y = 0, x, r, side = 0;
/* chorus: modulated short delay, 5..15 ms */
cho_buf[fx.cho_w & (CHO_LEN - 1u)] = (int16_t)clamp(cho_in[i] >> 1, -32768, 32767);
fx.cho_ph += cinc;
@@ -344,17 +439,37 @@ static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t
uint32_t ri = (uint32_t)r >> 8;
int32_t f = r & 255, c0 = cho_buf[(fx.cho_w - ri) & (CHO_LEN - 1u)];
int32_t c1 = cho_buf[(fx.cho_w - ri - 1u) & (CHO_LEN - 1u)];
y += (c0 + (((c1 - c0) * f) >> 8)) << 1;
int32_t cl = c0 + (((c1 - c0) * f) >> 8);
y += cl << 1;
if (wd) { /* (JIANT) WIDTH: a second tap, the LFO opposite, right */
int32_t r2 = (400 << 8) + ((32768 - osc_sine(fx.cho_ph)) * cdepth >> 8);
uint32_t r2i = (uint32_t)r2 >> 8;
int32_t f2 = r2 & 255, d0 = cho_buf[(fx.cho_w - r2i) & (CHO_LEN - 1u)];
int32_t d1 = cho_buf[(fx.cho_w - r2i - 1u) & (CHO_LEN - 1u)];
int32_t sc = ((cl - (d0 + (((d1 - d0) * f2) >> 8))) * wd) >> 7; /* (L 2cl, R 2cr at 127) */
y -= sc;
side += sc;
}
}
fx.cho_w++;
/* delay with a low-passed feedback */
/* delay with a low-passed (COLR) and low-cut (HPF) feedback */
x = dly_buf[(fx.dly_w - dl) & (DLY_LEN - 1u)];
fx.dly_lp += mulq15(x - fx.dly_lp, col);
fx.dly_hp += mulq15(fx.dly_lp - fx.dly_hp, hk);
dly_buf[fx.dly_w & (DLY_LEN - 1u)] =
(int16_t)clamp((dly_in[i] >> 1) + mulq15(fx.dly_lp, fb), -32768, 32767);
(int16_t)clamp((dly_in[i] >> 1) + mulq15(fx.dly_lp - fx.dly_hp, fb), -32768, 32767);
if (wd) { /* (JIANT) the right echo later: mid and side */
int32_t xr = dly_buf[(fx.dly_w - dr) & (DLY_LEN - 1u)];
side += mulq15(x - xr, dmix);
x = (x + xr) >> 1;
}
fx.dly_w++;
y += mulq15(x << 1, dmix);
wet[i] = y;
if (side) { /* (the side: left +, right -) */
mix_l[i] += side;
mix_r[i] -= side;
}
}
rt = song.g[G_RTYPE] == 1;
if (rt != fx.rtype) { /* the model changed: the old one's block fades out, */
@@ -373,6 +488,8 @@ static void fx_buses(const int32_t *cho_in, const int32_t *dly_in, const int32_t
}
if (rt)
rev_spring(rev_in, wet, n);
else if (song.g[G_RMOD])
rev_room_mod(rev_in, wet, n);
else
rev_room(rev_in, wet, n);
}
@@ -463,6 +580,8 @@ static void mix_block(int32_t *out, uint32_t n)
send_c[i] = send_d[i] = send_r[i] = mix_l[i] = mix_r[i] = 0;
pfx_block(n, (perf_kill ? 0u : (perf_held | perf_latched) & PF_MIDI) | scene_pfx);
events_block(n);
if (song.playing)
ms_clock += n; /* (JIANT) the modulation sequences' clock (mod.c) */
macro_master(); /* CLIP / PNCH with the matrix (mod.c) */
master_begin();
duck_block();
+1 -1
View File
@@ -215,7 +215,7 @@ static uint32_t param_icon(const param_desc_t *d, int32_t v)
static uint32_t mod_src_icon(int32_t s)
{
static const uint8_t I[MS_N] = {ICON_MOD, ICON_LFO_WAVE, ICON_ENV, ICON_ACCENT, ICON_KEYTRACK, ICON_PROB,
ICON_MOD, ICON_MIDI, ICON_LEVEL, ICON_MIX, ICON_MIX, ICON_MIX, ICON_MIX}; /* (M1..M4) */
ICON_MOD, ICON_MIDI, ICON_LEVEL, ICON_MIX, ICON_MIX, ICON_MIX, ICON_MIX, ICON_AUTO}; /* (M1..M4, STEP) */
return I[clamp(s, 0, MS_N - 1)];
}
static uint32_t mod_dst_icon(const track_t *t, int32_t d)
+25 -1
View File
@@ -11,6 +11,8 @@
* RAND a new random value per note-on (its own generator: the shared rng is not touched), bipolar
* MODW MIDI CC1, AT channel aftertouch, EXPR CC11 of the track's channel (seq.c), 0..1; until a
* controller arrives (and after CC121 RESET ALL CONTROLLERS) MODW and AT are 0, EXPR 1
* STEP (JIANT) the track's modulation sequence (LFO > MSEQ, a CV sequencer): the level of its step now (LEN steps of
* DIV from PLAY; stopped: where it was), 0..1, slewed by SLEW (ms_tick, once a block when a slot reads it)
* M1..M4 (JIANT) the project's macros (macro_v, the knobs with LFO held), 0..1: the same for every track, so a
* macro reaches as many destinations as the slots that name it
* Destinations:
@@ -34,7 +36,9 @@
* presets read and write t->p from the main loop, which the ISR preempts; TIMER5 only fills the MIDI rings),
* and the engines read t->p as before. An engine reads its parameters in note_on (events_block) unmodulated.
* Nothing active (every slot with SRC, DST or AMT at 0): no work, and the sound is bit-identical. */
enum { MS_OFF, MS_LFO, MS_ENV, MS_VEL, MS_KEY, MS_RAND, MS_MODW, MS_AT, MS_EXPR, MS_M1, MS_N = MS_M1 + 4 };
enum { MS_OFF, MS_LFO, MS_ENV, MS_VEL, MS_KEY, MS_RAND, MS_MODW, MS_AT, MS_EXPR, MS_M1, MS_STEP = MS_M1 + 4, MS_N };
static uint32_t div_samples(uint32_t div); /* fx.c */
static uint32_t ms_clock; /* (JIANT) samples since PLAY (fx.c mix_block; seq.c seq_start: 0): MS_STEP's place */
enum { MD_OFF, MD_PITCH, MD_CUT, MD_SHP, MD_AMP, MD_PAN, MD_DIST, MD_CHO, MD_DLY, MD_REV, MD_RATE, MD_VIB, MD_E1,
MD_CLIP = MD_E1 + 8, MD_PNCH, MD_N };
static uint8_t macro_v[4]; /* (JIANT) the macros M1..M4, 0..127: the project's (project.c), LFO held turns them */
@@ -94,6 +98,8 @@ static int32_t mod_tsrc(const track_t *t, uint32_t s, int32_t lfo)
return t->at * 258;
case MS_EXPR:
return (127 - t->ex_off) * 258;
case MS_STEP:
return t->ms_v;
default:
return macro_v[(s - MS_M1) & 3u] * 258;
}
@@ -120,6 +126,19 @@ static void mod_voice_add(uint32_t s, uint32_t d, int32_t x, int32_t a, int32_t
*gain = mulq15(*gain, mod_gain(s, x, a));
}
/* (JIANT) MS_STEP: the level of the step now towards t->ms_v, at SLEW's pace (0: at once; 127: ~1.5 s) */
static __attribute__((noinline)) void ms_tick(track_t *t)
{
const int16_t *p = t->p;
uint32_t per = div_samples((uint32_t)p[P_MSDIV]), len = p[P_MSLEN] > 0 ? (uint32_t)p[P_MSLEN] : 1u;
int32_t target = p[P_MS0 + (per ? ms_clock / per % len : 0u)] * 258, s = p[P_MSSLW];
if (!s) {
t->ms_v = target;
return;
}
t->ms_v += ((target - t->ms_v) * (32767 / (1 + s * s / 8))) >> 15; /* (a block's step: 1 / (1 + s^2 / 8)) */
}
/* before a part's block (fx.c mix_part): the per-track offsets, the per-block destinations into t->p.
* 0 = no slot active (then nothing changed) */
static __attribute__((noinline)) int mod_begin(track_t *t)
@@ -134,6 +153,11 @@ static __attribute__((noinline)) int mod_begin(track_t *t)
if (k == NMSLOT)
return 0;
lfo = mulq15(t->lfo_val, t->lfo_fade); /* (the LFO of the block before: track_render ticks it) */
for (j = k; j < NMSLOT; j++)
if (p[P_M1SRC + 3u * j] == MS_STEP && p[P_M1AMT + 3u * j]) {
ms_tick(t); /* (once, for every slot reading it) */
break;
}
mod.on = 1;
mod.amp = 0;
mod.nv = mod.nk = 0;
+3 -2
View File
@@ -37,8 +37,9 @@ static int motion_param(uint32_t id)
* changes never become automation. FX sends and continuous mix are safe. */
return id < P_COUNT && (id <= P_REL || (id >= P_ED_FLT && id <= P_LD_AMP) ||
(id >= P_DIST && id <= P_REV) || id == P_GLIDE || id == P_PAN ||
id == P_DETUNE || (id >= P_FM1_ATK && id <= P_FM4_LEVEL) || id >= P_SOFS); /* (the sequence offset OFS
* PIT, the DRUM lane levels, E0..E7) */
id == P_DETUNE || (id >= P_FM1_ATK && id <= P_FM4_LEVEL) || (id >= P_SOFS && id <= P_LN7) ||
id == P_DTONE || id == P_MSSLW || (id >= P_MS0 && id <= P_MS15) || id >= P_E0); /* (the sequence offset OFS
* PIT, the DRUM lane levels, DIST's TONE, the modulation sequence's slew and levels, E0..E7) */
}
static int motion_valid(const motion_store_t *m)
{
+27 -3
View File
@@ -12,6 +12,7 @@ static const char *const N_ONOFF[] = {"OFF", "ON"};
/* seq.c kb_map; 1 = SNAP (stored projects: the former ON); 3 = SEQ: SNAP, and the sequencer's notes snap too as
* they play (seq.c seq_step; the steps keep what was written). Append-only: older projects hold 0..2 */
static const char *const N_QUANT[] = {"OFF", "SNAP", "WHITE", "SEQ"};
static const char *const N_DTYPE[] = {"SOFT", "HARD", "FOLD", "CRUSH", "RECT"}; /* (JIANT) fx.c DT_* */
static const char *const N_VOICE[] = {"POLY", "MONO", "LEG", "UNI"}; /* V_POLY .. V_UNISON */
static const char *const N_GLMODE[] = {"RATE", "TIME"};
static const char *const N_PRIO[] = {"LAST", "LOW", "HIGH"};
@@ -28,7 +29,7 @@ static const char *const N_SLCR[] = {"OFF", "GATE", "STUT"}; /* SL_O
static const char *const N_SLDIV[] = {"1/8", "1/16", "1/32", "8T", "16T", "32T"}; /* SL_DEN */
/* modulation matrix (mod.c): sources, destinations (E1..E8 = P_E0..P_E7: shown with the engine's labels) */
static const char *const N_MSRC[] = {"OFF", "LFO", "ENV", "VEL", "KEY", "RAND", "MODW", "AT", "EXPR",
"M1", "M2", "M3", "M4"}; /* (JIANT: the macros, LFO held) */
"M1", "M2", "M3", "M4", "STEP"}; /* (JIANT: the macros, LFO held; the modulation sequence) */
static const char *const N_MDST[] = {"OFF", "PITCH", "CUT", "SHP", "AMP", "PAN", "DIST", "CHO", "DLY", "REV", "RATE",
"VIB", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8",
"CLIP", "PNCH"}; /* (JIANT: the master, FX > MASTER) */
@@ -113,6 +114,15 @@ static const param_desc_t TP[P_COUNT] = {
LANE(0, "KICK"), LANE(1, "SNARE"), LANE(2, "CLAP"), LANE(3, "HATCL"),
LANE(4, "HATOP"), LANE(5, "TOM"), LANE(6, "RIM"), LANE(7, "BELL"),
#undef LANE
[P_DTYPE] = PE("TYPE", N_DTYPE, 0), /* (JIANT) DIST: SOFT (as before) HARD FOLD CRUSH RECT */
[P_DTONE] = PD("TONE", F_BIPCT, -64, 63, 0), /* .. its tone: darker / brighter */
[P_MSLEN] = PD("LEN", F_STEPS, 1, 16, 16), /* (JIANT) the modulation sequence (mod.c MS_STEP) */
[P_MSDIV] = PE("DIV", N_DIV, 2),
[P_MSSLW] = PD("SLEW", F_PCT, 0, 127, 0),
#define MSTEP(k) [P_MS0 + (k)] = PD("LVL", F_PCT, 0, 127, 0)
MSTEP(0), MSTEP(1), MSTEP(2), MSTEP(3), MSTEP(4), MSTEP(5), MSTEP(6), MSTEP(7),
MSTEP(8), MSTEP(9), MSTEP(10), MSTEP(11), MSTEP(12), MSTEP(13), MSTEP(14), MSTEP(15),
#undef MSTEP
};
static const param_desc_t GP[G_COUNT] = {
@@ -146,6 +156,12 @@ static const param_desc_t GP[G_COUNT] = {
* reverb send, inert since 1.0 */
[G_PUNCH] = PD("PNCH", F_PCT, 0, 100, 0), /* DRUM's transients: up to +6 dB the first 8 ms, the tail -5 dB */
[G_DUCK] = PD("DUCK", F_PCT, 0, 100, 0), /* the kick ducks the other parts: up to -18 dB */
/* (JIANT, FUNB) the buses: not in a project's header (project.c: after the punch-in lane) */
[G_DHPF] = PD("HPF", F_PCT, 0, 127, 0), /* the delay's feedback low cut: off .. ~1.2 kHz (COLR its high cut) */
[G_WIDTH] = PD("WIDE", F_PCT, 0, 127, 0), /* the delay's right echo up to 1/32 later, the chorus's taps apart */
[G_RMOD] = PD("MOD", F_PCT, 0, 127, 0), /* the reverb's modulation depth (ROOM: the combs, SPRING: its wobble) */
[G_RRATE] = PD("RATE", F_LFOHZ, 0, 127, 30), /* .. its rate */
[G_RPRE] = PD("PRE", F_INT, 0, 100, 0), /* the reverb's pre-delay, ms */
};
static const param_desc_t *track_desc(const track_t *t, uint32_t id)
@@ -342,7 +358,7 @@ enum { FAM_HOME, FAM_ENV, FAM_LFO, FAM_FX, FAM_SCL, FAM_EDIT, FAM_GLO, FAM_SAVE,
FAM_COUNT };
enum { SC_TRACK, SC_GLOBAL, SC_ENGINE, SC_STEP, SC_TRK }; /* SC_TRK: the TRACKS page (ui_input.c tracks_edit) */
enum { GR_NONE, GR_ADSR, GR_LFO, GR_STEPS, GR_ARP, GR_SCALE, GR_FX, GR_ROLL, GR_BROWSE, GR_SLOTS, GR_USER, GR_TRK,
GR_SLCR, GR_MOD, GR_PATS, GR_SONG, GR_TOOLS, GR_CHANCE, GR_MOTION, GR_EVENTS, GR_DXSND };
GR_SLCR, GR_MOD, GR_PATS, GR_SONG, GR_TOOLS, GR_CHANCE, GR_MOTION, GR_EVENTS, GR_DXSND, GR_MSEQ };
typedef struct {
const char *title;
@@ -356,10 +372,15 @@ static const page_t PAGES[] = {
{"LFO", FAM_LFO, SC_TRACK, GR_LFO, {P_LRATE, P_LWAVE, P_LPHASE, P_LFADE}},
{"LFO DEST", FAM_LFO, SC_TRACK, GR_NONE, {P_LD_PIT, P_LD_FLT, P_LD_SHP, P_LD_AMP}},
{"MOD", FAM_LFO, SC_TRACK, GR_MOD, {0xFF, P_M1SRC, P_M1DST, P_M1AMT}}, /* KNOB 1: the slot (mod_ui_slot) */
{"MSEQ", FAM_LFO, SC_TRACK, GR_MSEQ, {0xFF, P_MS0, P_MSLEN, P_MSDIV}}, /* JIANT: KNOB 1 the step (ms_ui_step) */
{"MSEQ 2", FAM_LFO, SC_TRACK, GR_NONE, {P_MSSLW, 0xFF, 0xFF, 0xFF}},
{"FX", FAM_FX, SC_TRACK, GR_FX, {P_DIST, P_CHOR, P_DLY, P_REV}},
{"DIST", FAM_FX, SC_TRACK, GR_NONE, {P_DIST, P_DTYPE, P_DTONE, 0xFF}}, /* JIANT: the drive's type and tone */
{"SLICER", FAM_FX, SC_TRACK, GR_SLCR, {P_SLCR, P_SLPAT, P_SLRATE, P_SLDEPTH}},
{"DLY", FAM_FX, SC_GLOBAL, GR_NONE, {G_DTIME, G_DFDBK, G_DCOLOR, G_DMIX}},
{"REVERB", FAM_FX, SC_GLOBAL, GR_NONE, {G_RTYPE, G_RSIZE, G_RDAMP, 0xFF}}, /* TYPE: ROOM / SPRING */
{"DLY 2", FAM_FX, SC_GLOBAL, GR_NONE, {G_DHPF, G_WIDTH, 0xFF, 0xFF}}, /* JIANT: the feedback's low cut, the width */
{"REVERB", FAM_FX, SC_GLOBAL, GR_NONE, {G_RTYPE, G_RSIZE, G_RDAMP, G_RPRE}}, /* TYPE: ROOM / SPRING */
{"REVERB 2", FAM_FX, SC_GLOBAL, GR_NONE, {G_RMOD, G_RRATE, 0xFF, 0xFF}}, /* JIANT: the networks' modulation */
{"CHORUS", FAM_FX, SC_GLOBAL, GR_NONE, {G_CRATE, G_CDEPTH, 0xFF, 0xFF}},
{"MASTER", FAM_FX, SC_GLOBAL, GR_NONE, {G_CLIP, G_PUNCH, G_DUCK, G_DREL}}, /* JIANT: clipper, drum bus, ducking */
{"SCL", FAM_SCL, SC_TRACK, GR_SCALE, {P_ROOT, P_SCALE, P_QUANT, P_TRANS}},
@@ -396,6 +417,7 @@ static const page_t PAGES[] = {
};
#define NPAGES (sizeof(PAGES) / sizeof(PAGES[0]))
static uint8_t mod_ui_slot; /* the MOD page: the matrix slot (0..3) KNOB 2..4 edit */
static uint8_t ms_ui_step; /* (JIANT) the MSEQ page: the step (0..15) KNOB 2 edits */
static const param_desc_t *page_desc(const page_t *pg, uint32_t slot, int16_t **valp)
{
@@ -414,6 +436,8 @@ static const param_desc_t *page_desc(const page_t *pg, uint32_t slot, int16_t **
}
if (pg->graph == GR_MOD) /* SRC DST AMT of the slot shown */
id += 3u * mod_ui_slot;
if (pg->graph == GR_MSEQ && id == P_MS0) /* the level of the step shown */
id += ms_ui_step & 15u;
*valp = &TSEL->p[id];
return track_desc(TSEL, id);
}
+37 -16
View File
@@ -55,6 +55,12 @@
* the 48 spare bytes before the kit: 64 nibbles at PROJ_PFX_OFF (3072), its tracks at 3104 (a FUN9 or an earlier
* FUNA has zeros there: no lane), and the macros M1..M4 (mod.c macro_v, one byte each) right after, at 3105.
*
* Format B ("FUNB", written since JIANT 0.2) = FUNA with 96 more bytes (3840: a flash object's whole payload): 21 track
* parameters before P_E0 (DIST TYPE TONE, the modulation sequence's LEN DIV SLEW and 16 levels: P_COUNT 120, P_E0 112),
* so the data ends at 3156 and everything after it moved up by 96 (the punch-in block at PROJ_PFX_OFF 3168, the kit at
* 3216); and five globals past the header's 27 (G_DHPF .. G_RPRE) after the macros: a 1 at PROJ_GX_OFF, then biased
* bytes. FUNA (99 parameters, no new globals) and older load mapped by count, the new values their defaults.
*
* Parameter locks (1.1, core.h MOTION_LOCK) are motion records with bit 7 of their id byte set (P_COUNT 99 < 128:
* the bit is free): no byte moved for them, and every project before 1.1 has none. FUN9 holds them. A FUN8 / FUN7
* record of a 1.1 development build may hold some: on load their ids move to today's positions as the others do,
@@ -77,7 +83,9 @@
*
* Built on the Mac too (tests/project_test.c, -DPROJ_HOST): the part above the #ifndef
* PROJ_HOST needs core.h, params.c (TP) and engines.c. */
#define PROJ_MAGIC 0x46554E41u /* "FUNA": FUN9 + the DRUM-X kit (JIANT) */
#define PROJ_MAGIC 0x46554E42u /* "FUNB": FUNA, 96 bytes longer (JIANT: DIST TYPE TONE, the modulation
* sequence: 120 parameters; the buses' new globals) */
#define PROJ_MAGIC_VA 0x46554E41u /* "FUNA": FUN9 + the DRUM-X kit (JIANT 0.1) */
#define PROJ_MAGIC_V9 0x46554E39u /* "FUN9": FUN8, 64 bytes longer (the DRUM lane levels, 99 parameters) */
#define PROJ_MAGIC_V8 0x46554E38u /* "FUN8": FUN7 + the tracks' FM6 patches */
#define PROJ_MAGIC_V7 0x46554E37u /* "FUN7": serialized (byte params, packed steps), chain, motion */
@@ -123,12 +131,12 @@ typedef struct { uint8_t note[4], n, time, flags, vel, hit, acc; } step10_t;
typedef struct { int16_t p[69]; uint8_t engine, preset; step10_t step[NSTEP]; uint8_t lane[NLANE][5]; } proj_trk_v5_t;
typedef struct { /* format 5, before the song chain */
uint32_t magic, size;
int16_t g[G_COUNT];
int16_t g[PROJ_NG_V2];
uint8_t sel, parts, phys, rsv;
proj_trk_v5_t t[NTRK];
uint32_t sum;
} project_v5_t;
typedef struct { uint32_t magic, size; int16_t g[G_COUNT]; uint8_t sel, parts, phys, rsv;
typedef struct { uint32_t magic, size; int16_t g[PROJ_NG_V2]; uint8_t sel, parts, phys, rsv;
proj_trk_v5_t t[NTRK]; chain_config_t chain; uint32_t sum; } project_v6_t;
_Static_assert(sizeof(project_v5_t) == 3352u && sizeof(project_v6_t) == 3388u, "frozen formats 5 / 6 sizes");
/* Serialized FUN7 keeps the retained cache's exact extent. Params are biased
@@ -138,7 +146,8 @@ _Static_assert(sizeof(project_v5_t) == 3352u && sizeof(project_v6_t) == 3388u, "
* never reads them, so every FUN7 file stays valid both ways; FUN6..FUN1 imports get no name.
* FUN8: the same, 3584 bytes, the four packed FM6 patches at PROJ_FM6_OFF (before the name); 16 bytes of the
* reserved tail were left for parameters added later. FUN9: the same, 3648 bytes (see the top). */
#define PROJ_STORE_SIZE 3744u /* FUNA */
#define PROJ_STORE_SIZE 3840u /* FUNB (a flash object's whole payload) */
#define PROJ_STORE_VA 3744u /* FUNA */
#define PROJ_STORE_V9 3648u /* FUN9 */
#define PROJ_STORE_V8 3584u /* FUN8 */
#define PROJ_STORE_V7 3388u /* FUN7 */
@@ -149,9 +158,11 @@ _Static_assert(sizeof(project_v5_t) == 3352u && sizeof(project_v6_t) == 3388u, "
#define PROJ_PFX_OFF (PROJ_DX_OFF - 48u) /* the punch-in lane (32) and its tracks (1): FUN9's 48 spare bytes, 0 in
* every FUN9 / FUNA written before it (proj_pack clears the store) */
typedef union { uint32_t align; uint8_t raw[PROJ_STORE_SIZE]; } project_store_t;
_Static_assert(G_COUNT == 27u, "FUN7 globals retain original IDs");
_Static_assert(sizeof(project_store_t) == 3744u && PROJ_STORE_V7 == sizeof(project_v6_t), "FUNA / FUN7 sizes");
_Static_assert(sizeof(dx_lane_t[8]) == 88u && PROJ_DX_OFF == 3120u, "the kit's place: where FUN9's patches were");
_Static_assert(G_NSTORE == 27u && G_NSTORE == PROJ_NG_V2, "FUN7 globals retain original IDs");
_Static_assert(sizeof(project_store_t) == 3840u && PROJ_STORE_V7 == sizeof(project_v6_t), "FUNB / FUN7 sizes");
_Static_assert(sizeof(dx_lane_t[8]) == 88u && PROJ_DX_OFF == 3216u, "the kit's place: FUNA's, 96 bytes on");
#define PROJ_GX_OFF (PROJ_PFX_OFF + 37u) /* (FUNB) after the lane, its tracks and the macros: 1, then the globals */
_Static_assert(37u + 1u + (G_COUNT - G_NSTORE) <= 48u, "the new globals in the punch-in block's spare bytes");
_Static_assert(68u + NTRK * (P_COUNT + 2u + NSTEP * 9u) + sizeof(chain_config_t) + sizeof(motion_store_t) <= PROJ_PFX_OFF,
"the punch-in lane after the serialized part");
typedef struct { /* a track of format 4, read only */
@@ -161,7 +172,7 @@ typedef struct { /* a track of format 4, read only
} proj_trk_v4_t;
typedef struct { /* format 4 (1.0 development builds), read only */
uint32_t magic, size;
int16_t g[G_COUNT];
int16_t g[PROJ_NG_V2];
uint8_t sel, parts, phys, rsv;
proj_trk_v4_t t[NTRK];
uint32_t sum;
@@ -173,7 +184,7 @@ typedef struct { /* a track of format 3, read only
} proj_trk_v3_t;
typedef struct { /* format 3 (0.9 .. 1.0), read only */
uint32_t magic, size;
int16_t g[G_COUNT];
int16_t g[PROJ_NG_V2];
uint8_t sel, parts, rsv[2];
proj_trk_v3_t t[NTRK];
uint32_t sum;
@@ -416,7 +427,7 @@ static int proj_from_v4(project_t *q, const project_v4_t *v4, int n)
memset(q, 0, sizeof *q);
q->magic = PROJ_MAGIC;
q->size = sizeof *q;
memcpy(q->g, v4->g, sizeof q->g);
proj_g_from_v2(q->g, v4->g);
proj_rtype_room(q->g);
q->sel = v4->sel;
q->parts = v4->parts;
@@ -438,7 +449,7 @@ static int proj_from_v3(project_t *q, const project_v3_t *v3, int n)
memset(q, 0, sizeof *q);
q->magic = PROJ_MAGIC;
q->size = sizeof *q;
memcpy(q->g, v3->g, sizeof q->g);
proj_g_from_v2(q->g, v3->g);
proj_rtype_room(q->g);
q->sel = v3->sel;
q->parts = v3->parts;
@@ -536,6 +547,8 @@ static int proj_import_any(project_t *q, const void *b, int n)
if (n == PROJ_STORE_SIZE && ((const uint32_t *)b)[1] >= 8u && ((const uint32_t *)b)[1] < PROJ_STORE_SIZE)
n = (int)((const uint32_t *)b)[1]; /* a retained slot holding an older, shorter record: its own size
* (every format checks its magic and hash) */
if (n == (int)PROJ_STORE_VA && ((const uint32_t *)b)[0] == PROJ_MAGIC_VA)
return proj_unpack(q, b, PROJ_STORE_VA); /* (JIANT 0.1: 99 parameters, no new globals) */
if (n == (int)PROJ_STORE_V9 && ((const uint32_t *)b)[0] == PROJ_MAGIC_V9)
return proj_unpack(q, b, PROJ_STORE_V9);
if (n == (int)PROJ_STORE_V8 && ((const uint32_t *)b)[0] == PROJ_MAGIC_V8)
@@ -564,7 +577,7 @@ static int proj_import_old(project_t *q, const void *b, int n)
v->size == bytes && ((const uint32_t *)b)[bytes / 4u - 1u] == proj_hash(b, bytes - 4u)) {
memset(q, 0, sizeof *q);
q->magic = PROJ_MAGIC; q->size = sizeof *q;
memcpy(q->g, v->g, sizeof q->g);
proj_g_from_v2(q->g, v->g);
proj_rtype_room(q->g);
q->sel = v->sel; q->parts = v->parts; q->phys = v->phys;
for (i = 0; i < NTRK; i++) {
@@ -615,7 +628,7 @@ static int proj_pack(project_store_t *out, const project_t *q)
if (q->fm6[t][i] > 127u) return 0;
if (!chain_valid(&q->chain) || !motion_valid(&q->motion) || P_COUNT > 127u) return 0;
memset(out, 0, sizeof *out); memcpy(b, &magic, 4); memcpy(b + 4, &size, 4);
memcpy(b + 8, q->g, sizeof q->g); b[62] = q->sel; b[63] = q->parts; b[64] = q->phys; b[66] = P_COUNT;
memcpy(b + 8, q->g, G_NSTORE * 2u); b[62] = q->sel; b[63] = q->parts; b[64] = q->phys; b[66] = P_COUNT;
for (t = 0; t < NTRK; t++) {
for (i = 0; i < P_COUNT; i++) {
if (q->t[t].p[i] < -64 || q->t[t].p[i] > 127) return 0;
@@ -641,6 +654,9 @@ static int proj_pack(project_store_t *out, const project_t *q)
b[PROJ_PFX_OFF + sizeof q->pfx_lane] = q->pfx_ltgt > 2u ? 0u : q->pfx_ltgt;
for (i = 0; i < 4u; i++)
b[PROJ_PFX_OFF + sizeof q->pfx_lane + 1u + i] = q->macro[i] & 127u;
b[PROJ_GX_OFF] = 1u; /* the new globals (biased bytes, as the parameters) */
for (i = G_NSTORE; i < G_COUNT; i++)
b[PROJ_GX_OFF + 1u + i - G_NSTORE] = (uint8_t)(clamp(q->g[i], -64, 127) + 64);
memcpy(b + PROJ_DX_OFF, q->dx, sizeof q->dx);
b[PROJ_DX_OFF + sizeof q->dx] = q->dx_mute & DXG_ALL;
b[PROJ_DX_OFF + sizeof q->dx + 1u] = (uint8_t)(q->dx_mute >> 8);
@@ -673,16 +689,21 @@ static int proj_motion_ids(motion_store_t *m, uint32_t np)
* its tail 64 bytes shorter) or FUN7 (PROJ_STORE_V7: no patches, the init one) */
static int proj_unpack(project_t *q, const uint8_t *b, uint32_t st)
{
uint32_t pos = 68u, t, i, magic, size, sum, np = b[66], v7 = st == PROJ_STORE_V7, va = st == PROJ_STORE_SIZE;
uint32_t pos = 68u, t, i, magic, size, sum, np = b[66], v7 = st == PROJ_STORE_V7;
uint32_t vb = st == PROJ_STORE_SIZE, va = vb || st == PROJ_STORE_VA; /* (va: FUNA or FUNB, the kit's layout) */
uint32_t name_off = st - 4u - PROJ_NAME_LEN, fm6_off = name_off - NTRK * FM6_PACKED;
uint32_t end = v7 ? name_off : va ? fm6_off - PROJ_DX_SIZE : fm6_off;
memcpy(&magic, b, 4); memcpy(&size, b + 4, 4); memcpy(&sum, b + st - 4u, 4);
if (magic != (v7 ? PROJ_MAGIC_V7 : st == PROJ_STORE_V8 ? PROJ_MAGIC_V8 : st == PROJ_STORE_V9 ? PROJ_MAGIC_V9 : PROJ_MAGIC) ||
if (magic != (v7 ? PROJ_MAGIC_V7 : st == PROJ_STORE_V8 ? PROJ_MAGIC_V8 : st == PROJ_STORE_V9 ? PROJ_MAGIC_V9 :
st == PROJ_STORE_VA ? PROJ_MAGIC_VA : PROJ_MAGIC) ||
size != st || sum != proj_hash(b, st - 4u) ||
np < 8u || np > P_COUNT || 68u + NTRK * (np + 2u + NSTEP * 9u) + sizeof q->chain + sizeof q->motion > end)
return 0;
memset(q, 0, sizeof *q); q->magic = PROJ_MAGIC; q->size = sizeof *q;
memcpy(q->g, b + 8, sizeof q->g); q->sel = b[62]; q->parts = b[63]; q->phys = b[64];
memcpy(q->g, b + 8, G_NSTORE * 2u); q->sel = b[62];
for (i = G_NSTORE; i < G_COUNT; i++) /* the new globals: FUNB's, else their defaults */
q->g[i] = vb && b[end - 48u + 37u] == 1u ? (int16_t)clamp((int32_t)b[end - 48u + 38u + i - G_NSTORE] - 64,
GP[i].min, GP[i].max) : GP[i].def; q->parts = b[63]; q->phys = b[64];
if (v7 && (q->g[G_RTYPE] < 0 || q->g[G_RTYPE] > 1)) /* a FUN7 may still hold the old drum channel there */
proj_rtype_room(q->g);
for (t = 0; t < NTRK; t++) {
+1
View File
@@ -662,6 +662,7 @@ static void keyboard_block(void)
static void seq_start(void)
{
uint32_t i;
ms_clock = 0; /* (JIANT) the modulation sequences from their step 0 */
motion_begin();
chain_start();
for (i = 0; i < NTRK; i++) { /* every track from its step 0, together */
+2 -1
View File
@@ -415,7 +415,8 @@ static void chain_play_ui(void)
static int lock_page_ok(uint32_t i)
{
uint32_t k;
if (i >= NPAGES || (PAGES[i].scope != SC_TRACK && PAGES[i].scope != SC_ENGINE) || PAGES[i].graph == GR_MOD)
if (i >= NPAGES || (PAGES[i].scope != SC_TRACK && PAGES[i].scope != SC_ENGINE) || PAGES[i].graph == GR_MOD ||
PAGES[i].graph == GR_MSEQ)
return 0;
for (k = 0; k < 4u; k++)
if (PAGES[i].id[k] != 0xFFu && motion_param(PAGES[i].id[k]))
+14
View File
@@ -918,6 +918,20 @@ static void draw_columns(void)
draw_act_column(3, "SAVE", T_THEME, ICON_AUTO);
return;
}
if (cur_page()->graph == GR_MSEQ) { /* (JIANT) STEP, its LVL, LEN, DIV */
const track_t *t = TSEL;
uint32_t id = P_MS0 + (ms_ui_step & 15u);
fmt_int(val, (int32_t)ms_ui_step + 1);
draw_column(0, "STEP", val, "/16", ms_ui_step < (uint32_t)t->p[P_MSLEN] ? VAL(0u) : T_DIM,
(int32_t)ms_ui_step * 1000 / 15, ICON_AUTO);
param_format(&TP[id], t->p[id], val, &unit);
draw_column(1, "LVL", val, unit, VAL(1u), RATIO(&TP[id], t->p[id]), ICON_LEVEL);
param_format(&TP[P_MSLEN], t->p[P_MSLEN], val, &unit);
draw_column(2, "LEN", val, unit, VAL(2u), RATIO(&TP[P_MSLEN], t->p[P_MSLEN]), ICON_AUTO);
param_format(&TP[P_MSDIV], t->p[P_MSDIV], val, &unit);
draw_column(3, "DIV", val, unit, VAL(3u), -1, ICON_RATE);
return;
}
if (cur_page()->graph == GR_MOD) { /* SLOT, then that slot's SRC DST AMT */
const track_t *t = TSEL;
uint32_t id = P_M1SRC + 3u * mod_ui_slot;
+25
View File
@@ -833,6 +833,8 @@ static uint32_t graph_signature(void)
h = (h ^ (uint32_t)t->p[i]) * 16777619u;
h ^= (uint32_t)TSEL->preset * 7u + (uint32_t)song.g[G_SLOT] * 13u + TSEL->user * 257u + up_gen * 7919u + ui.uslot * 104729u +
ui.ppick * 1299709u;
if (pg->graph == GR_MSEQ) /* (JIANT) the step picked, the one playing, the level now */
h ^= (ms_ui_step + 1u) * 40503u + (song.playing ? ui.frame * 2654435761u : 0u);
if (pg->graph == GR_SONG) {
for (uint32_t r = 0; r < CHAIN_ROWS; r++)
h = (h ^ (song_idx.scene[song_cur][r].on * (r + 1u))) * 16777619u;
@@ -1344,6 +1346,26 @@ static void graph_scope(uint16_t c)
}
/* SONG: the rows, each a section (the saved project A..D, sounds and steps) and its bars (song_chain.c) */
/* (JIANT) MSEQ: the 16 levels as bars (past LEN dim), the step KNOB 1 picked framed, the one playing in the accent, and
* the level the matrix reads now (STEP, slewed) as a line */
static void graph_mseq(const track_t *t, uint16_t c)
{
uint32_t i, len = t->p[P_MSLEN] > 0 ? (uint32_t)t->p[P_MSLEN] : 1u;
uint32_t per = div_samples((uint32_t)t->p[P_MSDIV]), now = song.playing && per ? ms_clock / per % len : 0xFFu;
int32_t y0 = 92, hmax = 80;
for (i = 0; i < 16u; i++) {
int32_t x = 13 + (int32_t)i * 13, h = t->p[P_MS0 + i] * hmax / 127;
uint16_t col = i >= len ? T_RAISE : i == now ? T_ACCENT : settings.palette == UI_JIANT_INDEX ?
heat_col(48 + t->p[P_MS0 + i] * 200 / 127) : c;
cv_rrect(x, y0 - hmax, 10, hmax, 2, T_RAISE, T_SURF);
if (h > 0)
cv_rrect(x, y0 - (h < 3 ? 3 : h), 10, h < 3 ? 3 : h, 2, col, T_RAISE);
if (i == ms_ui_step)
cv_rect(x, y0 + 3, 10, 2, T_TEXT);
}
if (song.playing)
cv_rect(13, y0 - t->ms_v * hmax / 32767, 205, 1, T_TEXT);
}
static void graph_song(void)
{
uint32_t first = ui.song_row > 2u ? ui.song_row - 2u : 0u, i;
@@ -1453,6 +1475,9 @@ static void draw_graph(void)
cv_oy = 0;
graph_user();
break;
case GR_MSEQ:
graph_mseq(t, c);
break;
case GR_SONG:
cv_oy = 0;
graph_song();
+5 -1
View File
@@ -729,6 +729,10 @@ static void edit_param(uint32_t slot, int32_t steps)
ui.ppick = (uint8_t)clamp((int32_t)pat_pick() + steps, 0, (int32_t)pat_count() - 1);
return;
}
if (pg->graph == GR_MSEQ && slot == 0u) { /* (JIANT) MSEQ: KNOB 1 the step, 2 its level */
ms_ui_step = (uint8_t)clamp((int32_t)ms_ui_step + steps, 0, 15);
return;
}
if (pg->graph == GR_MOD && slot == 0u) { /* MOD: KNOB 1 the slot, 2..4 its SRC DST AMT */
mod_ui_slot = (uint8_t)clamp((int32_t)mod_ui_slot + (steps > 0 ? 1 : -1), 0, 3);
return;
@@ -1409,7 +1413,7 @@ static void ui_input(void)
continue;
}
if (ui.home || pg->scope == SC_STEP || pg->scope == SC_TRK || page_desc(pg, k, &hv) ||
((pg->graph == GR_USER || pg->graph == GR_MOD || pg->graph == GR_PATS) && k == 0u)
((pg->graph == GR_USER || pg->graph == GR_MOD || pg->graph == GR_MSEQ || pg->graph == GR_PATS) && k == 0u)
|| pg->graph == GR_SONG || pg->graph == GR_DXSND) { /* (not an empty column) */
ui.hot_col = (uint8_t)k;
ui.hot_t = 40;
+4 -4
View File
@@ -175,8 +175,8 @@ int main(void)
reset();
trk[0].step[0] = (step_t){{60}, 1, ST_NOTE, 0, 96, 0, 0};
bad += check("LIST captures the runtime: 13 objects (id 8 empty, id 9 the FM6 patches), runtime 3744 B (FUNA)",
list(0, &len, &crc) == 0 && rep[2] == 10u && len == sizeof(project_store_t) && len == 3744u &&
bad += check("LIST captures the runtime: 13 objects (id 8 empty, id 9 the FM6 patches), runtime 3840 B (FUNB)",
list(0, &len, &crc) == 0 && rep[2] == 10u && len == sizeof(project_store_t) && len == 3840u &&
crc == st_crc32(ED_BK_RAW, len));
bad += check("an empty project slot lists as length 0", list(2, &len, &crc) == 0 && len == 0);
bad += check("GET of the runtime copy", get(0, 0, 64) == 0);
@@ -286,7 +286,7 @@ int main(void)
memcpy(v8, st.raw, 68);
v8[66] = 91;
for (k = 0; k < NTRK; k++) {
for (j = 0; j < 91u; j++) v8[pos++] = st.raw[pos9 + (j < 83u ? j : j + 8u)];
for (j = 0; j < 91u; j++) v8[pos++] = st.raw[pos9 + (j < 83u ? j : P_E0 + j - 83u)];
pos9 += P_COUNT;
memcpy(v8 + pos, st.raw + pos9, 2u + NSTEP * 9u);
pos += 2u + NSTEP * 9u; pos9 += 2u + NSTEP * 9u;
@@ -305,7 +305,7 @@ int main(void)
memset(&v6, 0, sizeof v6); /* FUN6: 69 parameters, steps out of range */
v6.magic = PROJ_MAGIC_V6;
v6.size = sizeof v6;
for (uint32_t i = 0; i < G_COUNT; i++)
for (uint32_t i = 0; i < G_NSTORE; i++)
v6.g[i] = GP[i].def;
for (uint32_t i = 0; i < NTRK; i++)
v6.t[i].engine = trk[i].engine;
+91
View File
@@ -620,12 +620,103 @@ static int demos(const char *dir)
return n == 5u;
}
/* (JIANT) the new sound: DIST TYPE (each type its own sound, SOFT as before), the modulation sequence (STEP), the
* buses' WIDTH (left and right apart), the delay's HPF, the reverb's MOD and pre-delay (each changes the sound) */
static uint64_t phrase_lr(int32_t *diff)
{
uint32_t b, i;
track_t *t = &trk[0];
*diff = 0;
trk_note_on(t, 60, 110);
for (b = 0; b < FS / CTL; b++) {
if (b == FS / 4u / CTL)
trk_note_off(t, 60);
blocks(1);
for (i = 0; i < CTL; i++) {
int32_t d = out_buf[2u * i] - out_buf[2u * i + 1u];
*diff += d < 0 ? -d : d > 0 ? d : 0;
if (*diff > 1 << 28)
*diff = 1 << 28;
}
}
return hash;
}
static void test_jiant_fx(void)
{
uint64_t h[5], h0, h1;
int32_t d0, d1;
uint32_t k, ok = 1;
for (k = 0; k < 5u; k++) {
fresh(0, 0);
trk[0].p[P_DIST] = 90;
trk[0].p[P_DTYPE] = (int16_t)k;
h[k] = phrase();
}
for (k = 1; k < 5u; k++)
ok &= h[k] != h[0] && h[k] != h[k - 1u];
check("DIST TYPE: SOFT HARD FOLD CRUSH RECT each sound their own (SOFT, the old drive: the goldens)", ok);
fresh(0, 0);
trk[0].p[P_DIST] = 90; trk[0].p[P_DTONE] = -60;
h0 = phrase();
check("DIST TONE darker: another sound", h0 != h[0]);
fresh(0, 0);
{
track_t *t = &trk[0];
slot(t, 0, MS_STEP, MD_E1, 64);
t->p[P_MSLEN] = 4; t->p[P_MSDIV] = 2; t->p[P_MSSLW] = 0;
t->p[P_MS0] = 0; t->p[P_MS0 + 1] = 127; t->p[P_MS0 + 2] = 64;
song.playing = 1;
ms_clock = div_samples(2) + 5u; /* (in step 2) */
ms_tick(t);
ok = t->ms_v == 127 * 258;
ms_clock = 6u * div_samples(2); /* (step 7 of LEN 4: step 3) */
ms_tick(t);
ok &= t->ms_v == 64 * 258;
t->p[P_MSSLW] = 100;
ms_clock = div_samples(2) + 5u;
ms_tick(t);
ok &= t->ms_v > 64 * 258 && t->ms_v < 127 * 258; /* (slewed: on its way) */
song.playing = 0;
check("MSEQ: STEP reads the level of the step now (LEN wraps), SLEW glides to it", ok);
}
fresh(0, 0);
trk[0].p[P_DLY] = 110; trk[0].p[P_CHOR] = 90; song.g[G_WIDTH] = 0;
h0 = phrase_lr(&d0);
fresh(0, 0);
trk[0].p[P_DLY] = 110; trk[0].p[P_CHOR] = 90; song.g[G_WIDTH] = 127;
h1 = phrase_lr(&d1);
check("WIDTH 0: left = right (the buses mono, as before); 127: left and right apart", d0 == 0 && d1 > 1000 && h0 != h1);
song.g[G_WIDTH] = 0;
fresh(0, 0);
trk[0].p[P_DLY] = 110; song.g[G_DFDBK] = 100;
h0 = phrase();
fresh(0, 0);
trk[0].p[P_DLY] = 110; song.g[G_DFDBK] = 100; song.g[G_DHPF] = 100;
check("delay HPF: the repeats thinner (another sound)", phrase() != h0);
song.g[G_DHPF] = 0;
for (k = 0; k < 2u; k++) {
fresh(0, 0);
trk[0].p[P_REV] = 120; song.g[G_RTYPE] = (int16_t)k;
h0 = phrase();
fresh(0, 0);
trk[0].p[P_REV] = 120; song.g[G_RTYPE] = (int16_t)k; song.g[G_RMOD] = 100;
h1 = phrase();
fresh(0, 0);
trk[0].p[P_REV] = 120; song.g[G_RTYPE] = (int16_t)k; song.g[G_RPRE] = 60;
check(k ? "SPRING: MOD (its wobble deeper) and PRE each change the tail" : "ROOM: MOD (its combs drift) and PRE each change the tail",
h1 != h0 && phrase() != h0);
song.g[G_RMOD] = song.g[G_RPRE] = 0;
}
song.g[G_RTYPE] = 0;
}
int main(int argc, char **argv)
{
test_off();
test_math();
test_midi();
test_cost();
test_jiant_fx();
if (argc > 1)
check("demos written", demos(argv[1]));
printf("%s\n", bad ? "MOD MATRIX TEST FAILED" : "mod matrix test passed");
+3 -3
View File
@@ -18,7 +18,7 @@ static int motion_recording(void)
project_t q; project_store_t packed;
project_capture(&q);
bad += check("project snapshot saves base + independent events while sounding", q.t[0].p[P_REV] == 23 && q.motion.event[0].value == 110 &&
proj_pack(&packed, &q) && sizeof packed == 3744u);
proj_pack(&packed, &q) && sizeof packed == 3840u);
seq_stop();
bad += check("stop before another step restores the original parameter", t->p[P_REV] == 23);
seq_start(); seq_tick(t, CTL);
@@ -77,8 +77,8 @@ static int compact_project(void)
motion_set_event(t, 3, P_REV, 110);
project_t before, after; project_store_t packed, corrupt;
project_capture(&before);
bad += check("FUNA fits the retained and flash extent", sizeof(proj_slot) == 4u * 3744u && proj_pack(&packed, &before));
bad += check("FUNA round trip preserves signed values/FM params/probability/motion", proj_import(&after, &packed, sizeof packed) &&
bad += check("FUNB fits the retained and flash extent", sizeof(proj_slot) == 4u * 3840u && proj_pack(&packed, &before));
bad += check("FUNB round trip preserves signed values/FM params/probability/motion", proj_import(&after, &packed, sizeof packed) &&
!memcmp(&before, &after, sizeof before));
corrupt = packed; corrupt.raw[112] ^= 1u;
bad += check("FUN7 torn or corrupted payload is refused", !proj_import(&after, &corrupt, sizeof corrupt));
+70 -45
View File
@@ -154,6 +154,43 @@ static int track_v3_ok(const proj_trk_t *n, const proj_trk_v3_t *o, uint32_t t)
return ok;
}
/* (JIANT, FUNB) an older record of the project packed in st: np parameters a track (the first np - 8, then E0..E7;
* the motion's engine ids moved down with them), the layout of that size (FUNA: the punch-in block and the kit; FUN8 /
* FUN9: the FM6 patches; the name at the end), its magic and hash. old_motion: where its motion went */
static uint32_t old_motion;
static void old_image(uint8_t *o, const project_store_t *st, uint32_t np, uint32_t size, uint32_t magic)
{
const uint8_t *b = st->raw;
uint32_t pos = 68u, src = 68u, t, j, sum, k;
uint32_t name = size - 4u - PROJ_NAME_LEN, fm6 = name - NTRK * FM6_PACKED;
memset(o, 0, size);
memcpy(o, b, 68);
memcpy(o, &magic, 4); memcpy(o + 4, &size, 4);
o[66] = (uint8_t)np;
for (t = 0; t < NTRK; t++) {
for (j = 0; j < np; j++) o[pos++] = b[src + (j < np - 8u ? j : P_E0 + j - (np - 8u))];
src += P_COUNT;
memcpy(o + pos, b + src, 2u + NSTEP * 9u);
pos += 2u + NSTEP * 9u; src += 2u + NSTEP * 9u;
}
memcpy(o + pos, b + src, sizeof(chain_config_t) + sizeof(motion_store_t));
old_motion = pos + sizeof(chain_config_t) + 4u;
for (k = 0; k < MOTION_MAX; k++) {
uint8_t *p = o + old_motion + k * 4u + 1u;
if ((*p & 0x7Fu) >= P_E0)
*p = (uint8_t)((*p & MOTION_LOCK) | ((*p & 0x7Fu) - (P_COUNT - np)));
}
if (size == PROJ_STORE_VA) {
memcpy(o + fm6 - 96u - 48u, b + PROJ_PFX_OFF, 37u); /* (the lane, its tracks, the macros: no new globals) */
memcpy(o + fm6 - 96u, b + PROJ_DX_OFF, 96u);
}
if (size >= PROJ_STORE_V8)
memcpy(o + fm6, b + PROJ_FM6_OFF, NTRK * FM6_PACKED);
memcpy(o + name, b + PROJ_NAME_OFF, PROJ_NAME_LEN);
sum = proj_hash(o, size - 4u);
memcpy(o + size - 4u, &sum, 4);
}
int main(void)
{
static project_v4_t v4;
@@ -173,9 +210,10 @@ int main(void)
bad += check("layout: SLICER after DETUNE, then the matrix just before P_E0",
P_SLCR == P_DETUNE + 1 && P_SLDEPTH + 1 == P_M1SRC && P_M4AMT + 1 == P_FM1_ATK && P_FM4_LEVEL + 1 == P_SOFS && P_POFS + 1 == P_LN0 &&
P_LN7 + 1 == P_E0 && P_E0 == 91 && P_COUNT == PROJ_NP_V3 + 42u && PROJ_NP_V3 == PROJ_NP_V2 + 4u);
bad += check("FUNA fits one flash object, the retained cache in NOINIT", sizeof(project_store_t) <= 4096u - 256u &&
sizeof(project_store_t) == 3744u && 0xC8u + 4u * sizeof(project_store_t) <= 0x3D50u);
P_LN7 + 1 == P_DTYPE && P_MS15 + 1 == P_E0 && P_E0 == 112 && P_COUNT == PROJ_NP_V3 + 63u &&
PROJ_NP_V3 == PROJ_NP_V2 + 4u);
bad += check("FUNB fits one flash object (its whole payload), the retained cache in NOINIT",
sizeof(project_store_t) == 4096u - 256u && 0xC8u + 4u * sizeof(project_store_t) <= 0x3D50u);
/* format 2, as written before the SLICER */
memset(&v2, 0, sizeof v2);
@@ -192,7 +230,7 @@ int main(void)
ok = proj_import(&q, &buf, (int)sizeof v2);
bad += check("FUN2 -> FUN6: converted, valid format 5 slot", ok && proj_ok(&q) && q.magic == PROJ_MAGIC);
ok = q.sel == 2;
for (i = 0; i < G_COUNT; i++)
for (i = 0; i < G_NSTORE; i++)
ok &= q.g[i] == (i == G_RTYPE || i == G_DRLVL || i == G_DRREV ? 0 : (int16_t)(500 + i));
bad += check("FUN2 -> FUN6: globals (id 24, the old drum channel: ROOM; 25 26, the drum part's: off) and selected track", ok);
ok = 1;
@@ -212,7 +250,7 @@ int main(void)
memset(&v3, 0, sizeof v3);
v3.magic = PROJ_MAGIC_V3;
v3.size = sizeof v3;
for (i = 0; i < G_COUNT; i++)
for (i = 0; i < G_NSTORE; i++)
v3.g[i] = (int16_t)(600 + i);
v3.sel = 3;
v3.parts = NPART;
@@ -223,7 +261,7 @@ int main(void)
memcpy(&buf, &v3, sizeof v3);
ok = proj_import(&q, &buf, (int)sizeof v3) && proj_ok(&q) && q.magic == PROJ_MAGIC && q.sel == 3 &&
q.parts == NPART;
for (i = 0; i < G_COUNT; i++)
for (i = 0; i < G_NSTORE; i++)
ok &= q.g[i] == (i == G_RTYPE ? 0 : (int16_t)(600 + i));
for (t = 0; t < NTRK; t++)
ok &= track_v3_ok(&q.t[t], &v3.t[t], t);
@@ -422,9 +460,9 @@ int main(void)
project_t a, c;
project_store_t st, st2;
uint32_t i, zero = 1;
bad += check("FUNA name at the end of the reserved tail, the FM6 patches and the kit before it, after the data (48 spare)",
PROJ_NAME_OFF == 3728u && PROJ_FM6_OFF == 3216u && PROJ_DX_OFF == 3120u &&
68u + NTRK * (P_COUNT + 2u + NSTEP * 9u) + sizeof(chain_config_t) + sizeof(motion_store_t) + 48u ==
bad += check("FUNB name at the end of the reserved tail, the FM6 patches and the kit before it, after the data (48 + 12 spare)",
PROJ_NAME_OFF == 3824u && PROJ_FM6_OFF == 3312u && PROJ_DX_OFF == 3216u &&
68u + NTRK * (P_COUNT + 2u + NSTEP * 9u) + sizeof(chain_config_t) + sizeof(motion_store_t) + 48u + 12u ==
PROJ_DX_OFF);
memset(&a, 0, sizeof a);
a.magic = PROJ_MAGIC; a.size = sizeof a; a.parts = NPART; a.phys = PROJ_PHYS;
@@ -474,7 +512,7 @@ int main(void)
}
memcpy(a.name, "FM SONG", 7);
a.sum = proj_sum(&a);
ok = proj_pack(&st, &a) && ((uint32_t *)st.raw)[0] == 0x46554E41u && proj_import(&c, &st, sizeof st);
ok = proj_pack(&st, &a) && ((uint32_t *)st.raw)[0] == 0x46554E42u && proj_import(&c, &st, sizeof st);
for (k = 0; k < NTRK; k++)
ok &= !memcmp(c.fm6[k], FM6_FACTORY[k * 2u], FM6_PACKED) && c.t[k].engine == ENGI_FM6 &&
!memcmp(st.raw + PROJ_FM6_OFF + k * FM6_PACKED, FM6_FACTORY[k * 2u], FM6_PACKED);
@@ -503,7 +541,7 @@ int main(void)
a.sum = proj_sum(&a);
ok = proj_pack(&st, &a) && st.raw[PROJ_PFX_OFF + 2] == 0x21 && st.raw[PROJ_PFX_OFF + 32] == 2 &&
proj_import(&c, &st, sizeof st) && !memcmp(c.pfx_lane, a.pfx_lane, sizeof a.pfx_lane) && c.pfx_ltgt == 2;
bad += check("FUNA: the punch-in lane round trips (FUN9's spare bytes at 3072)", ok);
bad += check("FUNA: the punch-in lane round trips (the spare bytes at PROJ_PFX_OFF)", ok);
a.dx[2].a[DXP_PITCH] = 200;
a.sum = proj_sum(&a);
ok = !proj_pack(&st2, &a);
@@ -517,16 +555,24 @@ int main(void)
}
ok &= !proj_import(&c, &st2, sizeof st2);
bad += check("FUNA: a kit value out of range: not packed, not loaded", ok);
memcpy(v9, st.raw, PROJ_DX_OFF); /* FUN9 = FUNA without the kit */
memcpy(v9 + PROJ_DX_OFF, st.raw + PROJ_FM6_OFF, NTRK * FM6_PACKED);
memcpy(v9 + 3632u, st.raw + PROJ_NAME_OFF, PROJ_NAME_LEN);
memcpy(v9, &magic9, 4);
memcpy(v9 + 4, &size9, 4);
sum9 = proj_hash(v9, 3644u);
memcpy(v9 + 3644u, &sum9, 4);
(void)magic9; (void)size9; (void)sum9;
old_image(v9, &st, 99u, 3648u, 0x46554E39u); /* FUN9 = FUNA without the kit (99 parameters) */
ok = proj_import(&c, v9, sizeof v9) && !c.dx_mute && !memcmp(c.dx, DX_KIT_DEF, sizeof c.dx) &&
!memcmp(c.fm6, a.fm6, sizeof c.fm6) && !memcmp(c.name, "FM SONG", 7);
bad += check("FUN9 (Felucca 1.1) loads: its patches and name, the factory DRUM-X kit", ok);
!memcmp(c.fm6, a.fm6, sizeof c.fm6) && !memcmp(c.name, "FM SONG", 7) && c.t[2].p[P_E7] == 4 &&
c.t[0].p[P_MSLEN] == 16 && c.g[G_RRATE] == 30;
bad += check("FUN9 (Felucca 1.1) loads: its patches and name, the factory DRUM-X kit, the new values' defaults", ok);
{ /* FUNA (JIANT 0.1, 99 parameters): its kit, mutes and lane; the new parameters and globals their defaults */
static uint8_t va[3744];
a.dx_mute = DXG_SNARE; a.g[G_RMOD] = 77; a.t[1].p[P_DTYPE] = 3; a.sum = proj_sum(&a);
ok = proj_pack(&st2, &a);
old_image(va, &st2, 99u, 3744u, 0x46554E41u);
ok &= proj_import(&c, va, sizeof va) && c.dx_mute == DXG_SNARE && !memcmp(c.dx, a.dx, sizeof c.dx) &&
c.t[2].p[P_E7] == 4 && c.t[1].p[P_DTYPE] == 0 && c.g[G_RMOD] == 0 && c.t[3].p[P_MSDIV] == 2;
bad += check("FUNA (JIANT 0.1) loads: kit, mutes, E0..E7 at P_E0; DIST TYPE, MSEQ, the new globals: defaults", ok);
ok = proj_import(&c, &st2, sizeof st2) && c.g[G_RMOD] == 77 && c.t[1].p[P_DTYPE] == 3;
bad += check("FUNB round trip: the new globals and parameters kept", ok);
a.dx_mute = 0; a.g[G_RMOD] = 0; a.t[1].p[P_DTYPE] = 0; a.sum = proj_sum(&a);
}
}
{ /* FUN8 as 1.0.x wrote it (3584 bytes, 91 parameters: E0..E7 at 83..90, the patches at 3056): the DRUM
* lane levels 100 %, E0..E7 and their motion at today's P_E0.., the patches and the name kept */
@@ -552,24 +598,9 @@ int main(void)
e.motion.event[2] = (motion_event_t){3u << 6 | 6u, (uint8_t)(P_E5 | MOTION_LOCK), -3};
e.sum = proj_sum(&e);
ok = proj_pack(&st, &e);
memset(v8, 0, sizeof v8);
memcpy(v8, st.raw, 68);
v8[66] = 91;
for (k = 0; k < NTRK; k++) {
for (j = 0; j < 91u; j++) v8[pos++] = st.raw[pos9 + (j < 83u ? j : j + 8u)];
pos9 += P_COUNT;
memcpy(v8 + pos, st.raw + pos9, 2u + NSTEP * 9u);
pos += 2u + NSTEP * 9u; pos9 += 2u + NSTEP * 9u;
}
memcpy(v8 + pos, st.raw + pos9, sizeof(chain_config_t) + sizeof(motion_store_t));
v8[pos + sizeof(chain_config_t) + 4u + 1u] = 83u + 3u; /* its E3 then */
v8[pos + sizeof(chain_config_t) + 4u + 8u + 1u] = (83u + 5u) | MOTION_LOCK; /* its E5 then, a lock */
memcpy(v8 + 3056u, st.raw + PROJ_FM6_OFF, NTRK * FM6_PACKED);
memcpy(v8 + 3568u, st.raw + PROJ_NAME_OFF, PROJ_NAME_LEN);
((uint32_t *)v8)[0] = 0x46554E38u;
((uint32_t *)v8)[1] = 3584u;
sum = proj_hash(v8, 3580u);
memcpy(v8 + 3580u, &sum, 4);
(void)pos; (void)pos9; (void)j;
old_image(v8, &st, 91u, 3584u, 0x46554E38u); /* (its E3 then: 86, its E5 a lock: 88 | the bit) */
ok &= v8[old_motion + 1u] == 83u + 3u && v8[old_motion + 8u + 1u] == ((83u + 5u) | MOTION_LOCK);
ok = ok && proj_import(&c, v8, sizeof v8);
for (k = 0; ok && k < NTRK; k++) {
for (j = P_LN0; j <= P_LN7; j++) ok &= c.t[k].p[j] == 127;
@@ -588,13 +619,7 @@ int main(void)
bad += check(" in a retained (longer) slot: loads", proj_import(&c, &slot, sizeof slot) && c.t[3].p[P_E3] == 30);
}
/* the same music as FUN7 (3388 bytes, no patches): the data where it was, the name at 3372 */
memcpy(v7, st.raw, PROJ_STORE_V7 - 16u);
memset(v7 + PROJ_FM6_OFF, 0, PROJ_STORE_V7 - 16u - PROJ_FM6_OFF);
memcpy(v7 + PROJ_STORE_V7 - 16u, st.raw + PROJ_NAME_OFF, 12);
((uint32_t *)v7)[0] = 0x46554E37u;
((uint32_t *)v7)[1] = PROJ_STORE_V7;
sum = proj_hash(v7, PROJ_STORE_V7 - 4u);
memcpy(v7 + PROJ_STORE_V7 - 4u, &sum, 4);
old_image(v7, &st, 99u, PROJ_STORE_V7, 0x46554E37u);
ok = proj_import(&c, v7, sizeof v7);
for (k = 0; k < NTRK; k++)
init &= !memcmp(c.fm6[k], FM6_INIT, FM6_PACKED);
+1 -1
View File
@@ -29,7 +29,7 @@ static int projects(void)
bad += check("FUN8 with an engine past the last (a valid hash) is not a project", e0 >= 256u);
memset(&v5, 0, sizeof v5); /* FUN5 the same */
v5.magic = PROJ_MAGIC_V5; v5.size = sizeof v5;
for (i = 0; i < G_COUNT; i++) v5.g[i] = GP[i].def;
for (i = 0; i < G_NSTORE; i++) v5.g[i] = GP[i].def;
for (i = 0; i < NTRK; i++) { v5.t[i].engine = trk[i].engine; memcpy(v5.t[i].p, trk[i].p, sizeof v5.t[i].p); }
v5.t[2].engine = NENGINES;
v5.sum = proj_hash(&v5, sizeof v5 - 4u);
+12 -2
View File
@@ -648,7 +648,7 @@ enum { S_HOME, S_HOME_IDLE, S_MESSAGE, S_MESSAGE_KEY, S_MESSAGE_NOFILE, S_PRESET
S_NAME_USER, S_NAME_TYPING, S_NAME_123, S_NAME_EMPTY, S_NAME_FULL, S_NAME_PLAYING, S_PROJECT_NAMED, S_SONG_NAMED,
S_USER_FOOT,
S_ROLL_EMPTY, S_ROLL_ACID, S_ROLL_CHORDS, S_ROLL_TIES, S_ROLL_LEN32, S_ROLL_HIGH, S_ROLL_LOW, S_ROLL_WIDE, S_ROLL_PLAYING,
S_ROLL_LOCKS, S_ROLL_LOCK_HELD, S_DRUM_LOCKS, S_DRUM_LOCK_HELD, S_MOTION_LOCKS, S_AUTO_LIST, S_AUTO_LIST_ADD, S_AUTO_LIST_DRUM, S_REC_LAYER, S_REC_LAYER_SET, S_REC_LAYER_SONG, S_MACRO_LAYER,
S_ROLL_LOCKS, S_ROLL_LOCK_HELD, S_DRUM_LOCKS, S_DRUM_LOCK_HELD, S_MOTION_LOCKS, S_AUTO_LIST, S_AUTO_LIST_ADD, S_AUTO_LIST_DRUM, S_REC_LAYER, S_REC_LAYER_SET, S_REC_LAYER_SONG, S_MACRO_LAYER, S_MSEQ, S_DIST_PAGE,
S_COUNTIN, S_COUNTIN2, S_MENU_AUDIO, S_HEAD_PLAY_REC, S_HEAD_REC_OTHER, S_HEAD_BPM_TURN, S_HEAD_BPM_LOCK,
S_HEAD_BPM_LOCKED, S_HEAD_GLO_TURN, S_HEAD_DOWNBEAT, S_HEAD_BEAT_2,
S_MOCK_HOME, S_MOCK_PRESETS, S_MOCK_SEQ, S_MOCK_DRUM, S_MOCK_MIXER, S_MOCK_DIALOG, S_MOCK_MENU, S_COUNT };
@@ -666,7 +666,7 @@ static const char *const S_NAME[S_COUNT] = {"home", "home_idle", "message", "mes
"name_user", "name_typing", "name_123", "name_empty", "name_full", "name_playing", "project_named", "song_named",
"user_foot",
"roll_empty", "roll_acid", "roll_chords", "roll_ties", "roll_len32_p2", "roll_high", "roll_low", "roll_wide", "roll_playing",
"roll_locks", "roll_lock_held", "drum_locks", "drum_lock_held", "motion_locks", "auto_list", "auto_list_add", "auto_list_drum", "layer_rec", "layer_rec_set", "layer_rec_song", "layer_macro",
"roll_locks", "roll_lock_held", "drum_locks", "drum_lock_held", "motion_locks", "auto_list", "auto_list_add", "auto_list_drum", "layer_rec", "layer_rec_set", "layer_rec_song", "layer_macro", "mseq", "dist",
"countin", "countin_2bars", "menu_audio", "head_play_rec", "head_rec_other", "head_bpm_turn", "head_bpm_lock",
"head_bpm_locked", "head_glo_turn", "head_downbeat", "head_beat_2",
"mock_home", "mock_presets", "mock_seq", "mock_drum", "mock_mixer", "mock_dialog", "mock_menu"};
@@ -851,6 +851,16 @@ static void setup(int s)
* over STEP armed, CLICK REC, COUNT-IN 2 BARS, LEVEL HIGH (KNOB 2 just turned); a song playing on an empty
* track (CLEAR dimmed: STOP TO EDIT) */
case S_REC_LAYER: go_home(); ui.layer = LAYER_REC; break;
case S_MSEQ: { /* a rising, falling line over LEN 12, step 5 picked, playing */
static const uint8_t L[16] = {10, 40, 70, 100, 127, 90, 60, 30, 0, 50, 110, 20, 80, 80, 80, 80};
uint32_t k;
for (k = 0; k < 16u; k++) TSEL->p[P_MS0 + k] = L[k];
TSEL->p[P_MSLEN] = 12; ms_ui_step = 4; ms_clock = div_samples(2) * 6u + 3u;
TSEL->ms_v = 60 * 258;
go_title("MSEQ");
break;
}
case S_DIST_PAGE: TSEL->p[P_DIST] = 70; TSEL->p[P_DTYPE] = 2; TSEL->p[P_DTONE] = 20; go_title("DIST"); break;
case S_MACRO_LAYER: /* M1: T1 CUT and T4's MRPH; M2: CLIP; M3 at 0, M4 none */
go_home(); ui.layer = LAYER_MACRO;
macro_v[0] = 90; macro_v[1] = 40; macro_v[3] = 127;
+9 -1
View File
@@ -2385,7 +2385,7 @@ static int test_layer(void)
bad += check("FX tap: nothing on press, the FX page when let go", ok && !ui.home && cur_page()->fam == FAM_FX);
frames(320); /* (not a double tap: #83) */
press(B_FX);
bad += check(" a second tap: the next page of the family (SLICER)", str_eq(cur_page()->title, "SLICER"));
bad += check(" a second tap: the next page of the family (DIST)", str_eq(cur_page()->title, "DIST"));
ui_power_on();
btn_down(B_FX);
for (flash = 0, i = 0; i < 22u; i++) { frame(); flash |= ui.layer; } /* 0.35 s */
@@ -3482,6 +3482,14 @@ static int test_macro_layer(void)
ok &= !song_idx.scene[song_cur][1].on;
trk[3].p[P_MUTE] = 0; chain_config.count = 0;
bad += check("SONG KNOB 4 SCENE: right stores the mutes and macros into the row, left takes it away", ok);
ui_power_on(); /* (JIANT) LFO > MSEQ: KNOB 1 the step, 2 its level, 3 LEN */
ms_ui_step = 0;
go_title("MSEQ"); frame();
turn(EN_K1, 3); frame();
turn(EN_K2, 10); frame();
turn(EN_K3, -4); frame();
bad += check("MSEQ: KNOB 1 picks step 4, KNOB 2 its level, KNOB 3 LEN", ms_ui_step == 3u && TSEL->p[P_MS0 + 3] == 10 &&
TSEL->p[P_MS0] == 0 && TSEL->p[P_MSLEN] == 12);
return bad;
}
+1 -1
View File
@@ -280,7 +280,7 @@ int main(void)
r.p[i] = (int16_t)(2000 + i);
up_params(&r, v, def);
ok = P_SLCR == 45 && P_SLDEPTH + 1 == P_M1SRC && P_M4AMT + 1 == P_FM1_ATK && P_FM4_LEVEL + 1 == P_SOFS &&
P_POFS + 1 == P_LN0 && P_LN7 + 1 == P_E0 && P_E0 == 91 && P_COUNT == 99;
P_POFS + 1 == P_LN0 && P_LN7 + 1 == P_DTYPE && P_MS15 + 1 == P_E0 && P_E0 == 112 && P_COUNT == 120;
for (i = 0; i < 45u; i++)
ok &= v[i] == (int16_t)(2000 + i);
for (i = P_SLCR; i < P_E0; i++)
+22
View File
@@ -48,6 +48,28 @@ takes P_COUNT and P_E0 from `INFO` keeps working (see the table below: in JIANT
levels), went in before the engine parameters, which moved from 83..90 to 91..98: P_COUNT 99, P_E0 91. No command
changed; projects were FUN9 (3648 bytes, see "Projects (FUN9)"; JIANT writes FUNA). See "The DRUM lane levels" below.
**JIANT FUNB (120 parameters, 32 globals):** 21 track parameters went in before the engine parameters, which moved from
91..98 to 112..119: P_COUNT 120, P_E0 112. Five globals were added after the 27 a project's header holds: G_COUNT 32.
No command changed; an editor that takes P_COUNT, G_COUNT and P_E0 from `INFO` keeps working.
| id | label | values |
| --- | --- | --- |
| 91 | TYPE | DIST's type, enum: 0 SOFT (the drive as before), 1 HARD, 2 FOLD (wavefolder), 3 CRUSH (bits and a held sample), 4 RECT (full-wave rectifier, an octave up) |
| 92 | TONE | DIST's tone, −64..63 (fmt BIPCT): darker / brighter |
| 93 | LEN | the modulation sequence's length, 1..16 steps |
| 94 | DIV | its step rate, the `N_DIV` enum (default 1/16) |
| 95 | SLEW | its glide between steps, 0..127 (0: steps) |
| 96..111 | LVL | its 16 levels, 0..127; the matrix reads the step playing as the source `STEP` (SRC 13) |
| G 27 | HPF | the delay's feedback low cut, 0..127 (off .. ~1.2 kHz; COLR is its high cut) |
| G 28 | WIDE | the buses' width, 0..127: the delay's right echo up to 1/32 later, the chorus's second tap opposite |
| G 29 | MOD | the reverb's modulation depth, 0..127 (ROOM: its combs' lengths drift; SPRING: its wobble deeper) |
| G 30 | RATE | its rate (fmt LFOHZ, default 30) |
| G 31 | PRE | the reverb's pre-delay, 0..100 ms |
Projects are FUNB (`46 55 4E 42`, 3840 bytes: FUNA's layout, 96 bytes longer, so everything after the data moved up by
96; the five globals as biased bytes after the punch-in lane's tracks and the macros, behind a 1). FUNA (3744, 99
parameters) and every older format load mapped by count, the new values at their defaults.
## Framing
A request is `F0 7D 46 4C <cmd> <args...> F7`:
+15 -6
View File
@@ -1410,7 +1410,7 @@ function makeMockDevice(opt = {}) {
const NONOFF = ["OFF", "ON"], NDIV = ["1/4", "1/8", "1/16", "1/32", "8T", "16T", "1/2", "1/1", "2BAR", "4BAR"], NGO = ["--", "GO"], NDASH = ["--"];
const D = (label, fmt, min, max, def, names = null, unit = "") => ({ label, fmt, min, max, def, names, unit });
const E = (label, names, def) => D(label, F.ENUM, 0, names.length - 1, def, names);
const MSRC = ["OFF", "LFO", "ENV", "VEL", "KEY", "RAND", "MODW", "AT", "EXPR", "M1", "M2", "M3", "M4"];
const MSRC = ["OFF", "LFO", "ENV", "VEL", "KEY", "RAND", "MODW", "AT", "EXPR", "M1", "M2", "M3", "M4", "STEP"];
const MDST = ["OFF", "PITCH", "CUT", "SHP", "AMP", "PAN", "DIST", "CHO", "DLY", "REV", "RATE", "VIB", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "CLIP", "PNCH"];
const TP = [
D("LVL", F.DB, 0, 127, 104),
@@ -1439,6 +1439,8 @@ function makeMockDevice(opt = {}) {
E("CLRSQ", NGO, 0), E("INIT", NGO, 0),
E("TYPE", ["ROOM", "SPRING"], 0), /* G_RTYPE (id 24, was G_DRCH): the reverb's model */
D("PNCH", F.PCT, 0, 100, 0), D("DUCK", F.PCT, 0, 100, 0), /* G_PUNCH, G_DUCK (JIANT; were G_DRLVL, G_DRREV) */
D("HPF", F.PCT, 0, 127, 0), D("WIDE", F.PCT, 0, 127, 0), /* (JIANT, FUNB) G_DHPF, G_WIDTH: the delay's low cut, width */
D("MOD", F.PCT, 0, 127, 0), D("RATE", F.LFOHZ, 0, 127, 30), D("PRE", F.INT, 0, 100, 0), /* the reverb's modulation, pre-delay */
];
const NONE = D("-", F.INT, 0, 0, 0);
const RATIO = [".5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "14", "16"];
@@ -1539,7 +1541,10 @@ function makeMockDevice(opt = {}) {
for (let op = 0; op < 4; op++) TP.push(D("ATK", F.TIME, 0, 127, 0), D("DEC", F.TIME, 0, 127, 0), D("SUS", F.PCT, 0, 127, 127), D("REL", F.TIME, 0, 127, 0), D("LVL", F.PCT, 0, 127, 127));
TP.push(D("OFS", F.INT, -32, 32, 0), D("PIT", F.SEMI, -24, 24, 0)); /* 81, 82: SHIFT (JIANT; the chord keys before) */
for (const l of ["KICK", "SNARE", "CLAP", "HATCL", "HATOP", "TOM", "RIM", "BELL"]) TP.push(D(l, F.PCT, 0, 127, 127)); /* 83..90: DRUM lane levels */
const P_COUNT = 99, G_COUNT = 27, NSTEP = 64, P_E0 = 91, G_ENGSEL = 20, P_SLCR = 45;
TP.push(E("TYPE", ["SOFT", "HARD", "FOLD", "CRUSH", "RECT"], 0), D("TONE", F.BIPCT, -64, 63, 0), /* 91, 92: DIST (JIANT, FUNB) */
D("LEN", F.STEPS, 1, 16, 16), E("DIV", NDIV, 2), D("SLEW", F.PCT, 0, 127, 0)); /* 93..95: the modulation sequence */
for (let k = 0; k < 16; k++) TP.push(D("LVL", F.PCT, 0, 127, 0)); /* 96..111: its levels */
const P_COUNT = 120, G_COUNT = 32, NSTEP = 64, P_E0 = 112, G_ENGSEL = 20, P_SLCR = 45;
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
const enumOrig = (d, v) => d.fmt === F.ENUM && d.names ? aliasOf(d.names, v - d.min) + d.min : v; /* params.c enum_orig */
/* four tracks (firmware v3), four synth parts (1.0); engine / preset / p / step below are the selected track's */
@@ -2505,12 +2510,14 @@ const stepEdit = new Map(); /* index -> time of the last edit */
const EXPECT = { pcount: 91, gcount: 27, pe0: 83 };
/* the same layout without the chord keys (P_COUNT 89, P_E0 81), the FM operator ENVs too (69, 61) or the matrix
(firmware 1.0: 57, 49) */
const knownLayout = (info) => info.gcount === EXPECT.gcount &&
[[99, 91], [91, 83], [89, 81], [69, 61], [57, 49]].some(([c, e]) => info.pcount === c && info.pe0 === e);
const knownLayout = (info) => (info.gcount === EXPECT.gcount || info.gcount === 32) && /* (JIANT FUNB: 5 more globals) */
[[120, 112], [99, 91], [91, 83], [89, 81], [69, 61], [57, 49]].some(([c, e]) => info.pcount === c && info.pe0 === e);
const P = { LEVEL: 0, SLEN: 29 };
const LAYOUT = (pe0) => [
{ t: "ENV", pages: [["ENV", 0, [1, 2, 3, 4]], ["ENV DEST", 0, [5, 6, 7, 8]]] },
{ t: "LFO", pages: [["LFO", 0, [9, 10, 11, 12]], ["LFO DEST", 0, [13, 14, 15, 16]]] },
{ t: "LFO", pages: [["LFO", 0, [9, 10, 11, 12]], ["LFO DEST", 0, [13, 14, 15, 16]],
...(pe0 >= 112 ? [["MSEQ", 0, [93, 94, 95]], ...[0, 1, 2, 3].map((k) => [`STEPS ${4 * k + 1}-${4 * k + 4}`, 0,
[96 + 4 * k, 97 + 4 * k, 98 + 4 * k, 99 + 4 * k]])] : [])] }, /* (JIANT) the modulation sequence: LEN DIV SLEW, its 16 levels */
...(pe0 >= 61 ? [{ t: "MOD", mod: 49 }] : []), /* the matrix: P_M1SRC 49 .. P_M4AMT 60, one row per slot */
{ t: "EDIT", engine: true, pages: [["EDIT 1", 0, [pe0, pe0 + 1, pe0 + 2, pe0 + 3]], ["EDIT 2", 0, [pe0 + 4, pe0 + 5, pe0 + 6, pe0 + 7]],
...(pe0 >= 91 && engName() === "DRUM" ? [["LANES", 0, P_LANES.slice(0, 4)], ["LANES 2", 0, P_LANES.slice(4)]] : [])] }, /* lane levels 83..90 */
@@ -2519,7 +2526,9 @@ const LAYOUT = (pe0) => [
...[0, 1, 2, 3].map((k) => [`OP${k + 1}`, 0, [61 + 5 * k, 62 + 5 * k, 63 + 5 * k, 64 + 5 * k]]),
["OP LVL", 0, [65, 70, 75, 80]]] }] : []),
{ t: "VOICE", pages: [["LEVEL", 0, [0]], ["VOICE", 0, [37, 38, 41, 42]], ["VOICE 2", 0, [43, 44, 39, 40]]] },
{ t: "FX", pages: [["FX", 0, [33, 34, 35, 36]], ["SLICER", 0, [45, 46, 47, 48]], ["DLY", 1, [4, 5, 6, 7]], ["REVERB", 1, [24, 8, 9]], ["CHORUS", 1, [10, 11]], ["MASTER", 1, [21, 25, 26, 13]]] }, /* G_RTYPE 24: ROOM / SPRING; MASTER: CLIP PNCH DUCK REL */
{ t: "FX", pages: [["FX", 0, [33, 34, 35, 36]], ...(pe0 >= 112 ? [["DIST", 0, [33, 91, 92]]] : []), ["SLICER", 0, [45, 46, 47, 48]],
["DLY", 1, [4, 5, 6, 7]], ...(pe0 >= 112 ? [["DLY 2", 1, [27, 28]]] : []), ["REVERB", 1, pe0 >= 112 ? [24, 8, 9, 31] : [24, 8, 9]],
...(pe0 >= 112 ? [["REVERB 2", 1, [29, 30]]] : []), ["CHORUS", 1, [10, 11]], ["MASTER", 1, [21, 25, 26, 13]]] }, /* G_RTYPE 24: ROOM / SPRING; MASTER: CLIP PNCH DUCK REL */
{ t: "SCL", pages: [["SCL", 0, [25, 26, 27, 28]]] },
{ t: "ARP", pages: [["ARP", 0, [17, 18, 19, 20]], ["ARP 2", 0, [21, 22, 23, 24]]] },
{ t: "SEQ PATTERN", tab: "seqgroups", pages: [["PATTERN", 0, [29, 30, 31, 32]], ...(pe0 >= 83 ? [["SHIFT", 0, P_SHIFT]] : [])] }, /* OFS PIT 81, 82 */
+16 -16
View File
@@ -47,7 +47,7 @@ async function editorMock() {
const rq = async (r, o) => link.request(r, o);
const info = E.parse[E.CMD.INFO](await rq(E.req.info()));
ok(info.nengines === 14 && info.engines[1] === "-" && info.engines[12] === "FM6" && info.engines[13] === "SLICE"
&& info.engines[5] === "VOICE" && info.engines[6] === "TRIO" && info.engines[7] === "WHEEL" && info.engines[8] === "GRAIN" && info.engines[9] === "-" && info.engines[10] === "DRUM" && info.engines[11] === "NOISE" && info.pcount === 99 && info.pe0 === 91 && info.engines[4] === "SAMPLE",
&& info.engines[5] === "VOICE" && info.engines[6] === "TRIO" && info.engines[7] === "WHEEL" && info.engines[8] === "GRAIN" && info.engines[9] === "-" && info.engines[10] === "DRUM" && info.engines[11] === "NOISE" && info.pcount === 120 && info.pe0 === 112 && info.engines[4] === "SAMPLE",
"editor: INFO");
let descs = 0;
for (let i = 0; i < info.pcount; i++) if (E.parse[E.CMD.DESC](await rq(E.req.desc(0, i))).label) descs++;
@@ -73,7 +73,7 @@ async function editorMock() {
const md = [];
for (let i = 49; i < 61; i++) md.push(E.parse[E.CMD.DESC](await rq(E.req.desc(0, i))));
ok(md.map((d) => d.label).join() === "SRC1,DST1,AMT1,SRC2,DST2,AMT2,SRC3,DST3,AMT3,SRC4,DST4,AMT4"
&& md[0].names.join() === "OFF,LFO,ENV,VEL,KEY,RAND,MODW,AT,EXPR,M1,M2,M3,M4" && md[1].names.length === 22
&& md[0].names.join() === "OFF,LFO,ENV,VEL,KEY,RAND,MODW,AT,EXPR,M1,M2,M3,M4,STEP" && md[1].names.length === 22
&& md[1].names[11] === "VIB" && md[1].names[19] === "E8" && md[1].names[21] === "PNCH" && md[2].min === -64 && md[2].max === 63 && md.every((d) => d.def === 0),
"editor: matrix parameters 49..60 over DESC (22 DST names: the macros M1..M4, the master CLIP PNCH)");
await rq(E.req.set(0, 52, 1));
@@ -231,7 +231,7 @@ async function editorMock() {
const rd = E.parse[E.CMD.DESC](await rq(E.req.desc(1, 14)));
const r1 = E.parse[E.CMD.SET](await rq(E.req.set(1, 14, 5)));
const r0 = E.parse[E.CMD.SET](await rq(E.req.set(1, 14, 0)));
ok(rd.label === "ROUT" && rd.def === 0 && eq(rd.names, ["CH1-4", "SEL"]) && r1.value === 1 && r0.value === 0 && info.gcount === 27,
ok(rd.label === "ROUT" && rd.def === 0 && eq(rd.names, ["CH1-4", "SEL"]) && r1.value === 1 && r0.value === 0 && info.gcount === 32,
"editor: MIDI IN routing (ROUT CH1-4 / SEL, global id 14)");
}
{
@@ -242,7 +242,7 @@ async function editorMock() {
const inert = [25, 26].map(async (id) => E.parse[E.CMD.DESC](await rq(E.req.desc(1, id))));
const [d25, d26] = await Promise.all(inert);
ok(rd.label === "TYPE" && rd.def === 0 && eq(rd.names, ["ROOM", "SPRING"]) && r1.value === 1 && r0.value === 0 &&
d25.label === "PNCH" && d26.label === "DUCK" && d25.max === 100 && info.gcount === 27,
d25.label === "PNCH" && d26.label === "DUCK" && d25.max === 100 && info.gcount === 32,
"editor: REVERB TYPE (ROOM / SPRING, global id 24; 25, 26 PNCH and DUCK, JIANT's master)");
}
const st = E.parse[E.CMD.STEP_SET](await rq(E.req.stepSet(5, { n: 2, notes: [60, 64], time: 0, flags: 1, vel: 100 })));
@@ -637,7 +637,7 @@ async function editorLibrarian() {
const ctx = { keys, engines: info.engines, firmware: info.version, pe0: info.pe0 };
const pts = [cap, { ...bass, engineName: info.engines[bass.engine], tags: ["bass", "device"] }];
const file = JSON.parse(JSON.stringify(E.libraryFile("library", pts, ctx)));
ok(file.format === "felucca-library" && file.version === 1 && file.pCount === 99 && file.paramLabels.length === 99 && file.paramLabels[81] === "OFS" && file.paramLabels[82].startsWith("PIT#") &&
ok(file.format === "felucca-library" && file.version === 1 && file.pCount === 120 && file.paramLabels.length === 120 && file.paramLabels[81] === "OFS" && file.paramLabels[82].startsWith("PIT#") &&
file.paramLabels[83] === "KICK" && file.paramLabels[90] === "BELL" && file.engines.length === 14,
"library file: versioned, with P_COUNT, labels and engines");
const back = E.readLibraryFile(file, ctx);
@@ -649,7 +649,7 @@ async function editorLibrarian() {
const eng2 = ["PHASE", "ANALOG", "SAMPLE"];
const fut = E.readLibraryFile(file, { keys: keys2, engines: eng2 });
const p0 = fut.patches[0].p;
ok(fut.patches.length === 2 && p0.length === 100 && p0[5] === null && p0[6] === cap.p[5] && p0[99] === cap.p[98]
ok(fut.patches.length === 2 && p0.length === 121 && p0[5] === null && p0[6] === cap.p[5] && p0[120] === cap.p[119]
&& fut.patches[0].engine === 1 && fut.patches[1].engine === 0, "library file: other ids / engine order mapped by label and name");
const lost = E.readLibraryFile({ ...file, patches: [{ ...file.patches[0], engineName: "WAVETABLE" }] }, ctx);
ok(lost.patches.length === 0 && lost.skipped === 1, "library file: a patch for an unknown engine is skipped");
@@ -657,33 +657,33 @@ async function editorLibrarian() {
ok(bankFile.kind === "bank" && bankFile.patches[0].slot === 10 && E.readLibraryFile(bankFile, ctx).patches[0].slot === 10, "library file: bank export keeps slot numbers");
{ /* files from the 69-parameter firmware (P_E0 61): the engine's 8 land on E0..E7 (91..98), FM op ENV, the
chord keys and the lane levels stay unset */
const p69 = [...cap.p.slice(0, 61), ...cap.p.slice(91, 99)];
const p69 = [...cap.p.slice(0, 61), ...cap.p.slice(112, 120)];
const sp = E.readLibraryFile({ format: "felucca-patch", version: 1, engine: cap.engine, engineName: info.engines[cap.engine], p: p69 }, ctx).patches[0].p;
const keys69 = [...keys.slice(0, 61), ...keys.slice(91)];
const keys69 = [...keys.slice(0, 61), ...keys.slice(112)];
const lp = E.readLibraryFile({ ...file, pCount: 69, paramLabels: keys69, patches: [{ ...file.patches[0], params: p69 }] }, ctx).patches[0].p;
const nk = E.readLibraryFile({ ...file, paramLabels: undefined, patches: [{ ...file.patches[0], params: p69 }] }, ctx).patches[0].p;
const good = (q) => q.length === 99 && eq(q.slice(0, 61), cap.p.slice(0, 61)) && eq(q.slice(91), cap.p.slice(91)) && q.slice(61, 91).every((v) => v === null);
const good = (q) => q.length === 120 && eq(q.slice(0, 61), cap.p.slice(0, 61)) && eq(q.slice(112), cap.p.slice(112)) && q.slice(61, 112).every((v) => v === null);
ok(good(sp) && good(lp) && good(nk), "library file: 69-parameter files (patch, labelled, unlabelled) map the engine's 8 to 91..98");
}
{ /* files from the 89-parameter firmware (P_E0 81, before the chord keys): the engine's 8 land on 91..98, the FM
op ENV in place, OFS PIT (once CHRD VOIC) unset (left as the track has them), the lane levels unset */
const p89 = [...cap.p.slice(0, 81), ...cap.p.slice(91, 99)];
const keys89 = [...keys.slice(0, 81), ...keys.slice(91)];
const p89 = [...cap.p.slice(0, 81), ...cap.p.slice(112, 120)];
const keys89 = [...keys.slice(0, 81), ...keys.slice(112)];
const sp = E.readLibraryFile({ format: "felucca-patch", version: 1, engine: cap.engine, engineName: info.engines[cap.engine], p: p89 }, ctx).patches[0].p;
const lp = E.readLibraryFile({ ...file, pCount: 89, pE0: 81, paramLabels: keys89, patches: [{ ...file.patches[0], params: p89 }] }, ctx).patches[0].p;
const nk = E.readLibraryFile({ ...file, paramLabels: undefined, patches: [{ ...file.patches[0], params: p89 }] }, ctx).patches[0].p;
const good = (q) => q.length === 99 && eq(q.slice(0, 81), cap.p.slice(0, 81)) && q.slice(81, 91).every((v) => v === null) && eq(q.slice(91), cap.p.slice(91));
const good = (q) => q.length === 120 && eq(q.slice(0, 81), cap.p.slice(0, 81)) && q.slice(81, 112).every((v) => v === null) && eq(q.slice(112), cap.p.slice(112));
ok(keys89[81] === "E0" && good(sp) && good(lp) && good(nk),
"library file: 89-parameter files (patch, labelled, unlabelled) map the engine's 8 to 91..98, the chord keys unset");
}
{ /* files from 1.0.x (91 parameters, P_E0 83, before the DRUM lane levels): the engine's 8 land on 91..98, the
chord keys in place, the lane levels unset (a sound load sets them to 100 %) */
const p91 = [...cap.p.slice(0, 83), ...cap.p.slice(91, 99)];
const keys91 = [...keys.slice(0, 83), ...keys.slice(91)];
const p91 = [...cap.p.slice(0, 83), ...cap.p.slice(112, 120)];
const keys91 = [...keys.slice(0, 83), ...keys.slice(112)];
const sp = E.readLibraryFile({ format: "felucca-patch", version: 1, engine: cap.engine, engineName: info.engines[cap.engine], p: p91 }, ctx).patches[0].p;
const lp = E.readLibraryFile({ ...file, pCount: 91, pE0: 83, paramLabels: keys91, patches: [{ ...file.patches[0], params: p91 }] }, ctx).patches[0].p;
const nk = E.readLibraryFile({ ...file, paramLabels: undefined, patches: [{ ...file.patches[0], params: p91 }] }, ctx).patches[0].p;
const good = (q) => q.length === 99 && eq(q.slice(0, 83), cap.p.slice(0, 83)) && q.slice(83, 91).every((v) => v === null) && eq(q.slice(91), cap.p.slice(91));
const good = (q) => q.length === 120 && eq(q.slice(0, 83), cap.p.slice(0, 83)) && q.slice(83, 112).every((v) => v === null) && eq(q.slice(112), cap.p.slice(112));
ok(keys91[83] === "E0" && good(sp) && good(lp) && good(nk),
"library file: 91-parameter files (1.0.x: patch, labelled, unlabelled) map the engine's 8 to 91..98, the lane levels unset");
}
@@ -790,7 +790,7 @@ async function editorLive() {
const dump = E.parse[C.DUMP](await pend, info);
const ch = ev.pushes.find((f) => f.cmd === C.CHANGED);
const cv = ch && E.parse[C.CHANGED](ch.a);
ok(dump.p.length === 99 && ch && ch.pending === C.DUMP && cv.scope === 0 && cv.id === 9 && cv.value === kn.value && !ev.unknown.length,
ok(dump.p.length === 120 && ch && ch.pending === C.DUMP && cv.scope === 0 && cv.id === 9 && cv.value === kn.value && !ev.unknown.length,
"live: CHANGED while DUMP waits -> push handler, reply still matched");
const rl = m.sim.reload();
m.sim.step(3);