From 2548577d132d5fbed793090713d995e30b0f7b21 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 18:10:20 +0000 Subject: [PATCH] fm4: ACC, accent to the index, on the OPS page (synthesis review) An accent on FM4 reached the level only (#303). ACC, the OPS page's second knob, multiplies an accented note's index by 1 + ACC/127, before fm_index_cap, so the accent is brighter as well as louder and stays inside the fold-over limit. 0 is the accent as it was; notes without an accent do not hear the knob. Control rate only: no loop changes. The slot is the SCN page's second, which every kit fills with SCN's default SPD (28). KIT.BIN's generation byte goes to 3 and kit_read opens an FM4 track from before it with ACC at 0. An FM4 preset writes its OPS numbers as they stand (value_of takes the machine), where a WAVE or KICK preset that leaves the page out writes the SCN defaults. EPIANO, BASS, BLIP and DUBSTB set ACC. scenario_fmwave turns ACC up as well. W124. Golden renders stand. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01Tw2EaFHmBTuHT9xVLai85a --- CHANGELOG.md | 4 +++ app/app.hpp | 5 ++-- app/ui_mixer.hpp | 3 +++ core/help.cpp | 3 ++- core/project.cpp | 14 ++++++++-- core/sounds.cpp | 30 +++++++++++++-------- docs/BUDGET.md | 5 ++++ docs/CHEATSHEET.md | 2 +- docs/DESIGN_NOTES.md | 10 +++++++ docs/FEATURES.md | 1 + docs/MANUAL.md | 8 +++++- docs/UNIT_CHECKLIST.md | 8 ++++++ dsp/fm.cpp | 6 +++++ dsp/fm.hpp | 3 ++- dsp/fmpoly.cpp | 1 + tests/scenario_fmwave.sh | 7 ++--- tests/test_fm.cpp | 57 ++++++++++++++++++++++++++++++++++++++++ tests/test_help.cpp | 4 ++- tests/test_project.cpp | 50 ++++++++++++++++++++++++----------- tests/test_sounds.cpp | 15 ++++++++--- tests/test_ui.cpp | 16 ++++++++--- 21 files changed, 206 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba00935..76ef9746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ the project file format or the controls. ### Added +- **FM4: ACC, accent to the tone.** The OPS page's second knob makes an accented note brighter + as well as louder: its index rises with ACC, to twice its value at 127. At 0 an accent changes + the level only. EPIANO, BASS, BLIP and DUBSTB come with ACC up. A project from before it opens + with ACC at 0 and sounds as it did. No CPU cost. - **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 diff --git a/app/app.hpp b/app/app.hpp index d307c3c6..265da45b 100644 --- a/app/app.hpp +++ b/app/app.hpp @@ -588,8 +588,9 @@ 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", "---", "---", "---"}; +// FM4's OPS page's (the SCN slots too): the modulator pair's wave and the accent's lift of the +// index (dsp/fm.hpp); two are free. +constexpr const char *kFmOpsNames[kScnParams] = {"WAV", "ACC", "---", "---"}; // 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_mixer.hpp b/app/ui_mixer.hpp index c6f229b0..87c4001b 100644 --- a/app/ui_mixer.hpp +++ b/app/ui_mixer.hpp @@ -635,6 +635,9 @@ case kScnFirst + 0: append(out, fm_wave_name(fm_wave(value))); return true; + case kScnFirst + 1: // ACC: a plain amount (the WAVE pair's SPD is a rate here) + append_number(out, value); + return true; default: return false; } diff --git a/core/help.cpp b/core/help.cpp index 6cf7ef93..54551b20 100644 --- a/core/help.cpp +++ b/core/help.cpp @@ -790,6 +790,7 @@ void knob_rows(const HelpPlace &place, bool slc_auto, char rows[kHelpRows][kHelp add_row(rows, count, "SIN2 HOLLOW ODD"); add_row(rows, count, "HALF NASAL EVEN"); add_row(rows, count, "DBL GLASSY"); + add_row(rows, count, "ACC: ACCENTS BRIGHTER"); break; } add_row(rows, count, "POS TO END EACH NOTE"); @@ -1076,7 +1077,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" : ""; + if (machine_is_fm(machine)) return slot == 0 ? "MODULATOR WAVE" : slot == 1 ? "ACCENT TO INDEX" : ""; return machine_reads_scn(machine) ? kScnWords[slot] : ""; default: return ""; } diff --git a/core/project.cpp b/core/project.cpp index e754bacc..39b21a25 100644 --- a/core/project.cpp +++ b/core/project.cpp @@ -75,7 +75,7 @@ // off, the defaults) // lfo slow (id 18), 8 x 1 byte: KitTrack::lfo_slow, 0-2 (absent: x1); then one byte, the // 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 +// (kKitPagesFmWave) FM4's WAV too, 3 (kKitPagesFmAccent) FM4's ACC 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, @@ -465,7 +465,10 @@ 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; +// 3: FM4 reads the page's second slot as ACC, the accent's lift of the index (2026-11-30). Every +// FM4 track from before it holds SCN's default SPD there (28), which would now brighten its accents. +constexpr uint8_t kKitPagesFmAccent = 3; +constexpr uint8_t kKitPagesWritten = kKitPagesFmAccent; constexpr uint32_t kKitLfoSlowWritten = kKitLfoSlowBytes + kKitDrumPagesBytes; constexpr uint32_t kKitLfoSlowOffset = kKitSlapOffset + kKitSlapBytes; constexpr uint32_t kKitTotalBytes = kHeaderBytes + kKitLfoSlowOffset + kKitLfoSlowWritten; @@ -1628,6 +1631,13 @@ SerializeResult kit_read(Kit &kit, const uint8_t *buffer, uint32_t size) { if (machine_is_fm(track.machine)) track.params[kKitScnFirst] = 0; } } + // And from before its ACC: an accent is louder and nothing else. + if (drum_pages < kKitPagesFmAccent) { + for (int t = 0; t < kTracks; t++) { + KitTrack &track = kit.tracks[t]; + if (machine_is_fm(track.machine)) track.params[kKitScnFirst + 1] = 0; + } + } return SerializeResult::ok; } diff --git a/core/sounds.cpp b/core/sounds.cpp index 8ecb70e6..dfdbeb4d 100644 --- a/core/sounds.cpp +++ b/core/sounds.cpp @@ -476,13 +476,15 @@ constexpr SoundPreset kFmPresets[] = { // The index (95) and IEN at the top put the brightness in the strike, VEL makes a hard hit // bark, and a touch of feedback adds edge. At IDX 50 it had almost nothing above 1 kHz even // in its attack, an organ more than a piano (the sound review, 2026-11-27). - {"EPIANO", {72, 24, 95, 10}, FLAT, {96, 127, 120, 80}, NO_ASR, {30, 64, 60, 13}}, + {"EPIANO", {72, 24, 95, 10}, FLAT, {96, 127, 120, 80}, NO_ASR, {30, 64, 60, 13}, + {0, 40, 0, 0}}, // A bell: 1:3.5, inharmonic, ringing for seconds while the index falls away. {"BELL", {72, 72, 60, 0}, FLAT, {115, 110, 60, 72}, NO_ASR, {40, 64, 30, 13}}, // A bass: the full stack with feedback, short and growling, the index snapping shut. More // index and feedback (2026-11-29): 4-8 kHz of a rolling line had sat 7-23 dB under RY // Oblivion's bass loops, now level with them. - {"BASS", {8, 24, 80, 55}, FLAT, {60, 110, 70, 122}, NO_ASR, {0, 64, 0, 13}}, + {"BASS", {8, 24, 80, 55}, FLAT, {60, 110, 70, 122}, NO_ASR, {0, 64, 0, 13}, + {0, 64, 0, 0}}, // Brass: a slow index rise to a held, half-open tone. Chords. IDX 75 and feedback for the // rasp: 4-8 kHz of a chord line had been 19-58 dB under the stab loops, now 7-12 (2026-11-29). {"BRASS", {40, 24, 75, 50}, FLAT, {80, 90, 60, 61}, {40, 100, 30, 80}, {20, 64, 40, 13}}, @@ -500,16 +502,20 @@ constexpr SoundPreset kFmPresets[] = { {"GLASS", {56, 104, 45, 20}, FLAT, {85, 110, 70, 92}, NO_ASR, {20, 64, 50, 13}}, // A blip: two pairs at 1:1, the index all in the strike, short. The bleep in bleep techno. // More index (2026-11-29): still a bleep, with a few more partials. - {"BLIP", {72, 24, 90, 0}, FLAT, {55, 127, 80, 120}, NO_ASR, {0, 64, 40, 13}}, + {"BLIP", {72, 24, 90, 0}, FLAT, {55, 127, 80, 120}, NO_ASR, {0, 64, 40, 13}, + {0, 50, 0, 0}}, // A chime: 1:14, high glassy partials over a long ring. {"CHIME", {72, 120, 40, 0}, FLAT, {120, 110, 60, 72}, NO_ASR, {30, 64, 30, 13}}, // A dub stab: pairs at 1:1, the index falling over a medium decay, a touch of detune and of // feedback. At IDX 45 it was a sine thud, its fourth harmonic up 26-44 dB under the // library's stabs; IDX 80 with IEN 110 puts the strike back (2026-11-29). - {"DUBSTB", {72, 24, 80, 30}, FLAT, {70, 110, 60, 99}, NO_ASR, {20, 64, 50, 13}}, + {"DUBSTB", {72, 24, 80, 30}, FLAT, {70, 110, 60, 99}, NO_ASR, {20, 64, 50, 13}, + {0, 45, 0, 0}}, // 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}}, + // (EPIANO, BASS, BLIP and DUBSTB end on ACC, the last four bytes' second: an accent strikes + // harder, with up to half as much index again. 2026-11-30.) // 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}, @@ -619,9 +625,9 @@ uint64_t sound_preset_writes(uint8_t machine) { case MachineId::hat: return (kSrcFltrAmp | kDrumPageBits) & ~(uint64_t(1) << kHatChoke); case MachineId::va_mono: 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. + // And WAV and ACC, the first two of the SCN slots (dsp/fm.hpp); the other two are not read. case MachineId::fm: - return kSrcFltrAmp | kAsrBits | kOscBits | (uint64_t(1) << kSoundScnFirst); + return kSrcFltrAmp | kAsrBits | kOscBits | (uint64_t(3) << kSoundScnFirst); case MachineId::wave_mono: case MachineId::wave_poly: return kSrcFltrAmp | kAsrBits | kOscBits | kScnBits; case MachineId::grain: @@ -634,13 +640,15 @@ uint64_t sound_preset_writes(uint8_t machine) { namespace { // The preset's value for KitTrack parameter p (only meaningful where the mask is set). -uint8_t value_of(const SoundPreset &s, int p) { +uint8_t value_of(const SoundPreset &s, int p, uint8_t machine) { if (p < 4) return s.src[p]; if (p < 8) return s.fltr[p - 4]; if (p < 12) return s.amp[p - 8]; if (p >= kSoundAsrFirst && p < kSoundAsrFirst + 4) return s.asr[p - kSoundAsrFirst]; if (p >= kSoundOscFirst && p < kSoundOscFirst + 4) return s.osc[p - kSoundOscFirst]; if (p >= kSoundScnFirst && p < kSoundScnFirst + 4) { + // FM4's OPS knobs are their own numbers: left out is SIN and no accent lift. + if (machine == uint8_t(MachineId::fm)) return s.scn[p - kSoundScnFirst]; const bool scans = s.scn[0] != 0 || s.scn[1] != 0 || s.scn[2] != 0 || s.scn[3] != 0; return scans ? s.scn[p - kSoundScnFirst] : kKitScnDefault[p - kSoundScnFirst]; } @@ -654,7 +662,7 @@ bool sound_preset_apply(uint8_t machine, int index, uint8_t *params) { if (s == nullptr || params == nullptr) return false; const uint64_t mask = sound_preset_writes(machine); for (int p = 0; p < kKitParams; p++) { - if ((mask >> p) & 1u) params[p] = value_of(*s, p); + if ((mask >> p) & 1u) params[p] = value_of(*s, p, machine); } return true; } @@ -664,7 +672,7 @@ bool sound_preset_matches(uint8_t machine, int index, const uint8_t *params) { if (s == nullptr || params == nullptr) return false; const uint64_t mask = sound_preset_writes(machine); for (int p = 0; p < kKitParams; p++) { - if (((mask >> p) & 1u) && params[p] != value_of(*s, p)) return false; + if (((mask >> p) & 1u) && params[p] != value_of(*s, p, machine)) return false; } return true; } @@ -683,7 +691,7 @@ bool machine_defaults_apply(uint8_t machine, uint8_t *params) { } const SoundPreset *s = sound_preset(machine, 0); if (s == nullptr) return false; - for (int p = 0; p < 12; p++) params[p] = value_of(*s, p); + for (int p = 0; p < 12; p++) params[p] = value_of(*s, p, machine); if (machine_has_asr_page(machine)) { for (int p = 0; p < 4; p++) params[kSoundAsrFirst + p] = s->asr[p]; if (machine_has_osc_page(machine)) { @@ -691,7 +699,7 @@ bool machine_defaults_apply(uint8_t machine, uint8_t *params) { } } if (machine_has_scn_page(machine)) { - for (int p = 0; p < 4; p++) params[kSoundScnFirst + p] = value_of(*s, kSoundScnFirst + p); + for (int p = 0; p < 4; p++) params[kSoundScnFirst + p] = value_of(*s, kSoundScnFirst + p, machine); } return true; } diff --git a/docs/BUDGET.md b/docs/BUDGET.md index 5cf9c085..cac085e5 100644 --- a/docs/BUDGET.md +++ b/docs/BUDGET.md @@ -318,6 +318,11 @@ control rate. No cost is expected. `scenario_fmwave` is `scenario_fm` with WAV o **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`). +### FM4's ACC (2026-11-30) + +One multiply a voice a control slice, on accented notes' index: no loop changes and no cost. +`scenario_fmwave` turns it up with WAV on DBL. + ### 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 0afc3a13..a3f0d3b9 100644 --- a/docs/CHEATSHEET.md +++ b/docs/CHEATSHEET.md @@ -380,7 +380,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. OPS (the ninth page) = WAV the modulators' wave: `SIN` plain FM · `SIN2` hollow, odd harmonics · `HALF` warm, even harmonics · `DBL` glassy. +**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 · ACC accented notes brighter, up to twice the index. **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. diff --git a/docs/DESIGN_NOTES.md b/docs/DESIGN_NOTES.md index 33db5023..e82181e7 100644 --- a/docs/DESIGN_NOTES.md +++ b/docs/DESIGN_NOTES.md @@ -810,5 +810,15 @@ drum bus clip (their fold-over is at -40 dB or lower). (`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. +- **FM4's ACC: accent to the index.** #303 sent FM4's accent to the level (1.4, the VA's). On + an FM voice the struck-harder sound is in the index, so OPS takes a second knob: an accented + note's index is multiplied by 1 + ACC/127, after IEN, VEL and BRT and before `fm_index_cap`, + which therefore holds an accent as it holds IDX. A knob and not a fixed lift, so that 0 is + the accent every existing song has. **The slot** is the SCN page's second, which every kit + fills with SCN's default SPD (28): the generation byte goes to 3 and `kit_read` puts an FM4 + track's slot at 0 below it. For the same reason an FM4 preset writes its OPS numbers as they + stand (`value_of` takes the machine): on the WAVE pair and KICK a preset that leaves the page + out writes the SCN defaults. EPIANO (the machine's default sound, so a new FM4 track too), + BASS, BLIP and DUBSTB set ACC 40 to 64. **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 65b8280c..da81671e 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -121,6 +121,7 @@ FM4 and GRAIN machines. | **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`) | +| **FM4's ACC: accent to the index** (2026-11-30, from the synthesis review): the OPS page's second knob lifts an accented note's index, to twice at 127, so an accent is brighter as well as louder; 0 is level only; EPIANO, BASS, BLIP and DUBSTB set it | Unreleased | ○ (W124) | The SCN page's second slot, 0-127. KIT.BIN's generation byte goes to 3: an FM4 track from before it opens at 0 (the slot held SCN's default SPD, 28). The lift comes before the fold-over cap. Control rate only: no cost. FM4 presets write the slot as their own number, 0 where they name none | | **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. 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 | diff --git a/docs/MANUAL.md b/docs/MANUAL.md index be749d0e..5cf5a817 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -1134,7 +1134,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` | `---` | `---` | `---` | +| OPS | **WAV** the modulators' wave: `SIN`, `SIN2`, `HALF`, `DBL` | **ACC** how much brighter an accented note is | `---` | `---` | 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 @@ -1158,6 +1158,12 @@ on `A8`, the organ, WAV is another drawbar. WAV costs no CPU. On very high notes 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`. +**ACC** on the same page is the accent's reach into the tone. An accented step is always louder; +with ACC up it is brighter as well, as a key struck harder is: the index rises with ACC, to twice +its value at 127. At 0 an accent only changes the level. Notes without an accent do not hear the +knob, and high notes stay inside the same limit that holds IDX. EPIANO, BASS, BLIP and DUBSTB +come with ACC up; put accents on a few steps of a bass line or a chord riff to hear it. + 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, diff --git a/docs/UNIT_CHECKLIST.md b/docs/UNIT_CHECKLIST.md index c9e31101..790f3f24 100644 --- a/docs/UNIT_CHECKLIST.md +++ b/docs/UNIT_CHECKLIST.md @@ -3766,3 +3766,11 @@ chord pattern playing. EDIT, the ninth page: it reads OPS with WAV `SIN`. - PROJECTS (FUNC + HOME, OPEN PROJECT): push B says `HOLD OK: MENU` and does nothing else. Hold OK on a project you can lose: `PROJECT MENU` with RENAME, DELETE, COLLECT OPEN PROJECT. CLR closes it; a tap of OK still asks `OK AGAIN: OPEN`. `____` + +**W124. FM4's ACC (3 min).** Track 7 on FM4, SOUNDS: BASS, a line with accents on a few steps. +EDIT, the ninth page, OPS: the second knob reads ACC `64`. +- The accented notes are louder and clearly brighter than the others. ACC to 0: they are only + louder. ACC to 127: brighter still, never harsh or folding on the high notes. `____` +- Notes without an accent do not change as ACC turns. `____` +- A project saved before this build with an FM4 track and accents: opens with ACC `0` and + sounds as it did. `____` diff --git a/dsp/fm.cpp b/dsp/fm.cpp index d8d2b949..3c9952e4 100644 --- a/dsp/fm.cpp +++ b/dsp/fm.cpp @@ -24,6 +24,8 @@ constexpr float kIndexDecayShare = 0.35f; // the index envelope falls in about constexpr float kVelocityRef = 100.0f * (1.0f / 127.0f); constexpr float kVelocityLevel = 0.75f / (0.25f + 0.75f * (100.0f / 127.0f)); constexpr float kAccentGain = 1.40f; +// ACC at 127: an accent doubles the index. +constexpr float kAccentIndex = 1.0f; constexpr float kLevelMax = 0.25f; // LVL 127: a chord sits with VA POLY's (tests/test_fm_machine.cpp) // Yamaha's eight 4-operator algorithms as link masks (m12 m13 m14 m23 m24 m34) and output @@ -198,6 +200,7 @@ FmSettings FmSettings::make(const TrackParams ¶ms, float rate, float inv_rat s.feedback = kFeedbackMaxTurns * params.unit(3); s.index_env = params.unit(9); s.velocity_index = params.unit(10); + s.accent_index = float(scn_byte(params.v, 1)) * (1.0f / 127.0f); s.keytrack = float(osc_byte(params.v, 2)) * (1.0f / 127.0f); const float lvl = params.unit(11); s.out_gain = kLevelMax * lvl * lvl; @@ -289,6 +292,9 @@ void FmVoice::run(const FmSettings &s, float *out, int n, float *env) { const float ienv = index_env_.step(s.index_shape); float index = s.index * ((1.0f - s.index_env) + s.index_env * ienv); index *= (1.0f - s.velocity_index) + s.velocity_index * velocity_; + // ACC: an accented note's index is up to twice the plain one's, so the accent bites as well + // as being louder. Before the cap below, which holds an accent as it holds a turn of IDX. + index *= accent_ ? 1.0f + kAccentIndex * s.accent_index : 1.0f; // BRT: the index falls with the key above middle C, so high notes do not turn to glass. index *= exp2(-s.keytrack * clamp((note_ - 60.0f) * (1.0f / 12.0f), 0.0f, 6.0f)); // An index whose sidebands would fold past Nyquist is capped, for the whole chain at once diff --git a/dsp/fm.hpp b/dsp/fm.hpp index 1bd9c3e3..9966cb9c 100644 --- a/dsp/fm.hpp +++ b/dsp/fm.hpp @@ -16,7 +16,7 @@ // 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) +// OPS WAV modulator wave ACC accent to the index (the SCN slots; two 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): @@ -92,6 +92,7 @@ struct FmSettings { enaga::dsp::EnvelopeShape index_shape{}; // stepped once per control slice int algorithm = 0; int wave = 0; // WAV, the modulator pair's table + float accent_index = 0.0f; // ACC, 0-1: how far an accent lifts the index (x2 at 1) 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 diff --git a/dsp/fmpoly.cpp b/dsp/fmpoly.cpp index 8cd441b4..acf3cf41 100644 --- a/dsp/fmpoly.cpp +++ b/dsp/fmpoly.cpp @@ -15,6 +15,7 @@ void FmPoly::init(float sample_rate) { defaults.set(kOscFirst + 2, 0); defaults.set(kOscFirst + 3, 0); defaults.set(kScnFirst, 0); // WAV: the sine + defaults.set(kScnFirst + 1, 0); // ACC: an accent is level only prepare(defaults); } diff --git a/tests/scenario_fmwave.sh b/tests/scenario_fmwave.sh index 94e493e3..0857a308 100755 --- a/tests/scenario_fmwave.sh +++ b/tests/scenario_fmwave.sh @@ -8,10 +8,11 @@ # 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 +# turn B 60 -> ACC up: accents lift the index # # 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. +# DOWN = 25, SELECT_LEFT = 8. Encoders 0 and 1 are A and B. The first press comes late: the +# panel link is not streaming in the first ~200 M cycles. set -euo pipefail cd "$(dirname "$0")/.." @@ -49,7 +50,7 @@ python3 -B tools/enaga_cached.py emulate "$STAGE" --cycles "$CYCLES" \ --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 \ + --key 8@830000000 --turn 0:3@950000000 --turn 1:60@1100000000 \ > "$LOG" 2>&1 || { echo "FAIL: emulate.py exited non-zero" >&2 tail -30 "$LOG" >&2 diff --git a/tests/test_fm.cpp b/tests/test_fm.cpp index a6860cca..cc0cc3b0 100644 --- a/tests/test_fm.cpp +++ b/tests/test_fm.cpp @@ -514,6 +514,63 @@ TEST(fm_velocity_and_accent_reach_the_level) { CHECK(peak > 0.2f); } +TEST(fm_accent_lifts_the_index_by_acc_and_only_on_an_accent) { + // ACC, the OPS page's second slot: at 0 an accent is the plain note 1.4 times as loud, + // sample for sample; turned up, the accented note has up to twice the index, so more of it is + // in the sidebands. A note without an accent does not hear the knob. + TrackParams p = fm_params(); + p.set(1, 16); // RAT 1 + p.set(2, 20); // IDX: a mild tone, far under the cap at middle C + static float out[5][4800]; + const int acc[5] = {0, 0, 127, 127, 64}; + const bool accent[5] = {false, true, false, true, true}; + for (int k = 0; k < 5; k++) { + p.set(kScnFirst + 1, uint8_t(acc[k])); + const FmSettings s = FmSettings::make(p, kRate, 1.0f / kRate); + CHECK_NEAR(s.accent_index, float(acc[k]) / 127.0f, 1e-6f); + FmVoice v; + v.reset(); + v.set_note(60.0f, 100.0f / 127.0f, accent[k]); + v.gate_on(); + for (float &x : out[k]) x = 0.0f; + render(v, s, out[k], 4800); + } + for (int i = 0; i < 4800; i++) { + CHECK_NEAR(out[1][i], 1.40f * out[0][i], 1e-5f); // ACC 0: louder, the same tone + CHECK(out[2][i] == out[0][i]); // no accent: the knob is not heard + } + // How much of the note is not its fundamental. + const double f = 261.6256; + const auto bright = [&](const float *x) { + const double all = rms(x, 4800), first = harmonic(x, 4800, f) / std::sqrt(2.0); + return std::sqrt(all * all > first * first ? all * all - first * first : 0.0) / all; + }; + CHECK(bright(out[4]) > 1.3 * bright(out[1])); // half way: brighter + CHECK(bright(out[3]) > 1.2 * bright(out[4])); // all the way: brighter again + // And no louder for it than an accent is: the lift is the tone's, within a dB. + CHECK_NEAR(float(rms(out[3], 4800) / rms(out[1], 4800)), 1.0f, 0.12f); +} + +TEST(fm_accent_to_the_index_stops_at_the_fold_over_cap) { + // Where IDX is already at the cap (a high note, a wide ratio), an accent with ACC at the + // top is the capped note and louder: the lift comes before the cap, not after it. + TrackParams p = fm_params(); + p.set(1, 64); // a wide ratio + p.set(2, 127); // IDX at the top + static float out[2][2400]; + for (int k = 0; k < 2; k++) { + p.set(kScnFirst + 1, k == 0 ? 0 : 127); + const FmSettings s = FmSettings::make(p, kRate, 1.0f / kRate); + FmVoice v; + v.reset(); + v.set_note(96.0f, 100.0f / 127.0f, true); + v.gate_on(); + for (float &x : out[k]) x = 0.0f; + render(v, s, out[k], 2400); + } + for (int i = 0; i < 2400; i++) CHECK(out[1][i] == out[0][i]); +} + // --- WAV: the modulator pair's wave -------------------------------------------------------- TEST(fm_wave_numbers_names_and_tables) { diff --git a/tests/test_help.cpp b/tests/test_help.cpp index e81fd71a..d0bbf5fc 100644 --- a/tests/test_help.cpp +++ b/tests/test_help.cpp @@ -123,7 +123,8 @@ TEST(help_knob_words_fit_beside_a_three_letter_name) { 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::fm), 41), "ACCENT TO INDEX") == 0); + CHECK(std::strcmp(help_param_words(uint8_t(MachineId::fm), 42), "") == 0); CHECK(std::strcmp(help_param_words(uint8_t(MachineId::midi), 24), "") == 0); // no page } @@ -171,6 +172,7 @@ TEST(help_starts_on_the_screens_own_page) { // 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")); + CHECK(first_page_has(place_of(HelpScreen::edit, 10, int(MachineId::fm)), "ACC: ACCENTS BRIGHTER")); // 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 9550c6d3..422edd23 100644 --- a/tests/test_project.cpp +++ b/tests/test_project.cpp @@ -2280,6 +2280,11 @@ int old_lfo(int t, int p) { return int(kit_lfo_from_band(p, g_kit_source.tracks[ // What a parameter loads as when its section is absent: 0, except the OSC page's, which loads // the legacy voice (core/project.hpp, kKitOscLegacy), and SCN's, which loads no scan // (kKitScnDefault). +// A kit from before FM4's ACC (the machine pages' generation under 3) opens an FM4 track with it +// at 0, whatever the SCN page's second slot held: the default SPD, 28, in every such kit. +int before_acc(int t, int p, int value) { + return machine_is_fm(g_kit_source.tracks[t].machine) && p == kKitScnFirst + 1 ? 0 : value; +} int absent_param(int p) { if (p >= kKitScnFirst) return int(kKitScnDefault[p - kKitScnFirst]); return p >= kKitAsrEnd && p < kKitOscEnd ? int(kKitOscLegacy[p - kKitAsrEnd]) : 0; @@ -2483,7 +2488,7 @@ TEST(kit_a_file_from_before_the_lfo_loads_with_every_lfo_and_arp_off) { CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), old_lfo(t, p)); } for (int p = kKitLfoEnd; p < kKitParams; p++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), absent_param(p)); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), before_acc(t, p, absent_param(p))); } } @@ -2499,7 +2504,7 @@ TEST(kit_a_file_from_before_the_lfo_loads_with_every_lfo_and_arp_off) { CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), migrated(t, p)); } for (int p = kKitSoundParams; p < kKitParams; p++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), absent_param(p)); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), before_acc(t, p, absent_param(p))); } CHECK_EQ(int(g_kit_loaded.tracks[t].machine), int(g_kit_source.tracks[t].machine)); } @@ -3795,7 +3800,7 @@ TEST(kit_lfo_trig_round_trips_and_an_older_file_runs_every_lfo_free) { for (int t = 0; t < kTracks; t++) { CHECK_EQ(int(g_kit_loaded.tracks[t].lfo_trig), int(kLfoTrigFree)); for (int p = 0; p < kKitParams; p++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), old_lfo(t, p)); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), before_acc(t, p, old_lfo(t, p))); } } @@ -3850,7 +3855,7 @@ TEST(kit_arp_settings_round_trip_and_an_older_file_plays_every_arp_as_before) { for (int t = 0; t < kTracks; t++) { for (int f = 0; f < kArpExtFields; f++) CHECK_EQ(int(arp_ext_get(g_kit_loaded.tracks[t].arp, f)), 0); for (int p = 0; p < kKitParams; p++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), old_lfo(t, p)); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), before_acc(t, p, old_lfo(t, p))); } for (int s = 0; s < kModSlots; s++) { CHECK_EQ(int(g_kit_loaded.tracks[t].mod[s].source), int(g_kit_source.tracks[t].mod[s].source)); @@ -3920,7 +3925,7 @@ TEST(kit_mod_slots_round_trip_and_an_older_file_loads_every_slot_off) { CHECK(!g_kit_loaded.tracks[t].mod[s].on()); } for (int p = 0; p < kKitParams; p++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), old_lfo(t, p)); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), before_acc(t, p, old_lfo(t, p))); } CHECK_EQ(int(g_kit_loaded.tracks[t].lfo_trig), int(g_kit_source.tracks[t].lfo_trig)); } @@ -4047,7 +4052,7 @@ TEST(kit_choke_groups_round_trip_and_an_older_file_has_none) { CHECK_EQ(int(g_kit_loaded.tracks[t].choke), 0); CHECK_EQ(int(g_kit_loaded.tracks[t].lfo_trig), int(g_kit_source.tracks[t].lfo_trig)); for (int p = 0; p < kKitParams; p++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), old_lfo(t, p)); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), before_acc(t, p, old_lfo(t, p))); } } @@ -4157,7 +4162,7 @@ TEST(kit_the_asr_page_round_trips_and_an_older_file_loads_it_at_zero) { CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), migrated(t, p)); } for (int p = kKitArpEnd; p < kKitParams; p++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), absent_param(p)); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), before_acc(t, p, absent_param(p))); } } } @@ -4255,7 +4260,7 @@ TEST(kit_the_scn_page_round_trips_and_an_older_file_loads_it_off) { CHECK_EQ(int(kit_read(g_kit_loaded, g_kit_alt, old_size)), int(SerializeResult::ok)); for (int t = 0; t < kTracks; t++) { for (int i = 0; i < kKitScnParams; i++) { - CHECK_EQ(int(g_kit_loaded.tracks[t].params[kKitScnFirst + i]), int(kKitScnDefault[i])); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[kKitScnFirst + i]), before_acc(t, kKitScnFirst + i, int(kKitScnDefault[i]))); } } @@ -4358,7 +4363,7 @@ TEST(kit_a_v060_kit_zeroes_the_drum_pages_and_a_mono_wid) { // 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) || - (machine_is_fm(m) && p == kKitScnFirst); + (machine_is_fm(m) && (p == kKitScnFirst || p == kKitScnFirst + 1)); CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), zeroed ? 0 : int(g_kit_source.tracks[t].params[p])); } @@ -4402,7 +4407,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]), 2); + CHECK_EQ(int(g_kit_file[generation]), 3); 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++) { @@ -4419,7 +4424,7 @@ TEST(kit_perc_noise_survives_a_new_kit_and_is_zeroed_in_one_from_before_it) { for (int p = 0; p < kKitParams; p++) { const bool zeroed = t == 2 && p >= kKitArpEnd && p < kKitAsrEnd; CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), - zeroed ? 0 : int(g_kit_source.tracks[t].params[p])); + zeroed ? 0 : before_acc(t, p, int(g_kit_source.tracks[t].params[p]))); } } @@ -4438,17 +4443,20 @@ 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) { +TEST(kit_fm_wave_and_accent_survive_a_new_kit_and_are_off_in_one_from_before_them) { 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; + g_kit_source.tracks[1].params[kKitScnFirst + 1] = 90; + g_kit_source.tracks[4].params[kKitScnFirst + 1] = 77; 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[1].params[kKitScnFirst + 1]), 90); CHECK_EQ(int(g_kit_loaded.tracks[4].params[kKitScnFirst]), 5); for (int older : {1, 0}) { g_kit_file[generation] = uint8_t(older); @@ -4456,14 +4464,26 @@ TEST(kit_fm_wave_survives_a_new_kit_and_is_the_sine_in_one_from_before_it) { 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++) { + // ACC, the second, is a generation younger and goes to 0 with it; the last two are not + // FM4's and are left alone. + CHECK_EQ(int(g_kit_loaded.tracks[1].params[kKitScnFirst + 1]), 0); + for (int k = 2; 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. + // ACC, the page's second slot, is generation 3: a kit that knows it keeps it (above, with + // the wave), and one written between the two keeps its wave and opens ACC at 0. A WAVE + // track's SPD in the same slot stays. + CHECK_EQ(int(g_kit_loaded.tracks[4].params[kKitScnFirst + 1]), 77); g_kit_file[generation] = 2; + 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]), 3); + CHECK_EQ(int(g_kit_loaded.tracks[1].params[kKitScnFirst + 1]), 0); + CHECK_EQ(int(g_kit_loaded.tracks[4].params[kKitScnFirst + 1]), 77); + // A wave past the last is damage: read as the last. + g_kit_file[generation] = 3; 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)); diff --git a/tests/test_sounds.cpp b/tests/test_sounds.cpp index 57dd2fbe..64955bed 100644 --- a/tests/test_sounds.cpp +++ b/tests/test_sounds.cpp @@ -165,10 +165,13 @@ 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. + // FM4 writes WAV and ACC, the first two SCN slots, and leaves the other two: a sound from + // before the waves puts it back on the sine, and the wave presets each pick theirs. ACC is + // the preset's own number, 0 where it names none (not SCN's default SPD, which a WAVE or + // KICK preset that leaves the page out writes there). const uint8_t fm = uint8_t(MachineId::fm); - CHECK(((sound_preset_writes(fm) >> kSoundScnFirst) & 0xFu) == 1u); + CHECK(((sound_preset_writes(fm) >> kSoundScnFirst) & 0xFu) == 3u); + bool lifts = false; bool waves[kKitFmWaves] = {}; for (int i = 0; i < sound_preset_count(fm); i++) { for (int p = 0; p < kKitParams; p++) params[p] = 77; @@ -176,10 +179,14 @@ TEST(sounds_a_preset_writes_its_pages_and_leaves_the_mix_the_lfo_and_the_arp) { 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); + CHECK_EQ(int(params[kSoundScnFirst + 1]), int(sound_preset(fm, i)->scn[1])); + CHECK_EQ(int(params[kSoundScnFirst + 2]), 77); + CHECK_EQ(int(params[kSoundScnFirst + 3]), 77); waves[params[kSoundScnFirst]] = true; + lifts = lifts || params[kSoundScnFirst + 1] != 0; } for (bool heard : waves) CHECK(heard); + CHECK(lifts); 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)); diff --git a/tests/test_ui.cpp b/tests/test_ui.cpp index 2d1904b1..7470d093 100644 --- a/tests/test_ui.cpp +++ b/tests/test_ui.cpp @@ -12345,7 +12345,7 @@ TEST(ui_a_percs_asr_page_is_nois) { 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. + // number that stops at the last wave, and the second as ACC. The page is OPS; two knobs are free. Strata &app = fresh(); post_track(Cmd::set_machine, 0, uint8_t(MachineId::fm)); pump(4); @@ -12373,11 +12373,19 @@ TEST(ui_fm4s_ninth_page_is_ops_and_wav_names_its_waves) { 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]; + // ACC, the second knob: a plain amount (not the WAVE pair's SPD, a rate, in the same slot). + CHECK(screen_has(app, "ACC")); + post_cmd_track_param(0, kScnFirst + 1, 0); + pump(4); app.on_encoder(1, +5); pump(); - CHECK_EQ(int(app_engine().params(0).v[kScnFirst + 1]), int(before)); + CHECK_EQ(int(app_engine().params(0).v[kScnFirst + 1]), 5); + check_layout(app, "EDIT OPS, FM4 with ACC turned"); + // The two free knobs do nothing. + const uint8_t before = app_engine().params(0).v[kScnFirst + 2]; + app.on_encoder(2, +5); + pump(); + CHECK_EQ(int(app_engine().params(0).v[kScnFirst + 2]), int(before)); key(ENAGA_KEY_F4); }