editor: SMK-37, the computer ports and the big CPUs' engines (SAMPLE, GRAIN, DRUM-X's samples)

- firmware (editor.c): INFO tags 'D' 1 board (SMK-37 Pro / Elite, a computer, the MPC Sample, the MPC plugin) and,
  FELUCCA_HOST_POWER only, 'H' 2 caps slots, both before 'Y'; on the big CPUs DESC / SET / TRACK_PARAM name the
  values beyond EDIT by the track's engine (hp_xdesc) and send enum names by value (DRUM-X's SLOT 112..). The FM-1
  binary is byte for byte as before (cmp build/felucca.bin, .fwsc), regress 0 golden changes.
- ports/core: the editor's SysEx (jiant_sysex, jiant_sysex_out, jiant_editor_poll, jiant_editor_host) through the
  firmware's own handler; felucca_hp.wasm leaves it out. JUCE standalone: SysEx in, replies out of its MIDI output
  (producesMidi only for the standalone; the plugins' buses unchanged); tests/sysex_check.cpp.
- web/editor.html: the device shown (tag, else port name), SMK-37 / MPC Sample port names, the structured layout for
  P_COUNT 123 (it showed a plain list) with a FILTER section, SAMPLE's TRIG REC, GRAIN's TRAVEL SOURCE PITCH and
  DRUM-X's SAMPLES pages on a device with 'H', SAMPLE sounds kept on such a device; the mock as a big CPU (?hp=1)
  or an SMK-37 (?board=1), its tables generated from and compared with descdump built with FELUCCA_HOST_POWER=1.
- tests: editor_test with FELUCCA_HOST_POWER, core_test, test_web devices section, web/editor_browser_test.mjs.
- docs: EDITOR_PROTOCOL.md "Device and big CPUs"; MPC Sample README: why its app does not answer the editor yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVqsRpEnNJfjWWrH3C4opq
This commit is contained in:
Claude committed 2026-11-21 17:15:04 +00:00
1 parent 98d298634b
commit ae9afc86e4
18 files changed
+633 -31

No files matched your search

+35 -1
View File
@@ -21,6 +21,19 @@ enum { ED_INFO = 1, ED_GET, ED_SET, ED_DUMP, ED_DESC, ED_STEP_GET, ED_STEP_SET,
ED_LYRIC, /* (JIANT 0.8.5) VOICE's lyric */
ED_MOTION = 64, ED_BACKUP_LIST, ED_BACKUP_GET, ED_BACKUP_PUT }; /* v6: song chain */
/* (SMK-37, ports/) INFO's 'D' tag: which device answers, so the editor can say so (an FM-1 sends no tag: its
* binary stays as it was). 1 SMK-37 Pro, 2 SMK-37 Elite, 3 a computer (a plugin, the standalone app), 4 the MPC Sample
* app, 5 the MPC plugin; the core's host names itself (ports/core jiant_editor_host). 'H' (big CPUs only): bit 0
* SAMPLE (engine 4), bit 1 GRAIN (engine 8), bit 2 DRUM-X's sample layer, bit 3 the values beyond EDIT's eight that
* DESC names by the track's engine (engines.c hp_xdesc) */
#if BOARD_SMK37
#define ED_BOARD (SMK_MODEL[7] == 'E' ? 2u : 1u)
#elif FELUCCA_HOST_POWER
static uint8_t ed_board = 3u;
#define ED_BOARD ed_board
#endif
#define ED_HP_CAPS 15u
static uint8_t ed_out[600];
static uint32_t ed_n;
@@ -228,7 +241,17 @@ static void ed_sync(void) /* main loop */
/* descriptor of parameter id of track t: the engine parameters of the engine it asked for
* (t->engine follows in the audio ISR, after a short fade) */
static const param_desc_t *ed_tdesc(const track_t *t, uint32_t id) { return param_desc_of(trk_eng(t), id); }
static const param_desc_t *ed_tdesc(const track_t *t, uint32_t id)
{
#if FELUCCA_HOST_POWER
/* (ports/) SAMPLE's and GRAIN's values beyond EDIT, DRUM-X's sample layer: in other engines' slots, named by the
* track's engine (engines.c hp_xdesc), so DESC, SET's clamp and TRACK_PARAM take them as the device's pages do */
const param_desc_t *x = id < P_COUNT ? hp_xdesc(t, id) : 0;
if (x)
return x;
#endif
return param_desc_of(trk_eng(t), id);
}
/* descriptor and value slot of (scope, id): scope 0 = the selected track, 1 = global */
static const param_desc_t *ed_desc(uint32_t scope, uint32_t id, int16_t **vp)
{
@@ -431,6 +454,13 @@ static void ed_handle(const uint8_t *f, uint32_t n) /* f: the bytes between F0
ed_b(0x56); ed_b(1); ed_b(FM6_NBANK); /* (JIANT 0.6.11, Felucca 1.4.1) FM6's voice bank: cmds 74..77, SLOT 9..40 */
ed_b(0x4A); ed_b(1); ed_b(1); /* (JIANT 0.6.62) 'J': this is JIANT (the web installer writes over it, web/index_pkg.html) */
ed_b(0x4F); ed_b(1); ed_b(LM_N); /* (0.8.5) 'O': the DRUM-X octaves, a step's lane modes 0..6 after its ratchet */
#if BOARD_SMK37 || FELUCCA_HOST_POWER
ed_b(0x44); ed_b(1); ed_b(ED_BOARD); /* 'D': the device answering (no tag: an FM-1); EDITOR_PROTOCOL.md "Device" */
#endif
#if FELUCCA_HOST_POWER
ed_b(0x48); ed_b(2); ed_b(ED_HP_CAPS); ed_b(SMP_NSLOT); /* 'H': a big CPU's engines (ports/): SAMPLE, GRAIN, DRUM-X's
* samples and their values beyond EDIT; the slots */
#endif
ed_b(0x59); ed_b(1); ed_b(LYR_LEN - 1u); /* (JIANT 0.8.5) 'Y': LYRIC (cmd 39), a track's lyric, at most 63 bytes */
break;
case ED_GET:
@@ -481,7 +511,11 @@ static void ed_handle(const uint8_t *f, uint32_t n) /* f: the bytes between F0
ed_str(d->unit, 8);
if (d->fmt == F_ENUM && d->names) /* up to 32 (0.7.0: the matrix DST has 30; was 24) */
for (i = 0; i <= (uint32_t)(d->max - d->min) && i < 32u; i++)
#if FELUCCA_HOST_POWER
ed_str(d->names[d->min + (int32_t)i], 8); /* (ports/) names by value, as param_format: DRUM-X's SLOT 112.. */
#else
ed_str(d->names[i], 8);
#endif
break;
case ED_STEP_GET:
case ED_STEP_SET: {
+27
View File
@@ -177,6 +177,33 @@ int main(void)
jiant_service();
}
{ /* the web editor's SysEx through the core (firmware/src/editor.c): INFO says the device and its big CPU ('D' 3,
* then the host's own number; 'H' 15 16), DESC names SAMPLE's TRIG on a SAMPLE track, another SysEx is not taken */
static const uint8_t info[] = {0xF0, 0x7D, 0x46, 0x4C, 1, 0xF7}, other[] = {0xF0, 0x7E, 0x7F, 0x06, 0x01, 0xF7};
static const uint8_t preset[] = {0xF0, 0x7D, 0x46, 0x4C, 8, 4, 0, 0xF7}; /* PRESET SAMPLE 0 */
static const uint8_t desc[] = {0xF0, 0x7D, 0x46, 0x4C, 5, 0, 83, 0xF7}; /* DESC track 83 (P_LN0) */
static uint8_t r[700];
size_t n = 0, m = 0;
int ok;
while (jiant_sysex_out(r, sizeof r))
;
ok = !jiant_sysex(info, sizeof info) && (n = jiant_sysex_out(r, sizeof r)) > 20 && r[0] == 0xF0 && r[4] == 1 &&
r[n - 1] == 0xF7 && r[n - 4] == 0x59 && r[n - 8] == 0x48 && r[n - 7] == 2 && r[n - 6] == 15 && r[n - 5] == 16 &&
r[n - 11] == 0x44 && r[n - 10] == 1 && r[n - 9] == 3 && !jiant_sysex_out(r, sizeof r);
CHECK(ok, "editor: INFO through jiant_sysex: 'D' 1 3 (a computer), 'H' 2 15 16, 'Y' last");
jiant_editor_host(4);
jiant_sysex(info, sizeof info);
n = jiant_sysex_out(r, sizeof r);
CHECK(n > 20 && r[n - 9] == 4, "editor: jiant_editor_host(4): 'D' 1 4 (the MPC Sample)");
jiant_editor_host(3);
jiant_sysex(preset, sizeof preset);
n = jiant_sysex_out(r, sizeof r);
jiant_sysex(desc, sizeof desc);
m = jiant_sysex_out(r, sizeof r);
CHECK(n == 8 && m > 16 && !strcmp((const char *)r + 14, "TRIG"), "editor: PRESET SAMPLE, then DESC 83: TRIG (SAMPLE's page)");
CHECK(jiant_sysex(other, sizeof other) == 1 && !jiant_sysex_out(r, sizeof r), "editor: another SysEx is not the editor's (1)");
CHECK(jiant_sysex_out(0, 0) == 0, "editor: nothing more queued");
}
printf(fails ? "core: %d FAILED\n" : "core: all passed\n", fails);
return fails != 0;
}
+81
View File
@@ -119,6 +119,87 @@ JC_API int jiant_boot(uint32_t seed, int skip_splash)
}
JC_API int jiant_booted(void) { return (int)web_booted; }
#ifndef JIANT_NO_EDITOR
/* ------------------------------------------------------------------ the web editor's SysEx (jiant_core.h) ---
* The firmware's own handler (firmware/src/editor.c, web/EDITOR_PROTOCOL.md), as the FM-1 runs it over USB: a request
* goes in whole (jiant_sysex), the replies and the live pushes come out whole (jiant_sysex_out). In place of usb.c's
* SysEx plumbing (FELUCCA_OTA: the firmware updates, never here): one frame in, a ring of messages out */
static uint8_t jc_ed_in[640];
static uint32_t jc_ed_in_n, jc_ed_ready, jc_ed_on;
static uint8_t jc_ed_out[16384]; /* F0..F7 messages, back to back */
static uint32_t jc_ed_w, jc_ed_r; /* (free-running) */
#if !FELUCCA_OTA
#define SXQ 64u /* (usb.c's outgoing ring, which editor.c ed_room asks: never full here) */
static uint32_t so_w, so_r;
#endif
static uint32_t ota_now_ms(void) { return fm1_ms; }
static int ota_wire_send(const uint8_t *p, uint32_t n)
{
uint32_t i;
if (n > sizeof jc_ed_out - (jc_ed_w - jc_ed_r))
return -1; /* (nobody reads: dropped whole) */
for (i = 0; i < n; i++)
jc_ed_out[(jc_ed_w + i) % sizeof jc_ed_out] = p[i];
jc_ed_w += n;
return 0;
}
static int ota_frame_get(const uint8_t **p, uint32_t *n)
{
if (!jc_ed_ready)
return 0;
*p = jc_ed_in;
*n = jc_ed_in_n;
return 1;
}
static void ota_frame_done(void) { jc_ed_ready = 0; }
#include "../../firmware/src/editor.c"
JC_API int jiant_sysex(const uint8_t *msg, size_t n)
{
if (!web_booted || !msg || n < 6u || msg[0] != 0xF0u || msg[n - 1u] != 0xF7u || msg[1] != ED_HDR0 || msg[2] != ED_HDR1 ||
msg[3] != ED_HDR2 || n - 2u > sizeof jc_ed_in)
return 1;
if (!jc_ed_on) { /* the editor's link is up (editor.c ed_sync: WATCH) */
jc_ed_on = 1;
usb.config = 1;
}
memcpy(jc_ed_in, msg + 1, n - 2u);
jc_ed_in_n = (uint32_t)(n - 2u);
jc_ed_ready = 1;
ed_service();
jc_ed_ready = 0;
return 0;
}
JC_API void jiant_editor_poll(void)
{
if (jc_ed_on && web_booted)
ed_service(); /* the live pushes (WATCH) */
}
JC_API size_t jiant_sysex_out(uint8_t *buf, size_t cap)
{
uint32_t n = 0;
if (jc_ed_r == jc_ed_w)
return 0;
while (jc_ed_r + n != jc_ed_w && jc_ed_out[(jc_ed_r + n) % sizeof jc_ed_out] != 0xF7u)
n++;
n++; /* (its F7) */
if (!buf || n > cap)
return n; /* the length it needs */
for (uint32_t i = 0; i < n; i++)
buf[i] = jc_ed_out[(jc_ed_r + i) % sizeof jc_ed_out];
jc_ed_r += n;
return n;
}
JC_API void jiant_editor_host(uint32_t board)
{
#if FELUCCA_HOST_POWER
ed_board = (uint8_t)(board ? board : 3u);
#else
(void)board;
#endif
}
#endif
JC_API void jiant_render(float *l, float *r, uint32_t n)
{
while (n) {
+11
View File
@@ -61,6 +61,17 @@ void jiant_render(float *l, float *r, uint32_t n);
/* a MIDI message as USB MIDI brings it: channel messages (0x80..0xEF) and the realtime clock (0xF8 clock, 0xFA
* start, 0xFB continue, 0xFC stop: they count only with jiant_clock_external(1)). 0 = the input ring was full. */
int jiant_midi(uint8_t status, uint8_t d1, uint8_t d2);
/* the web editor (web/editor.html, web/EDITOR_PROTOCOL.md) over the host's MIDI, as the FM-1 answers it over USB: the
* firmware's own handler. jiant_sysex takes one complete request (F0 7D 46 4C .. F7): 0 handled (its reply is queued),
* 1 not the editor's (another SysEx: the host may route it elsewhere). jiant_sysex_out gives the next queued message
* (a reply, or a live push while the editor WATCHes) into buf, its length; 0 none; more than cap: the length it needs,
* nothing taken. jiant_editor_poll (every ~10 ms, or after each jiant_render) lets the device push what changed on its
* panel. jiant_editor_host says which device answers (INFO's 'D' tag, the editor's label): 3 a computer (the default:
* a plugin, the standalone app), 4 the MPC Sample app, 5 the MPC plugin. All on the core's thread, as the rest */
int jiant_sysex(const uint8_t *msg, size_t n);
size_t jiant_sysex_out(uint8_t *buf, size_t cap);
void jiant_editor_poll(void);
void jiant_editor_host(uint32_t board);
/* 1: the sequencer follows the MIDI clock given to jiant_midi (GLO > CLOCK USB); 0: its own tempo */
void jiant_clock_external(int on);
void jiant_play(int on); /* PLAY / STOP, as the button does */
+5
View File
@@ -93,4 +93,9 @@ if(JIANT_CHECK AND NOT WIN32)
target_sources(editor_shot PRIVATE tests/editor_shot.cpp)
target_compile_definitions(editor_shot PRIVATE JUCE_MODAL_LOOPS_PERMITTED=1 JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0)
target_link_libraries(editor_shot PRIVATE JiantFM juce::juce_audio_utils PUBLIC juce::juce_recommended_config_flags)
# the web editor's SysEx through the standalone app's processor (tests/sysex_check.cpp)
juce_add_console_app(sysex_check PRODUCT_NAME "sysex_check")
target_sources(sysex_check PRIVATE tests/sysex_check.cpp)
target_compile_definitions(sysex_check PRIVATE JUCE_MODAL_LOOPS_PERMITTED=1 JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0)
target_link_libraries(sysex_check PRIVATE JiantFM juce::juce_audio_utils PUBLIC juce::juce_recommended_config_flags)
endif()
+4 -2
View File
@@ -15,6 +15,7 @@ SHIFT-click holds a button, and the computer keyboard as the emulator's (Z..' an
| --- | --- |
| Formats | VST3 (macOS, Windows, Linux), AU and AUv3 (macOS), AUv3 and the app (iOS / iPadOS), LV2 (Linux), standalone |
| MIDI | channels 1-4 play tracks 1-4 (GLO > MIDI IN ROUTE CH1-4); CCs as JIANT's MIDI map |
| Web editor | the standalone app answers [the web editor](../../web/editor.html) (its SysEx in, the replies out of the MIDI output chosen in its settings: connect the two through a virtual MIDI cable, e.g. IAC on macOS, loopMIDI on Windows); it shows as "JIANT FM app / plugin" with SAMPLE, GRAIN and DRUM-X's samples. The plugins take the editor's SysEx but have no MIDI output (their buses as before), so a DAW does not pass the replies back |
| Sync | **Host** (default): the sequencer follows the host's transport and tempo; **Internal**: its own tempo |
| Parameters | Volume (the MASTER knob), Sync |
| Saved | in the host's project: the live section, the songs, the user presets |
@@ -26,7 +27,7 @@ SHIFT-click holds a button, and the computer keyboard as the emulator's (Z..' an
```sh
ports/juce-plugin/build.sh # this computer's formats -> build/juce-plugin/JiantFM_artefacts/Release
ports/juce-plugin/build.sh -DJIANT_CHECK=ON # and the checks: tests/plugin_check.cpp, tests/editor_shot.cpp
ports/juce-plugin/build.sh -DJIANT_CHECK=ON # and the checks: tests/plugin_check.cpp, tests/editor_shot.cpp, tests/sysex_check.cpp
```
JUCE 9.0.5 is fetched (or `JUCE_DIR=<a checkout>`). macOS: `-G Xcode` (AUv3). iOS:
@@ -36,7 +37,8 @@ every platform on each push to `ports/`, and keeps the results as the run's arti
The check (`plugin_check <plugin>`) loads the built plugin as a host loads it (JUCE's VST3 / AU hosting): its
description, a chord at 44.1, 48 and 96 kHz in blocks of 32 to 1024 frames (it sounds, then it is silent after the
note-offs, nothing non-finite), the state out and back, a second instance silent, the editor made. macOS adds Apple's
`auval`.
`auval`. `sysex_check` makes the processor as the standalone app does and sends the web editor's INFO, PRESET and DESC
through processBlock: the replies come back in its MIDI (the device as a computer, its big CPU's engines).
## Installing
@@ -229,6 +229,8 @@ void JiantProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBu
const uint8_t* d = m.getRawData();
if (m.getRawDataSize() >= 1 && d[0] >= 0x80 && d[0] < 0xF0)
jiant_midi(d[0], m.getRawDataSize() > 1 ? d[1] : 0, m.getRawDataSize() > 2 ? d[2] : 0);
else if (m.isSysEx()) // the web editor (web/editor.html), as the FM-1 takes it
jiant_sysex(d, size_t(m.getRawDataSize()));
++it;
}
while (ck < nclk && clock_[size_t(ck)].offset <= at)
@@ -244,6 +246,21 @@ void JiantProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBu
at = next;
}
// the editor's replies and its live pushes: out of the standalone app's MIDI output; a plugin has none (dropped)
jiant_editor_poll();
bool out = producesMidi();
if (out)
midi.clear();
for (size_t n; (n = jiant_sysex_out(sysexOut_.data(), sysexOut_.size())) != 0;) {
if (n > sysexOut_.size()) { // (never: editor.c's replies are at most 600 bytes) skipped
std::vector<uint8_t> big(n);
jiant_sysex_out(big.data(), n);
continue;
}
if (out)
midi.addEvent(sysexOut_.data(), int(n), juce::jmax(0, frames - 1));
}
publish();
if (snapReq_.exchange(false, std::memory_order_acq_rel)) {
snapLen_ = jiant_state_save(snapshot_.data(), snapshot_.size());
+4 -1
View File
@@ -32,7 +32,9 @@ public:
bool hasEditor() const override { return true; }
const juce::String getName() const override { return "JIANT FM"; }
bool acceptsMidi() const override { return true; }
bool producesMidi() const override { return false; }
// the standalone app sends MIDI out (its MIDI output, chosen in its settings): the web editor's replies (jiant_sysex);
// the plugins none (their buses as before: JucePlugin_ProducesMidiOutput 0)
bool producesMidi() const override { return wrapperType == wrapperType_Standalone; }
double getTailLengthSeconds() const override { return 0.0; }
int getNumPrograms() override { return 1; }
int getCurrentProgram() override { return 0; }
@@ -71,6 +73,7 @@ private:
static constexpr uint32_t kQueue = 512;
std::array<Command, kQueue> queue_ {};
std::atomic<uint32_t> qWrite_ {0}, qRead_ {0};
std::array<uint8_t, 1024> sysexOut_ {}; // (the editor's replies, one at a time into the MidiBuffer)
// audio -> editor
std::atomic<uint32_t> screenSeq_ {0};
+62
View File
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant)
// The web editor through the standalone app (the plugin's own processor, made as the standalone wrapper makes it): its
// SysEx in the MIDI that reaches processBlock, the replies in the MIDI it gives back (what the app sends out of the
// MIDI output chosen in its settings). INFO: the device ('D' 3, a computer) and its big CPU ('H' 15 16, SAMPLE and
// GRAIN named); PRESET SAMPLE and DESC 83: SAMPLE's TRIG; a note in is not echoed out.
// sysex_check
#include "../Source/JiantProcessor.h"
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter();
static int fails;
static void check(const char* what, bool ok)
{
std::printf("juce sysex: %-70s %s\n", what, ok ? "ok" : "FAIL");
fails += !ok;
}
int main()
{
juce::ScopedJuceInitialiser_GUI gui;
juce::AudioProcessor::setTypeOfNextNewPlugin(juce::AudioProcessor::wrapperType_Standalone);
std::unique_ptr<juce::AudioProcessor> p(createPluginFilter());
juce::AudioProcessor::setTypeOfNextNewPlugin(juce::AudioProcessor::wrapperType_Undefined);
check("the standalone app has a MIDI output (producesMidi)", p->producesMidi());
p->setRateAndBufferSizeDetails(48000.0, 256);
p->prepareToPlay(48000.0, 256);
juce::AudioBuffer<float> buf(2, 256);
auto run = [&](std::initializer_list<uint8_t> sx, bool note = false) {
juce::MidiBuffer midi;
std::vector<uint8_t> v(sx);
if (v.size())
midi.addEvent(v.data(), int(v.size()), 0);
if (note)
midi.addEvent(juce::MidiMessage::noteOn(1, 60, uint8_t(100)), 1);
p->processBlock(buf, midi);
std::vector<std::vector<uint8_t>> out;
for (const auto m : midi)
out.emplace_back(m.data, m.data + m.numBytes);
return out;
};
run({});
auto info = run({0xF0, 0x7D, 0x46, 0x4C, 1, 0xF7});
bool ok = info.size() == 1;
if (ok) {
const auto& r = info[0];
size_t n = r.size();
std::string s(r.begin(), r.end());
ok = n > 40 && r[0] == 0xF0 && r[4] == 1 && r[n - 1] == 0xF7 && r[n - 4] == 0x59 && r[n - 8] == 0x48 &&
r[n - 6] == 15 && r[n - 5] == 16 && r[n - 11] == 0x44 && r[n - 9] == 3 &&
s.find("SAMPLE") != std::string::npos && s.find("GRAIN") != std::string::npos;
}
check("INFO in, its reply out: 'D' 3 (a computer), 'H' 15 16, SAMPLE and GRAIN", ok);
auto pr = run({0xF0, 0x7D, 0x46, 0x4C, 8, 4, 0, 0xF7});
auto d = run({0xF0, 0x7D, 0x46, 0x4C, 5, 0, 83, 0xF7});
check("PRESET SAMPLE, DESC 83: TRIG", pr.size() == 1 && pr[0].size() == 8 && d.size() == 1 && d[0].size() > 20 &&
std::string(d[0].begin() + 14, d[0].begin() + 18) == "TRIG");
auto nt = run({}, true);
check("a note in is not echoed out", nt.empty());
std::printf(fails ? "juce sysex: %d FAILED\n" : "juce sysex: all passed\n", fails);
return fails != 0;
}
+12
View File
@@ -153,6 +153,18 @@ the sum as ever, and a closed hat chokes the open one's sample as its synth. CHA
sequencer's, as for the synth.
## The web editor: not yet
The MPC Sample is a USB MIDI device to a computer (its USB-C gadget, `f_midi`, shown as "MPC Sample"), both ways, and
sample-base hands the app every packet from it, SysEx included (`App::midi`), and lets it send (`App::midi_output`).
But this app drops SysEx and sends nothing, so [the web editor](../../web/editor.html) gets no answer from it (the editor
says so in its MIDI ports' help). The firmware's side is ready: the core answers the editor (`jiant_sysex`,
`jiant_sysex_out`, `jiant_editor_host(4)` so it shows as "MPC Sample"; `ports/core/core_test.c`), and the JUCE standalone
app uses it. What the app still needs, untested without a unit: the requests from the MIDI thread to the audio thread
(where the core runs) through a lock-free byte ring, the replies back the same way and out to the port the request came
from; and a reply longer than sample-base's 256-byte `MidiPacket` (DUMP is about 400 bytes) sent as consecutive
packets, which needs checking that its output queue keeps a SysEx split that way in one piece.
## Release
```sh
+34 -2
View File
@@ -41,7 +41,7 @@ static void js_desc(const param_desc_t *d)
for (i = 0; i <= d->max - d->min; i++) {
if (i)
putchar(',');
js_str(d->names[i]);
js_str(d->names[FELUCCA_HOST_POWER ? d->min + i : i]); /* (ports/: as editor.c's DESC) */
}
putchar(']');
} else {
@@ -241,6 +241,38 @@ int main(void)
printf("]]");
}
}
printf("]}\n");
printf("]");
#if FELUCCA_HOST_POWER
/* (ports/, built with -DFELUCCA_HOST_POWER=1 into desc_hp.json) the big CPUs' pages beyond EDIT 1 / 2 (params.c
* PAGES from HP_PAGE0, ui.c page_visible): each with its engine, ids and the descriptors DESC sends for them on a
* track of that engine at its first preset (editor.c ed_tdesc: engines.c hp_xdesc) */
printf(",\n\"HP\":{\"caps\":%u,\"slots\":%u,\"pages\":[", 15u, (unsigned)SMP_NSLOT);
for (k = HP_PAGE0; k < NPAGES; k++) {
uint32_t en = k < HP_PAGE0 + 2u ? ENGI_SAMPLE : k < HP_PAGE0 + 5u ? ENGI_GRAIN : ENGI_DRUM;
track_t *t = &trk[0];
for (i = 0; i < P_COUNT; i++)
t->p[i] = param_desc_of(en, i)->def;
host_preset_values(t, en, 0, &ENGINES[en]->presets[0]);
hp_preset_x(t, ENGINES[en], 0);
t->engine = t->eng_req;
printf("%s\n {\"engine\":", k > HP_PAGE0 ? "," : "");
js_str(ENGINES[en]->name);
printf(",\"name\":");
js_str(PAGES[k].title);
printf(",\"ids\":[");
for (i = 0, e = 0; i < 4u; i++)
if (PAGES[k].id[i] != 0xFFu)
printf("%s%u", e++ ? "," : "", (unsigned)PAGES[k].id[i]);
printf("],\"descs\":[");
for (i = 0, e = 0; i < 4u; i++)
if (PAGES[k].id[i] != 0xFFu) {
printf("%s", e++ ? "," : "");
js_desc(hp_xdesc(t, PAGES[k].id[i]));
}
printf("]}");
}
printf("]}");
#endif
printf("}\n");
return 0;
}
+53 -3
View File
@@ -141,12 +141,14 @@ static int motion_locks(void)
return bad;
}
/* (ports/) a big CPU's build answers with two more tags before 'Y' ('D' 1 board, 'H' 2 caps slots): host_power below */
#define ED_TEST_HX (FELUCCA_HOST_POWER ? 7u : 0u)
static int preferences(void)
{
int bad = 0;
uint8_t a[4] = {0, 7, 0, 0};
reset();
uint32_t n = request(ED_INFO, a, 0), n0 = n - 6u; /* (0.8.5: the 'O' tag, the DRUM lane modes, then 'Y' last, LYRIC) */
uint32_t n = request(ED_INFO, a, 0), n0 = n - 6u - ED_TEST_HX; /* (0.8.5: the 'O' tag, the DRUM lane modes, then 'Y' last, LYRIC) */
bad += check("INFO explicitly tags display capabilities after SONG without changing command 33",
ED_SONG == 33 && ED_UI_STATE == 34 && ED_FAV_SET == 38 &&
host_wire[n0 - 37] == CHAIN_ROWS && host_wire[n0 - 36] == 0x55 &&
@@ -163,7 +165,7 @@ static int preferences(void)
host_wire[n0 - 10] == 0x4C && host_wire[n0 - 9] == 1 && host_wire[n0 - 8] == 1 && /* 1.1 parameter locks */
host_wire[n0 - 7] == 0x56 && host_wire[n0 - 6] == 1 && host_wire[n0 - 5] == 32 && /* (0.6.11) FM6 voice bank */
host_wire[n0 - 4] == 0x4A && host_wire[n0 - 3] == 1 && host_wire[n0 - 2] == 1 && /* (0.6.62) JIANT: the installer */
host_wire[n - 7] == 0x4F && host_wire[n - 6] == 1 && host_wire[n - 5] == LM_N && /* (0.8.5) DRUM lane modes */
host_wire[n0 - 1] == 0x4F && host_wire[n0] == 1 && host_wire[n0 + 1] == LM_N && /* (0.8.5) DRUM lane modes */
host_wire[n - 4] == 0x59 && host_wire[n - 3] == 1 && host_wire[n - 2] == LYR_LEN - 1u); /* (0.8.5) LYRIC, 63 */
request(ED_UI_SET, a, 2);
bad += check("UI_SET updates the actual palette and reports RAM-only saving",
@@ -983,6 +985,54 @@ static int menu_protocol(void)
return bad;
}
/* (ports/) the big CPUs' build (FELUCCA_HOST_POWER: run_tests.sh builds this file so too): INFO's 'D' (3, a
* computer, until the host names itself) and 'H' (caps 15, 16 slots) just before 'Y'; the FM-1's INFO has neither (its
* binary is unchanged). DESC names the values beyond EDIT by the selected track's engine: SAMPLE's TRIG page in the DRUM
* lane levels' ids, GRAIN's QUANT / DAMP, DRUM-X's sample layer (SMORPH .. SLEVEL) */
static int host_power(void)
{
static uint8_t a[8];
uint32_t n, i, found = 0;
int bad = 0;
reset();
n = request(ED_INFO, a, 0);
for (i = 5; i + 3 < n; i++)
if (host_wire[i] == 0x44 && host_wire[i + 1] == 1 && host_wire[i + 3] == 0x48)
found = i;
#if FELUCCA_HOST_POWER
bad += check("(ports/) INFO: 'D' 1 3 (a computer), 'H' 2 15 16 (SAMPLE GRAIN DRUM-X samples, 16 slots), then 'Y'",
found && found == n - 11u && host_wire[found + 2] == 3 && host_wire[found + 4] == 2 && host_wire[found + 5] == 15 &&
host_wire[found + 6] == SMP_NSLOT && host_wire[n - 4] == 0x59);
{
static const struct { uint32_t eng, id; const char *label; } want[] = {
{ENGI_SAMPLE, P_E0, "SLOT"}, {ENGI_SAMPLE, P_LN0, "TRIG"}, {ENGI_SAMPLE, P_LN4, "REC"},
{ENGI_GRAIN, P_E0, "SLOT"}, {ENGI_GRAIN, P_LN0, "TRAVEL"}, {ENGI_GRAIN, P_GXQUANT, "QUANT"},
{ENGI_GRAIN, P_GXDAMP, "DAMP"}, {ENGI_DRUM, P_DXSMORPH, "SMORPH"}, {ENGI_DRUM, P_DXSBLEND, "BLEND"},
{ENGI_DRUM, P_DXSSLOT, "SLOT"}, {ENGI_DRUM, P_DXSMAP, "MAP"}, {ENGI_DRUM, P_DXSLEVEL, "SLEVEL"},
};
uint32_t ok = 1;
for (i = 0; i < sizeof want / sizeof want[0]; i++) {
a[0] = 1; a[1] = G_ENGSEL; a[2] = (8192 + want[i].eng) & 127; a[3] = (8192 + want[i].eng) >> 7;
request(ED_SET, a, 4);
a[0] = 0; a[1] = (uint8_t)want[i].id;
request(ED_DESC, a, 2);
if (ed_eng(TSEL) != want[i].eng || strcmp((const char *)host_wire + 5 + 3 + 6, want[i].label)) {
printf(" DESC %u of engine %u: %s\n", (unsigned)want[i].id, (unsigned)want[i].eng, (const char *)host_wire + 5 + 3 + 6);
ok = 0;
}
}
bad += check("(ports/) DESC by the track's engine: SAMPLE TRIG REC, GRAIN TRAVEL QUANT DAMP, DRUM-X SMORPH..SLEVEL", ok);
a[0] = 0; a[1] = P_DXSSLOT; /* (the track is DRUM's now) SLOT 112..127: its names by value */
request(ED_DESC, a, 2);
bad += check("(ports/) DESC of DRUM-X's SLOT (112..127) names 1 .. 16 (by value, as the device shows them)",
!strcmp((const char *)host_wire + 20, "1") && !strcmp((const char *)host_wire + 22, "2"));
}
#else
bad += check("FM-1: INFO has no 'D' / 'H' tag (its bytes as before)", !found);
#endif
return bad;
}
/* DRUM is DRUM-X (JIANT 0.1: Felucca's kits retired): DESC of E0 names MRPH (KIT's slot), E4 NOIS (SNAP's), E6 unused;
* a project of Felucca with KIT values loads them as MRPH */
static int drum_kit_retired(void)
@@ -1022,7 +1072,7 @@ int main(void)
{
int bad = preferences() + motion_locks() + framing() + uart_recovery() + steps() + stop_failures() + song_protocol() + malformed_saves() +
fm6_patches() + user_preset_roundtrip() + live_sync() + usb_burst() + menu_protocol() + drum_kit_retired() +
lyric_protocol();
lyric_protocol() + host_power();
printf("%s\n", bad ? "EDITOR TEST FAILED" : "editor test passed");
return bad != 0;
}
+9
View File
@@ -292,6 +292,9 @@ if [ -f build/gen/felucca_tables.h ]; then
$CC -w -Ibuild/gen -Ifirmware/src -o "$OUT/editor_test" tests/editor_test.c -lm
run "editor: real C protocol, malformed transfers, queue recovery, MENU settings (writes build/host/menu.json)" \
env MENU_JSON="$OUT/menu.json" "$OUT/editor_test"
$CC -w -DFELUCCA_HOST_POWER=1 -Ibuild/gen -Ifirmware/src -o "$OUT/editor_test_hp" tests/editor_test.c -lm
run "editor: the same with FELUCCA_HOST_POWER=1 (ports/): INFO's 'D' and 'H' tags, DESC of SAMPLE / GRAIN / DRUM-X's samples by engine" \
"$OUT/editor_test_hp"
$CC -w -Ibuild/gen -Ifirmware/src -o "$OUT/robust_test" tests/robust_test.c -lm
run "robustness: engine numbers, retained old projects, preset patterns, malformed requests" \
"$OUT/robust_test"
@@ -323,6 +326,8 @@ if [ -f build/gen/felucca_tables.h ]; then
$CC -w -Ibuild/gen -Ifirmware/src -o "$OUT/descdump" tests/descdump.c -lm
echo "== parameter and engine tables as JSON (for the editor mock test)"
"$OUT/descdump" > "$OUT/desc.json" || fail=1
$CC -w -DFELUCCA_HOST_POWER=1 -Ibuild/gen -Ifirmware/src -o "$OUT/descdump_hp" tests/descdump.c -lm
"$OUT/descdump_hp" > "$OUT/desc_hp.json" || fail=1 # (ports/: the big CPUs' tables, the editor's mock with hostPower)
$CC -O2 -w -Ibuild/gen -Ifirmware/src -o "$OUT/drumx_test" tests/drumx_test.c -lm
mkdir -p build/drumx_demo
run "DRUM-X: every lane sounds and ends, MORPH, PITCH, NOIS, hat choke, group mutes, demos" "$OUT/drumx_test" build/drumx_demo
@@ -435,6 +440,10 @@ run "navigation map (docs/navigation-map*.svg) matches the firmware's chains" py
if command -v node >/dev/null 2>&1; then
run "web pages: editor protocol, package builder, update protocol" node web/test_web.mjs
if node -e "require('playwright')" >/dev/null 2>&1; then
run "editor in Chromium: FM-1, SMK-37 and a big CPU (SAMPLE, GRAIN, DRUM-X's samples) on its mock" \
node web/editor_browser_test.mjs
fi
run "web backup: capture, validation before writes, restore order" node web/test_backup.mjs
run "web manual: every control has an entry, the search, the screens, the map is the firmware's (web/manual)" node web/test_manual.mjs
else
+32 -1
View File
@@ -349,7 +349,7 @@ at 1..3 and hides 6 5 8: what it sets still plays the right kit, and the device
| cmd | Request args | Reply args |
| --- | --- | --- |
| 1 INFO | — | version string, NENGINES, P_COUNT, G_COUNT, NSTEP, P_E0, then NENGINES engine-name strings, then (v3) NTRK (6 since JIANT 0.6, 4 before), then (v6) CHAIN_ROWS (16), then the tagged blocks `55 01 uiCaps`, `4D 01 64 01`, `42 01 3`, `46 01 nfactory nbank`, `53 01 3`, (1.0.3) `50 01 3` and (1.0.4) `4E 01 count` (MENU settings; 12, 1.1: 15, 1.2: 17, 1.1.5: 18) and (1.0.5) `52 01 4` (ratchet) and (1.1) `4C 01 1` (parameter locks) and (JIANT 0.6.11) `56 01 32` (FM6's voice bank) and (JIANT 0.6.62) `4A 01 1` (JIANT) and (JIANT 0.8.5) `4F 01 7` (DRUM lane modes) (below), (JIANT 0.8.5) `59 01 63` (LYRIC, always the last tag) and, just before it, (1.0) `43 02 major minor`: the protocol's version (see "Stability contract (1.0)"); older firmware ends earlier |
| 1 INFO | — | version string, NENGINES, P_COUNT, G_COUNT, NSTEP, P_E0, then NENGINES engine-name strings, then (v3) NTRK (6 since JIANT 0.6, 4 before), then (v6) CHAIN_ROWS (16), then the tagged blocks `55 01 uiCaps`, `4D 01 64 01`, `42 01 3`, `46 01 nfactory nbank`, `53 01 3`, (1.0.3) `50 01 3` and (1.0.4) `4E 01 count` (MENU settings; 12, 1.1: 15, 1.2: 17, 1.1.5: 18) and (1.0.5) `52 01 4` (ratchet) and (1.1) `4C 01 1` (parameter locks) and (JIANT 0.6.11) `56 01 32` (FM6's voice bank) and (JIANT 0.6.62) `4A 01 1` (JIANT) and (JIANT 0.8.5) `4F 01 7` (DRUM lane modes) (below), on an SMK-37 or a computer `44 01 board` and on a computer `48 02 caps slots` (see "Device and big CPUs"), (JIANT 0.8.5) `59 01 63` (LYRIC, always the last tag) and, just before it, (1.0) `43 02 major minor`: the protocol's version (see "Stability contract (1.0)"); older firmware ends earlier |
| 2 GET | scope, id | scope, id, v14 |
| 3 SET | scope, id, v14 | scope, id, v14 (the value after clamping). Setting global `G_ENGSEL` (id from DESC label "ENG") changes the engine: its defaults, then its first preset (as on the device) |
| 4 DUMP | — | engine, preset, then P_COUNT × v14 (the selected track), then G_COUNT × v14 (globals) |
@@ -1140,3 +1140,34 @@ through the device's dictionary (~2100 words; a word it lacks by rough letter ru
into plain ones (stress is not marked in singing) and ñ into "ny" before sending. A set takes effect at once (RAM: no
flash write, also while playing): the track's lyric starts over at its next note. Saved with the project (FUNC's
`L` `Y` block per track that has one; a project without it loads with none) and in the backup's runtime object (id 0).
## Device and big CPUs (INFO `44`, `48`)
JIANT runs on more than the FM-1, and the editor says which device answers and offers what that one has. Both tags
come just before `59` (LYRIC, still the last). An FM-1 sends neither: its INFO, and its binary, are as before.
- `44 01 board` ('D'): 1 SMK-37 Pro, 2 SMK-37 Elite (the SMK build, `BOARD_SMK37`), 3 a computer (a plugin, the
standalone app: `ports/core`, its default), 4 the MPC Sample app, 5 the MPC plugin (the core's host says which:
`jiant_editor_host`). No tag: an FM-1, or SMK-37 firmware from before the tag (the editor then goes by the port's
name, "JIANT SMK-37").
- `48 02 caps slots` ('H', `FELUCCA_HOST_POWER` builds only): caps bit 0 SAMPLE is engine 4, bit 1 GRAIN is engine 8,
bit 2 DRUM-X has its sample layer, bit 3 the values below; `slots` the sample slots (16).
On such a device the selected track's engine names some parameter ids beyond EDIT's eight, which hold other engines'
values elsewhere (`engines.c` `hp_xdesc`): `DESC`, `SET`'s clamp and `TRACK_PARAM` take them as the device's pages do.
Read their `DESC` again after the engine changes (and after SAMPLE's TRIG: AMOUNT's name follows it).
| Engine | Page | ids (P_COUNT 123) |
| --- | --- | --- |
| SAMPLE | TRIG: TRIG AMOUNT RATE SLICES | 83 84 85 86 (P_LN0..3) |
| SAMPLE | REC: REC WOW STOP DECAY | 87 88 89 90 (P_LN4..7) |
| GRAIN | TRAVEL: TRAVEL REGION FEEDBK SHIMMR | 83 84 85 86 |
| GRAIN | SOURCE: WINDOW WIDTH SOURCE REC | 87 88 89 90 |
| GRAIN | PITCH: QUANT DAMP | 72 78 |
| DRUM | SAMPLES: SMORPH BLEND SLOT MAP | 61 72 80 78 |
| DRUM | SAMPLES 2: SLEVEL | 75 |
DRUM-X's SLOT (112..127, "1".."16") and MAP (125..127, SLOTS LANES KEYS) are lists that do not start at 0: on these
devices `DESC` sends a list's names by value (the name of min first), as the device shows them. The parameter lists
are in `ports/mpc-sample/README.md`. On a computer the core answers the editor through `jiant_sysex` /
`jiant_sysex_out` (`ports/core/jiant_core.h`); the JUCE standalone app sends the replies out of its MIDI output.
+99 -20
View File
@@ -465,6 +465,18 @@ const parse = {
/* (JIANT 0.8.5) 'Y' 1 n, the last tag: LYRIC (cmd 39), a track's lyric of at most n bytes; 0 = none */
const ty = trailer.length - 3;
o.lyric = ty >= 0 && trailer[ty] === 0x59 && trailer[ty + 1] === 1 ? trailer[ty + 2] : 0;
/* (SMK-37, ports/) just before 'Y': 'D' 1 board (none: an FM-1), 'H' 2 caps slots (a big CPU's engines) */
o.board = 0; o.hostPower = null;
if (o.lyric) {
let k = ty;
if (trailer[k - 4] === 0x48 && trailer[k - 3] === 2) {
const c = trailer[k - 2];
o.hostPower = { caps: c, slots: trailer[k - 1], sample: !!(c & 1), grain: !!(c & 2), drumSamples: !!(c & 4), extra: !!(c & 8) };
k -= 4;
}
if (trailer[k - 3] === 0x44 && trailer[k - 2] === 1) o.board = trailer[k - 1];
}
return o;
},
[CMD.LYRIC](a) { const r = new Reader(a); return { track: r.b(), rc: r.b(), text: r.s() }; },
@@ -782,9 +794,19 @@ class Link {
}
}
/* (SMK-37, ports/) the device that answers: INFO's 'D' tag, else (an FM-1, or SMK-37 firmware from before the tag)
the port's name */
const BOARDS = ["FM-1", "SMK-37 Pro", "SMK-37 Elite", "JIANT FM app / plugin", "MPC Sample", "MPC plugin"];
function deviceName(info, port) {
if (info && info.board && BOARDS[info.board]) return BOARDS[info.board];
const n = String(port || "");
if (/smk[ _-]*37/i.test(n)) return /elite/i.test(n) ? "SMK-37 Elite" : "SMK-37";
if (/mpc/i.test(n)) return "MPC";
return "FM-1";
}
/* the names an FM-1 shows under (the installer's fm1ota.js PORT_RE: JIANT, Felucca, Skiff, the stock firmware's, the
USB composite's, and the generic names Windows gives a USB MIDI device whose name it cached or never read) */
const editorPort = (p) => /felucca|jiant|skiff|fm[ _-]*1|m[ _-]*vave|cuvave|composite|sinco|usb[ _-]*midi|usb audio/i.test(p.name || "") && p.state !== "disconnected";
const editorPort = (p) => /felucca|jiant|skiff|fm[ _-]*1|smk[ _-]*37|mpc sample|m[ _-]*vave|cuvave|composite|sinco|usb[ _-]*midi|usb audio/i.test(p.name || "") && p.state !== "disconnected"; /* (SMK-37: "JIANT SMK-37"; the MPC Sample's gadget: "MPC Sample") */
/* (2026-10-30) never asked: software ports and other makers' synths a user is likely to have plugged in */
const notEditorPort = (p) => /wavetable|iac driver|midi through|loopmidi|loopbe|virtual|rtpmidi|network|bluetooth/i.test(p.name || "");
let seenPorts = "";
@@ -1549,6 +1571,7 @@ function fromPerc(pt, engines, pe0) {
if (!(name === "SAMPLE" || (pt.engine === 4 && (!name || name === "-"))) || !Array.isArray(p) || drum < 0) return null; /* (4: "-" once retired) */
const e0 = pe0 ?? p.length - 8;
if (p[e0] !== PERC_SET) return null;
if (names && names[4] === "SAMPLE") return null; /* ((ports/) a big CPU plays SAMPLE: its sounds stay, core.h drum_from_perc) */
const q = p.slice();
DRUM_KIT_E.forEach((v, i) => { q[e0 + i] = v; });
return { ...pt, engine: drum, engineName: "DRUM", p: q, params: undefined };
@@ -1768,6 +1791,27 @@ function makeMockDevice(opt = {}) {
P("TRANCE GATE", [3, 64, 0, 1, 127, 0, 0, 0], [0, 40, 0, 10], 1, 0), P("RING IN", [0, 64, 0, 1, 127, 90, 0, 0], [0, 64, 127, 30], 1, 0),
P("CRUSH IN", [2, 72, 0, 0, 127, 0, 90, 60], [0, 64, 127, 20], 1, 0)] },
];
/* (ports/) a big CPU's device (opt.hostPower: the MPC Sample, the plugins, the app; INFO 'D' and 'H'): SAMPLE in 4 and
GRAIN in 8 (engines.c with FELUCCA_HOST_POWER), and the values their pages and DRUM-X's sample layer keep in other
engines' slots, named by the track's engine (engines.c hp_xdesc) */
const HP_ENG = {
/* (ports/, generated from tests/descdump.c built with FELUCCA_HOST_POWER=1: test_web.mjs compares) */
4: { name: "SAMPLE", titles: ["SAMPLE", "WARP"], edit: [E("SLOT", ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"], 0), D("START", F.PCT, 0, 127, 0), D("LENGTH", F.PCT, 0, 127, 127), E("MODE", ["ONE", "GATE", "LOOP", "PING", "REV", "SLICE", "SCRUB", "TAPE"], 0), D("TUNE", F.SEMI, -24, 24, 0), D("FEEDBK", F.PCT, 0, 127, 0), D("TONE", F.PCT, 0, 127, 64), D("DSTROY", F.PCT, 0, 127, 0)],
presets: [P("ONE SHOT", [0, 0, 127, 0, 0, 0, 64, 0], [0, 100, 127, 40], 0, 0), P("GATE", [0, 0, 127, 1, 0, 0, 64, 0], [0, 100, 127, 30], 0, 0), P("LOOP", [0, 0, 127, 2, 0, 0, 64, 0], [4, 100, 127, 60], 0, 0), P("PING PONG", [0, 20, 60, 3, 0, 0, 64, 0], [10, 100, 127, 70], 0, 0), P("REVERSE", [0, 0, 127, 4, 0, 0, 64, 0], [0, 100, 127, 40], 0, 0), P("SLICE 16", [0, 0, 127, 5, 0, 0, 64, 0], [0, 100, 127, 20], 0, 11), P("SLICE 8", [0, 0, 127, 5, 0, 0, 64, 0], [0, 100, 127, 20], 0, 10), P("RANDOM SLC", [0, 0, 127, 5, 0, 0, 64, 0], [0, 100, 127, 20], 0, 11), P("VEL SLICE", [0, 0, 127, 5, 0, 0, 64, 0], [0, 100, 127, 20], 0, 9), P("SCRUB", [0, 0, 127, 6, 0, 0, 64, 0], [10, 100, 127, 50], 0, 0), P("TAPE STOP", [0, 0, 127, 7, 0, 0, 64, 0], [0, 100, 127, 100], 0, 0), P("RATCHET", [0, 0, 127, 0, 0, 0, 64, 0], [0, 100, 127, 30], 0, 12), P("CHOKE", [0, 0, 127, 0, 0, 0, 64, 0], [0, 100, 127, 20], 0, 12), P("ROUND ROBIN", [0, 0, 127, 0, 0, 0, 64, 0], [0, 100, 127, 30], 0, 12), P("LEGATO", [0, 0, 127, 1, 0, 0, 64, 0], [4, 100, 127, 40], 0, 4), P("CHANCE", [0, 0, 127, 0, 0, 0, 64, 0], [0, 100, 127, 30], 0, 12), P("FEEDBACK", [0, 0, 127, 0, 0, 90, 60, 0], [0, 100, 127, 50], 0, 3), P("METAL COMB", [0, 0, 127, 1, 0, 118, 110, 0], [0, 100, 127, 60], 0, 7), P("DESTROY", [0, 0, 127, 0, 0, 40, 50, 70], [0, 100, 127, 40], 0, 0), P("RESAMPLE", [0, 0, 127, 2, 0, 0, 64, 0], [0, 100, 127, 40], 0, 0)] },
8: { name: "GRAIN", titles: ["GRAIN", "CLOUD"], edit: [E("SLOT", ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"], 0), D("POS", F.PCT, 0, 127, 0), D("SCAN", F.BIPCT, -64, 63, 0), D("SIZE", F.PCT, 0, 127, 64), D("DENSE", F.PCT, 0, 127, 70), D("SPRAY", F.PCT, 0, 127, 10), D("SPREAD", F.PCT, 0, 127, 0), D("REVRS", F.PCT, 0, 127, 0)],
presets: [P("CLOUD", [0, 0, 8, 70, 70, 20, 0, 0], [40, 100, 127, 70], 0, 5), P("FROZEN CLOUD", [0, 40, 0, 80, 85, 10, 2, 0], [60, 100, 127, 90], 0, 5), P("SCAN", [0, 0, 20, 60, 70, 5, 0, 0], [20, 100, 127, 60], 0, 5), P("STRETCH 0.5X", [0, 0, -36, 75, 80, 4, 0, 0], [10, 100, 127, 60], 0, 5), P("STRETCH 2X", [0, 0, 21, 65, 80, 4, 0, 0], [10, 100, 127, 60], 0, 5), P("SHIMMER", [0, 30, 4, 90, 80, 30, 0, 0], [80, 100, 127, 110], 0, 5), P("SPRAY", [0, 20, 0, 40, 100, 90, 30, 30], [20, 100, 127, 60], 0, 5), P("OCTAVES", [0, 30, 4, 70, 80, 20, 60, 0], [30, 100, 127, 80], 0, 5), P("REVERSE", [0, 0, 10, 80, 60, 10, 0, 127], [20, 100, 127, 60], 0, 5), P("GLITCH", [0, 0, 40, 20, 90, 40, 20, 40], [0, 100, 127, 30], 0, 3), P("KEY POSITION", [0, 0, 0, 55, 70, 4, 0, 0], [10, 100, 127, 50], 0, 6), P("LIVE DELAY", [0, 30, 0, 60, 60, 20, 0, 0], [10, 100, 127, 80], 0, 0), P("LIVE FREEZE", [0, 10, 0, 85, 90, 15, 0, 0], [40, 100, 127, 100], 0, 0), P("FEEDBACK", [0, 10, 6, 70, 75, 20, 4, 10], [30, 100, 127, 90], 0, 5)] },
};
const HP_PAGES = [
{ engine: "SAMPLE", name: "TRIG", ids: [83, 84, 85, 86], descs: [E("TRIG", ["NORM", "CHOKE", "RATCH", "RAND", "ROUND", "VEL", "LEGAT", "CHNCE"], 0), D("-", F.PCT, 0, 127, 64), E("RATE", ["1/4", "1/8", "1/8T", "1/16", "16T", "1/32"], 3), D("SLICES", F.INT, 2, 64, 16)] },
{ engine: "SAMPLE", name: "REC", ids: [87, 88, 89, 90], descs: [E("REC", ["OFF", "IN 1", "IN 2", "IN 4", "IN 8", "IN H", "MST 1", "MST 2", "MST 4", "MST 8", "MST H", "T1 1", "T1 2", "T1 4", "T1 8", "T1 H", "T2 1", "T2 2", "T2 4", "T2 8", "T2 H", "T3 1", "T3 2", "T3 4", "T3 8", "T3 H", "T4 1", "T4 2", "T4 4", "T4 8", "T4 H", "T5 1", "T5 2", "T5 4", "T5 8", "T5 H", "T6 1", "T6 2", "T6 4", "T6 8", "T6 H"], 0), D("WOW", F.PCT, 0, 127, 40), D("STOP", F.PCT, 0, 127, 64), D("DECAY", F.PCT, 0, 127, 64)] },
{ engine: "GRAIN", name: "TRAVEL", ids: [83, 84, 85, 86], descs: [E("TRAVEL", ["FWD", "REV", "PING", "RAND", "STRCH", "FREEZ", "KEY"], 0), D("REGION", F.PCT, 0, 127, 127), D("FEEDBK", F.PCT, 0, 127, 0), E("SHIMMR", ["OFF", "+OCT", "+5TH", "-OCT", "+2OCT"], 0)] },
{ engine: "GRAIN", name: "SOURCE", ids: [87, 88, 89, 90], descs: [E("WINDOW", ["HANN", "TRI", "FLAT", "PERC", "SWELL"], 0), D("WIDTH", F.PCT, 0, 127, 64), E("SOURCE", ["SLOT", "IN", "MST"], 0), E("REC", ["OFF", "IN 1", "IN 2", "IN 4", "IN 8", "IN H", "MST 1", "MST 2", "MST 4", "MST 8", "MST H", "T1 1", "T1 2", "T1 4", "T1 8", "T1 H", "T2 1", "T2 2", "T2 4", "T2 8", "T2 H", "T3 1", "T3 2", "T3 4", "T3 8", "T3 H", "T4 1", "T4 2", "T4 4", "T4 8", "T4 H", "T5 1", "T5 2", "T5 4", "T5 8", "T5 H", "T6 1", "T6 2", "T6 4", "T6 8", "T6 H"], 0)] },
{ engine: "GRAIN", name: "PITCH", ids: [72, 78], descs: [E("QUANT", ["FREE", "OCT", "5TH"], 0), D("DAMP", F.PCT, 0, 127, 127)] },
{ engine: "DRUM", name: "SAMPLES", ids: [61, 72, 80, 78], descs: [D("SMORPH", F.PCT, 0, 127, 0), E("BLEND", ["XFADE", "S>B", "B>S", "FOLW", "RING"], 0), D("SLOT", F.ENUM, 112, 127, 112, ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"]), D("MAP", F.ENUM, 125, 127, 125, ["SLOTS", "LANES", "KEYS"])] },
{ engine: "DRUM", name: "SAMPLES 2", ids: [75], descs: [D("SLEVEL", F.PCT, 0, 127, 127)] },
];
const HP_AMT = ["-", "-", "COUNT", "RANGE", "SLOTS", "RANGE", "-", "CHANCE"]; /* SAMPLE's AMOUNT by TRIG (eng_sample.c SMP_AMT) */
if (opt.hostPower) { ENG[4] = HP_ENG[4]; ENG[8] = HP_ENG[8]; }
const FM6_E = ENG.findIndex((e) => e.name === "FM6"), FM6_OWN = FM6.FACTORY_PK.length, DRUM_E = ENG.findIndex((e) => e.name === "DRUM");
/* factory PATTERNS[] (engines.c; the device loads them from SEQ > PATTERNS, presets only suggest one): absolute
notes, 0 rest; flags 1 accent, 2 slide, 4 tie (holds the previous note) */
@@ -1821,7 +1865,13 @@ function makeMockDevice(opt = {}) {
Object.defineProperty(st, k, { enumerable: false, get: () => st.tracks[st.sel][k], set: (v) => { st.tracks[st.sel][k] = v; } });
}
const watchMs = opt.watchMs || 3000;
const desc = (scope, id) => (scope === 0 && id < P_COUNT ? (id >= P_E0 ? ENG[st.engine].edit[id - P_E0] : TP[id])
const hpDesc = (id) => { /* (ports/) editor.c ed_tdesc: engines.c hp_xdesc */
if (!opt.hostPower) return null;
const pg = HP_PAGES.find((x) => x.engine === ENG[st.engine].name && x.ids.includes(id));
const d = pg && pg.descs[pg.ids.indexOf(id)];
return d && pg.engine === "SAMPLE" && id === pg.ids[1] && pg.name === "TRIG" ? { ...d, label: HP_AMT[st.p[pg.ids[0]]] || "-" } : d;
};
const desc = (scope, id) => (scope === 0 && id < P_COUNT ? hpDesc(id) || (id >= P_E0 ? ENG[st.engine].edit[id - P_E0] : TP[id])
: scope === 1 && id < G_COUNT ? GP[id] : null);
const EMPTY = { n: 0, notes: [0, 0, 0, 0], time: 2, flags: 0, vel: 0, hit: 0, acc: 0, chance: 100, ratchet: 1 };
const isDrum = () => ENG[st.engine].name === "DRUM";
@@ -1859,6 +1909,8 @@ function makeMockDevice(opt = {}) {
for (let i = P_SLCR + 4; i < P_E0; i++) if (!trackOwn(i, P_E0)) st.p[i] = TP[i].def; /* a factory preset turns the
matrix off; the SLICER, the chord keys, the steps and the other track
settings stay (ui.c apply_preset_to) */
if (opt.hostPower) /* (ports/) engines.c hp_preset_x: the extra values' defaults */
for (const pg of HP_PAGES) if (pg.engine === e.name) pg.ids.forEach((id, k) => { st.p[id] = pg.descs[k].def; });
if (st.engine === FM6_E) { /* eng_fm6.c fm6_track_loaded */
const t = st.tracks[st.sel];
t.own = null;
@@ -1884,7 +1936,7 @@ function makeMockDevice(opt = {}) {
}
function setEngine(ei) {
if (ei % ENG.length === 1) { fm4Load(0); return; } /* DIGITAL (retired): its first preset, as FM6 (ui.c set_engine_of) */
if ([4, 6, 9].includes(ei % ENG.length)) ei = 0; /* SAMPLE TRIO PHYS (retired, core.h eng_gone): ANALOG; (snd5) 8 STRING 13 ADD */
if ([4, 6, 9].includes(ei % ENG.length) && !(opt.hostPower && ei % ENG.length === 4)) ei = 0; /* ((ports/) SAMPLE is there) */ /* SAMPLE TRIO PHYS (retired, core.h eng_gone): ANALOG; (snd5) 8 STRING 13 ADD */
st.engine = ei % ENG.length;
for (let i = 0; i < 8; i++) st.p[P_E0 + i] = ENG[st.engine].edit[i].def;
applyPreset(0);
@@ -2083,6 +2135,8 @@ function makeMockDevice(opt = {}) {
if (syncCaps()) { b(0x53); b(1); b(syncCaps()); if (!opt.noFm6) { b(0x50); b(1); b(3); } if (ratchetOn()) { b(0x52); b(1); b(4); }
if (!opt.noFm6 && !opt.noVbank && ratchetOn()) { b(0x56); b(1); b(32); }
if (lanesOn()) { b(0x4F); b(1); b(7); } } } /* (FM6 v2: no bank, preset patches; 0.6.11: the voice bank; 0.8.5: the lanes' modes) */
if (opt.board || opt.hostPower) { b(0x44); b(1); b(opt.board || 3); } /* (SMK-37, ports/) 'D': the device */
if (opt.hostPower) { b(0x48); b(2); b(15); b(16); } /* (ports/) 'H': SAMPLE GRAIN DRUM-X's samples, 16 slots */
if (st.uiCaps && !opt.noLyric) { b(0x59); b(1); b(63); } /* (0.8.5) LYRIC, the last tag */
}
break;
@@ -2230,7 +2284,7 @@ function makeMockDevice(opt = {}) {
case CMD.PRESET:
if (a.length < 2 || a[0] >= ENG.length) return null;
if (a[0] === 1) fm4Load(a[1]); /* a DIGITAL preset: its sound, as FM6 */
else if (a[0] === 4 && a[1] === PERC_SET) setEngine(DRUM_E); /* SAMPLE preset 4, once PERC: DRUM's kit */
else if (a[0] === 4 && a[1] === PERC_SET && !opt.hostPower) setEngine(DRUM_E); /* SAMPLE preset 4, once PERC: DRUM's kit */
else {
if (a[0] !== st.engine) setEngine(a[0]);
applyPreset(a[1]);
@@ -2289,10 +2343,11 @@ function makeMockDevice(opt = {}) {
}
/* a WebMIDI-like access object: one input and one output named "Felucca" */
const input = { id: "mock-in", name: "JIANT", type: "input", state: "connected", onmidimessage: null };
const portName = opt.portName || "JIANT";
const input = { id: "mock-in", name: portName, type: "input", state: "connected", onmidimessage: null };
let busy = false;
const output = {
id: "mock-out", name: "JIANT", type: "output", state: "connected",
id: "mock-out", name: portName, type: "output", state: "connected",
send(data) {
const f = unframe(data);
if (!f) { console.error("mock: refused a frame that is not F0 7D 46 4C ... F7", data); return; }
@@ -2377,7 +2432,7 @@ function makeMockDevice(opt = {}) {
];
return {
state: st, sim,
tables: { TP, GP, ENG, PATTERNS, P_COUNT, G_COUNT, NSTEP, P_E0, G_ENGSEL, P_SLCR, NTRK,
tables: { HP_PAGES, HP_ENG, TP, GP, ENG, PATTERNS, P_COUNT, G_COUNT, NSTEP, P_E0, G_ENGSEL, P_SLCR, NTRK,
FM6: { bank: 0, own: FM6_OWN, init: FM6.INIT_PK, factory: FM6.FACTORY_PK } }, /* test_web.mjs: == the firmware */
stop: () => timers.forEach(clearInterval),
access: { sysexEnabled: true, inputs: new Map([[input.id, input]]), outputs: new Map([[output.id, output]]), onstatechange: null },
@@ -2438,7 +2493,7 @@ function enumShown(d) {
/* the order the device shows its engines in (src/engines.c ENGINE_ORDER): the lists here follow it, the protocol keeps
the engine numbers. engineOrder(names): the indices of names in that order, "-" (a reserved number) left out; a name
the list does not know (another firmware) follows in index order */
const ENGINE_ORDER = ["DRUM", "VOICE", "ANIMAL", "LOFI", "ANALOG", "FM6", "PHASE", "WHEEL", "NOISE", "STRING", "ADD", "INPUT", "SAMPLE", "DIGITAL"]; /* (0.9.9: DRUM-X, VOICE,
const ENGINE_ORDER = ["DRUM", "VOICE", "ANIMAL", "LOFI", "ANALOG", "FM6", "PHASE", "WHEEL", "NOISE", "STRING", "ADD", "INPUT", "SAMPLE", "GRAIN", "DIGITAL"]; /* (0.9.9: DRUM-X, VOICE,
ANIMAL first, as the parts at power-on; DIGITAL, FELUCCA_FM4 builds only, last; was ANALOG FM6 DIGITAL PHASE LOFI VOICE WHEEL NOISE
DRUM ANIMAL, the order PROGRAM CHANGE still numbers the sounds in: engines.c ENGINE_PC_ORDER) */
function engineOrder(names) {
@@ -2457,6 +2512,15 @@ function devicePresetRows(info, names, preferences) {
.filter((row) => !preferences.state.filter || row.favorite);
}
/* (ports/) the big CPUs' pages beyond EDIT 1 / 2 (params.c PAGES from HP_PAGE0, ui.c page_visible): the ids of other
engines' slots their values live in (core.h P_LN0..7 83..90, P_LRTRG 61, P_FM3_DEC 72, P_FM3_LEVEL 75, P_FM4_SUS 78,
P_FM4_LEVEL 80), shown only for a device whose INFO says it has them ('H'), on a track of that engine; DESC names them */
const HP_PAGES = {
SAMPLE: [["TRIG", 0, [83, 84, 85, 86]], ["REC", 0, [87, 88, 89, 90]]],
GRAIN: [["TRAVEL", 0, [83, 84, 85, 86]], ["SOURCE", 0, [87, 88, 89, 90]], ["PITCH", 0, [72, 78]]],
DRUM: [["SAMPLES", 0, [61, 72, 80, 78]], ["SAMPLES 2", 0, [75]]],
};
const hpIds = (name) => (HP_PAGES[name] || []).flatMap((pg) => pg[2]);
/*PROTO-END*/
/* ===================================================================== UI === */
@@ -2493,7 +2557,7 @@ const GLYPH = {
/* section headings (LAYOUT titles) and page titles */
const HEAD_IC = { ENV: "function_env_adsr_exp", LFO: "waveform_sine", MOD: "symbol_waves", EDIT: "ui_knob", VOICE: "symbol_keyboard",
FX: "symbol_effector", SCL: "symbol_tuning", ARP: "control_arrow_up_down", "SEQ PATTERN": "symbol_grid",
GLOBAL: "symbol_cog", INSTRUMENT: "symbol_keyboard" };
GLOBAL: "symbol_cog", INSTRUMENT: "symbol_keyboard", FILTER: "function_filter_lpf_peak" };
const PAGE_IC = { FLT: "function_filter_lpf_peak", FILT: "function_filter_lpf_peak", DLY: "symbol_echo", REVERB: "symbol_spring", CHORUS: "symbol_waves",
SLICER: "symbol_grid", CHORD: "symbol_keyboard" };
/* WAVE / WAVE2 choices; phase-distortion shapes without a close glyph (SPLS, RSAW, RTRI, RTRP) get none */
@@ -2521,7 +2585,7 @@ const TEXT = {
fm6Init: "初期音色", fm6Voice: "ボイス", fm6Ops: "オペレーター", fm6Carriers: "キャリア", fm6Feedback: "フィードバック",
fm6PitchEg: "ピッチ EG", fm6Freq: "周波数",
fm6Legend: "R1〜R4 / L1〜L4: EG のレートとレベル、BP LD RD LC RC: キーボードレベルスケーリング、RS: レートスケーリング、AMS: LFO 音量変調、KVS: ベロシティ、OL: 出力レベル、MODE: 比率 / 固定、FC FF: 周波数(粗・細)、DET: デチューン(7 が中央)。● はキャリア。",
midiPorts: "MIDI ポート(自動接続できない場合)", midiPortHelp: "ブラウザが認識したポートです。入力と出力が両方必要です。空の場合は MIDI ポートが認識されていません。", midiInput: "入力", midiOutput: "出力",
midiPorts: "MIDI ポート(自動接続できない場合)", midiPortHelp: "ブラウザが認識したポートです。入力と出力が両方必要です。空の場合は MIDI ポートが認識されていません。SMK-37 は FM-1 と同じく USB で接続します。JIANT FM アプリ(スタンドアロン)は設定で MIDI 入力と出力を選び、その相手のポート(仮想 MIDI ケーブルなど)をここで選んでください。MPC Sample のアプリはまだエディターに応答しません。", midiInput: "入力", midiOutput: "出力",
fm6BankSend: "本体のボイスバンクへ送る (B1–B32)", fm6BankSent: "ボイスバンクを送りました:", fm6BankFail: "ボイスバンクを送れませんでした (rc ", fm6BankNow: "本体のボイスバンク:", fm6BankNone: "なし",
fm6Pick: "読み込んだファイルの音色(押すと編集へ):", fm6Picked: "編集中:", fm6Sent: "トラックへ送りました:", fm6Read: "トラックから読みました",
fm6Loaded: "読み込みました", fm6BadSum: "チェックサム不一致あり",
@@ -2615,7 +2679,7 @@ const TEXT = {
level: "レベル", pan: "パン", mute: "ミュート", rec: "REC", selectTrack: "選択", selectedTrack: "選択中",
projHelp: "プロジェクトは本体の状態をまとめて保存します: 全トラックの音色とパターン、曲の並び順、選択中のトラック、グローバル設定。",
slot: "スロット", songTitle: "ソング", songHelp: "保存スロットのパターンと繰り返す回数を順に並べます。音色は現在のまま。並び順を残すには、上のプロジェクトを保存してください。切替はトラック1のパターン終端、曲末で停止します。", songAdd: "行を追加", songRemove: "最後の行を削除", songPlay: "先頭から再生", songStop: "停止", songReps: "回", songEmpty: "行を追加してください", songBusy: "停止してから編集してください", songInvalid: "スロットと回数を確認してください", songPlaying: "再生中の行", songSaved: "並び順を変更しました。プロジェクトを保存すると残せます。",
system: "システム", firmware: "ファームウェア", sync: "同期", tracksN: "トラック", stepsN: "ステップ数", enginesL: "エンジン",
system: "システム", deviceL: "デバイス", firmware: "ファームウェア", sync: "同期", tracksN: "トラック", stepsN: "ステップ数", enginesL: "エンジン",
userBank: "ユーザープリセット", none: "なし",
},
en: {
@@ -2625,7 +2689,7 @@ const TEXT = {
fm6Init: "Init voice", fm6Voice: "Voice", fm6Ops: "Operators", fm6Carriers: "carriers", fm6Feedback: "feedback",
fm6PitchEg: "Pitch EG", fm6Freq: "Frequency",
fm6Legend: "R1..R4 / L1..L4: EG rates and levels; BP LD RD LC RC: keyboard level scaling; RS: rate scaling; AMS: LFO amplitude modulation; KVS: velocity; OL: output level; MODE: ratio / fixed; FC FF: coarse / fine frequency; DET: detune (7 = centre). ● = carrier.",
midiPorts: "MIDI ports (choose manually if Auto fails)", midiPortHelp: "These are the ports reported by the browser. Both an input and an output are required; empty lists mean the browser is not seeing a MIDI port.", midiInput: "Input", midiOutput: "Output",
midiPorts: "MIDI ports (choose manually if Auto fails)", midiPortHelp: "These are the ports reported by the browser. Both an input and an output are required; empty lists mean the browser is not seeing a MIDI port. An SMK-37 connects by USB as the FM-1 does. The JIANT FM app (standalone): pick a MIDI input and output in its settings, then their other ends here (a virtual MIDI cable, for example). The MPC Sample's app does not answer the editor yet.", midiInput: "Input", midiOutput: "Output",
fm6BankSend: "Send to the device's voice bank (B1–B32)", fm6BankSent: "Voice bank sent:", fm6BankFail: "The voice bank was not sent (rc ", fm6BankNow: "The device's voice bank:", fm6BankNone: "none",
fm6Pick: "Voices of the imported file (click to edit):", fm6Picked: "Editing:", fm6Sent: "Sent to track", fm6Read: "Read from track",
fm6Loaded: "Loaded", fm6BadSum: "a checksum did not match",
@@ -2719,7 +2783,7 @@ const TEXT = {
level: "Level", pan: "Pan", mute: "Mute", rec: "REC", selectTrack: "Select", selectedTrack: "Selected",
projHelp: "A project keeps the sounds and patterns of all tracks, the song chain, the selected track and the global settings.",
slot: "Slot", songTitle: "Song", songHelp: "Arrange sections (the saved projects A–D, with their sounds) and choose how many bars each plays (1–64). Save a project above to keep the chain. Rows change on the bar; the song stops at the end and the music before it comes back.", songAdd: "Add row", songRemove: "Remove last row", songPlay: "Play from start", songStop: "Stop", songReps: "bars", songEmpty: "Add a row first", songBusy: "Stop before editing", songInvalid: "Check sections and bars", songPlaying: "Playing row", songSaved: "Chain changed. Save a project to keep it.",
system: "System", firmware: "Firmware", sync: "Sync", tracksN: "Tracks", stepsN: "Steps", enginesL: "Engines",
system: "System", deviceL: "Device", firmware: "Firmware", sync: "Sync", tracksN: "Tracks", stepsN: "Steps", enginesL: "Engines",
userBank: "User presets", none: "none",
},
};
@@ -2848,8 +2912,8 @@ 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) => [EXPECT.gcount, 32, 36, 37, 66, 67, 69, 71].includes(info.gcount) && /* (JIANT FUNB: 5, 9, then 10 more globals; 0.6.3: the SLICER's 29) */
[[120, 112], [99, 91], [91, 83], [89, 81], [69, 61], [57, 49]].some(([c, e]) => info.pcount === c && info.pe0 === e);
const knownLayout = (info) => [EXPECT.gcount, 32, 36, 37, 66, 67, 69, 71, 73].includes(info.gcount) && /* (JIANT FUNB: 5, 9, then 10 more globals; 0.6.3: the SLICER's 29) */
[[123, 115], [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]]] },
@@ -2858,7 +2922,9 @@ const LAYOUT = (pe0) => [
[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 */
...(pe0 >= 91 && engName() === "DRUM" ? [["LANES", 0, P_LANES.slice(0, 4)], ["LANES 2", 0, P_LANES.slice(4)]] : []), /* lane levels 83..90 */
...hpPages(pe0)] }, /* (ports/) SAMPLE's TRIG REC, GRAIN's TRAVEL SOURCE PITCH, DRUM-X's SAMPLES */
...(pe0 >= 115 ? [{ t: "FILTER", pages: [["FILTER", 0, [112, 113, 114]]] }] : []), /* (JIANT 0.5) TYPE CUT RES (P_FTYPE ..) */
...(pe0 >= 81 && engName() === "DIGITAL" ? [{ t: "OP ENV", pages: [ /* P_FM1_ATK 61: ATK DEC SUS REL LVL per operator (a
FELUCCA_FM4=1 firmware only: DIGITAL retired, its engine is "-") */
...[0, 1, 2, 3].map((k) => [`OP${k + 1}`, 0, [61 + 5 * k, 62 + 5 * k, 63 + 5 * k, 64 + 5 * k]]),
@@ -2875,6 +2941,12 @@ const LAYOUT = (pe0) => [
{ t: "SEQ PATTERN", tab: "seqgroups", pages: [["PATTERN", 0, [29, 30, 31, 32]], ...(pe0 >= 83 ? [["STRETCH · TRACK", 0, P_SHIFT]] : [])] }, /* ROTATE PITCH 81, 82 (SHIFT until 0.6.91) */
{ t: "GLOBAL", tab: "setgroups", pages: [["GLOBAL", 1, [0, 1, 2, 3]], ["SYSTEM", 1, [14]]] }, /* G_ROUTE: MIDI IN */
];
function hpPages(pe0) {
const hp = dev && dev.info && dev.info.hostPower;
const name = engName();
if (!hp || pe0 < 115 || !(name === "SAMPLE" && hp.sample || name === "GRAIN" && hp.grain || name === "DRUM" && hp.drumSamples)) return [];
return HP_PAGES[name];
}
/* globals that are actions or placeholders on the device: buttons instead, or hidden */
const G_SKIP = new Set(["SLOT", "NAME", "LOAD", "SAVE", "ENG", "SET", "CLRSQ", "INIT", "MIDI", "SYNC", "CPU", "CLK"]);
const key = (s, id) => s + ":" + id;
@@ -2922,7 +2994,8 @@ async function connect() {
sayK("connecting");
try {
if (!access) {
if (MOCK) { mock = makeMockDevice({ legacy: QS.get("legacy") === "1" }); access = mock.access; }
if (MOCK) { mock = makeMockDevice({ legacy: QS.get("legacy") === "1", hostPower: QS.get("hp") === "1", /* (?hp=1: a big CPU, ?board=1: an SMK-37) */
board: +QS.get("board") || 0, portName: QS.get("port") || undefined }); access = mock.access; }
else {
try { access = await navigator.requestMIDIAccess({ sysex: true }); }
catch (e) { sayK("denied"); return; }
@@ -3055,12 +3128,17 @@ async function load(d) {
async function getDescOrNull(s, i, d = dev) { try { return await getDesc(s, i, d); } catch (e) { if (e.message === "closed") throw e; return null; } }
/* rebuilds the controls only when the engine or its parameters changed (a slider being dragged survives) */
const HP_ALL = [...new Set(Object.keys(HP_PAGES).flatMap(hpIds))];
async function rereadEngineDesc(d = dev) {
assertSession(d);
const pe0 = d.info.pe0;
const before = JSON.stringify(d.pdesc.slice(pe0));
for (let i = 0; i < 8 && pe0 + i < d.info.pcount; i++) d.pdesc[pe0 + i] = await getDescOrNull(0, pe0 + i, d);
if (d.built !== d.dump.engine || JSON.stringify(d.pdesc.slice(pe0)) !== before) buildGroups();
/* (ports/) the values a big CPU keeps in other engines' slots: their descriptors are the track engine's (and its
SAMPLE TRIG's: AMOUNT's name); read again for every engine that has them, and when leaving one (the slots' own) */
const hpBefore = JSON.stringify(HP_ALL.map((i) => d.pdesc[i]));
if (d.info.hostPower) for (const i of HP_ALL) if (i < d.info.pcount) d.pdesc[i] = await getDescOrNull(0, i, d);
if (d.built !== d.dump.engine || JSON.stringify(d.pdesc.slice(pe0)) !== before || JSON.stringify(HP_ALL.map((i) => d.pdesc[i])) !== hpBefore) buildGroups();
}
async function loadSteps(d = dev) {
@@ -3114,8 +3192,9 @@ function renderSysinfo() {
const box = $("sysinfo");
if (!dev || !dev.info) { box.replaceChildren(); return; }
const i = dev.info;
$("version").textContent = `${deviceName(i, dev.input && dev.input.name)} · ${i.version}`; /* (SMK-37, ports/) which device */
const rows = [
["firmware", i.version], ["sync", t(dev.watch ? "live" : "polling")], ["enginesL", i.engines.join(", ")],
["deviceL", deviceName(i, dev.input && dev.input.name)], ["firmware", i.version], ["sync", t(dev.watch ? "live" : "polling")], ["enginesL", i.engines.join(", ")],
["tracksN", i.ntrk ? String(i.ntrk) : "1"], ["stepsN", String(i.nstep)],
["userBank", dev.bank ? String(dev.bank.total) : t("none")],
];
@@ -3348,7 +3427,7 @@ async function sendSet(s, id, k) {
showValue(k, r.value, false);
mixFromDump();
}
if (!s && dev && id === dev.info.pe0) { dev.dump = await getDump(); await rereadEngineDesc(); refreshAll(); } /* (V10.40) WAVE / EXCITE / MODE:
if (!s && dev && (id === dev.info.pe0 || dev.info.hostPower && hpIds(engName())[0] === id)) { dev.dump = await getDump(); await rereadEngineDesc(); refreshAll(); } /* (ports/: SAMPLE's TRIG names AMOUNT) */ /* (V10.40) WAVE / EXCITE / MODE:
* some knobs change name and range (ANALOG SAW3's INT 3, STRING FDBK) */
} catch (e) { if (e.message !== "closed") console.warn(e); }
}
+81
View File
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant)
// (SMK-37, ports/) the editor in a real browser (Playwright's Chromium) on its mock device (?mock=1: Web MIDI faked by
// the page itself):
// node web/editor_browser_test.mjs [out-dir-for-screenshots]
// An FM-1 (no 'D' / 'H' tags): "FM-1" shown, no SAMPLE / GRAIN offered, no sample pages on DRUM. An SMK-37 ('D' 1 1):
// its name. A big CPU (?hp=1: 'D' 1 3, 'H' 2 15 16): SAMPLE and GRAIN offered, their pages (SAMPLE WARP TRIG REC,
// GRAIN CLOUD TRAVEL SOURCE PITCH) and DRUM-X's SAMPLES; the FILTER section of P_COUNT 123 firmware.
import path from "path";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { chromium } = require("playwright");
const HERE = path.dirname(new URL(import.meta.url).pathname);
const OUT = process.argv[2] || null;
const page0 = "file://" + path.join(HERE, "editor.html");
let fails = 0;
const check = (what, ok, extra = "") => { console.log(`editor (browser): ${what.padEnd(70)} ${ok ? "ok" : "FAIL"} ${extra}`); if (!ok) fails++; };
const b = await chromium.launch();
async function open(qs) {
const p = await b.newPage({ viewport: { width: 1280, height: 900 }, deviceScaleFactor: 2 });
p.on("pageerror", (e) => { console.log("pageerror:", e.message); fails++; });
await p.goto(`${page0}?mock=1${qs}`);
await p.click("#connect");
await p.waitForFunction(() => /·/.test(document.querySelector("#version").textContent), null, { timeout: 60000 });
return p;
}
const heads = (p) => p.$$eval("#groups h2, #groups h3", (a) => a.map((x) => x.textContent.replace(/[^\x20-\x7e]/g, "").trim())); /* (an icon's glyph out) */
const engines = (p) => p.$$eval("#engine option", (a) => a.map((x) => x.textContent));
/* the controls are rebuilt as the replies come: wait until the headings hold what is expected (or 20 s) */
async function settle(p, want = []) {
let last = "", same = 0;
for (let i = 0; i < 200 && same < 10; i++) {
await p.waitForTimeout(100);
const h = await heads(p), now = JSON.stringify(h);
same = now === last && want.every((x) => h.includes(x)) ? same + 1 : 0;
last = now;
}
}
async function engine(p, e, want) {
await p.selectOption("#engine", String(e));
await settle(p, want);
}
{
const p = await open("");
await settle(p, ["FILTER"]);
const h = await heads(p), en = await engines(p);
check("FM-1: its name, the structured layout (ENV .. FILTER)", (await p.textContent("#version")).startsWith("FM-1 ·") &&
h.includes("ENV") && h.includes("FILTER"));
check("FM-1: no SAMPLE / GRAIN to pick", !en.includes("SAMPLE") && !en.includes("GRAIN"));
await engine(p, 10, ["EDIT DRUM"]);
check("FM-1: DRUM without the sample pages", !(await heads(p)).includes("SAMPLES"));
await p.close();
}
{
const p = await open("&board=1&port=JIANT%20SMK-37");
check("SMK-37: shown by its tag", (await p.textContent("#version")).startsWith("SMK-37 Pro ·"));
await p.close();
}
{
const p = await open("&hp=1");
check("big CPU: shown, SAMPLE and GRAIN offered", (await p.textContent("#version")).startsWith("JIANT FM app / plugin ·") &&
(await engines(p)).slice(-2).join() === "SAMPLE,GRAIN");
for (const [e, name, want] of [[4, "sample", ["EDIT SAMPLE", "SAMPLE", "WARP", "TRIG", "REC"]],
[8, "grain", ["EDIT GRAIN", "GRAIN", "CLOUD", "TRAVEL", "SOURCE", "PITCH"]], [10, "drum", ["EDIT DRUM", "SAMPLES", "SAMPLES 2"]]]) {
await engine(p, e, want);
const h = await heads(p);
check(`big CPU: ${name.toUpperCase()}'s pages (${want.slice(1).join(" ")})`, want.every((x) => h.includes(x)), want.filter((x) => !h.includes(x)).join());
if (OUT) await p.screenshot({ path: path.join(OUT, `editor-${name}.png`), fullPage: true });
}
const labels = await p.$$eval("#groups .row", (a) => a.map((x) => x.textContent));
check("big CPU: DRUM-X's SMORPH BLEND SLOT MAP SLEVEL", ["SMORPH", "BLEND", "MAP", "SLEVEL"].every((l) => labels.some((t) => t.startsWith(l))));
await engine(p, 0, ["EDIT ANALOG"]);
check("big CPU: ANALOG without them", !(await heads(p)).some((x) => ["TRIG", "TRAVEL", "SAMPLES"].includes(x)));
await p.close();
}
await b.close();
console.log(fails ? `EDITOR BROWSER TEST FAILED (${fails})` : "editor browser test passed");
process.exit(fails ? 1 : 0);
+1
View File
@@ -16,6 +16,7 @@
* web/emu/build.sh -> build/emu/felucca_hp.wasm */
#define FELUCCA_HOST_POWER 1
#define JIANT_NO_REAL_LOAD 1
#define JIANT_NO_EDITOR 1 /* (no MIDI in the browser page: the editor's SysEx handler not built) */
#include "../../ports/core/jiant_core.c"
EXPORT uint32_t web_host_power(void) { return 1u; }
+66 -1
View File
@@ -68,7 +68,8 @@ const E = vm.runInNewContext(proto + `
mixer, parseNotes, parseHits, hitsText, gridFromSteps, LANE_NOTE, LANE_OF, readDevicePreferences, devicePresetRows, engineOrder, ENGINE_ORDER, aliasOf, fmtValue, FM6, enumShown, F,
FM4, fromDigital, fromPerc, DRUM_KIT_E,
MENU: typeof MENU === "undefined" ? null : MENU, MENU_TABS: typeof MENU_TABS === "undefined" ? null : MENU_TABS,
readDeviceMenu: typeof readDeviceMenu === "undefined" ? null : readDeviceMenu, fm6Bank, crc32, lyricText })`,
readDeviceMenu: typeof readDeviceMenu === "undefined" ? null : readDeviceMenu, fm6Bank, crc32, lyricText,
deviceName, editorPort, HP_PAGES, hpIds })`,
{ setTimeout, clearTimeout, setInterval, clearInterval, console });
/* (JIANT 0.6.11, from Felucca 1.4.1's test) FM6's voice bank (cmds 74..77; the editor's fm6Bank) against the mock: INFO 56 01 32, a 32-voice .syx
@@ -514,6 +515,69 @@ function mockTables() {
"editor: SWG 100 shows 100 % (not 79), 0..127 percents unchanged");
}
/* (SMK-37, ports/) the devices beside the FM-1: INFO's 'D' (the device: 1 SMK-37 Pro, 2 Elite, 3 a computer, 4 the MPC
Sample app, 5 the MPC plugin) and 'H' (a big CPU's engines: SAMPLE, GRAIN, DRUM-X's samples, the slots), both just
before 'Y'; an FM-1 sends neither. The editor's pages for the big CPUs' engines (HP_PAGES) == the firmware's
(params.c PAGES from HP_PAGE0: build/host/desc_hp.json, tests/descdump.c with FELUCCA_HOST_POWER=1), and the mock with
hostPower is that device: its SAMPLE / GRAIN tables and the values DESC names by the track's engine */
async function editorDevices() {
const C = E.CMD;
const infoOf = async (opt) => { const { rq, done } = attachMock(opt); const i = E.parse[C.INFO](await rq(E.req.info())); done(); return i; };
const fm1 = await infoOf({}), smk = await infoOf({ board: 1, portName: "JIANT SMK-37" }), hp = await infoOf({ hostPower: true });
ok(fm1.board === 0 && !fm1.hostPower && fm1.lyric === 63 && fm1.laneModes === 7, "devices: an FM-1's INFO: no 'D', no 'H' (its tags as before)");
ok(smk.board === 1 && !smk.hostPower && smk.lyric === 63 && smk.laneModes === 7, "devices: an SMK-37's INFO: 'D' 1 1, no 'H'");
ok(hp.board === 3 && hp.hostPower && hp.hostPower.caps === 15 && hp.hostPower.slots === 16 && hp.hostPower.sample &&
hp.hostPower.grain && hp.hostPower.drumSamples && hp.lyric === 63 && hp.engines[4] === "SAMPLE" && hp.engines[8] === "GRAIN",
"devices: a big CPU's INFO: 'D' 1 3, 'H' 2 15 16 (SAMPLE in 4, GRAIN in 8), 'Y' still last");
ok(E.deviceName(fm1, "JIANT") === "FM-1" && E.deviceName(smk, "JIANT SMK-37") === "SMK-37 Pro" &&
E.deviceName({ board: 2 }, "") === "SMK-37 Elite" && E.deviceName(fm1, "JIANT SMK-37") === "SMK-37" &&
E.deviceName(hp, "") === "JIANT FM app / plugin" && E.deviceName({ board: 4 }, "MPC Sample") === "MPC Sample",
"devices: the name shown (the tag, else the port: an SMK-37 before the tag)");
ok(["JIANT SMK-37", "MIDIIN2 (JIANT SMK-37)", "MPC Sample", "JIANT", "FM-1"].every((n) => E.editorPort({ name: n, state: "connected" })) &&
!E.editorPort({ name: "IAC Driver Bus 1", state: "connected" }), "devices: the SMK-37's and the MPC Sample's ports are asked first");
/* DESC by the track's engine on the big CPUs */
const { rq, done } = attachMock({ hostPower: true });
const info = E.parse[C.INFO](await rq(E.req.info()));
const desc = async (id) => E.parse[C.DESC](await rq(E.req.desc(0, id)));
await rq(E.req.preset(4, 0));
const trig = await desc(83), amt0 = await desc(84);
await rq(E.req.set(0, 83, 2));
const amt2 = await desc(84);
ok(trig.label === "TRIG" && trig.names[2] === "RATCH" && amt0.label === "-" && amt2.label === "COUNT",
"devices: SAMPLE's TRIG over DESC; AMOUNT named by it (NORM: hidden, RATCH: COUNT)");
await rq(E.req.preset(8, 0));
const tr = await desc(83), q = await desc(72);
await rq(E.req.preset(10, 0));
const sm = await desc(61), slot = await desc(80), dump = E.parse[C.DUMP](await rq(E.req.dump()), info);
ok(tr.label === "TRAVEL" && q.label === "QUANT" && sm.label === "SMORPH" && slot.min === 112 && slot.names[0] === "1" &&
dump.p[80] === 112 && dump.p[78] === 125, "devices: GRAIN's TRAVEL / QUANT, DRUM-X's SMORPH, SLOT 112..127 named 1..16");
await rq(E.req.preset(0, 0));
ok((await desc(61)).label !== "SMORPH", "devices: on another engine those ids are the track's own again");
done();
ok(E.fromPerc({ engine: 4, p: [...new Array(115).fill(0), 4, 0, 0, 0, 0, 0, 0, 0] }, info.engines, 115) === null &&
!!E.fromPerc({ engine: 4, p: [...new Array(115).fill(0), 4, 0, 0, 0, 0, 0, 0, 0] }, fm1.engines, 115),
"devices: a SAMPLE sound (SLOT 5) stays SAMPLE on a big CPU; on an FM-1 a PERC one still becomes DRUM");
ok(E.hpIds("DRUM").join() === "61,72,80,78,75" && E.hpIds("ANALOG").length === 0, "devices: the editor's DRUM-X SAMPLES pages");
const dj = join(DESC, "../desc_hp.json");
if (!existsSync(dj)) { console.log("devices: big CPU tables == firmware (no build/host/desc_hp.json)".padEnd(64) + " skip"); return; }
const fw = JSON.parse(readFileSync(dj, "utf8"));
const norm = (d) => ({ label: d.label, fmt: d.fmt, min: d.min, max: d.max, def: d.def, names: d.names || null, unit: d.unit || "" });
const pages = fw.HP.pages.map((pg) => ({ engine: pg.engine, name: pg.name, ids: pg.ids }));
const mine = Object.entries(E.HP_PAGES).flatMap(([engine, pgs]) => pgs.map(([name, , ids]) => ({ engine, name, ids })));
ok(JSON.stringify(mine) === JSON.stringify(pages) && fw.HP.caps === 15 && fw.HP.slots === 16,
"devices: the editor's SAMPLE / GRAIN / DRUM-X pages == the firmware's (params.c from HP_PAGE0)");
const m = E.makeMockDevice({ auto: false, hostPower: true }), T = m.tables;
m.stop();
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
const engOk = [4, 8].every((e) => T.ENG[e].name === fw.ENG[e].name && same(T.ENG[e].titles, fw.ENG[e].titles) &&
same(T.ENG[e].edit.map(norm), fw.ENG[e].edit) && same(T.ENG[e].presets.map((p) => [p.name, p.e, p.env, p.mono, p.pat]),
fw.ENG[e].presets.map((p) => [p.name, p.e, p.env, p.mono, p.pat])));
ok(engOk && same(T.HP_PAGES.map((pg) => ({ engine: pg.engine, name: pg.name, ids: pg.ids, descs: pg.descs.map(norm) })), fw.HP.pages) &&
same(E.ENGINE_ORDER.filter((n) => fw.ENG.some((e) => e.name === n)), fw.ORDER),
"devices: the mock's SAMPLE, GRAIN, their pages and the engine order == the big CPUs' firmware");
}
/* ------------------------------------------------------------------ DIGITAL retired --- */
/* DIGITAL (engine 1, four-operator FM) was replaced by FM6 (src/fm4_convert.c): the editor's conversion == the
firmware's (build/host/desc.json "FM4": its presets and 48 sounds), engine 1 is "-" with no presets, G_ENGSEL 1 and
@@ -1997,6 +2061,7 @@ await editorFm6Bank();
await editorLyric();
await editorSamplePresets();
mockTables();
await editorDevices();
await editorLibrarian();
await editorGrid();
await editorRatchet();