diff --git a/firmware/src/drum_smp.c b/firmware/src/drum_smp.c new file mode 100644 index 00000000..7540bd24 --- /dev/null +++ b/firmware/src/drum_smp.c @@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */ +/* (ports/, FELUCCA_HOST_POWER only) DRUM-X's sample layer: each lane's hit has, beside its synthesized sound, a sample + * (a slot of smp_slots.c, or a slice of one: a kit), and SMORPH blends the two (0: the synth alone, exactly the FM-1's + * DRUM-X; nothing of this runs). Included by eng_drum.c; on the FM-1 none of it exists, and the values below sit in + * slots a DRUM track there never reads (so a project from here loads there as its synth kit). + * + * SMORPH (P_LRTRG, 0 in every store before) 0 synth .. 127 sample + * BLEND (P_FM3_DEC, 0 before) XFADE the two crossfaded; S>B the synth's transient on the sample's body; B>S the + * sample's transient on the synth's body; FOLW the sample following the synth's amplitude; RING one by the other + * SLOT (P_FM4_LEVEL, 112..127: slot 1..16) MAP (P_FM4_SUS, 125..127): SLOTS lane l the slot SLOT + l (a hit at + * velocity 100 or more: SLOT + 8 + l if it holds a sample, the velocity layer), LANES SLOT cut in 8, lane l its + * slice l, KEYS SLOT cut in 16, the GM note 36 + n its slice n + * SLEVEL (P_FM3_LEVEL, 127 = 100 %) the sample's level + * The kit's TUNE (E1) and the lane's GM pitch tune the sample, DECAY (E3) below its middle shortens it, DRIVE (E7) and + * the bus shape the sum as ever; a closed hat chokes the open one's sample as its synth. CHANCE, the lanes' ratchets + * and TOUCH are the sequencer's, as for the synth */ +#define P_DXSMORPH P_LRTRG +#define P_DXSBLEND P_FM3_DEC +#define P_DXSSLOT P_FM4_LEVEL +#define P_DXSMAP P_FM4_SUS +#define P_DXSLEVEL P_FM3_LEVEL +enum { DXB_XFADE, DXB_SB, DXB_BS, DXB_FOLLOW, DXB_RING, DXB_N }; +enum { DXM_SLOTS, DXM_LANES, DXM_KEYS }; +static const char *const N_DXS_BLEND[] = {"XFADE", "S>B", "B>S", "FOLW", "RING", 0}; +static const char *const N_DXS_SLOT[129] = { + [112] = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", 0}; +static const char *const N_DXS_MAP[129] = {[125] = "SLOTS", "LANES", "KEYS", 0}; +static const param_desc_t DXS_DESC[5] = { + {"SMORPH", F_PCT, 0, 127, 0, 0, 0}, + {"BLEND", F_ENUM, 0, DXB_N - 1, 0, N_DXS_BLEND, 0}, + {"SLOT", F_ENUM, 112, 127, 112, N_DXS_SLOT, 0}, + {"MAP", F_ENUM, 125, 127, 125, N_DXS_MAP, 0}, + {"SLEVEL", F_PCT, 0, 127, 127, 0, 0}, +}; +static const param_desc_t *dxs_desc(uint32_t id) +{ + switch (id) { + case P_DXSMORPH: return &DXS_DESC[0]; + case P_DXSBLEND: return &DXS_DESC[1]; + case P_DXSSLOT: return &DXS_DESC[2]; + case P_DXSMAP: return &DXS_DESC[3]; + case P_DXSLEVEL: return &DXS_DESC[4]; + default: return 0; + } +} + +typedef struct { + double pos; + float inc, env, peak, g, kd; /* speed; the synth's follower, its peak; the sample's decay now, a sample */ + uint32_t a, b, ver, age; /* the region [a, b); its slot's version; samples since the hit */ + uint8_t slot, on, lane, choke; +} dxs_v_t; +static dxs_v_t dxs_v[NPART][NVOICE]; + +static inline dxs_v_t *dxs_vs(const track_t *t, const voice_t *v) +{ + return &dxs_v[(uint32_t)(t - trk) % NPART][(uint32_t)(v - t->v) % NVOICE]; +} +static int dxs_playing(const track_t *t, const voice_t *v) /* the sample still to sound (drum_amp keeps the voice) */ +{ + return t->p[P_DXSMORPH] > 0 && dxs_vs(t, v)->on; +} + +/* a hit: the lane's sample from its slot (or slice), at the lane's pitch */ +static void dxs_note_on(track_t *t, voice_t *v, uint32_t lane, const drum_lane_t *L) +{ + dxs_v_t *D = dxs_vs(t, v); + uint32_t base = (uint32_t)clamp(t->p[P_DXSSLOT], 112, 127) - 112u, map = (uint32_t)clamp(t->p[P_DXSMAP], 125, 127) - 125u; + uint32_t slot = base, k, ns = 0, sl = 0; + const smp_obj_t *o; + int32_t semis = 0; + D->on = 0; + if (t->p[P_DXSMORPH] <= 0) + return; + if (lane == DV_HATC) /* the closed hat chokes the open one's sample too */ + for (k = 0; k < NVOICE; k++) + if (dxs_v[(uint32_t)(t - trk) % NPART][k].on && dxs_v[(uint32_t)(t - trk) % NPART][k].lane == DV_HATO) + dxs_v[(uint32_t)(t - trk) % NPART][k].choke = 1; + if (map == DXM_SLOTS) { + slot = (base + lane) % SMP_NSLOT; + if (v->vel >= 100u && smp_get((base + 8u + lane) % SMP_NSLOT)) + slot = (base + 8u + lane) % SMP_NSLOT; /* the velocity layer */ + semis = L->st; + } else if (map == DXM_LANES) { + ns = 8u; + sl = lane; + semis = L->st; + } else { + ns = 16u; + sl = (uint32_t)clamp((int32_t)v->note - 36, 0, 15); + } + o = smp_get(slot); + if (!o) + return; + D->slot = (uint8_t)slot; + D->ver = smp_slot[slot].ver; + D->a = 0; + D->b = o->frames; + if (ns) { + uint32_t len = o->frames / ns; + D->a = sl * len; + D->b = D->a + (len ? len : 1u); + } + D->pos = (double)D->a; + D->inc = powf(2.0f, ((float)semis * 16.0f + (float)(t->p[P_E1] - 64) * 3.0f + (float)t->pfx_pit) / 192.0f); + D->env = D->peak = 0.0f; + D->g = 1.0f; + { /* DECAY below its middle: the sample shortened, tau 10 ms .. 1 s (the middle and above: as it is) */ + int32_t d = clamp(t->p[P_E3], 0, 127); + D->kd = d >= 64 ? 1.0f : expf(-1.0f / (0.01f * powf(100.0f, (float)d / 64.0f) * (float)FS)); + } + D->age = 0; + D->lane = (uint8_t)lane; + D->choke = 0; + D->on = 1; +} + +/* the layer into the hit's block y (the synth, dx_run's), by SMORPH and BLEND */ +static void dxs_layer(track_t *t, voice_t *v, int32_t *y, uint32_t n) +{ + dxs_v_t *D = dxs_vs(t, v); + const smp_obj_t *o = smp_get(D->slot); + float mo = (float)clamp(t->p[P_DXSMORPH], 0, 127) / 127.0f, lvl = (float)clamp(t->p[P_DXSLEVEL], 0, 127) / 127.0f; + uint32_t bl = (uint32_t)clamp(t->p[P_DXSBLEND], 0, DXB_N - 1), i; + float vg = 0.5f + 0.5f * (float)v->vel / 127.0f; /* (voice.c takes the velocity after: a little more here) */ + if (!D->on || !o || D->ver != smp_slot[D->slot].ver) + D->on = 0; + for (i = 0; i < n; i++) { + float s = 0.0f, x = (float)y[i], w, r; + if (D->on) { + if (D->pos >= (double)D->b || D->g < 0.0005f) { + D->on = 0; + } else { + s = 0.5f * (smp_read(o, 0, D->pos) + smp_read(o, 1, D->pos)) * 0.75f * lvl * D->g * vg; + D->pos += (double)D->inc; + D->g *= D->kd; + if (D->choke) + D->g *= 0.995f; + } + } + w = expf(-(float)D->age / (0.006f * (float)FS)); /* the transient's window: ~6 ms */ + if (D->age < 0x7FFFFFFFu) + D->age++; + switch (bl) { + case DXB_SB: r = x * (w + (1.0f - w) * (1.0f - mo)) + s * (1.0f - w) * mo; break; + case DXB_BS: r = x * (1.0f - w * mo) + s * w * mo; break; + case DXB_FOLLOW: { + float a = fabsf(x); + D->env += (a - D->env) * (a > D->env ? 0.2f : 0.002f); + D->peak = D->env > D->peak ? D->env : D->peak; + r = x * (1.0f - mo) + s * (D->peak > 1.0f ? D->env / D->peak : 0.0f) * mo; + break; + } + case DXB_RING: r = x * (1.0f - mo) + x * s * (2.0f / 16384.0f) * mo; break; + default: r = x * (1.0f - mo) + s * mo; break; + } + y[i] = (int32_t)smp_finite(r > 200000.0f ? 200000.0f : r < -200000.0f ? -200000.0f : r); + } +} diff --git a/firmware/src/eng_drum.c b/firmware/src/eng_drum.c index d5b2e672..d562c472 100644 --- a/firmware/src/eng_drum.c +++ b/firmware/src/eng_drum.c @@ -224,6 +224,10 @@ static drum_lane_t *drum_lane_of(track_t *t, const voice_t *v) return L->owner == i + 1u ? L : 0; } +#if FELUCCA_HOST_POWER +#include "drum_smp.c" /* (ports/) the lanes' sample layer: SMORPH, BLEND, SLOT, MAP, SLEVEL */ +#endif + /* Different GM pitches on a lane still share its one sounding voice. */ static voice_t *drum_reuse(track_t *t, uint32_t note) { @@ -281,6 +285,9 @@ static void drum_note_on(track_t *t, voice_t *v) dx_trigger(&L->x); if (lane == DV_HATC) /* a closed hat chokes the open one */ dx_choke(&K[DV_HATO].x); +#if FELUCCA_HOST_POWER + dxs_note_on(t, v, lane, L); /* (ports/) its sample (SMORPH 0: none) */ +#endif } /* the voice's amplitude: the hit, not the ADSR (which still runs, held at full so a release never ends @@ -292,7 +299,11 @@ static int32_t drum_amp(track_t *t, voice_t *v, int32_t adsr) return 0; if (v->stage == 4u) /* (0.6.74) given up: env_tick's fade, not held at full */ return adsr; - if (!L || (!L->x.live && !L->x.trig && !L->fl)) { /* (0.8.5: a FLAM's hit to come keeps it) */ + if (!L || (!L->x.live && !L->x.trig && !L->fl +#if FELUCCA_HOST_POWER + && !dxs_playing(t, v) /* (ports/: its sample still sounding) */ +#endif + )) { /* (0.8.5: a FLAM's hit to come keeps it) */ v->active = v->gate = 0; v->stage = 0; v->env = 0; @@ -487,6 +498,10 @@ static void drum_render(track_t *t, voice_t *v, int32_t *out, uint32_t n, const dx_run(&dx_kit[(uint32_t)v->s[0] & (DV_NLANE - 1u)], &L->x, p[P_E0] + dx_mot_v + L->rm + lfo_shp, L->st * 16 + L->rt + L->bc + (p[P_E1] - 64) * 3 + t->pfx_pit + lfo_pit, p[P_E3] - 64 + DXO_DEC[L->dm & 3u], p[P_E2] - 64 + DXO_TON[L->dm & 3u], p[P_E4] - 64, p[P_E6], p[P_E5], y, n); +#if FELUCCA_HOST_POWER + if (p[P_DXSMORPH] > 0) /* (ports/) the sample layer blended in */ + dxs_layer(t, v, y, n); +#endif { /* PUNCH: the boost before the knee (driven into it, as * Drum Buss), the tail's cut on the amplitude ramp */ int32_t pu = pnch_eff; diff --git a/firmware/src/engines.c b/firmware/src/engines.c index 53c05119..486df33f 100644 --- a/firmware/src/engines.c +++ b/firmware/src/engines.c @@ -4,6 +4,9 @@ /* Engine table (order = PRESETS browsing order and the engine numbers of the editor protocol), the * factory patterns (SEQ > PATTERNS) and the parts' sounds at power-on. */ #include "dsp.c" +#if FELUCCA_HOST_POWER +#include "smp_slots.c" /* (ports/) the sample slots, the recorder, the LIVE buffers */ +#endif #include "eng_analog.c" #include "eng_phase.c" #include "eng_lofi.c" @@ -15,7 +18,6 @@ #include "eng_animal.c" /* (JIANT 0.8.3) ANIMAL: animal calls (CMOS PULSE WHSTL WING GLOTT) */ #include "fm4_convert.c" /* DIGITAL's tables, and its sounds -> FM6 */ #if FELUCCA_HOST_POWER -#include "smp_slots.c" /* (ports/) the sample slots, the recorder, the LIVE buffers */ static void voice_kill(voice_t *v); /* (voice.c) */ #include "eng_sample.c" /* (ports/) SAMPLE: one shot, experimental modes, feedback, DESTROY, REC */ #include "eng_grain.c" /* (ports/) GRAIN: granular, on a slot or LIVE */ @@ -89,6 +91,8 @@ static const param_desc_t *hp_xdesc(const track_t *t, uint32_t id) const engine_t *e = ENGINES[t->eng_req < NENGINES ? t->eng_req : 0u]; if (e == &ENG_SAMPLE && id >= P_LN0 && id <= P_LN7) return smp_xdesc(t, id - P_LN0); + if (e == &ENG_DRUM && (id == P_DXSMORPH || id == P_DXSBLEND || id == P_DXSSLOT || id == P_DXSMAP || id == P_DXSLEVEL)) + return dxs_desc(id); if (e == &ENG_GRAIN && ((id >= P_LN0 && id <= P_LN7) || id == P_GXQUANT || id == P_GXDAMP)) return gr_xdesc(t, id); return 0; @@ -99,6 +103,10 @@ static void hp_preset_x(track_t *t, const engine_t *e, uint32_t pi) if (e == &ENG_SAMPLE) for (i = 0; i < 8u; i++) t->p[P_LN0 + i] = SMP_PRESET_X[pi % NELEM(SMP_PRESETS)][i]; + if (e == &ENG_DRUM) { /* (DRUM-X's sample layer: off, slot 1, SLOTS) */ + t->p[P_DXSSLOT] = 112; + t->p[P_DXSMAP] = 125; + } if (e == &ENG_GRAIN) { const uint8_t *x = GR_PRESET_X[pi % NELEM(GR_PRESETS)]; for (i = 0; i < 8u; i++) diff --git a/ports/core/build.sh b/ports/core/build.sh index 311642c0..e2528bc6 100755 --- a/ports/core/build.sh +++ b/ports/core/build.sh @@ -28,5 +28,9 @@ if [ "${1:-}" = test ]; then # the sample engines (SAMPLE, GRAIN, DRUM-X's samples) with the firmware's internals at hand $CC -O2 -ffp-contract=off -std=gnu99 -w "-DFELUCCA_VERSION=\"$VERSION\"" -Ibuild/gen -Ifirmware/src -Iports/core \ ports/core/sample_test.c -lm -o "$OUT/sample_test" - "$OUT/sample_test" + "$OUT/sample_test" "$OUT/hp_state.bin" + # .. and the FM-1's side: that project loaded by the core built as the FM-1 is (no host power) + $CC -O2 -ffp-contract=off -std=gnu99 -w "-DFELUCCA_VERSION=\"$VERSION\"" -Ibuild/gen -Ifirmware/src -Iports/core \ + ports/core/fm1_load_test.c -lm -o "$OUT/fm1_load_test" + "$OUT/fm1_load_test" "$OUT/hp_state.bin" fi diff --git a/ports/core/fm1_load_test.c b/ports/core/fm1_load_test.c new file mode 100644 index 00000000..d43da9a3 --- /dev/null +++ b/ports/core/fm1_load_test.c @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */ +/* The FM-1's side of a project made on a big CPU (ports/core/build.sh test): the core built as the FM-1 is + * (FELUCCA_HOST_POWER 0: no SAMPLE, no GRAIN, DRUM-X without its sample layer) loads the state sample_test saved with a + * SAMPLE, a GRAIN and a DRUM-X track whose sample layer is on: SAMPLE and GRAIN play as ANALOG (the retired engines' + * way, project.c proj_phys_gone), DRUM-X as its synth kit (the layer's values sit in slots the FM-1 never reads), and + * everything sounds, finite. + * fm1_load_test STATE */ +#define FELUCCA_HOST_POWER 0 +#include "jiant_core.c" +#include + +static int fails; +#define CHECK(c, ...) do { if (c) printf(" ok " __VA_ARGS__); else { printf(" FAIL " __VA_ARGS__); fails++; } \ + printf("\n"); } while (0) +static float ol[44100], or_[44100]; + +int main(int argc, char **argv) +{ + static uint8_t st[4u << 20]; + size_t n; + uint32_t i, k, bad = 0; + double e[3] = {0, 0, 0}; + FILE *f = argc > 1 ? fopen(argv[1], "rb") : 0; + printf("the FM-1 (no host power) loading a big CPU's project\n"); + if (!f) { + printf(" FAIL no state file\n"); + return 1; + } + n = fread(st, 1, sizeof st, f); + fclose(f); + jiant_boot(3, 1); + CHECK(jiant_state_load(st, n) == 0, "the state loads (%zu bytes)", n); + jiant_render(ol, or_, 4096); + CHECK(trk[0].engine == ENGI_DRUM && trk[1].engine == ENGI_PHYS_TO && trk[2].engine == ENGI_PHYS_TO && + trk[1].eng_req == ENGI_PHYS_TO && trk[2].eng_req == ENGI_PHYS_TO, + "T1 DRUM-X; T2 SAMPLE and T3 GRAIN as ANALOG (engines %u %u %u)", trk[0].engine, trk[1].engine, trk[2].engine); + for (k = 0; k < 3u; k++) { + for (i = 0; i < 6u; i++) + trk[i].p[P_MUTE] = i != k; + jiant_midi((uint8_t)(0x90 | k), k ? 60 : 36, 100); + jiant_render(ol, or_, 22050); + jiant_midi((uint8_t)(0x80 | k), k ? 60 : 36, 0); + for (i = 0; i < 22050u; i++) { + bad += !(ol[i] == ol[i]) || fabsf(ol[i]) > 2.0f; + e[k] += (double)ol[i] * ol[i]; + } + jiant_render(ol, or_, 22050); + } + CHECK(e[0] > 1.0 && e[1] > 1.0 && e[2] > 1.0 && !bad, "each plays (energy %.0f %.0f %.0f), finite", e[0], e[1], e[2]); + printf(fails ? "fm1 load: %d FAILED\n" : "fm1 load: all passed\n", fails); + return fails != 0; +} diff --git a/ports/core/sample_test.c b/ports/core/sample_test.c index 8bca581a..6d929e4e 100644 --- a/ports/core/sample_test.c +++ b/ports/core/sample_test.c @@ -7,6 +7,8 @@ * heavy settings printed. */ #include "jiant_core.c" #include +#include +#include static int fails; #define CHECK(c, ...) do { if (c) printf(" ok " __VA_ARGS__); else { printf(" FAIL " __VA_ARGS__); fails++; } \ @@ -121,8 +123,64 @@ static void heavy_grain(track_t *t) t->p[P_GXWIDTH] = 127; } +/* DRUM-X with its sample layer set up but SMORPH 0 (variant 1) or as it boots, no slots (0): a pattern of hits rendered + * from boot, its hash. In a child process (each from its own boot) */ +static uint64_t drum_hash(int variant) +{ + int fd[2]; + uint64_t h = 0; + pid_t pid; + if (pipe(fd)) + return 1; + pid = fork(); + if (pid == 0) { + uint32_t k, j; + uint64_t x = 1469598103934665603ull; + static float a[44100]; + jiant_boot(11, 1); /* (booted before the fork: the parent's state, the same for both) */ + for (k = 0; k < 16u; k++) + jiant_slot_clear(k); + for (k = 1; k < 6u; k++) + trk[k].p[P_MUTE] = 1; + set_engine_of(&trk[0], ENGI_DRUM); + ren(4096); + if (variant) { + for (k = 0; k < 44100u; k++) + a[k] = 0.5f * (float)sin(2.0 * M_PI * 1000.0 * k / 44100.0); + for (k = 0; k < 16u; k++) + jiant_slot_load(k, a, a, 22050, 44100, "SINE"); + trk[0].p[P_DXSBLEND] = DXB_RING; + trk[0].p[P_DXSMAP] = 126; + trk[0].p[P_DXSSLOT] = 115; + trk[0].p[P_DXSLEVEL] = 30; + } + for (k = 0; k < 16u; k++) { + static const uint8_t N[4] = {36, 42, 38, 46}; + note(N[k & 3u], 90 + k); + ren(5512); + for (j = 0; j < 5512u; j++) { + uint32_t b; + memcpy(&b, &ol[j], 4); + x = (x ^ b) * 1099511628211ull; + memcpy(&b, &or_[j], 4); + x = (x ^ b) * 1099511628211ull; + } + off(N[k & 3u]); + } + if (write(fd[1], &x, sizeof x) != sizeof x) + _exit(2); + _exit(0); + } + close(fd[1]); + if (read(fd[0], &h, sizeof h) != sizeof h) + h = 2; + close(fd[0]); + waitpid(pid, 0, 0); + return h; +} + static float S1[44100], S2[44100]; -int main(void) +int main(int argc, char **argv) { track_t *t = &trk[0]; uint32_t i; @@ -567,6 +625,110 @@ int main(void) nv, x, 100.0 / x / (nv ? nv : 1u)); CHECK(nv == 48u && x > 1.0, "48 GRAIN voices at once (clouds of up to %u grains), faster than real time", GR_N); } + printf("DRUM-X's sample layer\n"); + { + uint64_t h0 = drum_hash(0), h1 = drum_hash(1); + CHECK(h0 == h1 && h0 > 2u, "SMORPH 0, slots loaded, BLEND SLOT MAP SLEVEL set: bit for bit DRUM-X as it is (%016llx)", + (unsigned long long)h0); + } + for (i = 0; i < 44100u; i++) { /* slots 9..16: 1 kHz, 16 slices of 100 Hz steps in slot 9 */ + S1[i] = 0.6f * (float)sin(2.0 * M_PI * 1000.0 * i / 44100.0); + S2[i] = 0.6f * (float)sin(2.0 * M_PI * 100.0 * (1u + i / 2756u) * i / 44100.0); + } + for (i = 9; i < 16u; i++) + jiant_slot_load(i, S1, 0, 44100, 44100, "KHZ"); + jiant_slot_load(8, S2, 0, 44100, 44100, "STEPS"); + use(ENGI_DRUM, 0); + CHECK(t->p[P_DXSSLOT] == 112 && t->p[P_DXSMAP] == 125 && !t->p[P_DXSMORPH] && + !strcmp(track_desc(t, P_DXSMORPH)->label, "SMORPH") && !strcmp(track_desc(t, P_DXSSLOT)->names[112], "1"), + "a DRUM preset: the layer off, SLOT 1, MAP SLOTS"); + t->p[P_DXSSLOT] = 112 + 9; /* SLOTS from 10: the kick (lane 0) slot 10 */ + t->p[P_DXSMORPH] = 127; + t->p[P_E3] = 127; + { + uint32_t c; + note(36, 90); + ren(22050); + off(36); + c = zc(ol, 4410, 13230) * 5u; + CHECK(c > 950u && c < 1050u && wrms(ol, 4410, 13230) > 0.01, "SMORPH 127 XFADE: the kick is its sample (%u Hz)", c); + t->p[P_DXSMORPH] = 64; + note(36, 90); + ren(22050); + off(36); + CHECK(wrms(ol, 4410, 13230) > 0.005, "SMORPH 64: both (%.3f)", wrms(ol, 4410, 13230)); + } + { + uint32_t b, bad = 0; + nonfinite = 0; + t->p[P_DXSMORPH] = 127; + for (b = 0; b < DXB_N; b++) { + t->p[P_DXSBLEND] = (int16_t)b; + note(36, 90); + note(38, 90); + note(42, 90); + ren(11025); + off(36); off(38); off(42); + bad += wrms(ol, 0, 11025) < 0.001; + if (b == DXB_SB) /* the synth's transient first, the sample's body after */ + CHECK(zc(ol, 8000, 11025) * 44100u / 3025u > 900u, "S>B: the sample's body after the hit (%u Hz)", + zc(ol, 8000, 11025) * 44100u / 3025u); + } + CHECK(!bad && !nonfinite, "every BLEND sounds, finite (XFADE S>B B>S FOLW RING)"); + } + t->p[P_DXSBLEND] = DXB_XFADE; + ren(2u * 44100u); + t->p[P_DXSMAP] = 127; /* KEYS: slot 9 in 16, 36 + n its slice n */ + t->p[P_DXSSLOT] = 112 + 8; + { + uint32_t c; + note(36 + 5, 100); /* (41: a tom: slice 6, 600 Hz) */ + ren(4410); + off(41); + c = zc(ol, 400, 2400) * 44100u / 2000u; + CHECK(c > 520u && c < 680u, "KEYS: note 41 plays slice 6 (%u Hz, 600)", c); + ren(11025); + } + t->p[P_DXSMAP] = 125; + t->p[P_DXSSLOT] = 112 + 9; + { /* a closed hat chokes the open hat's sample */ + note(46, 100); + ren(4410); + note(42, 100); + ren(4410); + { + uint32_t k, open = 0; + for (k = 0; k < NVOICE; k++) + open += dxs_v[0][k].on && dxs_v[0][k].lane == DV_HATO && !dxs_v[0][k].choke; + CHECK(!open, "the closed hat chokes the open one's sample"); + } + off(46); off(42); + ren(22050); + } + t->p[P_DXSMORPH] = 0; CHECK(!nonfinite, "the output always finite"); + if (argc > 1) { /* a project for the FM-1's side (fm1_load_test): T1 DRUM-X with its + * samples on, T2 SAMPLE, T3 GRAIN */ + FILE *f; + size_t n; + uint8_t *st; + use(ENGI_DRUM, 0); + t->p[P_DXSMORPH] = 100; + t->p[P_DXSBLEND] = DXB_SB; + set_engine_of(&trk[1], ENGI_SAMPLE); + set_engine_of(&trk[2], ENGI_GRAIN); + ren(4096); + apply_preset_to(&trk[1], 16); + apply_preset_to(&trk[2], 5); + ren(4096); + n = jiant_state_save(0, 0); + st = malloc(n); + f = fopen(argv[1], "wb"); + CHECK(st && f && jiant_state_save(st, n) == n && fwrite(st, 1, n, f) == n && trk[1].engine == ENGI_SAMPLE && + trk[2].engine == ENGI_GRAIN, "a project with SAMPLE, GRAIN and DRUM-X's samples saved for the FM-1 (%zu bytes)", n); + if (f) + fclose(f); + free(st); + } return fails != 0; }