mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 04:44:33 +01:00
Add optional physical and MIDI keyboard split with retained note ownership
This commit is contained in:
1 parent
f5db692957
commit
e3c9e26c3e
12 files changed
+156
-21
No files matched your search
@@ -39,6 +39,8 @@ jobs:
|
||||
cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/ctl64_timing_test.c -lm -o build/song-check/timing
|
||||
build/song-check/timing > build/song-check/timing.log
|
||||
python3 tests/uac_input_irq_test.py > build/song-check/usb-input.log
|
||||
cc -O1 -w -Wno-implicit-function-declaration -Ibuild/gen -Ifirmware/src tests/midi_control_test.c -lm -o build/song-check/midi
|
||||
build/song-check/midi | tee build/song-check/midi.log
|
||||
- name: JieLi toolchain cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -62,6 +64,7 @@ jobs:
|
||||
env:
|
||||
AC79_SDK: /home/runner/fw-AC79_AIoT_SDK
|
||||
JIELI_TOOLCHAIN: /home/runner/.jieli/toolchain
|
||||
FELUCCA_REPIN: keep
|
||||
run: python3 tools/build.py > build/song-check/target.log 2>&1 || { cat build/song-check/target.log; exit 1; }
|
||||
- name: Firmware memory and reach checks
|
||||
run: tail -n 20 build/song-check/target.log
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#define FELUCCA_ID "FM-1_900" /* package identity (build.py: the .fwsc marker string) */
|
||||
#endif
|
||||
#ifndef FELUCCA_VERSION
|
||||
#define FELUCCA_VERSION "V10.6c-voice" /* (2026-11-03) V10.61: PROX tuned (the user: it works with the phone, but the phone had to go far away for PROX to let go; a narrower field, a quicker response): the PROX page's KNOB 1 MIN (0 .. 90 %: under it PROX is 0), KNOB 2 MAX (100 .. 10 %: over it PROX is full), both over the calibrated FAR .. NEAR, 10 % apart at least; KNOB 3 SPEED 1..5 (the level's smoothing 1/32 as before .. 1/2: quicker, noisier); saved as FAR / NEAR; 0, 100 and 1 as V10.60. (2026-11-03) V10.60: room (the user's ask): the conversion of DIGITAL's sounds to FM6 (fm4_convert.c) and the read of JIANT 0.1-0.5's projects (FUNB..FUN7, project.c proj_unpack) moved into the Bluetooth segment (without it: a DIGITAL sound loads as the FM6 factory preset that covers it, those old projects are not read); the app slot 4.3 KB free (was 0.8), the segment 2.7 KB; BTAPP_FN / BTAPP_RO in core.h. (2026-11-03) V10.59: FX > RPT 1/8 at slow tempos (the user: dimmed at 61 BPM): a REPEAT longer than the loop at 22 kHz (371 ms) records at 11 kHz, lo-fi (the effect's), up to 742 ms: 1/8 from 41 BPM (was 81), 1/16 from 21 (was 41); the faster ones as before, bit for bit. (2026-11-03) V10.58: users' reports: the master EQ (and TAPE) went back to flat on its own (going to GLO's pages, since V10.44): every read of a stored project or section (a slot checked, a section listed) set the EQ and TAPE playing; they now live in the project read and are applied only when it is loaded; MENU in BOTTOM and HUD showed its four cards under the panel (a blank band over it): the panel right under the tabs there, the cards at the foot as on every page of theirs; AIR's HOME: the beings swim under its cards (they crossed the tabs and the values); FX > EQ with SCOPE ON: the master's scope behind the curve. (2026-11-03) V10.57: USB > HOST takes an audio interface at 48 kHz too (the user's OP-Z, and the many interfaces with no 44,100): set to 48,000 when it has no 44,100, read at the I2S clock from a step of 48 / 44.1 (the reader's interpolation, its drift steering as before); packets of up to 50 frames taken. (2026-11-03) V10.56: USB IN+OUT no longer mixes the computer's or the phone's audio into the last track by itself (the user: recording from KOALA with IN+OUT on looped into a digital feedback, the app sending the FM-1's own output back): the input sounds where an INPUT track takes it; STEMS+IN keeps its own stem as before. (2026-11-03) V10.55: GEN's sounds right again: V10.42 replaced FM6 presets 8..12 and 14 and WHEEL 5, 6, and GEN still picked them by number for its roles (a SUB BASS played the bells, leads the electric pianos and plucks, a pedal bass the organs): its BELL EP PLUCK STRINGS SINE KEYS ORGAN DUB CHORD and KEYS take today's nearest (BELL MARIMBA TINE EP PLUCK PAD WAVE ORGAN GOSPEL JAZZ PERC); INPUT's meters keep FOLLOW's frame with the input silent; the host tests brought up to date with the UI (the DJ FILTER on LIVE > MANO, the roll's 13 px columns, INPUT in the engine lists). (2026-11-03) V10.54: the INPUT engine (the user's ask: the audio input routed, the track in an audio mode, an envelope follower): engine 15 plays the USB audio input (an interface on HOST, or the computer's USB IN+OUT) on its track: SOURCE IN 1 / IN 2 / 1+2 / STEREO (two tracks can take IN 1 and IN 2; STEREO keeps the image through the part's chain as IMAGE does), GAIN, GATE, PLAY THRU / KEYS (only while a note plays, at its envelope: a trance gate from the steps), WIDTH, RING (KEYS: a sine at the note), BITS, RATE; the track's FILTER DIST LEVEL PAN sends as any part's; EDIT INPUT shows both inputs' meters, GATE's level and FOLLOW; while a track is INPUT the last track's IN+OUT mix steps aside; MOD SRC FOLLOW, the input's envelope, on any track and any destination. (2026-11-03) V10.53: USB > HOST takes an audio interface too, an experiment (the user's ask: a USB audio input into the synth): a class compliant USB audio 1.0 capture (16-bit, mono or stereo, 44,1 kHz among its rates: Behringer UM2 / UCA and the like), alone or behind a powered hub, set to 44,1 kHz (SET_CUR) and read each frame (isochronous IN) into IN+OUT's ring: it plays through the last track (its LEVEL PAN and sends, as USB IN+OUT's host audio); usb_host_desc.h uh_parse_uac, tested; not yet on hardware. (2026-11-03) V10.52: a synth's STEREO page shows IMAGE at work (the user: no visual feedback): the field L .. R, each voice sounding a blob at its place, its size its level now, its note over it (IMAGE 0: the notes in a row), the silent ones a tick where they would sit, the span IMAGE opens as a bar. (2026-11-03) V10.51: the roll follows the playhead for real (the user: V10.47's did not): the bar playing was chosen in the roll's drawing, and a playhead out of the bar shown changed nothing the panel's redraw looks at (graph_signature): never drawn, never followed; now chosen there. (2026-11-03) V10.50: the user's fixes to V10.49: a synth's STEREO IMAGE its own parameter (P_SIMG, theLine truncated
|
||||
#define FELUCCA_VERSION "V10.6c-split" /* (2026-11-03) V10.61: PROX tuned (the user: it works with the phone, but the phone had to go far away for PROX to let go; a narrower field, a quicker response): the PROX page's KNOB 1 MIN (0 .. 90 %: under it PROX is 0), KNOB 2 MAX (100 .. 10 %: over it PROX is full), both over the calibrated FAR .. NEAR, 10 % apart at least; KNOB 3 SPEED 1..5 (the level's smoothing 1/32 as before .. 1/2: quicker, noisier); saved as FAR / NEAR; 0, 100 and 1 as V10.60. (2026-11-03) V10.60: room (the user's ask): the conversion of DIGITAL's sounds to FM6 (fm4_convert.c) and the read of JIANT 0.1-0.5's projects (FUNB..FUN7, project.c proj_unpack) moved into the Bluetooth segment (without it: a DIGITAL sound loads as the FM6 factory preset that covers it, those old projects are not read); the app slot 4.3 KB free (was 0.8), the segment 2.7 KB; BTAPP_FN / BTAPP_RO in core.h. (2026-11-03) V10.59: FX > RPT 1/8 at slow tempos (the user: dimmed at 61 BPM): a REPEAT longer than the loop at 22 kHz (371 ms) records at 11 kHz, lo-fi (the effect's), up to 742 ms: 1/8 from 41 BPM (was 81), 1/16 from 21 (was 41); the faster ones as before, bit for bit. (2026-11-03) V10.58: users' reports: the master EQ (and TAPE) went back to flat on its own (going to GLO's pages, since V10.44): every read of a stored project or section (a slot checked, a section listed) set the EQ and TAPE playing; they now live in the project read and are applied only when it is loaded; MENU in BOTTOM and HUD showed its four cards under the panel (a blank band over it): the panel right under the tabs there, the cards at the foot as on every page of theirs; AIR's HOME: the beings swim under its cards (they crossed the tabs and the values); FX > EQ with SCOPE ON: the master's scope behind the curve. (2026-11-03) V10.57: USB > HOST takes an audio interface at 48 kHz too (the user's OP-Z, and the many interfaces with no 44,100): set to 48,000 when it has no 44,100, read at the I2S clock from a step of 48 / 44.1 (the reader's interpolation, its drift steering as before); packets of up to 50 frames taken. (2026-11-03) V10.56: USB IN+OUT no longer mixes the computer's or the phone's audio into the last track by itself (the user: recording from KOALA with IN+OUT on looped into a digital feedback, the app sending the FM-1's own output back): the input sounds where an INPUT track takes it; STEMS+IN keeps its own stem as before. (2026-11-03) V10.55: GEN's sounds right again: V10.42 replaced FM6 presets 8..12 and 14 and WHEEL 5, 6, and GEN still picked them by number for its roles (a SUB BASS played the bells, leads the electric pianos and plucks, a pedal bass the organs): its BELL EP PLUCK STRINGS SINE KEYS ORGAN DUB CHORD and KEYS take today's nearest (BELL MARIMBA TINE EP PLUCK PAD WAVE ORGAN GOSPEL JAZZ PERC); INPUT's meters keep FOLLOW's frame with the input silent; the host tests brought up to date with the UI (the DJ FILTER on LIVE > MANO, the roll's 13 px columns, INPUT in the engine lists). (2026-11-03) V10.54: the INPUT engine (the user's ask: the audio input routed, the track in an audio mode, an envelope follower): engine 15 plays the USB audio input (an interface on HOST, or the computer's USB IN+OUT) on its track: SOURCE IN 1 / IN 2 / 1+2 / STEREO (two tracks can take IN 1 and IN 2; STEREO keeps the image through the part's chain as IMAGE does), GAIN, GATE, PLAY THRU / KEYS (only while a note plays, at its envelope: a trance gate from the steps), WIDTH, RING (KEYS: a sine at the note), BITS, RATE; the track's FILTER DIST LEVEL PAN sends as any part's; EDIT INPUT shows both inputs' meters, GATE's level and FOLLOW; while a track is INPUT the last track's IN+OUT mix steps aside; MOD SRC FOLLOW, the input's envelope, on any track and any destination. (2026-11-03) V10.53: USB > HOST takes an audio interface too, an experiment (the user's ask: a USB audio input into the synth): a class compliant USB audio 1.0 capture (16-bit, mono or stereo, 44,1 kHz among its rates: Behringer UM2 / UCA and the like), alone or behind a powered hub, set to 44,1 kHz (SET_CUR) and read each frame (isochronous IN) into IN+OUT's ring: it plays through the last track (its LEVEL PAN and sends, as USB IN+OUT's host audio); usb_host_desc.h uh_parse_uac, tested; not yet on hardware. (2026-11-03) V10.52: a synth's STEREO page shows IMAGE at work (the user: no visual feedback): the field L .. R, each voice sounding a blob at its place, its size its level now, its note over it (IMAGE 0: the notes in a row), the silent ones a tick where they would sit, the span IMAGE opens as a bar. (2026-11-03) V10.51: the roll follows the playhead for real (the user: V10.47's did not): the bar playing was chosen in the roll's drawing, and a playhead out of the bar shown changed nothing the panel's redraw looks at (graph_signature): never drawn, never followed; now chosen there. (2026-11-03) V10.50: the user's fixes to V10.49: a synth's STEREO IMAGE its own parameter (P_SIMG, theLine truncated
|
||||
#endif
|
||||
#if FELUCCA_OTA && !FELUCCA_FLASH
|
||||
#error "FELUCCA_OTA needs FELUCCA_FLASH"
|
||||
|
||||
+23
-12
@@ -22,6 +22,8 @@ static void mn_set(uint32_t ch, uint32_t note, uint32_t v)
|
||||
uint32_t sh = (note & 1u) * 4u;
|
||||
*b = (uint8_t)((*b & ~(15u << sh)) | (v & 15u) << sh);
|
||||
}
|
||||
static uint8_t midi_sound[16][128] __attribute__((section(".pool")));
|
||||
static uint16_t midi_refs[NTRK][128] __attribute__((section(".pool")));
|
||||
static uint16_t midi_owners[NTRK]; /* avoids rescanning all 2048 entries for CC123 */
|
||||
#define MIDI_PEDAL_NOTE 0x8u
|
||||
|
||||
@@ -38,7 +40,9 @@ static midi_channel_t *midi_channel(uint32_t ch)
|
||||
|
||||
static uint32_t midi_targets(uint32_t ch)
|
||||
{
|
||||
return midi_channel(ch)->targets | (1u << trk_index(midi_track(ch)));
|
||||
uint32_t mask = midi_channel(ch)->targets | (1u << trk_index(midi_track(ch)));
|
||||
if (split_cfg[0] && ch == split_cfg[6]) mask |= (1u << split_track(0)) | (1u << split_track(1));
|
||||
return mask;
|
||||
}
|
||||
|
||||
static void midi_expression(track_t *t, const midi_channel_t *c)
|
||||
@@ -60,11 +64,7 @@ static void midi_expression_channel(uint32_t ch)
|
||||
/* a MIDI note of track t sounds note */
|
||||
static int midi_note_held(const track_t *t, uint32_t note)
|
||||
{
|
||||
uint32_t ch, id = trk_index(t) + 1u;
|
||||
for (ch = 0; ch < 16u; ch++)
|
||||
if ((mn_get(ch, note) & 0x7u) == id)
|
||||
return 1;
|
||||
return 0;
|
||||
return note < 128u && midi_refs[trk_index(t)][note] != 0u;
|
||||
}
|
||||
|
||||
/* a key held on track t sounds note */
|
||||
@@ -84,14 +84,17 @@ static int midi_local_held(const track_t *t, uint32_t note)
|
||||
static void midi_release(uint32_t ch, uint32_t note)
|
||||
{
|
||||
uint32_t id = mn_get(ch, note) & 0x7u;
|
||||
mn_set(ch, note, 0);
|
||||
uint32_t source = note;
|
||||
note = midi_sound[ch][source];
|
||||
mn_set(ch, source, 0);
|
||||
if (id) {
|
||||
if (midi_refs[id - 1u][note]) midi_refs[id - 1u][note]--;
|
||||
midi_owners[id - 1u]--;
|
||||
if (!--midi_ch[ch].owned[id - 1u])
|
||||
midi_ch[ch].targets &= (uint8_t)~(1u << (id - 1u));
|
||||
}
|
||||
if (id && drum_track(&trk[id - 1u]) && drum_oct_of(note)) { /* (0.8.5) a band of the kit's octaves */
|
||||
dxo_off(&trk[id - 1u], DXO_MIDI + (ch << 7) + note);
|
||||
dxo_off(&trk[id - 1u], DXO_MIDI + (ch << 7) + source);
|
||||
if (!midi_local_held(&trk[id - 1u], drum_oct_base(note)))
|
||||
input_off(&trk[id - 1u], drum_oct_base(note));
|
||||
} else if (id && !midi_local_held(&trk[id - 1u], note))
|
||||
@@ -115,7 +118,10 @@ static void midi_note_event(uint32_t ch, uint32_t note, uint32_t vel)
|
||||
midi_channel_t *c = midi_channel(ch);
|
||||
uint32_t id = mn_get(ch, note) & 0x7u;
|
||||
if (vel) {
|
||||
track_t *t = midi_track(ch);
|
||||
uint32_t high = note >= split_cut(1), sound = note;
|
||||
int split = split_cfg[0] && ch == split_cfg[6];
|
||||
track_t *t = split ? &trk[split_track(high)] : midi_track(ch);
|
||||
if (split && !drum_track(t)) sound = (uint32_t)clamp((int32_t)note + 12 * split_oct(high), 0, 127);
|
||||
/* Repeated notes replace the previous press, including a pedal-held one. */
|
||||
if (id)
|
||||
midi_release(ch, note);
|
||||
@@ -123,7 +129,9 @@ static void midi_note_event(uint32_t ch, uint32_t note, uint32_t vel)
|
||||
if (t != TSEL)
|
||||
midi_hint = (uint8_t)(trk_index(t) + 1u);
|
||||
c->targets |= (uint8_t)(1u << trk_index(t));
|
||||
midi_play(t, ch, note, vel);
|
||||
midi_play(t, ch, sound, vel);
|
||||
midi_sound[ch][note] = (uint8_t)sound;
|
||||
midi_refs[trk_index(t)][sound]++;
|
||||
mn_set(ch, note, (uint8_t)(trk_index(t) + 1u));
|
||||
midi_owners[trk_index(t)]++;
|
||||
c->owned[trk_index(t)]++;
|
||||
@@ -159,6 +167,7 @@ static void __attribute__((noinline)) midi_forget_track(uint32_t track)
|
||||
midi_ch[ch].owned[track] = 0;
|
||||
}
|
||||
midi_owners[track] = 0;
|
||||
memset(midi_refs[track], 0, sizeof midi_refs[track]);
|
||||
midi_bend_q8[track] = midi_bend_target[track] = 0;
|
||||
}
|
||||
|
||||
@@ -397,7 +406,7 @@ static void __attribute__((noinline)) midi_event(uint32_t st, uint32_t ch, uint3
|
||||
midi_song_req = (uint8_t)(d1 + 1u);
|
||||
return;
|
||||
}
|
||||
if (ch >= NPART && !song.g[G_ROUTE])
|
||||
if (ch >= NPART && !song.g[G_ROUTE] && !(split_cfg[0] && ch == split_cfg[6]) && !midi_channel(ch)->targets)
|
||||
return;
|
||||
if (st == 0x90u || st == 0x80u)
|
||||
midi_note_event(ch, d1, st == 0x90u ? d2 : 0);
|
||||
@@ -405,10 +414,12 @@ static void __attribute__((noinline)) midi_event(uint32_t st, uint32_t ch, uint3
|
||||
midi_channel(ch)->bend = (int16_t)((int32_t)(d1 | (d2 << 7)) - 8192);
|
||||
midi_expression_channel(ch);
|
||||
} else if (st == 0xB0u) {
|
||||
mod_midi(midi_track(ch), st, d1, d2);
|
||||
uint32_t mask = split_cfg[0] && ch == split_cfg[6] ? midi_targets(ch) : 1u << trk_index(midi_track(ch));
|
||||
for (uint32_t i = 0; i < NTRK; i++) if (mask & (1u << i)) mod_midi(&trk[i], st, d1, d2);
|
||||
midi_control(ch, d1, d2);
|
||||
} else if (st == 0xD0u)
|
||||
mod_midi(midi_track(ch), st, d1, d2);
|
||||
else if (st == 0xC0u) /* (0.6.72) PROGRAM CHANGE: the UI loads it (ui.c midi_pc_poll) */
|
||||
midi_pc_req[trk_index(midi_track(ch)) % NTRK] = (uint8_t)(d1 + 1u);
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ enum { GR_NONE, GR_ADSR, GR_LFO, GR_STEPS, GR_ARP, GR_SCALE, GR_FX, GR_ROLL, GR_
|
||||
GR_SLCR, GR_MOD, GR_PATS, GR_SONG, GR_TOOLS, GR_CHANCE, GR_MOTION, GR_EVENTS, GR_DXSND, GR_MSEQ, GR_SLPIT,
|
||||
GR_FMOP, GR_FMOP2, GR_FMENV,
|
||||
GR_COMP, GR_EUCLID, GR_MORPH, GR_DXIMG, GR_FUGUE, GR_SHAPE, GR_PUNCH, GR_BUSES, GR_FOCUS, GR_STAGE,
|
||||
GR_LYRIC, GR_GCOMP, GR_LIVE, GR_SCENE, GR_SONGSAVE }; /* (p2, main 0.9.11) GLO > LIVE: MANO, RIELES (ui_live.c); the enum's last */ /* (0.8.5) EDIT > WORDS: VOICE's lyric (sing.c) */ /* (0.8.5:
|
||||
GR_LYRIC, GR_GCOMP, GR_LIVE, GR_SCENE, GR_SONGSAVE, GR_SPLIT }; /* (p2, main 0.9.11) GLO > LIVE: MANO, RIELES (ui_live.c); the enum's last */ /* (0.8.5) EDIT > WORDS: VOICE's lyric (sing.c) */ /* (0.8.5:
|
||||
* LENTE's EDIT > FOCUS, ENV > STAGE) */ /* (0.6.99) FX > PUNCH: the punch-in lane */ /* (JIANT 0.6.39) SEQ > COMP: the step components (ui_input.c comp_*, ui_graph.c graph_comp) */ /* (JIANT 0.6.10, from Felucca 1.5: FM6's operator pages, ui_fm6op.c) */
|
||||
|
||||
typedef struct {
|
||||
@@ -702,6 +702,8 @@ static const page_t PAGES[] = {
|
||||
* LOAD ECO / LITE / FULL (the USB card: the header's icon) */
|
||||
{"SYSTEM 2", FAM_GLO, SC_GLOBAL, GR_NONE, {G_MIDI, G_MIDI, G_MIDI, 0xFF}}, /* (V10.37) KNOB 3 Bluetooth's state */ /* (0.9.9-snd8) MIDI IN at a glance (ui_draw.c):
|
||||
* KNOB 1 USB's state OFF WAIT BUS ENUM MIDI, KNOB 2 the TRS messages come in */
|
||||
{"KEY SPLIT", FAM_GLO, SC_GLOBAL, GR_SPLIT, {0, 0xFF, 0xFF, 0xFF}},
|
||||
{"KEY SPLIT 2", FAM_GLO, SC_GLOBAL, GR_SPLIT, {4, 0xFF, 0xFF, 0xFF}},
|
||||
{"COMPS", FAM_GLO, SC_GLOBAL, GR_GCOMP, {0xFF, 0xFF, 0xFF, 0xFF}}, /* (0.9.9-seq2f) the global lane's step: ACTION
|
||||
* LENGTH CONDITION VALUE (ui_input.c gco_knob) */
|
||||
{"COMPS 2", FAM_GLO, SC_GLOBAL, GR_GCOMP, {0xFF, 0xFF, 0xFF, 0xFF}}, /* .. its TRACKS, MONO / POLY */
|
||||
|
||||
@@ -151,6 +151,7 @@ typedef struct {
|
||||
uint8_t gl[GL_N][5]; /* (0.9.9-seq2f) GLO > COMPS, the global lane (seq.c glane): FUNC's 'G' 'C'
|
||||
* block, empty before */
|
||||
char name[PROJ_NAME_LEN]; /* the project's name: upper-case ASCII 32..126, 0-padded; "" = none */
|
||||
uint8_t split[8]; /* optional KS extension, absent = OFF */
|
||||
uint8_t fit[NTRK]; /* FIT/SPAN per track; optional RF extension */
|
||||
uint32_t sum;
|
||||
} project_t;
|
||||
@@ -927,12 +928,19 @@ static uint32_t proj_packed_size(const project_t *q)
|
||||
}
|
||||
for (t = 0; t < NTRK; t++)
|
||||
if (q->fit[t]) { n += 2u + NTRK; break; }
|
||||
for (i = 0; i < sizeof q->split; i++) if (q->split[i]) { n += 2u + sizeof q->split; break; }
|
||||
return n;
|
||||
}
|
||||
static int proj_split_ok(const uint8_t *s)
|
||||
{
|
||||
return s[0] <= 1u && s[1] <= 26u && s[2] < NTRK && s[3] < NTRK &&
|
||||
(int8_t)s[4] >= -4 && (int8_t)s[4] <= 4 && (int8_t)s[5] >= -4 && (int8_t)s[5] <= 4 && s[6] < 16u && s[7] < 128u;
|
||||
}
|
||||
static int proj_pack(project_store_t *out, const project_t *q)
|
||||
{
|
||||
uint8_t *b = out->raw; uint32_t pos = 68u, t, i; uint32_t magic = PROJ_MAGIC, size = PROJ_STORE_SIZE, sum;
|
||||
proj_full = 0;
|
||||
if (!proj_split_ok(q->split)) return 0;
|
||||
for (t = 0; t < NTRK; t++) { /* the values first: out untouched when one is wrong */
|
||||
if ((q->fit[t] & 127u) > 64u || q->t[t].engine >= NENGINES) return 0;
|
||||
for (i = 0; i < FM6_PACKED; i++)
|
||||
@@ -1092,6 +1100,8 @@ static int proj_pack(project_store_t *out, const project_t *q)
|
||||
b[pos++] = 'R'; b[pos++] = 'F';
|
||||
for (t = 0; t < NTRK; t++) b[pos++] = fit_valid(q->fit[t]);
|
||||
}
|
||||
for (i = 0; i < sizeof q->split && !q->split[i]; i++) {}
|
||||
if (i < sizeof q->split) { b[pos++] = 'K'; b[pos++] = 'S'; memcpy(b + pos, q->split, sizeof q->split); pos += sizeof q->split; }
|
||||
memcpy(b + PROJC_PFX_OFF, q->pfx_lane, sizeof q->pfx_lane);
|
||||
b[PROJC_PFX_OFF + sizeof q->pfx_lane] = q->pfx_ltgt > 2u ? 0u : q->pfx_ltgt;
|
||||
for (i = 0; i < 4u; i++)
|
||||
@@ -1398,6 +1408,13 @@ static int proj_unpack_c(project_t *q, const uint8_t *b)
|
||||
if ((v & 127u) > 64u) return 0;
|
||||
q->fit[t] = (uint8_t)v;
|
||||
}
|
||||
pos += 2u + NTRK;
|
||||
}
|
||||
memset(q->split, 0, sizeof q->split);
|
||||
if (pos + 2u <= room && b[pos] == 'K' && b[pos + 1u] == 'S') {
|
||||
if (pos + 2u + sizeof q->split > room) return 0;
|
||||
memcpy(q->split, b + pos + 2u, sizeof q->split);
|
||||
if (!proj_split_ok(q->split)) return 0;
|
||||
}
|
||||
proj_new_tracks(q, nt); /* (a FUNC of fewer tracks: the rest at power-on) */
|
||||
for (t = nt; t < NTRK; t++)
|
||||
@@ -1664,6 +1681,7 @@ static void project_capture(project_t *p)
|
||||
for (i = 0; i < G_COUNT; i++)
|
||||
p->g[i] = mom_base(MOM_G, i, song.g[i]); /* (0.9.9-seq2e: a MOMENTARY value: the one kept) */
|
||||
p->g[G_DJF] = mom_base(MOM_G, G_DJF, motion_djf_value()); /* (0.9.1) the knob's, not what its automation set */
|
||||
memcpy(p->split, split_cfg, sizeof split_cfg);
|
||||
p->sel = song.sel;
|
||||
p->parts = NPART;
|
||||
p->phys = PROJ_PHYS;
|
||||
@@ -1908,6 +1926,7 @@ static int project_restore_runtime(const project_t *input)
|
||||
}
|
||||
{ /* (V10.31) SCENE */
|
||||
uint32_t i;
|
||||
memcpy(split_cfg, p->split, sizeof split_cfg);
|
||||
scn_on = p->scene[0] & 1u;
|
||||
for (i = 0; i < NTRK; i++) {
|
||||
uint32_t r = (p->scene[1u + i / 2u] >> (4u * (i & 1u))) & 15u;
|
||||
@@ -2036,6 +2055,7 @@ static __attribute__((noinline)) void system_init(void) /* (snd8: out of its c
|
||||
memcpy(dx_kit, DX_KIT_DEF, sizeof dx_kit);
|
||||
memset(dx_mot, 0, sizeof dx_mot);
|
||||
dx_acoustic = 0;
|
||||
memset(split_cfg, 0, sizeof split_cfg);
|
||||
scn_on = 0; memset(scn_role, 0, sizeof scn_role); /* (V10.31) SCENE */
|
||||
dx_tone = 0;
|
||||
dx_hands = 0;
|
||||
@@ -2301,6 +2321,7 @@ static uint32_t as_mix(uint32_t h, const void *p, uint32_t n) /* FNV-1a, conti
|
||||
static uint32_t autosave_sig(void)
|
||||
{
|
||||
uint32_t h = 2166136261u, i, j;
|
||||
h = as_mix(h, split_cfg, sizeof split_cfg);
|
||||
for (i = 0; i < NTRK; i++) {
|
||||
const track_t *t = &trk[i];
|
||||
for (j = 0; j < P_COUNT; j++) {
|
||||
|
||||
+16
-3
@@ -1,5 +1,11 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only
|
||||
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */
|
||||
/* Optional keyboard split. Kept in the pool so DSP globals retain their addresses.
|
||||
* on, physical cut (0=13), low/high track, low/high signed octaves, MIDI channel, MIDI cut (0=60). */
|
||||
static uint8_t split_cfg[8] __attribute__((section(".pool")));
|
||||
static uint32_t split_cut(uint32_t midi) { return split_cfg[midi ? 7 : 1] ? split_cfg[midi ? 7 : 1] : (midi ? 60u : 13u); }
|
||||
static uint32_t split_track(uint32_t high) { return split_cfg[2u + high] % NTRK; }
|
||||
static int32_t split_oct(uint32_t high) { return (int8_t)split_cfg[4u + high]; }
|
||||
static uint8_t shift_valid[2][NTRK];
|
||||
/* Keyboard, scale, arpeggiator, sequencer and transport.
|
||||
* Everything here runs in the audio ISR, once per CTL-sample block (64 samples since 0.9.9 ctl64; the note-ons it
|
||||
@@ -1285,12 +1291,17 @@ static void keyboard_block(void)
|
||||
lv.kb |= 1u << k;
|
||||
} else if (song.grid) /* the DRUM grid: a lane key plays its lane, the rest are the UI's */
|
||||
kb_note[k] = key_black(k) && key_place(k) < NLANE ? DRUM_LANE_NOTE[key_place(k)] : KB_SILENT;
|
||||
else
|
||||
else {
|
||||
uint32_t high = k >= split_cut(0);
|
||||
if (split_cfg[0]) kb_trk[k] = (uint8_t)split_track(high);
|
||||
kb_note[k] = (uint8_t)kb_map(&trk[kb_trk[k]], k);
|
||||
kb_oct[k] = (int8_t)(!song.grid && drum_track(&trk[kb_trk[k]]) ? song.octave : 0); /* (0.8.5) */
|
||||
if (split_cfg[0] && kb_note[k] != KB_SILENT && !drum_track(&trk[kb_trk[k]]))
|
||||
kb_note[k] = (uint8_t)clamp((int32_t)kb_note[k] + 12 * split_oct(high), 0, 127);
|
||||
}
|
||||
kb_oct[k] = (int8_t)(!song.grid && drum_track(&trk[kb_trk[k]]) ? song.octave + (split_cfg[0] ? split_oct(k >= split_cut(0)) : 0) : 0); /* split drum octave retained until release */
|
||||
if (kb_note[k] == KB_SILENT)
|
||||
continue;
|
||||
if (scn_on && !song.grid) { /* (V10.25) SCENE: every track with a role */
|
||||
if (scn_on && !song.grid && !split_cfg[0]) { /* (V10.25) SCENE: every track with a role */
|
||||
scn_keys |= 1u << k;
|
||||
scene_fp(k, 1);
|
||||
continue;
|
||||
@@ -2857,6 +2868,7 @@ static void events_block(uint32_t n)
|
||||
memset(midi_sel_on, 0, sizeof midi_sel_on);
|
||||
memset(midi_ch, 0, sizeof midi_ch);
|
||||
memset(midi_owners, 0, sizeof midi_owners);
|
||||
memset(midi_refs, 0, sizeof midi_refs);
|
||||
midi_hint = 0;
|
||||
for (i = 0; i < NTRK; i++) {
|
||||
trk[i].rh_n = trk[i].rskip_n = 0;
|
||||
@@ -2964,3 +2976,4 @@ static void events_block(uint32_t n)
|
||||
#include "song_play.c" /* the song: the ISR's part (song_chain.c) */
|
||||
|
||||
|
||||
|
||||
@@ -1622,6 +1622,17 @@ static void draw_columns(void)
|
||||
empty_column(3);
|
||||
return;
|
||||
}
|
||||
if (cur_page()->graph == GR_SPLIT) {
|
||||
static const uint8_t fields[8] = {0, 2, 3, 1, 4, 5, 6, 7};
|
||||
static const char *const labels[8] = {"SPLIT", "LOW TRK", "HIGH TRK", "KEY CUT", "LOW OCT", "HIGH OCT", "MIDI CH", "MIDI CUT"};
|
||||
for (uint32_t c = 0; c < 4; c++) {
|
||||
uint32_t x = cur_page()->id[0] + c, f = fields[x];
|
||||
int32_t v = f == 1u ? (int32_t)split_cut(0) + 1 : f == 7u ? (int32_t)split_cut(1) : f == 4u || f == 5u ? (int8_t)split_cfg[f] : split_cfg[f] + (f == 2u || f == 3u || f == 6u);
|
||||
fmt_int(val, v);
|
||||
hot_text_column(c, labels[x], f ? val : split_cfg[0] ? "ON" : "OFF");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (FIT_PAGE(cur_page())) {
|
||||
pf_column(0, "LEN", &TP[P_SLEN], TSEL->p[P_SLEN], T_TEXT, ICON_AUTO);
|
||||
fmt_int(val, (int32_t)fit_span(TSEL));
|
||||
|
||||
+11
-1
@@ -1432,6 +1432,15 @@ static void edit_param(uint32_t slot, int32_t steps)
|
||||
ui.act = (uint8_t)(a + 1);
|
||||
return;
|
||||
}
|
||||
if (pg->graph == GR_SPLIT) {
|
||||
static const uint8_t fields[8] = {0, 2, 3, 1, 4, 5, 6, 7};
|
||||
uint32_t f = fields[pg->id[0] + slot];
|
||||
int32_t v = f == 1u ? (int32_t)split_cut(0) : f == 7u ? (int32_t)split_cut(1) : f == 4u || f == 5u ? (int8_t)split_cfg[f] : split_cfg[f];
|
||||
int32_t lo = f == 1u || f == 7u ? 1 : f == 4u || f == 5u ? -4 : 0;
|
||||
int32_t hi = f == 0u ? 1 : f == 1u ? 26 : f == 2u || f == 3u ? NTRK - 1 : f == 4u || f == 5u ? 4 : f == 6u ? 15 : 127;
|
||||
split_cfg[f] = (uint8_t)clamp(v + steps, lo, hi);
|
||||
ui.force = 1; return;
|
||||
}
|
||||
if (FIT_PAGE(pg) && (slot == 1u || slot == 2u)) {
|
||||
uint32_t v = TSEL->seq_fit, span = fit_span(TSEL);
|
||||
if (slot == 1u) span = (uint32_t)clamp((int32_t)span + steps, 1, 64);
|
||||
@@ -2880,7 +2889,7 @@ static void ui_input_frame(void)
|
||||
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_MSEQ || pg->graph == GR_PATS || BAR_PAGE(pg)) &&
|
||||
k == 0u)
|
||||
|| FIT_PAGE(pg) || pg->graph == GR_SONG || pg->graph == GR_DXSND || pg->graph == GR_FOCUS || pg->graph == GR_STAGE ||
|
||||
|| FIT_PAGE(pg) || pg->graph == GR_SPLIT || pg->graph == GR_SONG || pg->graph == GR_DXSND || pg->graph == GR_FOCUS || pg->graph == GR_STAGE ||
|
||||
pg->graph == GR_GCOMP || pg->graph == GR_LIVE) { /* (not an empty column) */
|
||||
ui.hot_col = (uint8_t)k;
|
||||
ui.hot_t = 40, ui.knob_ms = fm1_ms;
|
||||
@@ -2991,3 +3000,4 @@ timeout:
|
||||
#include "ui_dx.c" /* EDIT > SOUND / SOUND 2: the DRUM-X kit */
|
||||
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ static const ng_t CG_FX[] = {{"TRACK", "TRK"}, {"BUSES", "BUS"}, {"DELAY", "DLY"
|
||||
{"SLICER", "SLC"}, {"PUNCH", "PCH"}, {"MASTER", "MST"}};
|
||||
static const nv_t CE_GLO[] = {NV("MANO", 0, 0, 0), NV("RIELES", 0, 0, 0), NV("MIXER", 0, 1, 0), NV("SENDS", 0, 1, 0),
|
||||
NV("COMPS", 0, 2, 3), NV("COMPS 2", 0, 2, 3), NV("GLOBAL", 0, 3, 1),
|
||||
NV("SYSTEM", 0, 4, 2), NV("SYSTEM 2", 0, 4, 2)}; /* (V10.37) the performing pages first, the
|
||||
NV("SYSTEM", 0, 4, 2), NV("SYSTEM 2", 0, 4, 2), NV("KEY SPLIT", 0, 4, 2), NV("KEY SPLIT 2", 0, 4, 2)}; /* (V10.37) the performing pages first, the
|
||||
* settings (GLOBAL, SYSTEM) last */ /* (0.9.9-seq2f) the global lane; (p2) LIVE first
|
||||
* (ui_live.c) */
|
||||
static const ng_t CG_GLO[] = {{"LIVE", 0}, {"MIX", 0}, {"COMPS", "CMP"}, {"GLOBAL", 0}, {"SYSTEM", 0}};
|
||||
|
||||
@@ -8,7 +8,7 @@ static void midi_test_reset(void)
|
||||
{
|
||||
ui_power_on();
|
||||
memset(midi_ch, 0, sizeof midi_ch); memset(midi_sel_on, 0, sizeof midi_sel_on);
|
||||
memset(midi_owners, 0, sizeof midi_owners); memset(midi_bend_q8, 0, sizeof midi_bend_q8);
|
||||
memset(midi_owners, 0, sizeof midi_owners); memset(midi_refs, 0, sizeof midi_refs); memset(split_cfg, 0, sizeof split_cfg); memset(midi_bend_q8, 0, sizeof midi_bend_q8);
|
||||
memset(midi_bend_target, 0, sizeof midi_bend_target); memset(&midi_clock, 0, sizeof midi_clock);
|
||||
memset(&um, 0, sizeof um); memset(midi_in_source, 0, sizeof midi_in_source);
|
||||
mi_r = mi_w = 0; midi_in_overflow = 0; midi_beat_samples = 0;
|
||||
@@ -413,9 +413,51 @@ static int clock_steady_test(void)
|
||||
}
|
||||
return bad;
|
||||
}
|
||||
static int split_test(void)
|
||||
{
|
||||
int bad = 0;
|
||||
midi_test_reset();
|
||||
bad += check("SPLIT defaults OFF", !split_cfg[0]);
|
||||
split_cfg[0]=1; split_cfg[2]=0; split_cfg[3]=1; split_cfg[4]=(uint8_t)-1; split_cfg[5]=1;
|
||||
split_cfg[6]=9; split_cfg[7]=60;
|
||||
queued(0x99,48,100,1); queued(0x99,72,100,1);
|
||||
bad += check("MIDI split: channel 10 reaches independent tracks and octaves", mn_get(9,48)==1 && mn_get(9,72)==2 && midi_refs[0][36]==1 && midi_refs[1][84]==1);
|
||||
queued(0xB9,64,127,1); queued(0x89,48,0,1); queued(0x89,72,0,1);
|
||||
bad += check("MIDI split: sustain holds both zones", (mn_get(9,48)&8) && (mn_get(9,72)&8));
|
||||
split_cfg[0]=0; split_cfg[2]=3; split_cfg[3]=2; split_cfg[4]=2; split_cfg[5]=0;
|
||||
queued(0xB9,64,0,1);
|
||||
bad += check("MIDI split: original notes release after settings change and split OFF", !mn_get(9,48) && !mn_get(9,72) && !midi_refs[0][36] && !midi_refs[1][84]);
|
||||
split_cfg[0]=1; split_cfg[6]=0; split_cfg[2]=0; split_cfg[3]=1; split_cfg[4]=(uint8_t)-4; split_cfg[5]=4;
|
||||
queued(0x90,0,100,1); queued(0x90,12,100,1); queued(0x90,127,100,1);
|
||||
bad += check("MIDI split: clamped notes retain separate owners", midi_refs[0][0]==2 && midi_refs[1][127]==1);
|
||||
queued(0x80,0,0,1);
|
||||
bad += check("MIDI split: first duplicate release retains the other owner", midi_refs[0][0]==1 && midi_note_held(&trk[0],0));
|
||||
queued(0xB0,123,0,1);
|
||||
bad += check("MIDI split: CC123 releases both zones", !midi_refs[0][0] && !midi_refs[1][127]);
|
||||
queued(0x90,48,100,1); queued(0x90,72,100,1); queued(0xB0,120,0,1);
|
||||
bad += check("MIDI split: CC120 clears both zones and ownership", !midi_owners[0] && !midi_owners[1] && !midi_refs[0][0] && !midi_refs[1][120]);
|
||||
split_cfg[4]=0; split_cfg[5]=0;
|
||||
queued(0xE0,127,127,1);
|
||||
bad += check("MIDI split: bend reaches both configured zones before note-on", midi_bend_target[0]==512 && midi_bend_target[1]==512);
|
||||
midi_test_reset();
|
||||
split_cfg[0]=1;split_cfg[2]=0;split_cfg[3]=1;split_cfg[4]=(uint8_t)-1;split_cfg[5]=1;
|
||||
scn_on=1; /* split has priority over SCENE for normal keyboard notes */
|
||||
fm1_in.notes=(1u<<7)|(1u<<19); events_block(CTL);
|
||||
bad += check("physical split: independent tracks, octaves, SCENE priority", kb_trk[7]==0 && kb_trk[19]==1 && kb_note[7]==48 && kb_note[19]==84 && !scn_keys);
|
||||
split_cfg[2]=2; split_cfg[3]=3; split_cfg[4]=2; split_cfg[0]=0;
|
||||
fm1_in.notes=0;events_block(CTL);
|
||||
bad += check("physical split: changing split keeps original note-off ownership", !kb_on[7] && !kb_on[19]);
|
||||
scn_on=0;
|
||||
for(uint32_t i=0;i<NPAGES;i++) if(PAGES[i].graph==GR_SPLIT && !PAGES[i].id[0]) {ui.home=0;ui.page=i;break;}
|
||||
edit_param(0,1);edit_param(1,1);edit_param(2,1);edit_param(3,1);
|
||||
bad += check("split page knobs configure ON, tracks and physical cut", split_cfg[0]==1 && split_cfg[2]==3 && split_cfg[3]==4 && split_cut(0)==14);
|
||||
midi_test_reset();
|
||||
return bad;
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
int bad = controls_test() + sustain_test() + ownership_test() + clock_test(1) + clock_test(2) + clock_arp_and_boundaries() +
|
||||
int bad = split_test() + controls_test() + sustain_test() + ownership_test() + clock_test(1) + clock_test(2) + clock_arp_and_boundaries() +
|
||||
arp_ext_stop_test() + usb_burst_test() + route_test() + cc_map_test() + clock_steady_test();
|
||||
printf("%s\n", bad ? "MIDI CONTROL/CLOCK TEST FAILED" : "MIDI control/clock integration tests passed"); return bad != 0;
|
||||
}
|
||||
|
||||
@@ -504,6 +504,7 @@ static int songs_test(void)
|
||||
#include "song_save_cases.h"
|
||||
#include "fit_storage_cases.h"
|
||||
#include "voice_user_cases.h"
|
||||
#include "split_storage_cases.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -841,6 +842,7 @@ int main(void)
|
||||
bad += song_save_test();
|
||||
bad += fit_storage_test();
|
||||
bad += voice_user_test();
|
||||
bad += split_storage_test();
|
||||
printf("%s\n", bad ? "PERSISTENCE TEST FAILED" : "persistence test passed");
|
||||
return bad != 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
static int split_storage_test(void)
|
||||
{
|
||||
int bad=0; uint32_t sig;
|
||||
const uint8_t conf[8]={1,13,0,1,255,1,9,60};
|
||||
reset();memset(split_cfg,0,sizeof split_cfg);
|
||||
memcpy(split_cfg,conf,sizeof conf);
|
||||
bad += check("SPLIT: write actual NOR flash", !project_save(0));
|
||||
memset(split_cfg,0,sizeof split_cfg); project_load(0);transport_req=0;
|
||||
bad += check("SPLIT: project restores both keyboards and octaves", !memcmp(split_cfg,conf,sizeof conf));
|
||||
sig=autosave_sig();split_cfg[0]=0;
|
||||
bad += check("SPLIT: edits change autosave signature",sig!=autosave_sig());
|
||||
memset(split_cfg,0,sizeof split_cfg);project_capture(&proj_scratch);
|
||||
bad += check("SPLIT: legacy payload without KS decodes OFF",proj_pack(&proj_wire,&proj_scratch) && proj_import(&proj_scratch,&proj_wire,sizeof proj_wire) && !proj_scratch.split[0]);
|
||||
memcpy(split_cfg,conf,sizeof conf);project_capture(&proj_scratch);
|
||||
proj_scratch.split[2]=NTRK;
|
||||
bad += check("SPLIT: invalid destinations refuse serialization", !proj_pack(&proj_wire,&proj_scratch));
|
||||
memset(split_cfg,0,sizeof split_cfg);
|
||||
return bad;
|
||||
}
|
||||
Reference in new issue
Block a user