From 0da8f40ed0032f2544c70384d471792c5d84f152 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 17:04:03 +0000 Subject: [PATCH 1/3] kick: TAP turns past 9 (slot 40's limit is the WAVE pair's alone) Slot 40 is SCN's MOD on WAVE MONO and WAVE POLY, a number 0-9, and TAP on KICK, a level. Its limit was by index alone (kit_param_max), so the engine, the knob, a lock, a user sound and the kit's reader all held KICK's TAP at 9 of 127: 7% on the screen and a ghost about 49 dB under the hit. kit_param_max(machine, index) keeps the limit on the machines that scan; where the machine is not known (scenes, random ranges) the slot takes 127 and the WAVE voice reads a MOD past its last mode as the last, as it always did. No kit can hold a TAP above 9, so every kit plays as it was saved. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Tw2EaFHmBTuHT9xVLai85a --- CHANGELOG.md | 4 ++++ app/engine.cpp | 6 +++--- app/ui_mixer.hpp | 2 +- core/project.cpp | 2 +- core/project.hpp | 17 ++++++++++++++--- core/usersounds.cpp | 2 +- tests/test_engine.cpp | 26 ++++++++++++++++++++++++++ tests/test_project.cpp | 13 ++++++++++--- tests/test_wave_scan.cpp | 5 ++++- 9 files changed, 64 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a1d0d5..3d39a335 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -179,6 +179,10 @@ the project file format or the controls. ### Fixed +- **KICK TAPS: TAP turns all the way up.** The knob stopped at 9 of 127, shown as 7%, where the + ghost hits are barely heard: the slot is the WAVE pair's MOD, which has ten modes, and every + machine stopped there. TAP reaches 100%, by the knob, a lock and a saved sound. A kit keeps the + TAP it was saved with. - **KICK TAPS: no click on the ghost hits.** Each ghost starts its sine at zero; it used to start wherever the run's phase had got to, which stepped the output. - **CLR out of PREP no longer removes a zone.** Leaving PREP with CLR lands on ZONES, where CLR diff --git a/app/engine.cpp b/app/engine.cpp index 056b5c01..89981f43 100644 --- a/app/engine.cpp +++ b/app/engine.cpp @@ -663,7 +663,7 @@ bool Engine::apply_sound(const Command &command, int track, int) { value = uint8_t(next < 0 ? 0 : (next > 127 ? 127 : next)); } // WAV and DST stop at their last shape and destination (core/project.hpp). - const uint8_t top = kit_param_max(command.a); + const uint8_t top = kit_param_max(machine_id_[track], command.a); value = value > top ? top : value; params_[track].v[command.a] = clamp_7bit(value); // `performed_` is built FROM `params_`, and the per-block copy in process() @@ -752,7 +752,7 @@ bool Engine::apply_sound(const Command &command, int track, int) { for (int i = 0; i < 8; i++) { const int p = int(command.step) + i; if (p >= kTrackParams || !user_sound_owns(machine, p)) continue; - const uint8_t top = kit_param_max(p); + const uint8_t top = kit_param_max(machine_id_[track], p); params_[track].v[p] = bytes[i] > top ? top : bytes[i]; if ((locked >> p & 1u) == 0) effective_[track].v[p] = params_[track].v[p]; } @@ -1020,7 +1020,7 @@ bool Engine::apply_step_edit(const Command &command, int track, int step) { uint8_t value = command.c == kSemitoneFlag && tune_param(machine_id_[track]) == param ? tune_step(machine_id_[track], base, int(int8_t(command.b))) : clamp_7bit(int(base) + int(int8_t(command.b))); - const uint8_t top = kit_param_max(param); + const uint8_t top = kit_param_max(machine_id_[track], param); if (value > top) value = top; // WAV and DST stop at their last one if (!pattern_set_lock(live(), track, step, param, value)) { diff --git a/app/ui_mixer.hpp b/app/ui_mixer.hpp index 1588d398..7bf73c5e 100644 --- a/app/ui_mixer.hpp +++ b/app/ui_mixer.hpp @@ -941,7 +941,7 @@ ShownParam shown; shown.base = engine_.params(selected_).v[index]; shown.heard = shown.base; - shown.top = kit_param_max(index); + shown.top = kit_param_max(engine_.machine_id(selected_), index); if (held_step_ >= 0 && index >= 0 && index < kTrackParams) { shown.locked = pattern_get_lock(engine_.pattern(), selected_, held_step_, uint8_t(index), shown.heard); diff --git a/core/project.cpp b/core/project.cpp index ac6890e5..3910665b 100644 --- a/core/project.cpp +++ b/core/project.cpp @@ -1458,7 +1458,7 @@ SerializeResult kit_read(Kit &kit, const uint8_t *buffer, uint32_t size) { if (!r.seek(kHeaderBytes + offset[15])) return refuse(SerializeResult::malformed); for (int t = 0; t < kTracks; t++) { for (int p = kKitScnFirst; p < kKitParams; p++) { - kit.tracks[t].params[p] = clamp_u8(r.u8(), 0, kit_param_max(p)); + kit.tracks[t].params[p] = clamp_u8(r.u8(), 0, kit_param_max(kit.tracks[t].machine, p)); } } if (!r.ok()) return refuse(SerializeResult::truncated); diff --git a/core/project.hpp b/core/project.hpp index 1cf4e5db..b44832b7 100644 --- a/core/project.hpp +++ b/core/project.hpp @@ -110,12 +110,14 @@ constexpr uint8_t kKitLfoDestMax = uint8_t(kKitSoundParams); // OFF, then the 1 // The marker byte the layout sections hold: 1 = WAV and DST are numbers. constexpr uint8_t kLfoLayoutNumbers = 1; -// The highest value a parameter byte may hold: 127 for all but WAV, DST and SCN's MOD. Knobs, -// locks, random ranges and LIVE RND clamp to it, so a knob does not wind past the last shape. +// The highest value a parameter byte may hold when the machine is not known (a scene, a lock, a +// random range): 127 for all but the LFO's WAV and DST. Slot 40 is a number, 0-9, on the WAVE +// pair alone (SCN's MOD); on KICK it is TAP, a level, so the limit there needs the machine +// (kit_param_max(machine, index), below the machine predicates). The WAVE voice reads a MOD +// past its last mode as the last (va_scan_mode). constexpr uint8_t kit_param_max(int index) { return index == kKitLfoWaveIndex ? kKitLfoWaveMax : index == kKitLfoDestIndex ? kKitLfoDestMax - : index == kKitScanModeIndex ? kKitScanModeMax : uint8_t(127); } @@ -283,6 +285,15 @@ constexpr bool machine_reads_scn(uint8_t id) { return machine_is_wave(id); } // shows, names, saves and presets the page's bytes asks here. constexpr bool machine_has_scn_page(uint8_t id) { return machine_reads_scn(id) || machine_is_kick(id); } +// The highest value a parameter byte may hold on this machine: kit_param_max(index), and SCN's +// MOD stops at its last mode on the machines that scan. Knobs, the kit's reader and a loaded +// sound clamp to it, so a knob does not wind past the last mode. KICK's TAP shares the slot and +// is a level, 0-127: until 2026-11-30 every machine stopped at 9 there, which held TAP at 7%. +constexpr uint8_t kit_param_max(uint8_t machine, int index) { + return index == kKitScanModeIndex && machine_reads_scn(machine) ? kKitScanModeMax + : kit_param_max(index); +} + // FM4: four sine operators in one of eight algorithms (dsp/fm.hpp). constexpr bool machine_is_fm(uint8_t id) { return id == uint8_t(MachineId::fm); } diff --git a/core/usersounds.cpp b/core/usersounds.cpp index 0b8c4a84..fb6c3d43 100644 --- a/core/usersounds.cpp +++ b/core/usersounds.cpp @@ -170,7 +170,7 @@ bool user_sound_store(UserSoundBank &bank, int slot, const char *name, const uin s.used = true; copy_name(s.name, name); for (int p = 0; p < kKitParams; p++) { - const uint8_t top = kit_param_max(p); + const uint8_t top = kit_param_max(bank.machine, p); s.params[p] = params[p] > top ? top : params[p]; } s.extras = sanitized(extras); diff --git a/tests/test_engine.cpp b/tests/test_engine.cpp index aaa2ceef..8e93040a 100644 --- a/tests/test_engine.cpp +++ b/tests/test_engine.cpp @@ -4976,3 +4976,29 @@ TEST(engine_a_song_position_lands_a_queued_change_at_once) { post(Cmd::stop, 0, 0, 0); pump(); } + +// Slot 40 is SCN's MOD on the WAVE pair, a number that stops at the last mode, and TAP on KICK, +// a level. Until 2026-11-30 every machine stopped at 9 there, so TAP never passed 7%. +TEST(engine_kicks_tap_reaches_its_top_and_a_wave_mod_stops_at_the_last_mode) { + Engine &engine = clean(); + const int kick = 0, wave = 1; + post(Cmd::set_machine, kick, 0, uint8_t(MachineId::kick)); + post(Cmd::set_machine, wave, 0, uint8_t(MachineId::wave_poly)); + pump(); + post(Cmd::set_param, kick, 0, kScnFirst, 100); + post(Cmd::set_param, wave, 0, kScnFirst, 100); + pump(); + CHECK_EQ(int(engine.params(kick).v[kScnFirst]), 100); + CHECK_EQ(int(engine.params(wave).v[kScnFirst]), kKitScanModes - 1); + // A lock moved by the encoder follows the same rule. + put_trig(kick, 1); + put_trig(wave, 1); + post(Cmd::lock_delta, kick, 1, kScnFirst, 20); + post(Cmd::lock_delta, wave, 1, kScnFirst, 20); + pump(); + uint8_t value = 0; + CHECK(pattern_get_lock(engine.pattern(), kick, 1, uint8_t(kScnFirst), value)); + CHECK_EQ(int(value), 120); + CHECK(pattern_get_lock(engine.pattern(), wave, 1, uint8_t(kScnFirst), value)); + CHECK_EQ(int(value), kKitScanModes - 1); +} diff --git a/tests/test_project.cpp b/tests/test_project.cpp index 12afb335..7ef075c8 100644 --- a/tests/test_project.cpp +++ b/tests/test_project.cpp @@ -2451,9 +2451,13 @@ TEST(kit_the_lfo_and_arp_bytes_round_trip_and_are_clamped_on_the_way_in) { for (int t = 0; t < kTracks; t++) { for (int p = kKitSoundParams; p < kKitParams; p++) { if (!kit_param_real(p)) continue; - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), int(kit_param_max(p))); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), + int(kit_param_max(g_kit_loaded.tracks[t].machine, p))); } } + // SCN's MOD stops at its last mode on the WAVE pair alone (tracks 5 and 6 of fill_kit). + CHECK_EQ(int(g_kit_loaded.tracks[5].params[kKitScnFirst]), kKitScanModes - 1); + CHECK_EQ(int(g_kit_loaded.tracks[0].params[kKitScnFirst]), 127); } TEST(kit_a_file_from_before_the_lfo_loads_with_every_lfo_and_arp_off) { @@ -4227,11 +4231,14 @@ TEST(kit_the_scn_page_round_trips_and_an_older_file_loads_it_off) { } } - // A MOD byte no build writes reads as DRFT, the last mode. + // A MOD byte no build writes reads as DRFT, the last mode, on a WAVE track (5 of fill_kit's). + // On any other machine the slot is not a mode: 127, a parameter's top. + g_kit_file[section_at(g_kit_file, kSectionKitScn) + 4 * 5] = 200; g_kit_file[section_at(g_kit_file, kSectionKitScn) + 4 * 3] = 200; refresh_crc(g_kit_file); CHECK_EQ(int(kit_read(g_kit_loaded, g_kit_file, kKitFileBytes)), int(SerializeResult::ok)); - CHECK_EQ(int(g_kit_loaded.tracks[3].params[kKitScnFirst]), kKitScanModes - 1); + CHECK_EQ(int(g_kit_loaded.tracks[5].params[kKitScnFirst]), kKitScanModes - 1); + CHECK_EQ(int(g_kit_loaded.tracks[3].params[kKitScnFirst]), 127); // A kit from before the page (and so before SLAP, the section after it). fresh_kit_file(); diff --git a/tests/test_wave_scan.cpp b/tests/test_wave_scan.cpp index 48044a3a..4c0fbe89 100644 --- a/tests/test_wave_scan.cpp +++ b/tests/test_wave_scan.cpp @@ -121,7 +121,10 @@ TEST(wave_scan_knob_mappings) { CHECK(va_scan_mode(9) == ScanMode::drift); CHECK(va_scan_mode(200) == ScanMode::drift); // past the last reads as the last CHECK_EQ(kScanModes, kKitScanModes); - CHECK_EQ(int(kit_param_max(kMod)), kScanModes - 1); + CHECK_EQ(int(kit_param_max(uint8_t(MachineId::wave_mono), kMod)), kScanModes - 1); + CHECK_EQ(int(kit_param_max(uint8_t(MachineId::wave_poly), kMod)), kScanModes - 1); + // KICK's TAP shares the slot and is a level. + CHECK_EQ(int(kit_param_max(uint8_t(MachineId::kick), kMod)), 127); CHECK_EQ(int(kit_param_max(kSpd)), 127); const char *const names[kScanModes] = {"OFF", "FWD", "REV", "LOOP", "LREV", "PING", "RET", "SINE", "RAND", "DRFT"}; From 53eca0163f990c19b77169f0639c432e66eca332 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 17:27:20 +0000 Subject: [PATCH 2/3] fm4: modulator waves on a ninth page, OPS (synthesis review item 11) WAV, the SCN page's first slot on FM4, gives operators 2 and 4 the sine or one of three variants of it read from a table of the same size: SIN2 (sin x |sin|, odd harmonics), HALF (the upper half, even harmonics) and DBL (one cycle at double speed, then nothing). The carrier pair stays sine. The loop takes a second table pointer and is otherwise unchanged; SIN is bit-exact, so the golden renders stand. The tables carry no DC (operators 2 and 4 are heard on A6-A8). A table is not band-limited, so fm_index_cap counts a waved modulator as 3, 4 or 8 times its frequency wide, and a note whose modulators times that would pass half the rate reads the sine, chosen at the note's start or when WAV moves. Fold-over under 5 kHz stays 42 dB or more under the loudest partial on eleven presets, C2 to C7, where the sine's own worst is 41.5. WAV is a number, 0-3 (kit_param_max by machine). KIT.BIN's generation byte goes to 2: an FM4 track from before WAV opens on SIN, whatever the slot held. Presets REED, HORN, TINE; every other FM4 preset writes SIN. New scenario_fmwave (scenario_fm with WAV on DBL), W122. cl6x not measured: the emulator runs on Roland's PC. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Tw2EaFHmBTuHT9xVLai85a --- CHANGELOG.md | 5 ++ app/app.hpp | 3 + app/ui_editview.hpp | 7 ++ app/ui_mixer.hpp | 4 ++ core/help.cpp | 10 +++ core/project.cpp | 18 ++++- core/project.hpp | 16 +++-- core/sounds.cpp | 16 ++++- docs/BUDGET.md | 8 +++ docs/CHEATSHEET.md | 8 +-- docs/DESIGN_NOTES.md | 26 ++++++++ docs/FEATURES.md | 1 + docs/MANUAL.md | 21 +++++- docs/UNIT_CHECKLIST.md | 14 ++++ dsp/fm.cpp | 67 ++++++++++++++++--- dsp/fm.hpp | 41 +++++++++++- dsp/fmloops.h | 4 +- dsp/fmloops.ti.c | 10 +-- dsp/fmpoly.cpp | 1 + tests/scenario_fmwave.sh | 120 +++++++++++++++++++++++++++++++++ tests/test_engine.cpp | 6 ++ tests/test_fm.cpp | 135 ++++++++++++++++++++++++++++++++++++++ tests/test_fm_machine.cpp | 5 +- tests/test_golden.cpp | 1 + tests/test_help.cpp | 5 ++ tests/test_project.cpp | 49 ++++++++++++-- tests/test_sounds.cpp | 16 +++++ tests/test_ui.cpp | 38 +++++++++++ 28 files changed, 619 insertions(+), 36 deletions(-) create mode 100755 tests/scenario_fmwave.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d39a335..60915721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ the project file format or the controls. ### Added +- **FM4: modulator waves, the OPS page.** FM4's ninth EDIT page has WAV, the wave of the + modulator pair: `SIN` (FM as it was), `SIN2` (hollow, odd harmonics), `HALF` (warm, even + harmonics) and `DBL` (glassy). Three of the waves the classic 4-operator synths had beside + the sine. No CPU cost. Three new sounds: REED, HORN and TINE. A project from before it opens + on `SIN`. - **PERC: a noise layer, the NOIS page.** PERC's seventh EDIT page has NSE (noise mix), NDC (the noise's own decay) and NCL (its colour, 400 Hz to 12 kHz): shakers, brushes and the stick's snap on a tom from the FM machine. NSE 0 is PERC as it was. Three new sounds: SHAKER, diff --git a/app/app.hpp b/app/app.hpp index a972a509..e29ba254 100644 --- a/app/app.hpp +++ b/app/app.hpp @@ -576,6 +576,7 @@ const char *page_name_on(Page page, uint8_t machine) { if (machine_is_perc(machine) && page == Page::asr) return "NOIS"; if (machine_is_kick(machine) && page == Page::osc) return "TAIL"; if (machine_is_kick(machine) && page == Page::scn) return "TAPS"; + if (machine_is_fm(machine) && page == Page::scn) return "OPS"; return page_name(page); } // KICK's PNCH page's encoder names. @@ -587,6 +588,8 @@ constexpr const char *kHatCymNames[kAsrParams] = {"TLV", "TDC", "THP", "OPN"}; constexpr const char *kPercNoiseNames[kAsrParams] = {"NSE", "NDC", "NCL", "---"}; // And its TAPS page's (the SCN slots). constexpr const char *kKickTapNames[kScnParams] = {"TAP", "TDV", "TFB", "TDC"}; +// FM4's OPS page's (the SCN slots too): the modulator pair's wave (dsp/fm.hpp); three are free. +constexpr const char *kFmOpsNames[kScnParams] = {"WAV", "---", "---", "---"}; // The ASR page's encoder names (dsp/va.cpp's table). Only the VAs read the page; on any other // machine its four slots show "---". diff --git a/app/ui_editview.hpp b/app/ui_editview.hpp index f0071486..58a9554d 100644 --- a/app/ui_editview.hpp +++ b/app/ui_editview.hpp @@ -477,6 +477,13 @@ if (machine_is_kick(id)) { add("TAP GHOST HITS"); add("TDV EVERY 1/16 ..."); + } else if (machine_is_fm(id)) { + switch (fm_wave(kit.v[kScnFirst])) { + case 0: add("WAV MODULATORS SINE"); break; + case 1: add("SIN2 HOLLOW: REEDS"); break; + case 2: add("HALF NASAL: BRASS"); break; + default: add("DBL GLASSY: METAL"); break; + } } else if (!machine_reads_scn(id)) { add("NOT ON THIS MACHINE"); } else if (va_scan_mode(kit.v[kScnFirst]) == ScanMode::off) { diff --git a/app/ui_mixer.hpp b/app/ui_mixer.hpp index 7bf73c5e..c6f229b0 100644 --- a/app/ui_mixer.hpp +++ b/app/ui_mixer.hpp @@ -442,6 +442,7 @@ if (!track_param_real(index)) return "---"; if (index >= kScnFirst) { if (machine_is_kick(engine_.machine_id(track))) return kKickTapNames[index - kScnFirst]; + if (machine_is_fm(engine_.machine_id(track))) return kFmOpsNames[index - kScnFirst]; if (!machine_reads_scn(engine_.machine_id(track))) return "---"; return kScnNames[index - kScnFirst]; } @@ -631,6 +632,9 @@ case kOscFirst + 3: append_ratio(out, fm_carrier_ratio(value)); return true; + case kScnFirst + 0: + append(out, fm_wave_name(fm_wave(value))); + return true; default: return false; } diff --git a/core/help.cpp b/core/help.cpp index 84fdf929..cd54363b 100644 --- a/core/help.cpp +++ b/core/help.cpp @@ -784,6 +784,14 @@ void knob_rows(const HelpPlace &place, bool slc_auto, char rows[kHelpRows][kHelp add_row(rows, count, "TAP 0 NONE"); break; } + if (machine_is_fm(place.machine)) { + add_row(rows, count, "WAV: OPS 2 AND 4"); + add_row(rows, count, "SIN PLAIN FM"); + add_row(rows, count, "SIN2 HOLLOW ODD"); + add_row(rows, count, "HALF NASAL EVEN"); + add_row(rows, count, "DBL GLASSY"); + break; + } add_row(rows, count, "POS TO END EACH NOTE"); add_row(rows, count, "MOD OFF FWD REV LOOP"); add_row(rows, count, "LREV PING RET SINE"); @@ -818,6 +826,7 @@ void edit_title(const char *screen, const HelpPlace &place, char title[kHelpChar : page == 6 && machine_is_perc(place.machine) ? "NOIS" : page == 7 && machine_is_kick(place.machine) ? "TAIL" : page == kScanHelpPage && machine_is_kick(place.machine) ? "TAPS" + : page == kScanHelpPage && machine_is_fm(place.machine) ? "OPS" : kEditPageNames[page]; Line(title).add(screen).add(" ").add(name).add(" ").add(machine_name(place.machine)); } @@ -1067,6 +1076,7 @@ const char *help_param_words(uint8_t machine, int index) { static const char *const taps[4] = {"GHOST HITS", "DIVISION", "EACH TO NEXT", "GHOST LENGTH"}; return taps[slot]; } + if (machine_is_fm(machine)) return slot == 0 ? "MODULATOR WAVE" : ""; return machine_reads_scn(machine) ? kScnWords[slot] : ""; default: return ""; } diff --git a/core/project.cpp b/core/project.cpp index 3910665b..e754bacc 100644 --- a/core/project.cpp +++ b/core/project.cpp @@ -74,8 +74,9 @@ // slap (id 17), 8 x 4 bytes: KitTrack::slap, slap_time, slap_feedback, slap_tone (absent: // off, the defaults) // lfo slow (id 18), 8 x 1 byte: KitTrack::lfo_slow, 0-2 (absent: x1); then one byte, the -// drum pages' generation (kKitDrumPagesPerc: PERC's NOIS page is real). A section that -// stops before it is a kit from before NOIS, whose PERC tracks open with it at 0 +// machine pages' generation: 1 (kKitDrumPagesPerc) PERC's NOIS page is real, 2 +// (kKitPagesFmWave) FM4's WAV too. A section that stops before it is a kit from before +// NOIS; a kit below a page's generation opens with that page at 0 // zones (id 19), only in a kit that has zones, variable length: the track count (8), the // record size (126), then per track a zone count 0-16 and its 126-byte records (path, // START, END, LVL, TUN, MODE, CHK, GAIN, FLAGS; core/project.hpp, kSectionKitZones). @@ -461,6 +462,10 @@ constexpr uint32_t kKitLfoSlowBytes = uint32_t(kTracks); // writer that knows NOIS says so here, and a reader zeroes the three on a kit that does not. constexpr uint32_t kKitDrumPagesBytes = 1; constexpr uint8_t kKitDrumPagesPerc = 1; +// 2: FM4 reads the SCN page's first slot as WAV (2026-11-30). The same story: an FM4 track that +// was once a WAVE track can hold a scan mode there, which would now pick a wave. +constexpr uint8_t kKitPagesFmWave = 2; +constexpr uint8_t kKitPagesWritten = kKitPagesFmWave; constexpr uint32_t kKitLfoSlowWritten = kKitLfoSlowBytes + kKitDrumPagesBytes; constexpr uint32_t kKitLfoSlowOffset = kKitSlapOffset + kKitSlapBytes; constexpr uint32_t kKitTotalBytes = kHeaderBytes + kKitLfoSlowOffset + kKitLfoSlowWritten; @@ -1169,7 +1174,7 @@ SerializeResult kit_write(const Kit &kit, uint8_t *buffer, uint32_t capacity, ui w.u8(slap_sanitized(track.slap_tone)); } for (int t = 0; t < kTracks; t++) w.u8(lfo_slow_sanitized(kit.tracks[t].lfo_slow)); - w.u8(kKitDrumPagesPerc); + w.u8(kKitPagesWritten); if (zones_bytes != 0) { w.u8(uint8_t(kTracks)); @@ -1616,6 +1621,13 @@ SerializeResult kit_read(Kit &kit, const uint8_t *buffer, uint32_t size) { for (int p = kKitArpEnd; p < kKitAsrEnd; p++) track.params[p] = 0; } } + // And one from before FM4's WAV: the sine, the machine as that kit played it. + if (drum_pages < kKitPagesFmWave) { + for (int t = 0; t < kTracks; t++) { + KitTrack &track = kit.tracks[t]; + if (machine_is_fm(track.machine)) track.params[kKitScnFirst] = 0; + } + } return SerializeResult::ok; } diff --git a/core/project.hpp b/core/project.hpp index b44832b7..8ff52410 100644 --- a/core/project.hpp +++ b/core/project.hpp @@ -283,15 +283,23 @@ constexpr bool machine_is_wave(uint8_t id) { constexpr bool machine_reads_scn(uint8_t id) { return machine_is_wave(id); } // Does this machine have the page at all, as the scan or as KICK's TAPS (dsp/kick.hpp)? What // shows, names, saves and presets the page's bytes asks here. -constexpr bool machine_has_scn_page(uint8_t id) { return machine_reads_scn(id) || machine_is_kick(id); } +// FM4's is OPS, with one knob so far: WAV, the modulator pair's wave (dsp/fm.hpp). +constexpr bool machine_has_scn_page(uint8_t id) { + return machine_reads_scn(id) || machine_is_kick(id) || id == uint8_t(MachineId::fm); +} +// FM4's WAV is a number like SCN's MOD, in the same slot: SIN SIN2 HALF DBL. +constexpr int kKitFmWaves = 4; // static_asserted in dsp/fm.hpp +constexpr uint8_t kKitFmWaveMax = uint8_t(kKitFmWaves - 1); // The highest value a parameter byte may hold on this machine: kit_param_max(index), and SCN's -// MOD stops at its last mode on the machines that scan. Knobs, the kit's reader and a loaded +// MOD stops at its last mode on the machines that scan, as FM4's WAV does at its last wave. Knobs, the kit's reader and a loaded // sound clamp to it, so a knob does not wind past the last mode. KICK's TAP shares the slot and // is a level, 0-127: until 2026-11-30 every machine stopped at 9 there, which held TAP at 7%. constexpr uint8_t kit_param_max(uint8_t machine, int index) { - return index == kKitScanModeIndex && machine_reads_scn(machine) ? kKitScanModeMax - : kit_param_max(index); + return index != kKitScanModeIndex ? kit_param_max(index) + : machine_reads_scn(machine) ? kKitScanModeMax + : machine == uint8_t(MachineId::fm) ? kKitFmWaveMax + : kit_param_max(index); } // FM4: four sine operators in one of eight algorithms (dsp/fm.hpp). diff --git a/core/sounds.cpp b/core/sounds.cpp index 7bb08e42..8ecb70e6 100644 --- a/core/sounds.cpp +++ b/core/sounds.cpp @@ -510,6 +510,16 @@ constexpr SoundPreset kFmPresets[] = { // A drone: three carriers over one modulator, a slow swell, the index held, feedback for // breath. Long notes. {"DRONE", {88, 40, 50, 40}, FLAT, {100, 30, 30, 72}, {60, 120, 100, 90}, {50, 70, 30, 13}}, + // The modulator waves (WAV, the last four bytes' first; 2026-11-30). A reed: two pairs at + // 1:1 with SIN2, whose odd harmonics make the hollow tone of a clarinet or a reed organ. Held. + {"REED", {72, 24, 62, 20}, FLAT, {80, 60, 60, 72}, {10, 100, 30, 80}, {20, 64, 40, 13}, + {1, 0, 0, 0}}, + // A horn: BRASS's algorithm with HALF, whose even harmonics are the nasal part of a brass + // tone. HALF's first harmonic is half the sine's, so the same IDX is mellower: IDX is up. + {"HORN", {40, 24, 90, 40}, FLAT, {80, 90, 60, 59}, {45, 100, 35, 85}, {15, 64, 40, 13}, + {2, 0, 0, 0}}, + // A tine: two pairs at 1:1 with DBL, glassy from the first turn of IDX, ringing. + {"TINE", {72, 24, 45, 0}, FLAT, {100, 120, 90, 71}, NO_ASR, {25, 64, 50, 13}, {3, 0, 0, 0}}, }; // --- GRAIN: POS SIZ DEN SPR / PIT SHP DEC LVL / ATK SUS REL --- / SCN PSP (dsp/grain.cpp) ---- @@ -608,8 +618,10 @@ uint64_t sound_preset_writes(uint8_t machine) { case MachineId::perc: return kSrcFltrAmp | kDrumPageBits; // NOIS (dsp/perc.hpp) case MachineId::hat: return (kSrcFltrAmp | kDrumPageBits) & ~(uint64_t(1) << kHatChoke); case MachineId::va_mono: - case MachineId::va_poly: - case MachineId::fm: return kSrcFltrAmp | kAsrBits | kOscBits; + case MachineId::va_poly: return kSrcFltrAmp | kAsrBits | kOscBits; + // And WAV, the first of the SCN slots (dsp/fm.hpp); its other three are not read. + case MachineId::fm: + return kSrcFltrAmp | kAsrBits | kOscBits | (uint64_t(1) << kSoundScnFirst); case MachineId::wave_mono: case MachineId::wave_poly: return kSrcFltrAmp | kAsrBits | kOscBits | kScnBits; case MachineId::grain: diff --git a/docs/BUDGET.md b/docs/BUDGET.md index 2b0ea053..f167e7cb 100644 --- a/docs/BUDGET.md +++ b/docs/BUDGET.md @@ -310,6 +310,14 @@ No audio cost: SLOW multiplies a synced cycle's ticks or divides a free rate onc LFO's settings are made (`LfoSettings::make`), and the LFO then steps once a block as before. `scenario_lfoslow` checks the pushes and the page on the C674x; its peak is the factory beat's. +### FM4's WAV (2026-11-30) + +WAV changes which table operators 2 and 4 read: `strata_fm_add` and `strata_fm_add_free` take a +second table pointer and are otherwise the loops they were, and the choice of table is made at +control rate. No cost is expected. `scenario_fmwave` is `scenario_fm` with WAV on DBL. +**Not measured yet**: cl6x and the emulator run on Roland's PC; the cl6x listing of the two +loops should be compared with the one before (`tools/ti_loops.py`). + ### PERC's NOIS (2026-11-30) The noise layer is, a sounding voice, a block of `enaga_noise_add`, one envelope render, one diff --git a/docs/CHEATSHEET.md b/docs/CHEATSHEET.md index 73aab820..234e4498 100644 --- a/docs/CHEATSHEET.md +++ b/docs/CHEATSHEET.md @@ -39,7 +39,7 @@ pads and the performance mixer. | GRID | HOME (from anywhere) | All 8 tracks; STEP keys edit the selected track | | KEYS | HOME twice quickly (double-tap) | The pads are a piano (lower white, upper black keys), the STEP keys steps, on the selected track | | FUNC menu | FUNC+HOME ("system") | The project-wide rows: save, JAM REC, ARR REC, click, count-in, REC MODE, quantize, auto-fill, FX glide, TRANSPOSE (scale or semitones), loop length, chain, song, ARR UNDO, PROG CHG OUT, TEMPO GUARD, save as, open, kits, new, reload, clear pattern, load demo, GEN ALL (a part on every unmuted track, one undo level) | -| EDIT | EDIT | The selected track's sound: pages SRC, FLTR, AMP, FX, LFO, ARP, and on the VA, WAVE, FM4 and GRAIN machines ENV and OSC, and SCAN on the WAVE machines | +| EDIT | EDIT | The selected track's sound: pages SRC, FLTR, AMP, FX, LFO, ARP, and on the VA, WAVE, FM4 and GRAIN machines ENV and OSC, SCAN on the WAVE machines and OPS on FM4 | | MACHINE | FUNC+EDIT | Pick the machine on each track, and its MIDI OUT channel | | KIT | FUNC+EDIT twice, or the menu's KITS | Save and recall whole kits: 16 slots on the card, shared by all projects | | SAMPLES | FUNC+PROJECT ("pool"), or OK in EDIT or MACHINE on a SMP track, OK in MACHINE on a GRN track | Pick the track's WAV from `/SAMPLES` or `/RECORD`; FUNC+OK adds it as the track's next zone (SMP) | @@ -370,7 +370,7 @@ every pattern change sends its number 0-127 as a program change on your MIDI CH. **Machines:** KCK kick · SNR snare · HAT hat · PRC 2-op FM percussion · SMP sampler · GRN granular · MNO VA mono · PLY VA poly · WMN wavetable mono · WPL wavetable poly · FM4 four-operator FM. -**EDIT pages:** SRC source · FLTR filter (the insert chain's; on the VA and WAVE machines the voice's own) · AMP amplitude · FX effects (insert chain) · LFO the track's LFO · ARP its arpeggiator · ENV held notes and OSC oscillators (VA, WAVE, FM4 and GRAIN machines) · SCAN the wavetable scan (WAVE machines). +**EDIT pages:** SRC source · FLTR filter (the insert chain's; on the VA and WAVE machines the voice's own) · AMP amplitude · FX effects (insert chain) · LFO the track's LFO · ARP its arpeggiator · ENV held notes and OSC oscillators (VA, WAVE, FM4 and GRAIN machines) · SCAN the wavetable scan (WAVE machines) · OPS the modulators' wave (FM4). **LFO page:** WAV shape SIN TRI RMP (rising) SAW (falling) SQR S+H · RAT rate, `0.06`-`32` Hz free on the lower half, `8B` (bars) to `1/32` synced on the upper (`.` dotted, `T` triplet) · DEP depth, 127 = about 64 either side (about 3 octaves on a cutoff, never under ~100 Hz) · DST the parameter it moves, or OFF. Lockable, scene- and macro-able like any parameter. **Push B = TRIG:** FREE, RETRIG (each note restarts it), ONE-SHOT (each note runs one cycle: TRI attack-decay, SAW decay, RMP rise and hold, SQR gate, S+H per note). On VA and WAVE an LFO on TUN glides. **Push C / D = MOD slot 1 / 2:** push again for the source (LFO, ENV = the LFO's shape once per note, VEL, PRS = pad pressure, RND = random per note, OFF), turn any knob of the track for the depth, OK. A dim line under a bar is a slot's range. **ENV page (VA and WAVE machines; FM4's is below):** ATK attack `3MS`-`5.0S` · SUS sustain `0%` (one-shot: DEC is the length) to `100%` · REL release `60MS`-`8.0S` · FSU filter sustain (0 = the sweep closes, up = stays open). SUS up: a note holds while the pad or key is held, or for the step's LEN (MONO counts LEN only then). Pad: SUS 70%, ATK 400MS, REL 2.0S, chord step LEN 16 STP. REC records how long a held note was held as its step's LEN. **OSC page (VA MONO, VA POLY):** WAV `SAW` (0-31), `SQR` (32) to `P08` (127, a thin pulse) · OS2 `OFF` (0), `D0`-`D60` a detuned second saw in cents (1-63: chorus to Reese), `S+0`-`S+24` a pulse synced to OSC 1 (64-127: the sync sweep) · SUB the sub an octave down (0 = off) · DRV drive into the filter, thicker and dirtier, not louder. RES (SRC) self-oscillates near the top. @@ -379,7 +379,7 @@ MNO VA mono · PLY VA poly · WMN wavetable mono · WPL wavetable poly · FM4 fo **SCAN page (WAVE MONO, WAVE POLY):** moves the position from POS towards END with each note. MOD `OFF` `FWD` (once, holds) `REV` (from END, once) `LOOP` `LREV` (looped backwards) `PING` (there and back) `RET` (there and back once) `SINE` (eased there and back) `RAND` (a random frame a cycle) `DRFT` (glides to a random frame a cycle) · SPD the LFO's RAT: 0-63 free (28 = 1 Hz), 64-127 synced (96 ticks = a beat) · END frame 0-15 as POS · CRV `LIN` at 64, `+n` slow start, `-n` fast start. -**FM4 pages:** ENV = ATK SUS REL ISU (index sustain). OSC = DET `OFF`/`D1`-`D25` the second pair sharp · FIN fine ratio, `0` at 64 · BRT index keytrack · CAR carrier ratio 1 0.5 2 3 4. +**FM4 pages:** ENV = ATK SUS REL ISU (index sustain). OSC = DET `OFF`/`D1`-`D25` the second pair sharp · FIN fine ratio, `0` at 64 · BRT index keytrack · CAR carrier ratio 1 0.5 2 3 4. OPS (the ninth page) = WAV the modulators' wave: `SIN` plain FM · `SIN2` hollow, odd harmonics · `HALF` warm, even harmonics · `DBL` glassy. **SECTION (CHAIN, push A):** SECT = PAT pattern · REP repeats · MUT mute state (`--`, M1-M8, CAP an exact mask) · SCN scene on side B. MOVE = MRP morph move (SNAP, RIDE, BACK, SNAP A) · NRG ENERGY · BPM tempo · TRN TRANSPOSE. KIT = A song kit K1-K8 (KIT_1..8.BIN in the project folder), recalled on the entry's first beat; `KIT LATE` when it was read too late. @@ -397,7 +397,7 @@ MNO VA mono · PLY VA poly · WMN wavetable mono · WPL wavetable poly · FM4 fo | PLY | TUN, MOD, TON; FLTR: CUT, RES, ENV, FDE | DEC, -, DET detune, LVL (ENV page: ATK SUS REL FSU) | | WMN | TBL table (CLS PWM SYN FMT RSW HRM FLD PHD FM1 TIN DGT VOW GRL EPN PLK MLT), POS position, TON; FLTR: CUT (LP24), RES, ENV, FDE | DEC, -, MOT envelope to position (`OFF` at 64, `+15`/`-15`), LVL (ENV, OSC and SCAN pages) | | WPL | TBL, POS, TON; FLTR: CUT, RES, ENV, FDE | DEC, -, MOT, LVL (ENV, OSC and SCAN pages; chords, shares the 12 POLY voices) | -| FM4 | ALG algorithm `A1`-`A8`, RAT modulator ratio, IDX index, FBK feedback | DEC, IEN index envelope, VEL velocity to index, LVL (ENV and OSC pages; chords, shares the 12 POLY voices) | +| FM4 | ALG algorithm `A1`-`A8`, RAT modulator ratio, IDX index, FBK feedback | DEC, IEN index envelope, VEL velocity to index, LVL (ENV, OSC and OPS pages; chords, shares the 12 POLY voices) | **Insert chain (every track):** FLTR = DRV drive, CUT cutoff, RES resonance, MOD filter mode (OFF LP12 LP24 BP12 BP24 HP12 HP24). On MNO, PLY, WMN and WPL it is one knob, TON on SRC (64 flat, diff --git a/docs/DESIGN_NOTES.md b/docs/DESIGN_NOTES.md index 580aed61..93958eec 100644 --- a/docs/DESIGN_NOTES.md +++ b/docs/DESIGN_NOTES.md @@ -786,3 +786,29 @@ drum bus clip (their fold-over is at -40 dB or lower). LFO SLOW's section (the drum pages' generation, 1); `kit_read` zeroes a PERC track's four ASR bytes when the section stops before it or holds less. KIT.BIN is 1,615 bytes. Scenes, locks and user sounds are not cleared, as with CLAP and CYM. + +- **FM4's OPS page: modulator waves (item 11).** The 4-operator synths FM4's algorithms come + from got much of their character from operator waves beside the sine, each a variant of it + read from the same table. FM4 takes three: SIN2 (sin x |sin|, odd harmonics), HALF (the upper + half, even harmonics) and DBL (one cycle at double speed in the first half, harmonics 1 to 3 + about level). WAV sets the wave of the modulator pair, operators 2 and 4, with the knob pair + RAT and FIN; the carrier pair stays sine, so IDX 0 is a pure tone on the algorithms where 2 + and 4 only modulate. One knob for the pair, not one an operator: the machine has two ratio + knobs for four operators for the same reason. The loop reads a second table through a second + pointer (`strata_fm_block::wave`) and is otherwise the loop it was; SIN is bit-exact. + **DC.** HALF has a mean of 1/pi, which the table leaves out: as a modulator it is a fixed + phase offset, but on A6 to A8 operator 2 or 4 is heard, and a DC step under the envelope + thumps. **Fold-over.** A table is not band-limited. Two guards: `fm_index_cap` counts a + modulator with a wave as 3 (SIN2), 4 (HALF) or 8 (DBL) times its frequency wide, and a note + whose modulators times that would pass half the rate reads the sine (chosen at the note's + start or when WAV moves, so VariSpeed cannot swap the table under a ringing note). Measured + on eleven presets with each wave, a held note an octave from C2 to C7 + (synthesis-review/probe/fmwave.py): the strongest fold under 5 kHz stays 42 dB or more under + the loudest partial, where the sine's own worst is 41.5; without the guards DBL reached + -36 dB on BELL at C6. + **The slot.** The SCN page's first slot, a number 0-3 as SCN's MOD is 0-9 + (`kit_param_max(machine, index)`). The other three slots stay free. **The file.** An FM4 track + that was once a WAVE track can hold a scan mode there, so the generation byte on LFO SLOW's + section goes to 2 and `kit_read` puts an FM4 track's slot at 0 below that. No byte is added. + **KICK's TAP.** The same slot is TAP on KICK, and the limit of 9 was by index alone, so TAP + never passed 7%: the limit takes the machine. diff --git a/docs/FEATURES.md b/docs/FEATURES.md index cb40ebe2..7b4550be 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -120,6 +120,7 @@ FM4 and GRAIN machines. | **Synth presets re-voiced** against RY Oblivion's loops and one-shots (2026-11-29): 23 sounds on VA MONO/POLY, WAVE MONO/POLY and FM4; basses high-pass the sub's rumble (TON) and gain drive and top | #280 | ○ (W92) | Scored by octave bands, not by ear: the A/B renders are the judge. A few WAVE MONO basses at LVL 127 are 1-2 dB under their old level | | **Synthesis review pass** (2026-11-30): the VA POLY and WAVE POLY filter follows the keys above middle C (0.75 octave per octave); FM4 feedback averages two samples (no tone at half the sample rate), FM4 velocity and accent reach the level; KICK TAPS ghosts start at zero phase | #303 | ○ (W111) | Key tracking is a fixed amount, not a knob (the OSC page is full). FM4 notes at velocity 127 are 1.5 dB louder than they were. Worst case 47.74% with cl6x after it (docs/BUDGET.md) | | **Synthesis review, the taste calls** (2026-11-30): VA MONO's filter saturates (the resonant stage's state through the soft clip, every sample); HAT's six squares are band-limited; SNARE's body starts 35% sharp and settles in 6 ms | #307 | ○ (W117) | Fixed amounts, no knobs. ACID is about 1 dB quieter. 0.55 to 0.82 points with cl6x; GCC-only `stack` trips the CPU guard (docs/BUDGET.md) | +| **FM4's OPS page: modulator waves** (2026-11-30, synthesis review item 11): WAV on EDIT's ninth page gives operators 2 and 4 the sine or one of three variants of it, SIN2 (odd harmonics), HALF (even), DBL (the first three about level); the carriers stay sines; presets REED, HORN, TINE | Unreleased | ○ (W122) | The SCN page's first slot, a number 0-3. KIT.BIN's generation byte goes to 2, so a kit from before WAV opens on SIN; scenes, locks and user sounds are not cleared. A note whose wave would fold past half the rate plays the sine. Same loop, a second table pointer: cost not yet measured with cl6x (`scenario_fmwave` against `scenario_fm`) | | **PERC's NOIS page** (2026-11-30, synthesis review item 12): a noise layer beside the FM pair on the ASR page's slots: NSE mix (0 off, 64 noise under the full pair, 127 noise alone), NDC its own decay (3-800 ms, HOLD), NCL a band-pass 400 Hz-12 kHz; presets SHAKER, BRUSH, SNPTOM | Unreleased | ○ (W121) | KIT.BIN's LFO SLOW section grew one byte (the drum pages' generation), so a kit from before NOIS opens with it at 0; scenes, locks and user sounds are not cleared. Cost not yet measured with cl6x (`scenario_nois`) | | **GRAIN in stereo** (2026-11-30, synthesis review item 6): with the track's WID up each grain is born at its own place (sides in turn, 35-100% of the knob's reach) and the cloud renders as a pair into the stereo insert chain | Unreleased | ○ (W120) | One zone, no unison. A stereo sample is still summed. The same grains at any WID; WID 0 is bit-exact mono. Replaces the highs widening on GRAIN tracks. Cost not yet measured with cl6x (`scenario_grainwide`) | | MID: plays an outboard synth over MIDI; SRC/AMP knobs send CC 74/71/73/72, 70/75/76/77 | v0.1.0 | ○ (8d) | No sound or CPU of its own; no scale fold | diff --git a/docs/MANUAL.md b/docs/MANUAL.md index c8ffd4c0..c09b271c 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -99,7 +99,7 @@ arpeggiator stay as they were, and so does a MID track's page. Every track has **16 parameters on four pages** of four, one parameter per encoder A-D, then a fifth and a sixth page for its LFO and its arpeggiator (below). The VA, WAVE and FM4 machines add a -seventh and an eighth, ENV and OSC. +seventh and an eighth, ENV and OSC, and FM4 a ninth, OPS. - **SRC** and **AMP** belong to the machine and change meaning with it (section 3). - **FLTR** and **FX** belong to the insert chain: FLTR = DRV drive, CUT cutoff, RES resonance, @@ -1130,6 +1130,7 @@ and mellows as it rings (**IEN** says how much). | AMP | **DEC** decay, 15 ms to 8 s | **IEN** how much of IDX the index envelope moves (0 = a fixed timbre) | **VEL** velocity to index: harder is brighter (velocity always reaches the level) | **LVL** | | ENV | **ATK** | **SUS** (0 = one-shot) | **REL** | **ISU** index sustain: where the brightness settles while held | | OSC | **DET** second pair sharp: `OFF`, up to `D25` cents | **FIN** fine ratio, ±0.5 around RAT (`0` at 64) | **BRT** keytrack: high notes get less index, so they stay sweet | **CAR** carrier ratio: 1, 0.5, 2, 3, 4 | +| OPS | **WAV** the modulators' wave: `SIN`, `SIN2`, `HALF`, `DBL` | `---` | `---` | `---` | The algorithms: `A1` one stack 4>3>2>1 (the brightest), `A2` 3 and 4 into 2 into 1, `A3` 3>2>1 with 4 into 1, `A4` 4>3>1 with 2 into 1, `A5` two pairs 2>1 and 4>3 (the e-piano), `A6` 4 into @@ -1137,6 +1138,22 @@ three carriers, `A7` one pair 4>3 over two plain sines, `A8` four sines (an orga second drawbar). The SOUNDS list has EPIANO, BELL, BASS, BRASS, ORGAN, MALLET, PAD and GLASS. FBK costs a little more CPU than FBK 0. +**OPS** (the ninth EDIT page) gives the modulator pair, operators 2 and 4, a wave other than the +sine. The carriers stay sines, so IDX at 0 is still a pure tone and the wave is heard as IDX +comes up: + +- `SIN` is plain FM. +- `SIN2` (the sine times its own size) has odd harmonics: hollow. Reeds and clavs. +- `HALF` (the sine's upper half, then nothing) has even harmonics: nasal, and mellower than the + sine at the same IDX. Brass and organs. +- `DBL` (one cycle at double speed, then nothing) has its first three harmonics about level: + glassy and metallic from the first turn of IDX. + +On `A6`, `A7` and `A8` operator 2 or 4 plays straight out, so there the wave is heard as itself: +on `A8`, the organ, WAV is another drawbar. WAV costs no CPU. On very high notes at high RAT a +wave's own harmonics would fold back, so those notes play the sine. The sounds REED (`SIN2`), +HORN (`HALF`) and TINE (`DBL`) start from each wave; every other sound sets `SIN`. + High notes at high IDX are held back so they stay clean: in a stack the sidebands multiply, and past a point they would fold back as harsh, out-of-tune tones. The cap looks at the whole chain of operators, so `A1` at IDX 90 is a little less bright on high notes than its number suggests, @@ -1239,7 +1256,7 @@ and VA POLY's held PAD, STRING and SWELL under the stabs. | PLY | STAB (the factory stab), PAD (A05's pad), STRING, KEYS, RAVE (best with 5TH OCT chords), PLUCK, BRASS, DUBCHD (darker, longer dub chord), WARM (a warm pad), SWELL (opens as it swells), HOOVER (wide driven rave chord), ORGAN, TSTAB (the techno stab: one saw a voice, no sub, bright, high-passed off the bass) | | WMN | SWEEP, RESO (a resonant sweep), GROWL, FORMNT (formant), DIGI (digital), VOWEL, WARP, FMBASS (FM bass), ACIDWV (acid on a wavetable), HARMBS (harmonics bass), FOLD (fold lead), TINE (a bell pluck) | | WPL | PAD, EPIANO (electric piano), BELL, MALLET, PLUCK, CHOIR, PWMPAD (a PWM pad), GLASS (a crystalline pad), DIGPAD (digital pad), RESOPD (a resonant pad), STAB (a warm dub stab), VOXSTB (a vowel stab) | -| FM4 | EPIANO, BELL, BASS, BRASS, ORGAN, MALLET, PAD, GLASS, BLIP (the bleep), CHIME (1:14, ringing), DUBSTB (a dub stab), DRONE (held, slow index) | +| FM4 | EPIANO, BELL, BASS, BRASS, ORGAN, MALLET, PAD, GLASS, BLIP (the bleep), CHIME (1:14, ringing), DUBSTB (a dub stab), DRONE (held, slow index), REED (hollow, held), HORN (nasal, held), TINE (glassy, ringing) | | GRN | CLOUD (where to start), PAD (swells, holds for LEN), FREEZE (one moment held), SHIMMR (a third of the grains an octave up), DRIFT (a slow scan), STRTCH (half speed, own pitch), STUTTR (gapped plucked grains), CHOPS (short percussive grains for POS locks), HAZE (a dense wide wash), GLITCH (sparse sprayed plucks), TAPE (a worn slow scan) | Most lists are longer than the screen: they scroll as the cursor moves. PAD, STRING, KEYS, BRASS, diff --git a/docs/UNIT_CHECKLIST.md b/docs/UNIT_CHECKLIST.md index 147328ce..d7347148 100644 --- a/docs/UNIT_CHECKLIST.md +++ b/docs/UNIT_CHECKLIST.md @@ -3743,3 +3743,17 @@ NSE NDC NCL. RIM afterwards puts NSE back to `OFF`. `____` - A project saved before this build with a PRC track: opens with NSE `OFF` and sounds as it did. `____` + +**W122. FM4's OPS page and KICK's TAP (5 min).** Track 7 on FM4 (MACHINE), SOUNDS: EPIANO, a +chord pattern playing. EDIT, the ninth page: it reads OPS with WAV `SIN`. +- WAV to `SIN2`, `HALF`, `DBL`: three different tones, each brighter or more hollow than the + sine, at about the same loudness; the knob stops at `DBL`. Back to `SIN`: the e-piano as it + was. `____` +- IDX (SRC) to 0 on any wave: a plain tone, the same on all four. `____` +- SOUNDS: REED, HORN and TINE load and read `SIN2`, `HALF` and `DBL` on OPS; loading BELL + afterwards puts WAV back to `SIN`. `____` +- A project saved before this build with an FM4 track: opens with WAV `SIN` and sounds as it + did. `____` +- CPU with WAV on `DBL` against `SIN` on the same chords (the readout): `____` / `____` +- Track 1 (KCK), EDIT, TAPS: TAP turns past 7% up to 100%, and the ghost hits are clearly heard + from about 40%. `____` diff --git a/dsp/fm.cpp b/dsp/fm.cpp index 56e62794..d8d2b949 100644 --- a/dsp/fm.cpp +++ b/dsp/fm.cpp @@ -68,19 +68,50 @@ uint8_t osc_byte(const uint8_t (&v)[N], int k) { } } +// And the SCN page, whose first slot is WAV (the same guard as osc_byte). +template +uint8_t scn_byte(const uint8_t (&v)[N], int k) { + if constexpr (N >= kScnFirst + 4) { + return v[kScnFirst + k]; + } else { + return 0; + } +} + } // namespace -const float *fm_sine_table() { - static float table[STRATA_FM_SINE_SIZE + 1]; +const float *fm_wave_table(int wave) { + static float table[kFmWaves][STRATA_FM_SINE_SIZE + 1]; static bool filled = false; if (!filled) { + constexpr float kStep = 1.0f / float(STRATA_FM_SINE_SIZE); + constexpr float kHalfMean = 0.31830989f; // 1 / pi: the half sine's DC for (int i = 0; i < STRATA_FM_SINE_SIZE; i++) { - table[i] = enaga::dsp::sin_turns(float(i) * (1.0f / float(STRATA_FM_SINE_SIZE))); + const float sine = enaga::dsp::sin_turns(float(i) * kStep); + const bool first_half = i < STRATA_FM_SINE_SIZE / 2; + table[0][i] = sine; + table[1][i] = sine * (sine < 0.0f ? -sine : sine); + table[2][i] = (first_half ? sine : 0.0f) - kHalfMean; + table[3][i] = first_half ? enaga::dsp::sin_turns(float(2 * i) * kStep) : 0.0f; } - table[STRATA_FM_SINE_SIZE] = table[0]; + for (int w = 0; w < kFmWaves; w++) table[w][STRATA_FM_SINE_SIZE] = table[w][0]; filled = true; } - return table; + return table[wave < 0 ? 0 : (wave < kFmWaves ? wave : kFmWaves - 1)]; +} + +const float *fm_sine_table() { return fm_wave_table(0); } + +float fm_wave_band(int wave) { + static constexpr float kBand[kFmWaves] = {1.0f, 3.0f, 4.0f, 8.0f}; + return kBand[wave < 0 ? 0 : (wave < kFmWaves ? wave : kFmWaves - 1)]; +} + +int fm_wave(uint8_t value) { return value < uint8_t(kFmWaves) ? int(value) : kFmWaves - 1; } + +const char *fm_wave_name(int wave) { + static const char *const names[kFmWaves] = {"SIN", "SIN2", "HALF", "DBL"}; + return names[wave < 0 ? 0 : (wave < kFmWaves ? wave : kFmWaves - 1)]; } namespace { @@ -113,15 +144,20 @@ float fm_band(const Algorithm &a, const float f[4], float b4, float turns) { } // namespace -float fm_index_cap(int algorithm, const float f[4], float feedback, float limit) { +float fm_index_cap(int algorithm, const float f_in[4], float feedback, float limit, + float wave_band) { const Algorithm &a = kAlgorithms[algorithm < 0 ? 0 : algorithm % kFmAlgorithms]; + // The modulator pair's wave: its harmonics are there before any modulation. + const float f[4] = {f_in[0], f_in[1] * wave_band, f_in[2], f_in[3] * wave_band}; // Op 4's own band with its feedback, which is self-modulation of index FBK. const float fb_rad = 6.2831853f * feedback; const float b4 = f[3] * (1.0f + fb_rad + (fb_rad < 1.0f ? fb_rad : 1.0f)); // A modulator past Nyquist cannot be played at all (its increment is clamped, so it would // sound at the wrong frequency): no index. RAT 14 on a high note is the case. const bool mod2 = a.m12 > 0.0f, mod3 = a.m13 + a.m23 > 0.0f, mod4 = a.m14 + a.m24 + a.m34 > 0.0f; - if ((mod2 && f[1] >= 0.45f) || (mod3 && f[2] >= 0.45f) || (mod4 && f[3] >= 0.45f)) return 0.0f; + if ((mod2 && f_in[1] >= 0.45f) || (mod3 && f_in[2] >= 0.45f) || (mod4 && f_in[3] >= 0.45f)) { + return 0.0f; + } if (fm_band(a, f, b4, kIndexMaxTurns) <= limit) return kIndexMaxTurns; if (fm_band(a, f, b4, 0.0f) >= limit) return 0.0f; float lo = 0.0f, hi = kIndexMaxTurns; @@ -147,6 +183,7 @@ FmSettings FmSettings::make(const TrackParams ¶ms, float rate, float inv_rat s.rate = rate; s.inv_rate = inv_rate; s.algorithm = fm_algorithm(params.get(0)); + s.wave = fm_wave(scn_byte(params.v, 0)); const float mod = fm_ratio(params.get(1)) + fm_fine(osc_byte(params.v, 1)); const float car = fm_carrier_ratio(osc_byte(params.v, 3)); @@ -227,6 +264,16 @@ void FmVoice::run(const FmSettings &s, float *out, int n, float *env) { inc = inc < 0.49f ? inc : 0.49f; b.inc[op] = uint32_t(inc * 4294967296.0f); } + // WAV, for this note: a variant whose harmonics would pass half the rate on this note reads + // the sine instead, since a table is not band-limited and they would fold straight back. + // Chosen when the note starts or the knob moves, not every slice, so VariSpeed cannot swap + // the table under a ringing note. + if (fresh_ || s.wave != wave_asked_) { + wave_asked_ = s.wave; + const float top = s.ratio[1] > s.ratio[3] ? s.ratio[1] : s.ratio[3]; + wave_ = base * top * fm_wave_band(s.wave) < 0.5f ? s.wave : 0; + } + b.wave = fm_wave_table(wave_); const Algorithm &a = kAlgorithms[s.algorithm]; b.m12 = a.m12; b.m13 = a.m13; @@ -247,11 +294,13 @@ void FmVoice::run(const FmSettings &s, float *out, int n, float *env) { // An index whose sidebands would fold past Nyquist is capped, for the whole chain at once // (fm_index_cap): every link carries the same index, so one cap holds the algorithm's // balance and only lowers its brightness. Recomputed when the note or a knob moves. - if (pitch != cap_note_ || s.algorithm != cap_algorithm_ || s.feedback != cap_feedback_ || + if (pitch != cap_note_ || s.algorithm != cap_algorithm_ || wave_ != cap_wave_ || + s.feedback != cap_feedback_ || s.inv_rate != cap_inv_rate_ || s.ratio[0] != cap_ratio_[0] || s.ratio[1] != cap_ratio_[1] || s.ratio[2] != cap_ratio_[2] || s.ratio[3] != cap_ratio_[3]) { cap_note_ = pitch; cap_algorithm_ = s.algorithm; + cap_wave_ = wave_; cap_feedback_ = s.feedback; cap_inv_rate_ = s.inv_rate; float f[4]; @@ -259,7 +308,7 @@ void FmVoice::run(const FmSettings &s, float *out, int n, float *env) { cap_ratio_[op] = s.ratio[op]; f[op] = base * s.ratio[op]; } - cap_ = fm_index_cap(s.algorithm, f, s.feedback, kBandLimit); + cap_ = fm_index_cap(s.algorithm, f, s.feedback, kBandLimit, fm_wave_band(wave_)); } float target[3]; for (int m = 0; m < 3; m++) target[m] = clamp(index, 0.0f, cap_); diff --git a/dsp/fm.hpp b/dsp/fm.hpp index 1641c1a7..1bd9c3e3 100644 --- a/dsp/fm.hpp +++ b/dsp/fm.hpp @@ -16,6 +16,22 @@ // AMP DEC decay IEN index envelope VEL velocity>index LVL level // OSC DET pair detune FIN ratio fine BRT index keytrack CAR carrier ratio // ASR ATK attack SUS sustain REL release FSU index sustain +// OPS WAV modulator wave (the SCN slots; the other three are free) +// +// WAV gives the modulator pair one of four waves, the sine and three of the TX81Z's variants of +// it, each a table the size of the sine's (fm_wave_table): +// +// SIN the sine: FM as it always was +// SIN2 sin x |sin|: odd harmonics, the third 14 dB under the first. Hollow: reeds, clavs +// HALF the sine's upper half, then nothing: even harmonics, the second 7 dB under, and a +// first harmonic of half the sine's, so the same IDX is mellower. Nasal: brass, organs +// DBL one cycle at twice the speed, then nothing: the first three harmonics about level. +// Glassy and metallic at low IDX +// +// The carrier pair stays sine, so IDX 0 is still a pure tone -- except where an algorithm plays +// operator 2 or 4 straight out (6, 7 and 8), where the wave is heard as itself: on 8, the organ, +// WAV is a drawbar. The tables have no DC, which would thump on those; as a modulator DC is a +// fixed phase offset and inaudible. // // The index has its own envelope, faster than the amplitude's, because that is what makes FM // percussive: a bright attack that mellows as the note rings (Chowning 1973). IEN says how much @@ -27,12 +43,15 @@ #include #include "fmloops.h" +#include "project.hpp" // kKitFmWaves: WAV is a number #include "track.hpp" namespace strata { constexpr int kFmAlgorithms = 8; constexpr int kFmRatios = 8; +constexpr int kFmWaves = 4; +static_assert(kFmWaves == kKitFmWaves, "WAV's last number is the kit's limit for the slot"); // The knob zones, for the screen as well as for `make`. int fm_algorithm(uint8_t value); // 0..7 @@ -40,10 +59,19 @@ float fm_ratio(uint8_t value); // RAT: 0.5, 1, 2, 3, 3.5, 4, 7, 14 float fm_fine(uint8_t value); // FIN: -0.5..+0.5 added to RAT, 0 at 64 float fm_carrier_ratio(uint8_t value); // CAR: 1, 0.5, 2, 3, 4 float fm_detune_cents(uint8_t value); // DET: 0..25 cents +int fm_wave(uint8_t value); // WAV: a number, 0..kFmWaves - 1; past the last is the last +const char *fm_wave_name(int wave); // "SIN" "SIN2" "HALF" "DBL" // The operators' sine table (fmloops.h), 4 KiB in BSS, filled on the first call. FmPoly::init // and FmVoice::reset call it, so the fill never lands in the audio callback. const float *fm_sine_table(); +// The same for a WAV number: 0 is the sine's own table. All four are filled by the first call of +// either function (16 KiB of BSS together). +const float *fm_wave_table(int wave); +// How many times its own frequency a modulator with this wave reaches, for fm_index_cap: 1 for +// the sine, else about the last harmonic within 30 dB of its first, set by measurement +// (docs/DESIGN_NOTES.md, "FM4's OPS page"). +float fm_wave_band(int wave); // The largest index, in turns, that keeps every carrier's sidebands under `limit` (a fraction // of the sample rate) for this algorithm, these operator frequencies (`f`, fractions of the @@ -51,15 +79,19 @@ const float *fm_sine_table(); // reaches its own frequency plus (I + 1) times the band of each operator modulating it, so in a // stack the bands multiply, which a cap per pair does not see. Control rate, and only when the // note or the settings change (FmVoice caches it): a bisection of 16 steps. -float fm_index_cap(int algorithm, const float f[4], float feedback, float limit); +// `wave_band` is fm_wave_band of the modulator pair's wave: operators 2 and 4 count as that many +// times their frequency wide before any modulation. +float fm_index_cap(int algorithm, const float f[4], float feedback, float limit, + float wave_band = 1.0f); struct FmSettings { - // Reads SRC 0-3, AMP 8-11, the ASR page and the OSC page. Control rate, once per block. + // Reads SRC 0-3, AMP 8-11, the ASR page, the OSC page and the first SCN slot (WAV). Control rate, once per block. static FmSettings make(const TrackParams ¶ms, float rate, float inv_rate); enaga::dsp::EnvelopeShape amp_shape{}; enaga::dsp::EnvelopeShape index_shape{}; // stepped once per control slice int algorithm = 0; + int wave = 0; // WAV, the modulator pair's table float ratio[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float index = 0.0f; // IDX, turns of the target's phase at the envelope's peak float index_env = 0.0f; // IEN, 0-1: the part of the index the envelope moves @@ -109,6 +141,8 @@ class FmVoice { // scratch buffer the caller owns. void run(const FmSettings &s, float *out, int n, float *env); + // For tests: the wave the note reads (WAV, or 0 where its harmonics would fold). + int wave() const { return wave_; } // For tests: the index the last slice ended on, per modulator (operators 2-4). float last_index(int op) const { return op >= 2 && op <= 4 ? index_[op - 2] : 0.0f; } @@ -128,6 +162,9 @@ class FmVoice { float cap_feedback_ = -1.0f; float cap_inv_rate_ = 0.0f; int cap_algorithm_ = -1; + int cap_wave_ = -1; + int wave_ = 0; // the table this note reads: WAV, or the sine where WAV would fold + int wave_asked_ = -1; bool fresh_ = true; // the first slice of a note: no ramp from the last note's index int choke_left_ = 0; float choke_step_ = 0.0f; diff --git a/dsp/fmloops.h b/dsp/fmloops.h index fbbf37b4..28d81cbd 100644 --- a/dsp/fmloops.h +++ b/dsp/fmloops.h @@ -41,7 +41,9 @@ typedef struct { #define STRATA_FM_SINE_SIZE (1 << STRATA_FM_SINE_BITS) typedef struct { - const float *sine; /* STRATA_FM_SINE_SIZE + 1 points */ + const float *sine; /* STRATA_FM_SINE_SIZE + 1 points: operators 1 and 3, the carrier pair */ + const float *wave; /* and operators 2 and 4, the modulator pair: the sine or a variant + * of it, the same size (dsp/fm.hpp, WAV) */ uint32_t inc[4]; /* each operator's increment */ /* The links, as masks: 1 where the algorithm connects modulator j to target i. */ float m12, m13, m14, m23, m24, m34; diff --git a/dsp/fmloops.ti.c b/dsp/fmloops.ti.c index cac6f2e2..ee1477f2 100644 --- a/dsp/fmloops.ti.c +++ b/dsp/fmloops.ti.c @@ -23,15 +23,16 @@ void strata_fm_add(float *restrict out, int n, const float *restrict env, strata const float di2 = b->di2, di3 = b->di3, di4 = b->di4, dfb = b->dfb; float last4 = s->last4, prev4 = s->prev4; const float *restrict sine = b->sine; + const float *restrict wave = b->wave; int i; STRATA_BLOCK_LOOP for (i = 0; i < n; i++) { /* The mean of the last two (fmloops.h). `half * prev4` is ready an iteration early, so * the chain from one sample's sine to the next gains one add and no multiply. */ const float half = 0.5f * fb; - const float o4 = fm_sine(sine, p4, half * last4 + half * prev4); + const float o4 = fm_sine(wave, p4, half * last4 + half * prev4); const float o3 = fm_sine(sine, p3, m34 * i4 * o4); - const float o2 = fm_sine(sine, p2, (m23 * i3) * o3 + (m24 * i4) * o4); + const float o2 = fm_sine(wave, p2, (m23 * i3) * o3 + (m24 * i4) * o4); const float o1 = fm_sine(sine, p1, (m12 * i2) * o2 + (m13 * i3) * o3 + (m14 * i4) * o4); out[i] += env[i] * (c1 * o1 + c2 * o2 + c3 * o3 + c4 * o4); prev4 = last4; @@ -62,14 +63,15 @@ void strata_fm_add_free(float *restrict out, int n, const float *restrict env, float i2 = b->i2, i3 = b->i3, i4 = b->i4; const float di2 = b->di2, di3 = b->di3, di4 = b->di4; const float *restrict sine = b->sine; + const float *restrict wave = b->wave; float o4 = s->last4, o4_before = s->prev4; int i; STRATA_BLOCK_LOOP for (i = 0; i < n; i++) { o4_before = o4; - o4 = fm_sine(sine, p4, 0.0f); + o4 = fm_sine(wave, p4, 0.0f); const float o3 = fm_sine(sine, p3, m34 * i4 * o4); - const float o2 = fm_sine(sine, p2, (m23 * i3) * o3 + (m24 * i4) * o4); + const float o2 = fm_sine(wave, p2, (m23 * i3) * o3 + (m24 * i4) * o4); const float o1 = fm_sine(sine, p1, (m12 * i2) * o2 + (m13 * i3) * o3 + (m14 * i4) * o4); out[i] += env[i] * (c1 * o1 + c2 * o2 + c3 * o3 + c4 * o4); p1 += d1; diff --git a/dsp/fmpoly.cpp b/dsp/fmpoly.cpp index 1f7546fe..8cd441b4 100644 --- a/dsp/fmpoly.cpp +++ b/dsp/fmpoly.cpp @@ -14,6 +14,7 @@ void FmPoly::init(float sample_rate) { defaults.set(kOscFirst + 0, 0); defaults.set(kOscFirst + 2, 0); defaults.set(kOscFirst + 3, 0); + defaults.set(kScnFirst, 0); // WAV: the sine prepare(defaults); } diff --git a/tests/scenario_fmwave.sh b/tests/scenario_fmwave.sh new file mode 100755 index 00000000..94e493e3 --- /dev/null +++ b/tests/scenario_fmwave.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash +# FM4's OPS page in the emulator (2026-11-30): scenario_fm.sh's beat, track 7 switched to FM4 on +# keys alone, then EDIT's last page, which draws on the C674x as OPS on an FM4 track, and WAV +# turned to DBL, the wave with the most harmonics. The loop reads a second table through a +# second pointer and nothing else changes (dsp/fmloops.ti.c), so the peak should be +# scenario_fm.sh's on the same commit (docs/BUDGET.md, "FM4's WAV"). +# +# PLAY, EDIT, DOWN x6, FUNC+EDIT, DOWN x4, EDIT -> track 7 on FM4 (scenario_fm.sh) +# SELECT_LEFT -> the pages wrap: scr EDIT OPS +# turn A 3 -> WAV SIN SIN2 HALF DBL +# +# Keys (third_party/enaga/include/enaga/abi.h): F5 = 22 PLAY, F8 = 28 EDIT, F1 = 19 FUNC, +# DOWN = 25, SELECT_LEFT = 8. Encoder 0 is A. The first press comes late: the panel link is not +# streaming in the first ~200 M cycles. +set -euo pipefail + +cd "$(dirname "$0")/.." +# shellcheck source=tools/env.sh +source tools/env.sh + +CYCLES=1900000000 + +while [ $# -gt 0 ]; do + case "$1" in + --cycles) CYCLES="$2"; shift 2 ;; + *) echo "error: unknown argument: $1" >&2; exit 2 ;; + esac +done + +if [ ! -f "$ENAGA_EMULATOR/cpu.py" ]; then + echo "SKIP: no emulator at $ENAGA_EMULATOR" >&2 + exit 0 +fi + +strata_require_toolchain +strata_link_emulator_toolchain +tools/build.sh > /dev/null + +STAGE="$ENAGA_BUILD/stage/STRATA" +mkdir -p "$ENAGA_BUILD" +LOG="$ENAGA_BUILD/scenario_fmwave.log" + +echo "running the emulator for $CYCLES cycles: play, track 7 to FM4, EDIT OPS, WAV to DBL ..." +python3 -B tools/enaga_cached.py emulate "$STAGE" --cycles "$CYCLES" \ + --key 22@300000000 \ + --key 28@340000000 \ + --key 25@370000000 --key 25@400000000 --key 25@430000000 --key 25@460000000 \ + --key 25@490000000 --key 25@520000000 \ + --key 19@580000000 --key 28@585000000 \ + --key 25@620000000 --key 25@650000000 --key 25@680000000 --key 25@710000000 \ + --key 28@750000000 \ + --key 8@830000000 --turn 0:3@950000000 \ + > "$LOG" 2>&1 || { + echo "FAIL: emulate.py exited non-zero" >&2 + tail -30 "$LOG" >&2 + exit 1 +} + +rc=0 +python3 - "$LOG" <<'PY' || rc=$? +import json, re, sys + +CYCLES_PER_BLOCK = 496_000 + +text = open(sys.argv[1]).read() +match = re.search(r'^\{.*?^\}', text, re.S | re.M) +if not match: + print(" FAIL no JSON report in the emulator output") + sys.exit(1) +report = json.loads(match.group(0)) + +failures = [] + +def check(ok, label, detail=""): + print(f" {'ok ' if ok else 'FAIL'} {label}{' ' + detail if detail else ''}") + if not ok: + failures.append(label) + +log = report.get("log", []) +screens = [line for line in log if line.startswith("scr ")] + +check(report.get("app_status") == "APP RUNNING", "app is running", + f'status={report.get("app_status")!r}') +check(not report.get("crash_reason"), "no crash", f'reason={report.get("crash_reason")!r}') +# Enaga's emulator keeps the last 16 log lines, and the DOWN presses log a grid line each, so +# "strata ready" can scroll out. A drawn screen comes only after init(), so it proves the same thing. +check("strata ready" in log or (len(log) == 16 and any(l.startswith("scr ") for l in log)), + "init() ran to completion") +check("run int" in log, "the transport started", f"log={log}") +check("scr MACHINE" in screens, "F1+F8 opened MACHINE", f"screens={screens}") +# The log keeps its last 16 lines; the switch and the screens after it are the newest. +check("mch 7 FM4" in log, "track 7 reached FM4", f"log={log}") +check(not any(l.startswith("mch 7 ") and l != "mch 7 FM4" for l in log[log.index("mch 7 FM4") + 1:]) + if "mch 7 FM4" in log else False, "and stayed there", f"log={log}") +check(screens and screens[-1] == "scr EDIT OPS", "drew EDIT OPS, FM4's last page", f"screens={screens}") + +blocks = report.get("audio_blocks", 0) +check(blocks > 1000, "audio ran throughout", f"blocks={blocks}") +check(report.get("audio_overruns", -1) == 0, "no audio overruns", + f'overruns={report.get("audio_overruns")}') + +peak = report.get("audio_cycles_peak", 0) +percent = 100.0 * peak / CYCLES_PER_BLOCK +check(percent > 5.0, "the beat was sounding", f"{percent:.2f}% peak") +check(percent < 60.0, "load is inside the target", f"{percent:.2f}% peak") + +print() +print(f"emulator peak load: {percent:.2f}% ({peak} of {CYCLES_PER_BLOCK} cycles, {blocks} blocks)") +print("note: no cache model here. Compare with scenario_fm.sh on the same commit: the") +print(" difference is WAV on DBL against the sine (docs/BUDGET.md).") + +sys.exit(1 if failures else 0) +PY + +echo +if [ "$rc" -ne 0 ]; then + echo "SCENARIO FAILED; full log: $LOG" >&2 + exit 1 +fi +echo "SCENARIO OK (log: $LOG)" diff --git a/tests/test_engine.cpp b/tests/test_engine.cpp index 8e93040a..afccf09a 100644 --- a/tests/test_engine.cpp +++ b/tests/test_engine.cpp @@ -4990,6 +4990,12 @@ TEST(engine_kicks_tap_reaches_its_top_and_a_wave_mod_stops_at_the_last_mode) { pump(); CHECK_EQ(int(engine.params(kick).v[kScnFirst]), 100); CHECK_EQ(int(engine.params(wave).v[kScnFirst]), kKitScanModes - 1); + // FM4's WAV, the same slot again, stops at its last wave. + post(Cmd::set_machine, 2, 0, uint8_t(MachineId::fm)); + pump(); + post(Cmd::set_param, 2, 0, kScnFirst, 100); + pump(); + CHECK_EQ(int(engine.params(2).v[kScnFirst]), kKitFmWaves - 1); // A lock moved by the encoder follows the same rule. put_trig(kick, 1); put_trig(wave, 1); diff --git a/tests/test_fm.cpp b/tests/test_fm.cpp index 172288da..a6860cca 100644 --- a/tests/test_fm.cpp +++ b/tests/test_fm.cpp @@ -513,3 +513,138 @@ TEST(fm_velocity_and_accent_reach_the_level) { CHECK(peak <= 0.25f); CHECK(peak > 0.2f); } + +// --- WAV: the modulator pair's wave -------------------------------------------------------- + +TEST(fm_wave_numbers_names_and_tables) { + CHECK_EQ(fm_wave(0), 0); + CHECK_EQ(fm_wave(3), 3); + CHECK_EQ(fm_wave(9), kFmWaves - 1); // past the last reads as the last + CHECK_EQ(fm_wave(127), kFmWaves - 1); + const char *const names[kFmWaves] = {"SIN", "SIN2", "HALF", "DBL"}; + for (int w = 0; w < kFmWaves; w++) CHECK_EQ(fm_wave_name(w), names[w]); + CHECK(fm_wave_table(0) == fm_sine_table()); + CHECK(fm_wave_band(0) == 1.0f); + for (int w = 0; w < kFmWaves; w++) { + const float *t = fm_wave_table(w); + double sum = 0.0; + float top = 0.0f; + for (int i = 0; i < STRATA_FM_SINE_SIZE; i++) { + sum += t[i]; + top = std::fabs(t[i]) > top ? std::fabs(t[i]) : top; + } + // No DC (an operator played straight out would thump), bounded, and the guard point + // closes the turn. + CHECK(std::fabs(sum / STRATA_FM_SINE_SIZE) < 1e-3); + CHECK(top <= 1.001f && top > 0.6f); + CHECK(t[STRATA_FM_SINE_SIZE] == t[0]); + if (w > 0) CHECK(fm_wave_band(w) > 1.0f); + } +} + +TEST(fm_wave_gives_the_modulators_their_harmonics) { + // ALG 8, four plain operators at 220 Hz: 1 and 3 are always sines, 2 and 4 take the wave, so + // what WAV adds is the wave's own spectrum. SIN2 is odd (a third harmonic, no second), HALF + // even (a second, no third), DBL has both. + static float out[kFmWaves][9600]; + for (int w = 0; w < kFmWaves; w++) { + TrackParams p = fm_params(); + p.set(0, 127); // ALG 8 + p.set(kOscFirst + 1, 64); // FIN at its centre: the modulator pair at 1 too + p.set(kAsrFirst + 1, 127); // SUS + p.set(kScnFirst, uint8_t(w)); + const FmSettings s = FmSettings::make(p, kRate, 1.0f / kRate); + CHECK_EQ(s.wave, w); + FmVoice v; + v.reset(); + v.set_note(57.0f, 100.0f / 127.0f); + v.gate_on(); + for (float &x : out[w]) x = 0.0f; + render(v, s, out[w], 9600); + CHECK_EQ(v.wave(), w); + } + const auto h = [&](int w, int n) { return harmonic(out[w] + 4800, 4800, 220.0 * n); }; + CHECK(h(0, 2) < 1e-3 * h(0, 1) && h(0, 3) < 1e-3 * h(0, 1)); + CHECK(h(1, 3) > 0.05 * h(1, 1) && h(1, 2) < 0.01 * h(1, 1)); + CHECK(h(2, 2) > 0.1 * h(2, 1) && h(2, 3) < 0.01 * h(2, 1)); + CHECK(h(3, 2) > 0.2 * h(3, 1) && h(3, 3) > 0.1 * h(3, 1)); + // No DC from any of them. + for (int w = 0; w < kFmWaves; w++) { + double mean = 0.0; + for (int i = 4800; i < 9600; i++) mean += out[w][i]; + CHECK(std::fabs(mean / 4800.0) < 2e-3); + } +} + +TEST(fm_wave_changes_a_modulated_tone_and_the_sine_is_untouched) { + // A 1:1 pair with some index: every wave is a different tone, at a level near the sine's. + static float out[kFmWaves][4800]; + for (int w = 0; w < kFmWaves; w++) { + TrackParams p = fm_params(); + p.set(0, 72); // ALG 5, two pairs + p.set(2, 60); + p.set(kAsrFirst + 1, 127); + p.set(kAsrFirst + 3, 127); + p.set(kScnFirst, uint8_t(w)); + const FmSettings s = FmSettings::make(p, kRate, 1.0f / kRate); + FmVoice v; + v.reset(); + v.set_note(48.0f, 100.0f / 127.0f); + v.gate_on(); + for (float &x : out[w]) x = 0.0f; + render(v, s, out[w], 4800); + } + for (int w = 1; w < kFmWaves; w++) { + double diff = 0.0; + for (int i = 0; i < 4800; i++) diff += std::fabs(double(out[w][i]) - out[0][i]); + CHECK(diff / 4800.0 > 0.01); + CHECK(rms(out[w], 4800) > 0.7 * rms(out[0], 4800)); + CHECK(rms(out[w], 4800) < 1.4 * rms(out[0], 4800)); + } +} + +TEST(fm_wave_falls_back_to_the_sine_where_its_harmonics_would_fold) { + // RAT 14 on C7: the modulator is at 29 kHz, clamped, and a wave's harmonics would be far past + // half the rate. The note reads the sine; a low note of the same patch reads the wave. + TrackParams p = fm_params(); + p.set(1, 127); // RAT 14 + p.set(2, 60); + p.set(kScnFirst, 3); // DBL + const FmSettings s = FmSettings::make(p, kRate, 1.0f / kRate); + static float out[960]; + for (int pass = 0; pass < 2; pass++) { + FmVoice v; + v.reset(); + v.set_note(pass == 0 ? 96.0f : 36.0f, 1.0f); + v.gate_on(); + for (float &x : out) x = 0.0f; + render(v, s, out, 960); + CHECK_EQ(v.wave(), pass == 0 ? 0 : 3); + } + // And the knob is heard on a ringing note: the wave follows it at the next slice. + FmVoice v; + v.reset(); + v.set_note(48.0f, 1.0f); + v.gate_on(); + render(v, s, out, 64); + CHECK_EQ(v.wave(), 3); + p.set(kScnFirst, 1); + const FmSettings turned = FmSettings::make(p, kRate, 1.0f / kRate); + render(v, turned, out, 64); + CHECK_EQ(v.wave(), 1); +} + +TEST(fm_index_cap_counts_the_waves_harmonics) { + // The stack on a middle note: the cap binds, and binds sooner when the modulators are three + // or six times as wide before any modulation. + const float f[4] = {0.01f, 0.01f, 0.01f, 0.01f}; + const float sine = fm_index_cap(0, f, 0.0f, 1.0f); + const float sin2 = fm_index_cap(0, f, 0.0f, 1.0f, fm_wave_band(1)); + const float dbl = fm_index_cap(0, f, 0.0f, 1.0f, fm_wave_band(3)); + CHECK(sine < 2.0f); + CHECK(sin2 < sine); + CHECK(dbl < sin2); + CHECK(dbl > 0.0f); + // The default is the sine's. + CHECK(fm_index_cap(0, f, 0.0f, 1.0f, 1.0f) == sine); +} diff --git a/tests/test_fm_machine.cpp b/tests/test_fm_machine.cpp index 661e10a0..d5965fd7 100644 --- a/tests/test_fm_machine.cpp +++ b/tests/test_fm_machine.cpp @@ -90,6 +90,7 @@ TrackParams preset_params(const SoundPreset &s) { p.set(kAsrFirst + k, s.asr[k]); p.set(kOscFirst + k, s.osc[k]); } + p.set(kScnFirst, s.scn[0]); // WAV, FM4's; 0 on VA POLY, which does not read it return p; } @@ -323,7 +324,8 @@ TEST(fm_machine_unison_puts_the_sharp_voice_on_the_right) { } // Triggered before any prepare(), FM4 plays the patch init() promises: every byte at 64, the ASR -// page at 0, and the OSC page at rest (no detune, no keytrack, carrier 1; fine at its centre). +// page at 0, the OSC page at rest (no detune, no keytrack, carrier 1; fine at its centre) and +// WAV on the sine. TEST(fm_machine_plays_its_rest_patch_before_the_first_prepare) { static float before[kLen / 4], after[kLen / 4]; TrackParams rest{}; @@ -332,6 +334,7 @@ TEST(fm_machine_plays_its_rest_patch_before_the_first_prepare) { rest.set(kOscFirst + 0, 0); rest.set(kOscFirst + 2, 0); rest.set(kOscFirst + 3, 0); + rest.set(kScnFirst, 0); // WAV: the sine for (int pass = 0; pass < 2; pass++) { g_fm.init(kRate); if (pass == 1) g_fm.prepare(rest); diff --git a/tests/test_golden.cpp b/tests/test_golden.cpp index dd24894e..e3cd1c31 100644 --- a/tests/test_golden.cpp +++ b/tests/test_golden.cpp @@ -546,6 +546,7 @@ TEST(golden_fm_machine_moving_knobs) { TrackParams p{}; for (int i = 0; i < kTrackParams; i++) p.set(i, uint8_t((i * 41 + 19) % 128)); p.set(2, 120); // IDX high: the cap binds + p.set(kScnFirst, 0); // WAV: the sine, as the render was made p.set(kAsrFirst + 1, 110); // SUS: the notes hold p.set(3, 0); // FBK from 0: its first turn ramps up from none const Trig notes[] = {trig(84, 120, 0, false, 20000), trig(96, 100, 0, false, 20000), diff --git a/tests/test_help.cpp b/tests/test_help.cpp index 06d4c5af..7df55666 100644 --- a/tests/test_help.cpp +++ b/tests/test_help.cpp @@ -122,6 +122,8 @@ TEST(help_knob_words_fit_beside_a_three_letter_name) { CHECK(std::strcmp(help_param_words(uint8_t(MachineId::hat), 26), "TAIL HIGH-PASS") == 0); // CYM CHECK(std::strcmp(help_param_words(uint8_t(MachineId::perc), 24), "NOISE MIX") == 0); // NOIS CHECK(std::strcmp(help_param_words(uint8_t(MachineId::perc), 27), "") == 0); + CHECK(std::strcmp(help_param_words(uint8_t(MachineId::fm), 40), "MODULATOR WAVE") == 0); // OPS + CHECK(std::strcmp(help_param_words(uint8_t(MachineId::fm), 41), "") == 0); CHECK(std::strcmp(help_param_words(uint8_t(MachineId::midi), 24), "") == 0); // no page } @@ -166,6 +168,9 @@ TEST(help_starts_on_the_screens_own_page) { // PERC reads it as NOIS, its noise layer. CHECK(first_page_has(place_of(HelpScreen::edit, 6, int(MachineId::perc)), "EDIT NOIS PRC")); CHECK(first_page_has(place_of(HelpScreen::edit, 6, int(MachineId::perc)), "NSE 0 NO NOISE")); + // FM4's ninth page is OPS, the modulator pair's wave. + CHECK(first_page_has(place_of(HelpScreen::edit, 10, int(MachineId::fm)), "EDIT OPS FM4")); + CHECK(first_page_has(place_of(HelpScreen::edit, 10, int(MachineId::fm)), "SIN2 HOLLOW ODD")); // SNARE and HAT read it as pages of their own. CHECK(first_page_has(place_of(HelpScreen::edit, 6, int(MachineId::snare)), "EDIT CLAP SNR")); CHECK(first_page_has(place_of(HelpScreen::edit, 6, int(MachineId::hat)), "EDIT CYM HAT")); diff --git a/tests/test_project.cpp b/tests/test_project.cpp index 7ef075c8..9550c6d3 100644 --- a/tests/test_project.cpp +++ b/tests/test_project.cpp @@ -4210,8 +4210,12 @@ TEST(kit_the_scn_page_round_trips_and_an_older_file_loads_it_off) { fresh_kit_file(); for (int t = 0; t < kTracks; t++) { for (int i = 0; i < kKitScnParams; i++) { + // The first slot within its range on the track's machine: a mode on the WAVE pair, + // a wave on FM4 (track 7 of fill_kit's), a byte anywhere else. + const int top = int(kit_param_max(g_kit_source.tracks[t].machine, kKitScnFirst)) + 1; g_kit_source.tracks[t].params[kKitScnFirst + i] = - uint8_t(i == 0 ? t % kKitScanModes : (10 + 13 * t + 31 * i) % 128); + uint8_t(i == 0 ? t % (top < kKitScanModes ? top : kKitScanModes) + : (10 + 13 * t + 31 * i) % 128); } } uint32_t written = 0; @@ -4329,6 +4333,7 @@ TEST(kit_a_v060_kit_zeroes_the_drum_pages_and_a_mono_wid) { track.machine = machines[t]; for (int p = kKitArpEnd; p < kKitOscEnd; p++) track.params[p] = uint8_t(10 + p + t); for (int p = kKitScnFirst; p < kKitParams; p++) track.params[p] = uint8_t(1 + t); + if (machine_is_fm(machines[t])) track.params[kKitScnFirst] = 2; // WAV: HALF track.width = 50; } CHECK_EQ(int(kit_write(g_kit_source, g_kit_file, uint32_t(sizeof(g_kit_file)), nullptr)), @@ -4350,9 +4355,10 @@ TEST(kit_a_v060_kit_zeroes_the_drum_pages_and_a_mono_wid) { const bool asr = p >= kKitArpEnd && p < kKitAsrEnd; const bool osc_or_scn = (p >= kKitAsrEnd && p < kKitOscEnd) || p >= kKitScnFirst; // PERC's NOIS came later still (the generation byte on LFO SLOW's section, gone - // with it here), so its ASR bytes go to 0 too. + // with it here), so its ASR bytes go to 0 too, and FM4's WAV after that. const bool zeroed = ((drum || machine_is_perc(m)) && asr) || - (m == uint8_t(MachineId::kick) && osc_or_scn); + (m == uint8_t(MachineId::kick) && osc_or_scn) || + (machine_is_fm(m) && p == kKitScnFirst); CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), zeroed ? 0 : int(g_kit_source.tracks[t].params[p])); } @@ -4396,7 +4402,7 @@ TEST(kit_perc_noise_survives_a_new_kit_and_is_zeroed_in_one_from_before_it) { const uint32_t entry = section_entry_at(g_kit_file, kSectionKitLfoSlow); CHECK_EQ(peek_u32(g_kit_file, entry + 8), uint32_t(kTracks) + 1u); const uint32_t generation = section_at(g_kit_file, kSectionKitLfoSlow) + uint32_t(kTracks); - CHECK_EQ(int(g_kit_file[generation]), 1); + CHECK_EQ(int(g_kit_file[generation]), 2); CHECK_EQ(int(kit_read(g_kit_loaded, g_kit_file, kKitFileBytes)), int(SerializeResult::ok)); for (int t = 0; t < kTracks; t++) { for (int p = 0; p < kKitParams; p++) { @@ -4429,6 +4435,41 @@ TEST(kit_perc_noise_survives_a_new_kit_and_is_zeroed_in_one_from_before_it) { } } +// FM4's WAV, the SCN page's first slot (dsp/fm.hpp): generation 2 of the same byte. A kit that +// knows it keeps the wave; one from before it -- PERC's generation, or none -- opens on the +// sine, whatever the slot held, and a WAVE track's scan mode in the same slot stays. +TEST(kit_fm_wave_survives_a_new_kit_and_is_the_sine_in_one_from_before_it) { + fill_kit(g_kit_source); + g_kit_source.tracks[1].machine = uint8_t(MachineId::fm); + g_kit_source.tracks[4].machine = uint8_t(MachineId::wave_poly); + g_kit_source.tracks[1].params[kKitScnFirst] = 3; + g_kit_source.tracks[4].params[kKitScnFirst] = 5; + CHECK_EQ(int(kit_write(g_kit_source, g_kit_file, uint32_t(sizeof(g_kit_file)), nullptr)), + int(SerializeResult::ok)); + const uint32_t generation = section_at(g_kit_file, kSectionKitLfoSlow) + uint32_t(kTracks); + CHECK_EQ(int(kit_read(g_kit_loaded, g_kit_file, kKitFileBytes)), int(SerializeResult::ok)); + CHECK_EQ(int(g_kit_loaded.tracks[1].params[kKitScnFirst]), 3); + CHECK_EQ(int(g_kit_loaded.tracks[4].params[kKitScnFirst]), 5); + for (int older : {1, 0}) { + g_kit_file[generation] = uint8_t(older); + refresh_crc(g_kit_file); + CHECK_EQ(int(kit_read(g_kit_loaded, g_kit_file, kKitFileBytes)), int(SerializeResult::ok)); + CHECK_EQ(int(g_kit_loaded.tracks[1].params[kKitScnFirst]), 0); + CHECK_EQ(int(g_kit_loaded.tracks[4].params[kKitScnFirst]), 5); + // The slot's other three bytes are not FM4's and are left alone. + for (int k = 1; k < kKitScnParams; k++) { + CHECK_EQ(int(g_kit_loaded.tracks[1].params[kKitScnFirst + k]), + int(g_kit_source.tracks[1].params[kKitScnFirst + k])); + } + } + // A wave past the last is damage: read as the last. + g_kit_file[generation] = 2; + g_kit_file[section_at(g_kit_file, kSectionKitScn) + 4 * 1] = 9; + refresh_crc(g_kit_file); + CHECK_EQ(int(kit_read(g_kit_loaded, g_kit_file, kKitFileBytes)), int(SerializeResult::ok)); + CHECK_EQ(int(g_kit_loaded.tracks[1].params[kKitScnFirst]), kKitFmWaves - 1); +} + // --- one filter on the synth machines (D8) --------------------------------------------------- TEST(kit_an_older_kit_maps_its_insert_filter_onto_ton_on_the_synth_machines) { diff --git a/tests/test_sounds.cpp b/tests/test_sounds.cpp index 19ca8bb5..57dd2fbe 100644 --- a/tests/test_sounds.cpp +++ b/tests/test_sounds.cpp @@ -165,6 +165,22 @@ TEST(sounds_a_preset_writes_its_pages_and_leaves_the_mix_the_lfo_and_the_arp) { } CHECK(((sound_preset_writes(uint8_t(MachineId::va_mono)) >> kSoundAsrFirst) & 1u) != 0); uint8_t params[kKitParams] = {}; + // FM4 writes WAV, the first SCN slot, and leaves the other three: a sound from before the + // waves puts it back on the sine, and the wave presets each pick theirs. + const uint8_t fm = uint8_t(MachineId::fm); + CHECK(((sound_preset_writes(fm) >> kSoundScnFirst) & 0xFu) == 1u); + bool waves[kKitFmWaves] = {}; + for (int i = 0; i < sound_preset_count(fm); i++) { + for (int p = 0; p < kKitParams; p++) params[p] = 77; + params[kSoundScnFirst] = 2; + CHECK(sound_preset_apply(fm, i, params)); + CHECK(params[kSoundScnFirst] < kKitFmWaves); + CHECK_EQ(int(params[kSoundScnFirst]), int(sound_preset(fm, i)->scn[0])); + CHECK_EQ(int(params[kSoundScnFirst + 1]), 77); + waves[params[kSoundScnFirst]] = true; + } + for (bool heard : waves) CHECK(heard); + for (int p = 0; p < kKitParams; p++) params[p] = 0; CHECK(!sound_preset_apply(uint8_t(MachineId::sample), 0, params)); CHECK(!sound_preset_apply(uint8_t(MachineId::kick), 99, params)); CHECK(!sound_preset_matches(uint8_t(MachineId::kick), 99, params)); diff --git a/tests/test_ui.cpp b/tests/test_ui.cpp index 7c7da765..37e14db0 100644 --- a/tests/test_ui.cpp +++ b/tests/test_ui.cpp @@ -12295,6 +12295,44 @@ TEST(ui_a_percs_asr_page_is_nois) { key(ENAGA_KEY_F4); } +TEST(ui_fm4s_ninth_page_is_ops_and_wav_names_its_waves) { + // FM4 reads the SCN page's first slot as WAV, the modulator pair's wave (dsp/fm.hpp): a + // number that stops at the last wave. The page is OPS and its other three knobs are not read. + Strata &app = fresh(); + post_track(Cmd::set_machine, 0, uint8_t(MachineId::fm)); + pump(4); + key(ENAGA_KEY_F8); // EDIT, track 1 + goto_edit_page(app, Page::scn); + CHECK_EQ(UiProbe::param_page(app), int(Page::scn)); + check_layout(app, "EDIT OPS, FM4 on the sine"); + CHECK(screen_has(app, "OPS")); + CHECK(screen_has(app, "WAV")); + CHECK(screen_has(app, "SIN")); + CHECK(screen_has(app, "WAV MODULATORS SINE")); + CHECK(!screen_has(app, "NOT ON THIS MACHINE")); + CHECK(!screen_has(app, "SPD")); + CHECK_EQ(int(app_engine().params(0).v[kScnFirst]), 0); + const char *const names[kFmWaves] = {"SIN", "SIN2", "HALF", "DBL"}; + for (int w = 1; w < kFmWaves; w++) { + app.on_encoder(0, +1); + pump(); + CHECK_EQ(int(app_engine().params(0).v[kScnFirst]), w); + CHECK(screen_has(app, names[w])); + check_layout(app, "EDIT OPS, FM4 on a wave"); + } + CHECK(screen_has(app, "DBL GLASSY: METAL")); + // The knob stops on the last wave. + app.on_encoder(0, +20); + pump(); + CHECK_EQ(int(app_engine().params(0).v[kScnFirst]), kFmWaves - 1); + // The three free knobs do nothing. + const uint8_t before = app_engine().params(0).v[kScnFirst + 1]; + app.on_encoder(1, +5); + pump(); + CHECK_EQ(int(app_engine().params(0).v[kScnFirst + 1]), int(before)); + key(ENAGA_KEY_F4); +} + TEST(ui_envelope_a_dot_rides_the_amp_curve_while_a_note_plays) { Strata &app = fresh(); track_with_break(MachineId::sample); From e4e8d274b308f4acefe03c0aa957dfbb211578e1 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 17:30:08 +0000 Subject: [PATCH 3/3] docs: GRAIN stereo measured, 0.74 points with cl6x (d8b6c38, 66 scenarios) Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Tw2EaFHmBTuHT9xVLai85a --- docs/BUDGET.md | 18 ++++++++++++++++-- docs/DESIGN_NOTES.md | 4 ++-- docs/FEATURES.md | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/BUDGET.md b/docs/BUDGET.md index f167e7cb..5cf9c085 100644 --- a/docs/BUDGET.md +++ b/docs/BUDGET.md @@ -482,8 +482,22 @@ worst 34.20%, `genload`. **GRAIN (2026-11-30).** A GRAIN track's WID pans each grain at its onset and renders the cloud as a pair (`strata_grain_add_mono_pair`: one more multiply-add a sample a grain) into the stereo chain. `scenario_grainwide` is `scenario_grain` (SHIMMR on track 8) with track 8's WID at 48. -**Not measured yet**: cl6x and the emulator run on Roland's PC. The estimate is the review's, 1 to -1.5 points with cl6x, most of it the second chain. +Measured at `d8b6c38` (emulator, Enaga v0.4.0, Roland's PC, all 66 scenarios with both +compilers): + +| Scenario | cl6x | GCC-only | +| --- | --- | --- | +| `grain` (WID 0) | 28.62% | 63.49% | +| `grainwide` (WID 48) | 29.36% | 63.49% | +| `genload` | 32.16% | 67.06% | +| `stack` | 42.23% | 84.13% | +| `genall` (the worst with cl6x) | 43.84% | 73.88% | + +The wide cloud costs 0.74 points with cl6x, under the review's estimate of 1 to 1.5; GCC-only +the two peak on the same block, so the pair is not what sets that peak. cl6x built +`grainloops.ti.c` without a remark and all 66 scenarios pass. GCC-only 47 of 66 pass: 17 fail +only their load line (the GCC-only column has been over those lines since v0.7.0's pass, +docs/SCENARIO_LOG.md) and `controls` and `triplets` log a save too late. ### The line input (2026-11-28, emulator, Enaga v0.4.0) diff --git a/docs/DESIGN_NOTES.md b/docs/DESIGN_NOTES.md index 93958eec..33db5023 100644 --- a/docs/DESIGN_NOTES.md +++ b/docs/DESIGN_NOTES.md @@ -769,8 +769,8 @@ drum bus clip (their fold-over is at -40 dB or lower). loops with a second multiply-add; a two-channel source is still summed, since reading both channels per grain would double the loads of a loop that is already load-bound. One zone and no unison: a cloud is already many voices. On GRAIN this replaces the highs widening of - 2026-11-29, which no release carried. Not measured with cl6x yet: `scenario_grainwide` against - `scenario_grain`. + 2026-11-29, which no release carried. Measured: 0.74 points with cl6x, `scenario_grainwide` + against `scenario_grain` (docs/BUDGET.md). - **PERC's NOIS page (item 12).** Two sine operators cannot make a shaker, a clap's body or the stick on a tom, so PERC takes the ASR page's first three slots as SNARE and HAT did: NSE NDC diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 7b4550be..e47f2de9 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -122,7 +122,7 @@ FM4 and GRAIN machines. | **Synthesis review, the taste calls** (2026-11-30): VA MONO's filter saturates (the resonant stage's state through the soft clip, every sample); HAT's six squares are band-limited; SNARE's body starts 35% sharp and settles in 6 ms | #307 | ○ (W117) | Fixed amounts, no knobs. ACID is about 1 dB quieter. 0.55 to 0.82 points with cl6x; GCC-only `stack` trips the CPU guard (docs/BUDGET.md) | | **FM4's OPS page: modulator waves** (2026-11-30, synthesis review item 11): WAV on EDIT's ninth page gives operators 2 and 4 the sine or one of three variants of it, SIN2 (odd harmonics), HALF (even), DBL (the first three about level); the carriers stay sines; presets REED, HORN, TINE | Unreleased | ○ (W122) | The SCN page's first slot, a number 0-3. KIT.BIN's generation byte goes to 2, so a kit from before WAV opens on SIN; scenes, locks and user sounds are not cleared. A note whose wave would fold past half the rate plays the sine. Same loop, a second table pointer: cost not yet measured with cl6x (`scenario_fmwave` against `scenario_fm`) | | **PERC's NOIS page** (2026-11-30, synthesis review item 12): a noise layer beside the FM pair on the ASR page's slots: NSE mix (0 off, 64 noise under the full pair, 127 noise alone), NDC its own decay (3-800 ms, HOLD), NCL a band-pass 400 Hz-12 kHz; presets SHAKER, BRUSH, SNPTOM | Unreleased | ○ (W121) | KIT.BIN's LFO SLOW section grew one byte (the drum pages' generation), so a kit from before NOIS opens with it at 0; scenes, locks and user sounds are not cleared. Cost not yet measured with cl6x (`scenario_nois`) | -| **GRAIN in stereo** (2026-11-30, synthesis review item 6): with the track's WID up each grain is born at its own place (sides in turn, 35-100% of the knob's reach) and the cloud renders as a pair into the stereo insert chain | Unreleased | ○ (W120) | One zone, no unison. A stereo sample is still summed. The same grains at any WID; WID 0 is bit-exact mono. Replaces the highs widening on GRAIN tracks. Cost not yet measured with cl6x (`scenario_grainwide`) | +| **GRAIN in stereo** (2026-11-30, synthesis review item 6): with the track's WID up each grain is born at its own place (sides in turn, 35-100% of the knob's reach) and the cloud renders as a pair into the stereo insert chain | Unreleased | ○ (W120) | One zone, no unison. A stereo sample is still summed. The same grains at any WID; WID 0 is bit-exact mono. Replaces the highs widening on GRAIN tracks. Costs 0.74 points with cl6x (`scenario_grainwide` 29.36% against `scenario_grain` 28.62%) | | MID: plays an outboard synth over MIDI; SRC/AMP knobs send CC 74/71/73/72, 70/75/76/77 | v0.1.0 | ○ (8d) | No sound or CPU of its own; no scale fold | | Key and scale per pattern (15 scales), fold for the VA, WAVE and FM4 machines, GRAIN and unsliced SAMPLE; sharps everywhere | v0.1.0 | ○ (7) | | | **NOTE view**: TUN / PIT read as a note (where TUN puts C-4) and turn a semitone a click; push the knob for 0-127 | #88 | ○ (W3) | Chromatic, not by scale (TUN applies after the fold). 128 bytes per range, so many notes are a few cents off (`+`/`-`). Not saved: on at every start |