diff --git a/CHANGELOG.md b/CHANGELOG.md index b76745d4..cb410b10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,11 @@ the project file format or the controls. fit beside the playing one still loads after the boundary. SAVE says `SAVING K2 UNCHANGED` when the kit playing was edited since its section brought it: the save keeps the edit in the project's kit, and the song kit stays as stored. +- **The MIX page.** EDIT's last page, on every machine, holds the mixer's four settings as + parameters: WID the width, CHO the chorus send, SLP the SLAP level and DCK the duck depth in + percent. A turn there or on MIXER moves the same setting, and as parameters they can be locked + on a step, stored in a scene and swept by a macro. Scenes saved before keep none of them. + - **Next song.** On PROJECTS, push A queues the project under the cursor as the next song (`NEXT FIRST`, shown on every screen). When the transport stops, at the end of a SONG chain or on STOP, it opens while the last song's delay and reverb ring out, and under the internal clock diff --git a/app/app.hpp b/app/app.hpp index 265da45b..32210548 100644 --- a/app/app.hpp +++ b/app/app.hpp @@ -564,6 +564,7 @@ const char *page_name(Page page) { case Page::asr: return "ENV"; // the whole envelope (Roland, 2026-11-26) case Page::osc: return "OSC"; case Page::scn: return "SCAN"; + case Page::mix: return "MIX"; default: return "?"; } } @@ -599,14 +600,16 @@ constexpr const char *kAsrNames[kAsrParams] = {"ATK", "SUS", "REL", "FSU"}; constexpr const char *kOscNames[kOscParams] = {"WAV", "OS2", "SUB", "DRV"}; // And the WAVE pair's SCN page (dsp/va.cpp): the scan's mode, speed, end frame and curve. constexpr const char *kScnNames[kScnParams] = {"MOD", "SPD", "END", "CRV"}; +// And every machine's MIX page (dsp/track.hpp): width, chorus send, slapback level, duck depth. +constexpr const char *kMixNames[kMixParams] = {"WID", "CHO", "SLP", "DCK"}; // EDIT's pages: the four of sound, then the track's LFO (dsp/lfo.hpp), its arpeggiator // (core/arp.hpp), the VA machines' note envelope, ASR, and their oscillators, OSC (dsp/va.cpp), -// then the WAVE pair's scan, SCAN. Pages 8 and 9 are the hole between OSC and SCN +// then the WAVE pair's scan, SCAN, and every machine's MIX. Pages 8 and 9 are the hole between OSC and SCN // (dsp/track.hpp): no knob on them is live on any machine, so the selection keys step over them // as they step over a drum's ENV. Everywhere else a page is still four encoders over four // parameters. -constexpr int kEditPages = int(Page::scn) + 1; +constexpr int kEditPages = int(Page::mix) + 1; constexpr bool edit_page_hole(int page) { return page * kParamsPerPage >= kOscEnd && page * kParamsPerPage < kScnFirst; } diff --git a/app/engine.cpp b/app/engine.cpp index eb75ba63..e031e2cd 100644 --- a/app/engine.cpp +++ b/app/engine.cpp @@ -92,6 +92,8 @@ static_assert(kSoundOscFirst == kOscFirst && kFactoryOsc == kOscFirst, "core/'s OSC page and dsp/track.hpp's have diverged"); static_assert(kSoundScnFirst == kScnFirst && kKitScnFirst == kScnFirst && kKitOscEnd == kOscEnd, "core/'s SCN page and dsp/track.hpp's have diverged"); +static_assert(kKitMixFirst == kMixFirst && kKitMixParams == kMixParams && kKitMixDuckIndex == kMixDuck, + "core/'s MIX page and dsp/track.hpp's have diverged"); static_assert(kLfoTrigFree == uint8_t(LfoTrig::free) && kLfoTrigRetrig == uint8_t(LfoTrig::retrig) && kLfoTrigOneShot == uint8_t(LfoTrig::one_shot) && @@ -407,7 +409,10 @@ bool Engine::make_room_for_poly_voice(int track, uint8_t note) { // note to a machine asks here first, so this is the one place that holds it back. if (frozen_[track].on()) return false; PolyMachine *target = polys_[track]; - if (target == nullptr || !target->would_add_voice(note)) return true; + if (target == nullptr) return true; + // WID as this step sounds it, a lock on it included: the note is laid out at this width. + target->set_width(width_sanitized(sounding(track).v[kMixWidth])); + if (!target->would_add_voice(note)) return true; // A unison note (WID, core/width.hpp) takes two voices, so it makes room for two. The first // decides whether the note plays; past it, the machine steals one of its own if it must. @@ -443,10 +448,22 @@ bool Engine::make_room_for_poly_voice(int track, uint8_t note) { void Engine::sync_widths() { for (int t = 0; t < kTracks; t++) { - if (machines_[t] != nullptr) machines_[t]->set_width(width_sanitized(project_.kit.tracks[t].width)); + if (machines_[t] != nullptr) machines_[t]->set_width(width_sanitized(sounding(t).v[kMixWidth])); } } +// The kit's width, chorus, slap and duck fields into MIX's parameter bytes, after a MIXER turn: +// the base the knobs turn, and the sounding copy unless a lock holds it, as Cmd::set_param does. +void Engine::mix_params_from_kit(int track) { + for (int k = 0; k < kMixParams; k++) { + const int p = kMixFirst + k; + params_[track].v[p] = kit_mix_field(project_.kit.tracks[track], k); + if ((locked_[track] >> p & 1u) == 0) effective_[track].v[p] = params_[track].v[p]; + } + perform_dirty_ = true; + sync_widths(); +} + // --- the CPU guard ---------------------------------------------------------------------------- void Engine::run_cpu_guard() { @@ -507,8 +524,8 @@ void Engine::prepare_machine(int track) { // The sound's 16, the ASR and OSC pages' 8 and SCN's 4: a WAVE reads all of them (dsp/track.hpp). The // LFO and arp bytes between them are not compared, so turning an LFO knob does not re-prepare // a machine. - static_assert(kOscFirst == kAsrFirst + kAsrParams && kTrackParams == kScnFirst + kScnParams, - "ASR and OSC are eight bytes compared as one run, SCN the last four"); + static_assert(kOscFirst == kAsrFirst + kAsrParams && kScnEnd == kScnFirst + kScnParams, + "ASR and OSC are eight bytes compared as one run, SCN four more; MIX is the chain's"); if (prepare_memo_ && machine_prepared_for_[track] == machine && same_bytes(machine_prepared_[track].v, params.v, kParams) && same_bytes(machine_prepared_[track].v + kAsrFirst, params.v + kAsrFirst, @@ -527,18 +544,25 @@ void Engine::prepare_chain(int track) { // a dry plan prepares exactly what it did before. ChainMix mix = mix_[track]; mix.level *= perf_plan_.tracks; - // Send C, the chorus: a kit byte read here, at control rate, so nothing else has to copy it. - mix.chorus = float(chorus_send_sanitized(project_.kit.tracks[track].chorus)) * - (1.0f / float(kChorusSendMax)); + // MIX (WID CHO SLP DCK) from the sounding bytes, so a lock, a scene or a macro on one is + // heard; unmoved they are the kit's fields (mix_params_from_kit). + // Send C, the chorus. + mix.chorus = float(chorus_send_sanitized(params.v[kMixChorus])) * (1.0f / float(kChorusSendMax)); // WID on a mono track widens its highs in the chain; a POLY track's WID is its voices' and // a GRAIN track's its grains' (machine_plays_width). + if (machines_[track] != nullptr) machines_[track]->set_width(width_sanitized(params.v[kMixWidth])); mix.width = machine_plays_width(machine_id_[track]) ? 0.0f - : float(width_sanitized(project_.kit.tracks[track].width)) * (1.0f / float(kWidthMax)); - // SLAP: the kit's four bytes, the division at the tempo. Off, the chain reads none of the - // other three, so they stay 0: a tempo change then does not prepare the chain again. + : float(width_sanitized(params.v[kMixWidth])) * (1.0f / float(kWidthMax)); + // DCK, in percent as the kit holds it; the source track never ducks under itself. + const uint8_t depth = params.v[kMixDuck]; + mix.duck = track == duck_source_ ? 0.0f + : float(depth > kDuckDepthMax ? kDuckDepthMax : depth) / 100.0f; + // SLAP: its level from the bytes, the other three the kit's, the division at the tempo. Off, + // the chain reads none of the other three, so they stay 0: a tempo change then does not + // prepare the chain again. const KitTrack &kt = project_.kit.tracks[track]; - mix.slap = float(slap_sanitized(kt.slap)) * (1.0f / float(kSlapMax)); + mix.slap = float(slap_sanitized(params.v[kMixSlap])) * (1.0f / float(kSlapMax)); mix.slap_frames = 0.0f; mix.slap_feedback = 0.0f; mix.slap_tone_hz = 0.0f; @@ -677,6 +701,11 @@ bool Engine::apply_sound(const Command &command, int track, int) { // before the copy runs. The next step rebuilds effective_ from the kit anyway, // so a lock on this parameter still wins from then on. effective_[track].v[command.a] = clamp_7bit(value); + // MIX's bytes are the kit's width, chorus, slap and duck fields as well. + if (command.a >= kMixFirst) { + kit_mix_from_param(project_.kit.tracks[track], command.a, params_[track].v[command.a]); + if (command.a == kMixDuck) apply_duck(); + } } break; @@ -840,11 +869,13 @@ bool Engine::apply_sound(const Command &command, int track, int) { if (command.c == 1) { uint8_t &send = project_.kit.tracks[track].chorus; send = send == 0 ? kChorusSendToggle : uint8_t(0); + mix_params_from_kit(track); break; } const int next = int(project_.kit.tracks[track].chorus) + int(int8_t(command.b)); project_.kit.tracks[track].chorus = uint8_t(next < 0 ? 0 : (next > int(kChorusSendMax) ? int(kChorusSendMax) : next)); + mix_params_from_kit(track); break; } @@ -860,10 +891,11 @@ bool Engine::apply_sound(const Command &command, int track, int) { if (command.c == 1) { if (command.a == 0) *field = *field == 0 ? kSlapToggle : uint8_t(0); else if (command.a == 1) *field = uint8_t(*field >= top ? 0 : *field + 1); - break; + } else { + const int next = int(*field) + int(int8_t(command.b)); + *field = uint8_t(next < 0 ? 0 : (next > top ? top : next)); } - const int next = int(*field) + int(int8_t(command.b)); - *field = uint8_t(next < 0 ? 0 : (next > top ? top : next)); + if (command.a == 0) mix_params_from_kit(track); break; } @@ -877,7 +909,7 @@ bool Engine::apply_sound(const Command &command, int track, int) { const int next = int(width) + int(int8_t(command.b)); width = uint8_t(next < 0 ? 0 : (next > int(kWidthMax) ? int(kWidthMax) : next)); } - if (machines_[track] != nullptr) machines_[track]->set_width(width); + mix_params_from_kit(track); break; } @@ -1655,6 +1687,7 @@ bool Engine::apply_mixer(const Command &command, int track, int) { break; } apply_duck(); + if (DuckField(command.a) == DuckField::depth) mix_params_from_kit(track); break; } @@ -2988,6 +3021,7 @@ void Engine::kit_from_params() { for (int t = 0; t < kTracks; t++) { KitTrack &track = project_.kit.tracks[t]; for (int i = 0; i < kTrackParams; i++) track.params[i] = params_[t].v[i]; + for (int p = kMixFirst; p < kMixEnd; p++) kit_mix_from_param(track, p, params_[t].v[p]); track.level = mix_[t].level; // `machine` and `sample` are not derived from anything the engine owns yet: a track's // machine is fixed at init until M6 makes it switchable, and sample paths arrive with @@ -3044,6 +3078,8 @@ void Engine::params_from_kit() { rewire_machines(); for (int t = 0; t < kTracks; t++) { + // MIX's bytes are the fields KIT.BIN, the factory and a kit recall set. + kit_mix_to_params(project_.kit.tracks[t]); const KitTrack &track = project_.kit.tracks[t]; for (int i = 0; i < kTrackParams; i++) { params_[t].v[i] = track.params[i] > 127 ? uint8_t(127) : track.params[i]; diff --git a/app/engine.hpp b/app/engine.hpp index 9c183d42..df5c05bf 100644 --- a/app/engine.hpp +++ b/app/engine.hpp @@ -946,6 +946,7 @@ class Engine { bool run_choke(int t, float *mono, uint32_t frames, float *right = nullptr); // Each POLY track's machine takes its kit's WID (core/width.hpp). void sync_widths(); + void mix_params_from_kit(int track); uint32_t choke_at_[kTracks] = {kNoChokeFrame, kNoChokeFrame, kNoChokeFrame, kNoChokeFrame, kNoChokeFrame, kNoChokeFrame, kNoChokeFrame, kNoChokeFrame}; float choke_gain_[kTracks] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; diff --git a/app/ui_editview.hpp b/app/ui_editview.hpp index 58a9554d..054f34fe 100644 --- a/app/ui_editview.hpp +++ b/app/ui_editview.hpp @@ -119,6 +119,8 @@ return EditView::bars; case Page::scn: return machine_reads_scn(id) ? EditView::wave_scan : EditView::bars; + case Page::mix: + return EditView::bars; } return EditView::bars; } @@ -494,6 +496,11 @@ add("EACH NOTE: POS TO END"); } break; + case Page::mix: + // The duck's source never ducks under itself, so its DCK does nothing. + if (int(engine_.project().kit.duck.source) == selected_) add("SOURCE: NO DCK"); + add("ALSO ON MIXER"); + break; } *out = 0; } diff --git a/app/ui_mixer.hpp b/app/ui_mixer.hpp index 87c4001b..3e3d5c13 100644 --- a/app/ui_mixer.hpp +++ b/app/ui_mixer.hpp @@ -440,6 +440,7 @@ // The same for any track: a macro's target names its parameter on its own track's machine. const char *track_param_name_on(int track, int index) const { if (!track_param_real(index)) return "---"; + if (index >= kMixFirst) return kMixNames[index - kMixFirst]; 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]; @@ -664,6 +665,23 @@ append(out, "MAN"); return; } + // MIX: OFF at 0 for WID, CHO and SLP as MIXER shows them; WID on a POLY track with U + // from unison up; DCK the percent it is. + if (index >= kMixFirst && index < kMixEnd) { + if (index == kMixDuck) { + append_number(out, value); + *out++ = '%'; + } else if (value == 0) { + append(out, "OFF"); + } else { + if (index == kMixWidth && machine_is_poly(engine_.machine_id(selected_)) && + value >= kWidthUnison) { + *out++ = 'U'; + } + append_number(out, value); + } + return; + } if (machine_is_wave(engine_.machine_id(selected_)) && append_wave_value(out, index, value)) return; if (machine_is_fm(engine_.machine_id(selected_)) && append_fm_value(out, index, value)) return; if (machine_is_grain(engine_.machine_id(selected_)) && append_grain_value(out, index, value)) return; diff --git a/core/factory.cpp b/core/factory.cpp index fff23c2f..0bec1e31 100644 --- a/core/factory.cpp +++ b/core/factory.cpp @@ -217,6 +217,8 @@ void factory_kit(Kit &kit) { // 1-4 still steps the hats to 48. The kick, bass, acid and chord stay where they were. kit.tracks[kHats].width = 40; kit.tracks[kPerc].width = 32; + // MIX's parameter bytes are those fields (core/project.hpp, kit_mix_to_params). + for (int t = 0; t < kTracks; t++) kit_mix_to_params(kit.tracks[t]); } // --- the sends and the master --------------------------------------------- diff --git a/core/help.cpp b/core/help.cpp index 3016c498..2c72cc27 100644 --- a/core/help.cpp +++ b/core/help.cpp @@ -627,14 +627,19 @@ constexpr const char *kGrainOscWords[4] = {"SCAN SPEED", "PITCH SPRAY", "", ""}; // The WAVE pair's SCAN page (dsp/va.cpp, "SCN"). constexpr const char *kScnWords[4] = {"SCAN MODE", "SCAN SPEED", "SCAN END FRAME", "SCAN CURVE"}; constexpr int kScanHelpPage = 10; +// Every machine's MIX page (dsp/track.hpp): the mixer's four as parameters. +constexpr const char *kMixWords[4] = {"STEREO WIDTH", "CHORUS SEND", "SLAPBACK LEVEL", "DUCK DEPTH"}; +constexpr int kMixHelpPage = 11; const char *const kEditPageNames[kHelpEditPages] = {"SRC", "FLTR", "AMP", "FX", "LFO", "ARP", - "ENV", "OSC", "---", "---", "SCAN"}; + "ENV", "OSC", "---", "---", "SCAN", "MIX"}; -// Does the machine read EDIT's page 6 (ASR), 7 (OSC) or 10 (SCAN)? Nobody reads the hole. +// Does the machine read EDIT's page 6 (ASR), 7 (OSC) or 10 (SCAN)? Nobody reads the hole, and +// every machine has MIX. bool reads_page(uint8_t machine, int page) { if (page == 6) return machine_has_asr_page(machine); if (page == 7) return machine_has_osc_page(machine); + if (page == kMixHelpPage) return true; return page == kScanHelpPage && machine_has_scn_page(machine); } @@ -799,6 +804,11 @@ void knob_rows(const HelpPlace &place, bool slc_auto, char rows[kHelpRows][kHelp add_row(rows, count, "RAND DRFT"); add_row(rows, count, "SPD 64+ SYNCED"); break; + case kMixHelpPage: + add_row(rows, count, "THE MIXER SETTINGS"); + add_row(rows, count, "LOCK OR SCENE THEM"); + add_row(rows, count, "DCK IN PERCENT"); + break; default: break; } if (page == 0 && machine_is_wave(place.machine)) add_row(rows, count, "TBL 16 TABLES 8 EACH"); @@ -1079,6 +1089,7 @@ const char *help_param_words(uint8_t machine, int index) { } if (machine_is_fm(machine)) return slot == 0 ? "MODULATOR WAVE" : slot == 1 ? "ACCENT TO INDEX" : ""; return machine_reads_scn(machine) ? kScnWords[slot] : ""; + case kMixHelpPage: return kMixWords[slot]; default: return ""; } } diff --git a/core/help.hpp b/core/help.hpp index 8d69c753..a62793cc 100644 --- a/core/help.hpp +++ b/core/help.hpp @@ -48,8 +48,8 @@ enum class HelpScreen : uint8_t { count }; -// SRC FLTR AMP FX LFO ARP ASR OSC, two pages of the hole, SCAN: as app/app.hpp's kEditPages. -constexpr int kHelpEditPages = 11; +// SRC FLTR AMP FX LFO ARP ASR OSC, two pages of the hole, SCAN, MIX: as app/app.hpp's kEditPages. +constexpr int kHelpEditPages = 12; constexpr int kHelpMixerPages = 23; // as app/app.hpp's kMixerPageCount constexpr int kHelpRows = 10; // rows under the title, above the page line constexpr int kHelpChars = 21; // one line of Enaga's font on the 128-pixel screen diff --git a/core/perform.cpp b/core/perform.cpp index a21b2cf6..4724ed31 100644 --- a/core/perform.cpp +++ b/core/perform.cpp @@ -112,10 +112,11 @@ SerializeResult find_sections(const uint8_t *buffer, uint32_t size, uint16_t ver // --- PERFORM.BIN sizes ---------------------------------------------------- -constexpr uint32_t kPerformSections = 9; -// The last seven, the scenes' LFO bytes, their master EQ, their arp bytes, their ASR bytes, their -// OSC bytes, the LFO layout and their SCN bytes, may each be absent (an older file). -constexpr uint32_t kPerformOptionalSections = 7; +constexpr uint32_t kPerformSections = 10; +// The last eight, the scenes' LFO bytes, their master EQ, their arp bytes, their ASR bytes, their +// OSC bytes, the LFO layout, their SCN bytes and their MIX bytes, may each be absent (an older +// file). +constexpr uint32_t kPerformOptionalSections = 8; constexpr uint32_t kSceneTrackBytes = uint32_t(kKitSoundParams) + 2; // values, then the bitmask constexpr uint32_t kSceneBytes = kSceneTrackBytes * uint32_t(kTracks); constexpr uint32_t kScenesBytes = kSceneBytes * uint32_t(kScenes); @@ -157,12 +158,20 @@ constexpr uint32_t kSceneScnTrackBytes = uint32_t(kKitScnParams) + 1; constexpr uint32_t kSceneScnBytes = kSceneScnTrackBytes * uint32_t(kTracks) * uint32_t(kScenes); constexpr uint32_t kSceneScnOffset = kPerformLfoLayoutOffset + kPerformLfoLayoutBytes; -constexpr uint32_t kPerformTotalBytes = kHeaderBytes + kSceneScnOffset + kSceneScnBytes; +// MIX's four values and stored bits, the high half of the sixth mask byte. +constexpr uint32_t kSceneMixTrackBytes = uint32_t(kKitMixParams) + 1; +constexpr uint32_t kSceneMixBytes = + kSceneMixTrackBytes * uint32_t(kTracks) * uint32_t(kScenes); +constexpr uint32_t kSceneMixOffset = kSceneScnOffset + kSceneScnBytes; +constexpr uint32_t kPerformTotalBytes = kHeaderBytes + kSceneMixOffset + kSceneMixBytes; constexpr uint8_t kLfoStoredMask = uint8_t((1u << kKitLfoParams) - 1u); constexpr uint8_t kAsrStoredMask = uint8_t((1u << kKitAsrParams) - 1u); constexpr uint8_t kOscStoredMask = uint8_t((1u << kKitOscParams) - 1u); constexpr uint8_t kScnStoredMask = uint8_t((1u << kKitScnParams) - 1u); constexpr int kScnStoredByte = kKitScnFirst / 8; +constexpr uint8_t kMixStoredMask = uint8_t((1u << kKitMixParams) - 1u); +constexpr int kMixStoredByte = kKitMixFirst / 8; +constexpr int kMixStoredShift = kKitMixFirst % 8; static_assert(kKitSoundParams == 16, "section 1's stored bitmask is two bytes on the strength of " "16 sound parameters per track"); @@ -170,6 +179,9 @@ static_assert(kKitLfoParams + kKitArpParams == 8 && kSceneStoredBytes == 6, "the LFO's stored bits are the low half of the third mask byte, the arp's the high"); static_assert(kKitScnFirst % 8 == 0 && kKitScnParams == 4, "the SCN page's stored bits are the low half of the sixth mask byte"); +static_assert(kMixStoredByte == kScnStoredByte && kMixStoredShift == kKitScnParams && + kKitMixParams == 4 && kKitParams == kKitMixFirst + kKitMixParams, + "the MIX page's stored bits are the high half of the sixth mask byte"); static_assert(kKitArpEnd == 24 && kKitAsrParams == 4 && kKitOscParams == 4, "the ASR page's stored bits are the low half of the fourth mask byte, OSC's the high"); @@ -482,6 +494,7 @@ SerializeResult perform_write(const SceneSet &scenes, const MacroSet ¯os, ui {kSectionPerformSceneOsc, kSceneOscOffset, kSceneOscBytes}, {kSectionPerformLfoLayout, kPerformLfoLayoutOffset, kPerformLfoLayoutBytes}, {kSectionPerformSceneScn, kSceneScnOffset, kSceneScnBytes}, + {kSectionPerformSceneMix, kSceneMixOffset, kSceneMixBytes}, }; Writer w(buffer, capacity); @@ -552,11 +565,19 @@ SerializeResult perform_write(const SceneSet &scenes, const MacroSet ¯os, ui for (int s = 0; s < kScenes; s++) { const Scene &scene = scenes.scenes[s]; for (int t = 0; t < kTracks; t++) { - for (int p = kKitScnFirst; p < kKitParams; p++) w.u8(scene.values[t][p]); + for (int p = kKitScnFirst; p < kKitScnEnd; p++) w.u8(scene.values[t][p]); w.u8(uint8_t(scene.stored[t][kScnStoredByte] & kScnStoredMask)); } } + for (int s = 0; s < kScenes; s++) { + const Scene &scene = scenes.scenes[s]; + for (int t = 0; t < kTracks; t++) { + for (int p = kKitMixFirst; p < kKitParams; p++) w.u8(scene.values[t][p]); + w.u8(uint8_t((scene.stored[t][kMixStoredByte] >> kMixStoredShift) & kMixStoredMask)); + } + } + if (!w.ok() || w.size() != kPerformTotalBytes) return SerializeResult::buffer_too_small; return finish_container(w, buffer, kPerformTotalBytes, written); } @@ -575,7 +596,7 @@ SerializeResult perform_read(SceneSet &scenes, MacroSet ¯os, const uint8_t * kSectionPerformSceneLfo, kSectionPerformSceneMaster, kSectionPerformSceneArp, kSectionPerformSceneAsr, kSectionPerformSceneOsc, kSectionPerformLfoLayout, - kSectionPerformSceneScn}; + kSectionPerformSceneScn, kSectionPerformSceneMix}; uint32_t offset[kPerformSections] = {}; uint32_t length[kPerformSections] = {}; const SerializeResult found = find_sections(buffer, size, kPerformVersion, wanted, @@ -592,6 +613,7 @@ SerializeResult perform_read(SceneSet &scenes, MacroSet ¯os, const uint8_t * if (offset[6] != 0 && length[6] < kSceneOscBytes) return refuse(SerializeResult::malformed); if (offset[7] != 0 && length[7] < kPerformLfoLayoutBytes) return refuse(SerializeResult::malformed); if (offset[8] != 0 && length[8] < kSceneScnBytes) return refuse(SerializeResult::malformed); + if (offset[9] != 0 && length[9] < kSceneMixBytes) return refuse(SerializeResult::malformed); Reader r(buffer, size); if (!r.seek(kHeaderBytes + offset[0])) return refuse(SerializeResult::malformed); @@ -772,7 +794,7 @@ SerializeResult perform_read(SceneSet &scenes, MacroSet ¯os, const uint8_t * for (int s = 0; s < kScenes; s++) { Scene &scene = scenes.scenes[s]; for (int t = 0; t < kTracks; t++) { - for (int p = kKitScnFirst; p < kKitParams; p++) { + for (int p = kKitScnFirst; p < kKitScnEnd; p++) { scene.values[t][p] = clamp_u8(r.u8(), 0, kit_param_max(p)); } scene.stored[t][kScnStoredByte] = uint8_t(r.u8() & kScnStoredMask); @@ -781,6 +803,24 @@ SerializeResult perform_read(SceneSet &scenes, MacroSet ¯os, const uint8_t * if (!r.ok()) return refuse(SerializeResult::truncated); } + // The scenes' MIX bytes, into the sixth mask byte's high half (cleared with SCN's above). + // Absent: no scene stores one. DCK past 100 percent reads as 100. + if (offset[9] != 0) { + if (!r.seek(kHeaderBytes + offset[9])) return refuse(SerializeResult::malformed); + for (int s = 0; s < kScenes; s++) { + Scene &scene = scenes.scenes[s]; + for (int t = 0; t < kTracks; t++) { + for (int p = kKitMixFirst; p < kKitParams; p++) { + scene.values[t][p] = clamp_u8(r.u8(), 0, kit_param_max(p)); + } + const uint8_t bits = uint8_t(r.u8() & kMixStoredMask); + scene.stored[t][kMixStoredByte] = + uint8_t(scene.stored[t][kMixStoredByte] | (bits << kMixStoredShift)); + } + } + if (!r.ok()) return refuse(SerializeResult::truncated); + } + // The LFO layout (format decision C). Absent is a file whose scenes and macros hold WAV and // DST as the old bands: each becomes the number it meant, and past the last is the last. uint8_t lfo_layout = 0; diff --git a/core/perform.hpp b/core/perform.hpp index cf7f81cf..1425eace 100644 --- a/core/perform.hpp +++ b/core/perform.hpp @@ -353,6 +353,10 @@ constexpr uint16_t kSectionPerformLfoLayout = 8; // is: the four values, then a byte whose low four bits say which are stored -- the low half of the // sixth mask byte. OPTIONAL on read. constexpr uint16_t kSectionPerformSceneScn = 9; +// The scenes' MIX bytes (WID CHO SLP DCK, every machine's), laid out as SCN's: the four values, +// then a byte whose low four bits say which are stored -- the HIGH half of the sixth mask byte. +// OPTIONAL on read: a file from before MIX was a page stores none. +constexpr uint16_t kSectionPerformSceneMix = 10; // Loading is value-tolerant but structure-strict, exactly as the other three file types are: a // macro naming a track that does not exist is dropped, while a bad magic, an unknown version, a diff --git a/core/project.cpp b/core/project.cpp index 39b21a25..4b773b6d 100644 --- a/core/project.cpp +++ b/core/project.cpp @@ -519,6 +519,7 @@ void kit_clear(Kit &kit) { // SCN as a kit from before it loads: no scan, but END and SPD where a turn of MOD is // heard at once. for (int p = 0; p < kKitScnParams; p++) kit.tracks[t].params[kKitScnFirst + p] = kKitScnDefault[p]; + kit_mix_to_params(kit.tracks[t]); } } @@ -1167,7 +1168,7 @@ SerializeResult kit_write(const Kit &kit, uint8_t *buffer, uint32_t capacity, ui for (int t = 0; t < kTracks; t++) w.u8(chorus_send_sanitized(kit.tracks[t].chorus)); for (int t = 0; t < kTracks; t++) w.u8(width_sanitized(kit.tracks[t].width)); for (int t = 0; t < kTracks; t++) { - for (int p = kKitScnFirst; p < kKitParams; p++) w.u8(kit.tracks[t].params[p]); + for (int p = kKitScnFirst; p < kKitScnEnd; p++) w.u8(kit.tracks[t].params[p]); } for (int t = 0; t < kTracks; t++) { const KitTrack &track = kit.tracks[t]; @@ -1465,7 +1466,7 @@ SerializeResult kit_read(Kit &kit, const uint8_t *buffer, uint32_t size) { if (offset[15] != 0) { if (!r.seek(kHeaderBytes + offset[15])) return refuse(SerializeResult::malformed); for (int t = 0; t < kTracks; t++) { - for (int p = kKitScnFirst; p < kKitParams; p++) { + for (int p = kKitScnFirst; p < kKitScnEnd; p++) { kit.tracks[t].params[p] = clamp_u8(r.u8(), 0, kit_param_max(kit.tracks[t].machine, p)); } } @@ -1609,7 +1610,7 @@ SerializeResult kit_read(Kit &kit, const uint8_t *buffer, uint32_t size) { } if (machine_is_kick(m)) { for (int p = kKitAsrEnd; p < kKitOscEnd; p++) track.params[p] = 0; - for (int p = kKitScnFirst; p < kKitParams; p++) track.params[p] = 0; + for (int p = kKitScnFirst; p < kKitScnEnd; p++) track.params[p] = 0; } if (!machine_is_poly(m)) track.width = 0; } @@ -1638,6 +1639,8 @@ SerializeResult kit_read(Kit &kit, const uint8_t *buffer, uint32_t size) { if (machine_is_fm(track.machine)) track.params[kKitScnFirst + 1] = 0; } } + // MIX's four parameter bytes are the fields read above (no section of their own). + for (int t = 0; t < kTracks; t++) kit_mix_to_params(kit.tracks[t]); return SerializeResult::ok; } diff --git a/core/project.hpp b/core/project.hpp index 8ff52410..4a39d33b 100644 --- a/core/project.hpp +++ b/core/project.hpp @@ -75,7 +75,13 @@ constexpr int kKitOscParams = 4; constexpr int kKitOscEnd = kKitAsrEnd + kKitOscParams; constexpr int kKitScnFirst = 40; constexpr int kKitScnParams = 4; -constexpr int kKitParams = kKitScnFirst + kKitScnParams; +constexpr int kKitScnEnd = kKitScnFirst + kKitScnParams; +// MIX after SCN: WID CHO SLP DCK, the mix settings as parameters (dsp/track.hpp says why). Their +// bytes mirror KitTrack's width, chorus, slap and duck, which KIT.BIN stores as ever, so a kit +// file holds no MIX section of its own: kit_mix_to_params fills these four from the fields. +constexpr int kKitMixFirst = kKitScnEnd; +constexpr int kKitMixParams = 4; +constexpr int kKitParams = kKitMixFirst + kKitMixParams; static_assert(kKitOscEnd == 32 && kKitScnFirst > kKitOscEnd, "the hole sits between OSC and SCN"); // Whether `index` is a parameter at all: false in the hole and out of range. @@ -83,12 +89,15 @@ constexpr bool kit_param_real(int index) { return (index >= 0 && index < kKitOscEnd) || (index >= kKitScnFirst && index < kKitParams); } // How many are: every index but the hole's. -constexpr int kKitRealParams = kKitOscEnd + kKitScnParams; +constexpr int kKitRealParams = kKitOscEnd + kKitScnParams + kKitMixParams; // A real index counted without the hole, 0 .. kKitRealParams - 1, for a list of them. constexpr int kit_real_index(int index) { return index < kKitScnFirst ? index : index - (kKitScnFirst - kKitOscEnd); } // SCN's MOD byte is a number like the LFO's WAV (format decision C): the scan mode, 0 OFF. constexpr int kKitScanModeIndex = kKitScnFirst + 0; +// MIX's DCK byte is the duck depth in percent, 0-100, as KitTrack::duck is, so the two are one +// number and a mixer turn and a parameter turn agree to the step. +constexpr int kKitMixDuckIndex = kKitMixFirst + 3; constexpr int kKitScanModes = 10; // static_asserted in dsp/va.hpp constexpr uint8_t kKitScanModeMax = uint8_t(kKitScanModes - 1); // What a kit from before SCN loads as, and what a fresh track holds: no scan, SPD at 1 Hz, END @@ -111,13 +120,15 @@ constexpr uint8_t kKitLfoDestMax = uint8_t(kKitSoundParams); // OFF, then the 1 constexpr uint8_t kLfoLayoutNumbers = 1; // 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). +// random range): 127 for all but the LFO's WAV and DST and MIX's DCK (percent; kDuckDepthMax, +// static_asserted beside it). 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 == kKitMixDuckIndex ? uint8_t(100) : uint8_t(127); } @@ -529,8 +540,8 @@ struct KitTrack { // (core/onsets.hpp), 0 into equal slices. Not a parameter, so no lock, scene or LFO moves // it: it says what kind of sample this is, like the path beside it. uint8_t slice_mode = 0; - // How far this track ducks under the sidechain duck, in percent: 0 never, 100 fully. Not a - // parameter either -- like the fader beside it, it is the mixer's, and no lock moves it. + // How far this track ducks under the sidechain duck, in percent: 0 never, 100 fully. Also + // EDIT's MIX page DCK, parameter 47, in the same percent. uint8_t duck = kDuckDepthDefault; // LFO TRIG (dsp/lfo.hpp): when the track's LFO starts a cycle -- kLfoTrigFree, Retrig or // OneShot. A kit setting on the LFO page (push RAT), not a parameter: there is no 33rd byte @@ -548,8 +559,8 @@ struct KitTrack { // section 12. KitArp arp; // How much of the track goes to the chorus, send C (dsp/buses.hpp), 0-127: 0 none, 127 all, - // post-fader as SNA and SNB are. A kit setting turned on MIXER's CHO 1-4 / 5-8, not a - // parameter, for TRIG's reason: no lock, scene or LFO moves it. KIT.BIN's optional section 14. + // post-fader as SNA and SNB are. Turned on MIXER's CHO 1-4 / 5-8 or as EDIT's MIX page CHO, + // parameter 45 (kit_mix_to_params); KIT.BIN's optional section 14. uint8_t chorus = 0; // WID, the stereo width of a POLY track (VA POLY, WAVE POLY, FM4), 0-127, in zones: // 0 mono, as every track played before: the machine renders one channel @@ -557,13 +568,14 @@ struct KitTrack { // stays in the middle (core/width.hpp has the fan) // 64-127 unison: every note takes two voices, detuned apart (more as it rises) and // panned hard left and right - // A kit setting turned on MIXER's WID 1-4 / 5-8, not a parameter: FM4 has no free slot. + // Turned on MIXER's WID 1-4 / 5-8 or as EDIT's MIX page WID, parameter 44. // On every other (mono) machine 1-127 widens the track's highs in its insert chain, no zones // (dsp/chain.hpp, ChainMix::width; 2026-11-29). KIT.BIN's optional section 15. uint8_t width = 0; // SLAP, the track's own short echo (dsp/chain.hpp, 2026-11-29): separate from send A, so a // rim's 1/16 and a dub chord's dotted 1/8 can differ. Four kit settings on MIXER's SLAP page - // (the selected track), not parameters, for TRIG's reason; KIT.BIN's optional section 17. + // (the selected track); the level is also EDIT's MIX page SLP, parameter 46, and the other + // three are kit settings for TRIG's reason. KIT.BIN's optional section 17. // slap level 0-127: 0 off (the stage is skipped), 127 the echo as loud as the track // slap_time which division (kSlapDivisions): 1/32 ... 1/4 // slap_feedback 0-127: one echo at 0, up to 0.9 a pass at 127 @@ -590,6 +602,29 @@ struct KitTrack { KitSliceMan slice_man; }; +// MIX's four parameter bytes (WID CHO SLP DCK, kKitMixFirst) and KitTrack's fields are the same +// four numbers: the fields are what KIT.BIN, the factory and the showcases write, the bytes what +// a lock, a scene or a macro names. These keep them equal. `kit_mix_to_params` after anything +// that set the fields (a load, a default kit); `kit_mix_from_param` after a parameter turn. +constexpr uint8_t kit_mix_field(const KitTrack &track, int k) { + return k == 0 ? (track.width <= 127 ? track.width : uint8_t(127)) + : k == 1 ? (track.chorus <= 127 ? track.chorus : uint8_t(127)) + : k == 2 ? (track.slap <= 127 ? track.slap : uint8_t(127)) + : (track.duck <= 100 ? track.duck : uint8_t(100)); +} +inline void kit_mix_to_params(KitTrack &track) { + for (int k = 0; k < kKitMixParams; k++) track.params[kKitMixFirst + k] = kit_mix_field(track, k); +} +inline void kit_mix_from_param(KitTrack &track, int param, uint8_t value) { + const uint8_t top = kit_param_max(param); + const uint8_t v = value > top ? top : value; + if (param == kKitMixFirst + 0) track.width = v; + else if (param == kKitMixFirst + 1) track.chorus = v; + else if (param == kKitMixFirst + 2) track.slap = v; + else if (param == kKitMixFirst + 3) track.duck = v; +} +static_assert(kDuckDepthMax == 100, "kit_param_max and kit_mix_field hold DCK at 100 percent"); + constexpr int kLfoSlows = 3; constexpr uint32_t kLfoSlowFactor[kLfoSlows] = {1, 4, 16}; // A byte past the last is damage and reads as x1, as an absent one does. diff --git a/core/sounds.cpp b/core/sounds.cpp index dfdbeb4d..831509e8 100644 --- a/core/sounds.cpp +++ b/core/sounds.cpp @@ -603,7 +603,7 @@ constexpr int kHatChoke = 10; constexpr int kGrainPos = 0; constexpr int kGrainPit = 8; -static_assert(kSoundScnFirst + 4 == kKitParams, "the SCN page is the last four kit bytes"); +static_assert(kSoundScnFirst + 4 == kKitScnEnd, "the SCN page is the four kit bytes before MIX"); static_assert(kKitParams <= 64, "sound_preset_writes is one bit a parameter"); } // namespace diff --git a/core/usersounds.cpp b/core/usersounds.cpp index fb6c3d43..74992801 100644 --- a/core/usersounds.cpp +++ b/core/usersounds.cpp @@ -87,7 +87,9 @@ bool user_sound_extras_equal(const UserSoundExtras &a, const UserSoundExtras &b) } bool user_sound_owns(uint8_t machine, int p) { - return user_sounds_supported(machine) && kit_param_real(p); + // MIX (WID CHO SLP DCK) is the track's place in the mix, not its sound: a sound saved on a + // wide pad does not widen the kick it is loaded onto. + return user_sounds_supported(machine) && kit_param_real(p) && p < kKitMixFirst; } bool user_sounds_supported(uint8_t machine) { return sound_preset_writes(machine) != 0; } diff --git a/docs/CHEATSHEET.md b/docs/CHEATSHEET.md index efa3c660..04e545a5 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 in two parts. DO: save, GEN ALL (a part on every unmuted track, one undo level), JAM REC, ARR REC, ARR UNDO, save as, open, kits, new, reload, clear pattern, load demo. SET: click, count-in, REC MODE, quantize, auto-fill, FX glide, TRANSPOSE (scale or semitones), loop length, chain, song, PROG CHG OUT, TEMPO GUARD. The screen keys jump between the parts | -| 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 | +| 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, OPS on FM4, and MIX on every machine | | 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) | @@ -186,7 +186,7 @@ Page 1 NOTE VEL LEN MICR, page 2 PROB COND RTCH RAMP, page 3 ACNT SLID CHRD. | Mode | UP / DOWN | LEFT / RIGHT | Screen keys L/R | Pad-row L/R | A-D | OK / CLR | FUNC + arrow | | --- | --- | --- | --- | --- | --- | --- | --- | | GRID | Track | Step page 1-4 | EDIT page (for A-D) | Step page | Current EDIT page params | — / clear | Copy / paste | -| EDIT | Track | Page SRC FLTR AMP FX LFO ARP ENV OSC SCAN | Page | Step page | The page's 4 params | SMP: open SAMPLES; drums, synths and GRN: open SOUNDS / clear | Copy / paste | +| EDIT | Track | Page SRC FLTR AMP FX LFO ARP ENV OSC SCAN MIX | Page | Step page | The page's 4 params | SMP: open SAMPLES; drums, synths and GRN: open SOUNDS / clear | Copy / paste | | KEYS | Track | Octave (OCT 0-7) | EDIT page (for A-D) | Step page | Current EDIT page params | — | Copy / paste | | MACHINE | Machine | Machine column (3 over) | Track | Step page | A: machine, B: MIDI OUT channel (OFF, 1-16) | SMP/GRN: open SAMPLES; drums and synths: open SOUNDS / — | Copy / paste | | KIT | Slot | Page of 8 slots | Page of 8 slots | — | A: slot | Recall (twice) / back to MACHINE | DOWN: save here, UP: read the card again | @@ -349,6 +349,7 @@ every pattern change sends its number 0-127 as a program change on your MIDI CH. | EDIT ENV | `HOLDS: PAD OR LEN`, `SUS 0: ONE-SHOT`, `NOT ON THIS MACHINE` | Notes hold (SUS up); notes are one-shots; a machine with no ENV page | | EDIT OSC | `SAW + SUB DRIVEN`, `NOT ON THIS MACHINE` | What goes into the VA's filter; a machine with no OSC page | | EDIT SCAN | `EACH NOTE: POS TO END`, `SCAN OFF: TURN MOD`, `END = POS: NO TRAVEL` | The scan runs with each note; MOD is OFF; END on POS leaves nowhere to go | +| EDIT MIX | `ALSO ON MIXER`, `SOURCE: NO DCK` | The same four as MIXER's pages; the duck's source track never ducks | | PROJECT slots | `05>`, bright box | Queued slot; live slot (bright), has trigs (mid), empty (dark) | | PROJECT | `SMP OS.X- 12/64M` | Per track sample: O ready, S streamed from the card, . loading, X failed, - none; MiB used/budget | | Any | `STREAM LATE` | The card fell behind a streamed file; the gap played as silence | @@ -371,7 +372,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) · OPS the modulators' wave (FM4). +**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) · MIX the mixer settings WID CHO SLP DCK as parameters (every machine). **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. diff --git a/docs/CONTROLS.md b/docs/CONTROLS.md index b36b4592..abf3a08c 100644 --- a/docs/CONTROLS.md +++ b/docs/CONTROLS.md @@ -47,8 +47,8 @@ HOME "system", PLAY "◀◀", STOP "▶▶", MIXER "fx", EDIT "rec src". - **Arrow pad:** the cursor on the screen. UP/DOWN rows, LEFT/RIGHT sideways. OK picks, CLR goes back (or clears, where there is something selected to clear). - **Screen keys:** the screen's pages; FUNC + a screen key is **TRANSPOSE** (below), on every - screen. EDIT SRC FLTR AMP FX LFO ARP ENV OSC SCAN (SCAN on - the WAVE machines only; a page a machine lacks is stepped over); MIXER's twenty-three; + screen. EDIT SRC FLTR AMP FX LFO ARP ENV OSC SCAN MIX (SCAN on + the WAVE machines only; a page a machine lacks is stepped over; MIX on every machine); MIXER's twenty-three; PROJECT, CHAIN, PATTERN, SETUP, PROJECTS; the step page's field pages; SAMPLES' and KIT's pages of eight. On GRID and KEYS, where A-D turn the current EDIT page, they turn that page. The one-page screens give them their one sideways setting: MACHINE and SOUNDS the track, diff --git a/docs/DESIGN_NOTES.md b/docs/DESIGN_NOTES.md index 06caa6c3..6453d2f3 100644 --- a/docs/DESIGN_NOTES.md +++ b/docs/DESIGN_NOTES.md @@ -258,7 +258,7 @@ before the LFOs. Hold STEP + FUNC + push no longer clears a lock: it toggles the CyDrums' S1. The page is MOD SPD END CRV at parameter ids **40-43**, not 32-35: ids 32-36 are taken as lock ids by a step's extra chord notes (core/stepnotes.hpp), and a lock id is a parameter index, so 32-39 is a hole that no parameter, scene bit, macro target or file byte uses -(`track_param_real`, `kit_param_real`; kTrackParams and kKitParams are 44, kKitRealParams 36). +(`track_param_real`, `kit_param_real`; kTrackParams and kKitParams were 44 then, 48 with MIX). The EDIT pages follow: `Page::scn` is 10, pages 8 and 9 are skipped like any dead page. The KIT section (16) and the PERFORM section (9) hold only the four real bytes; an older file loads MOD OFF. MOD is a number 0-9 (format decision C), clamped on the way in. @@ -834,3 +834,27 @@ drum bus clip (their fold-over is at -40 dB or lower). 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. + +## The MIX page + +Roland, 2026-11-30 (second review, proposal 11): WID, CHO, SLAP's level and the duck depth as a +lockable page on EDIT, rather than staying MIXER-only kit settings. They are parameters 44-47 +(`kMixFirst`, after SCN; lock ids 44-63 were free), `Page::mix` = 11, every machine's last page. + +- **The kit fields stay the store.** KitTrack's `width`, `chorus`, `slap` and `duck` are what + KIT.BIN, the factory, the showcases and a kit recall write, so KIT.BIN has no MIX section: + `kit_mix_to_params` fills bytes 44-47 from the fields after a load, a default kit and in + `params_from_kit`; a parameter turn writes the field back (`kit_mix_from_param`), and a MIXER + turn the byte (`Engine::mix_params_from_kit`). One number each, so DCK is in percent, 0-100 + (`kit_param_max`), as the field is. +- **The chain reads the sounding bytes.** `prepare_chain` takes chorus, width, SLAP's level and + the duck depth from `sounding(track)`, so a lock, a scene and a macro are heard; at rest they + equal the fields and the golden renders do not move. A POLY track's width is set from the + sounding byte in `prepare_chain` and again before each note's voices are counted + (`make_room_for_poly_voice`), so a lock on WID lays that note out at its width. +- **Scenes:** PERFORM.BIN's optional section 10, four values and the high half of the sixth + stored byte per track (SCN has the low half); an older file stores none. +- **Not a sound's.** `user_sound_owns` is false for 44-47 (a saved sound leaves the mix alone, as + it left the fields), presets never write them, and they are not LFO or mod-slot targets. +- SLAP's time, feedback and tone stay kit settings on MIXER's SLAP page: four knobs a page, and + the level is the one worth automating. diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 2ecd03ba..a5e59fdf 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -45,7 +45,7 @@ UNIT_CHECKLIST.md's ~650 boxes, 6 are ticked. | **Screen frame**: top line with bar.beat, progress line, live strip of what is off rest, master meter with held peak and limiter light | #144 | ○ (W26) | The meter is 2 px wide; nothing may draw past x 124 | | **RESAMPLE, SAMPLES, SOUNDS, CHAIN, KITS, KEYS and PATTERN redrawn** (docs/SCREENS.md): RESAMPLE's meter, live take and length bar; the browsers' previews; CHAIN as blocks on a lane; KITS' machine pictures; KEYS' held chord and knob gauges; PATTERN's swing bars; no caption repeats a screen's name | #176 | ○ (W45) | draw() see docs/BUDGET.md "The screen" | | **PROJECT's slots and MACHINE redrawn to the drafts** (docs/SCREENS.md): a map of all 128 patterns (empty, used, playing, queued) and each of the shown bank's sixteen drawn as its steps; MACHINE's kit as pictures, every machine a picture of its sound, what it is for and what it costs | #175 | ○ (W44) | draw() 1.28 ms PROJECT, 2.50 ms MACHINE (emulator, cl6x) | -| **Stereo width WID** on VA POLY, WAVE POLY and FM4: MIXER WID 1-4 / 5-8, 1-63 spread (chord notes across the field), 64-127 unison (two voices a note, hard L/R, 6-40 cents); push OFF / 48 / 96 | #216 | ○ (W60) | A kit setting, not lockable; unison halves a track's notes (3) and counts two voices a note against the 12; docs/BUDGET.md "Stereo width" | +| **Stereo width WID** on VA POLY, WAVE POLY and FM4: MIXER WID 1-4 / 5-8, 1-63 spread (chord notes across the field), 64-127 unison (two voices a note, hard L/R, 6-40 cents); push OFF / 48 / 96 | #216 | ○ (W60) | A kit setting, lockable as EDIT's MIX WID since the MIX page; unison halves a track's notes (3) and counts two voices a note against the 12; docs/BUDGET.md "Stereo width" | | **LFO SLOW**: push WAV on the LFO page for X1, X4, X16: synced 8 bars becomes 32 or 128, a free 16 s cycle 64 or 256 s; RAT shows the real cycle | WIP | ○ (W91) | A kit setting (KIT.BIN section 18), not saved with a user sound; control rate, no CPU | | **HAT's OPN** (CYM page, D): a step longer than one plays open with OPN's decay, the next hit cuts it; GEN HATS writes open off-beats | this PR | ○ (W114) | 0 is off, so older kits play as before. Rolls and ENERGY ghosts stay closed. No locks; presets keep OPN (host: test_machines, test_generate) | | **SNARE's CLAP page** (BRS 2-5 bursts, HUM uneven gaps, VBR velocity to brightness) and **HAT's CYM page** (TLV TDC THP: a high-passed tail band with its own 0.2-6 s decay, for rides and crashes) | WIP | ○ (W90) | The seventh EDIT page on those machines, slots 24-26; all 0 is the old sound; docs/BUDGET.md "SNARE's CLAP and HAT's CYM" | @@ -231,6 +231,7 @@ FM4 and GRAIN machines. | Master: DJ filter, glue compressor, limiter, output level | v0.1.0 | ◐ | | | Master **kill EQ**: 3 bands at 250 Hz / 2.5 kHz, kill switches (FUNC + push A/B/C, FUNC + push D all three), scene-able, macro-able | v0.1.0, v0.6.0 | ○ (13d / U6, W77) | | | MIXER: 8 faders, 12 pages (3 for the duck since #89) | v0.1.0 | ◐ | | +| **EDIT MIX page** (every machine, the last page): WID CHO SLP DCK, MIXER's width, chorus send, SLAP level and duck depth as parameters 44-47: lockable on a step, in scenes and macros | this PR | ○ (W126) | The same kit bytes as MIXER's pages (KIT.BIN unchanged); scenes' MIX in an optional PERFORM.BIN section (older files store none); not a sound's, not an LFO or mod-slot target | ## Samples and resampling diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 4cf10f53..d62ff832 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -2234,11 +2234,21 @@ ride or stab at 40-80 sounds wide, while the kick's and the bass's lows stay mon cancels. PAN still places it, and the sends, a bounce and a freeze take the track as it was. A kit saved by 0.6.0 or earlier opens with WID at 0 on its mono tracks, which 0.6.0 did not widen. -WID is part of the **kit**, saved with the project and in the kit library, but not a parameter: -FM4 has no free knob slot, so no lock, scene or LFO moves it. A project or kit from before it -opens with every track mono. Spread costs a little (each voice is panned and the track's chain -runs twice), and so does a wide cloud; unison costs the voices it adds (docs/BUDGET.md "Stereo -width"). +WID is part of the **kit**, saved with the project and in the kit library. It is also a +parameter, on EDIT's **MIX** page (below), so a step can lock it and a scene or a macro can move +it. A project or kit from before it opens with every track mono. Spread costs a little (each voice is panned and the track's chain +runs twice), and so does a wide cloud; unison costs the voices it adds (docs/BUDGET.md "Stereo width"). + +### The MIX page: the mixer settings as parameters + +EDIT's last page, on every machine, is **MIX**: A **WID** the width, B **CHO** the chorus send, +C **SLP** the SLAP level and D **DCK** the duck depth in percent (0-100). They are the same four +settings as MIXER's WID, CHO, SLAP and DCK pages: a turn on either moves both. As parameters they +can be locked on a step, stored in a scene and swept by a macro, so a hat can widen on the fills, +a chord can drift into the chorus over a morph, or a scene can stop a pad ducking for the +breakdown. They are not a sound's: a saved sound leaves them as the track has them, and the LFO +and the mod slots do not reach them. On the duck's source track DCK does nothing (`SOURCE: NO +DCK`). SLAP's time, feedback and tone stay on MIXER's SLAP page. ### SLAP: a track's own echo diff --git a/docs/SPEC.md b/docs/SPEC.md index fe0b2bf8..e217438b 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -349,7 +349,7 @@ A project is one folder on the card. It loads fully into RAM when opened (patter - Little-endian binary: magic `STRA`, format version, section table, CRC-32 over the payload. - Written and read byte by byte through a small serializer. Never cast file bytes to structs (alignment rule). - An unknown version or a bad CRC is refused with a message on screen; it never crashes the app. -- **[rev]** A format grows by adding an OPTIONAL section at the end, not by a version bump: an older file without it loads with that feature off. PROJECT.BIN's section 7 (2026-11-27) holds EVOLVE: each track's period index, then the mode, the mutation and the amount; an older file opens with nothing evolving. PROJECT.BIN's section 8 (2026-11-28) holds Track Launch: each lane's source (0 its own part, 1-128 A01-H16), then the pin mask; an older file opens with every lane on its own part, a source past H16 or equal to the playing pattern reads as 0. PROJECT.BIN's section 9 (2026-11-28) holds the line input's strip, one byte per `InputField` (on, level, pan, delay, reverb, chorus, duck, tone, source, gain); an older file opens with the input off, and a shorter section reads the fields it has and defaults the rest. KIT.BIN's section 2 holds the four LFO bytes per track, and PERFORM.BIN's section 3 holds each scene's LFO values and their stored mask. KIT.BIN's section 3 holds the four ARP bytes per track and PERFORM.BIN's section 5 each scene's ARP values, and PROJECT.BIN's section 5 song mode (their stored bits are the high nibble of the LFO's mask byte). KIT.BIN's section 5 holds the four ASR bytes per track and PERFORM.BIN's section 6 each scene's (their stored bits are the low nibble of a fourth mask byte). KIT.BIN's section 6 holds the sidechain duck (eight depths, then source, attack, hold, release); a kit without it gets the duck v0.1.0 had fixed. KIT.BIN's section 7 holds the four OSC bytes per track and PERFORM.BIN's section 7 each scene's (their stored bits are the high nibble of the fourth mask byte); a kit without it loads WAV 0, OS2 0, SUB 102, DRV 0 (`kKitOscLegacy`). KIT.BIN's section 8 is the filter layout (D8) and section 9 each track's LFO TRIG (0 FREE, 1 RETRIG, 2 ONE-SHOT); a kit without it runs every LFO FREE. Section 10 holds the two mod slots per track, and section 11 each track's choke group (0 none, 1-4); a kit without it has no track in a group. Section 12 holds each track's arp settings, VAR RHYTHM ACCENT RATCHET, four table indices (core/arp.hpp); a kit without it plays every arp as before. PROJECT.BIN's section 10 (song sections) grew a tail on 2026-11-30: after the layout byte and the 64 eight-byte records, one KIT byte per entry (0 `--`, 1-8 the song kits K1-K8); an older build reads the first 513 bytes and ignores it, and a file without it opens with every entry's KIT `--`. An older reader ignores the extra sections. +- **[rev]** A format grows by adding an OPTIONAL section at the end, not by a version bump: an older file without it loads with that feature off. PROJECT.BIN's section 7 (2026-11-27) holds EVOLVE: each track's period index, then the mode, the mutation and the amount; an older file opens with nothing evolving. PROJECT.BIN's section 8 (2026-11-28) holds Track Launch: each lane's source (0 its own part, 1-128 A01-H16), then the pin mask; an older file opens with every lane on its own part, a source past H16 or equal to the playing pattern reads as 0. PROJECT.BIN's section 9 (2026-11-28) holds the line input's strip, one byte per `InputField` (on, level, pan, delay, reverb, chorus, duck, tone, source, gain); an older file opens with the input off, and a shorter section reads the fields it has and defaults the rest. KIT.BIN's section 2 holds the four LFO bytes per track, and PERFORM.BIN's section 3 holds each scene's LFO values and their stored mask. KIT.BIN's section 3 holds the four ARP bytes per track and PERFORM.BIN's section 5 each scene's ARP values, and PROJECT.BIN's section 5 song mode (their stored bits are the high nibble of the LFO's mask byte). KIT.BIN's section 5 holds the four ASR bytes per track and PERFORM.BIN's section 6 each scene's (their stored bits are the low nibble of a fourth mask byte). KIT.BIN's section 6 holds the sidechain duck (eight depths, then source, attack, hold, release); a kit without it gets the duck v0.1.0 had fixed. KIT.BIN's section 7 holds the four OSC bytes per track and PERFORM.BIN's section 7 each scene's (their stored bits are the high nibble of the fourth mask byte); a kit without it loads WAV 0, OS2 0, SUB 102, DRV 0 (`kKitOscLegacy`). KIT.BIN's section 8 is the filter layout (D8) and section 9 each track's LFO TRIG (0 FREE, 1 RETRIG, 2 ONE-SHOT); a kit without it runs every LFO FREE. Section 10 holds the two mod slots per track, and section 11 each track's choke group (0 none, 1-4); a kit without it has no track in a group. Section 12 holds each track's arp settings, VAR RHYTHM ACCENT RATCHET, four table indices (core/arp.hpp); a kit without it plays every arp as before. PROJECT.BIN's section 10 (song sections) grew a tail on 2026-11-30: after the layout byte and the 64 eight-byte records, one KIT byte per entry (0 `--`, 1-8 the song kits K1-K8); an older build reads the first 513 bytes and ignores it, and a file without it opens with every entry's KIT `--`. PERFORM.BIN's section 10 (2026-11-30) holds each scene's MIX values (WID CHO SLP DCK, parameters 44-47) and their stored bits (the high nibble of the sixth mask byte); a file without it has no scene storing one. MIX itself needs no KIT.BIN section: its bytes are the kit's width, chorus, slap and duck fields. An older reader ignores the extra sections. **Core structures (sketch)** diff --git a/docs/UNIT_CHECKLIST.md b/docs/UNIT_CHECKLIST.md index e9697764..fc5548cb 100644 --- a/docs/UNIT_CHECKLIST.md +++ b/docs/UNIT_CHECKLIST.md @@ -3782,3 +3782,13 @@ track on a different file from the kit's own (a loud one-shot on step 1 is easie up to the boundary. Again on the next pass. `____` - On entry 2, turn a knob of any track, then FUNC + HOME, OK: `SAVING K2 UNCHANGED`. Let the chain come round to entry 2 again: the stored K2 plays, without the edit. `____` + +**W126. The MIX page (4 min).** A01, PLAY. Select track 3 (the hats), EDIT, SELECT LEFT from SRC. +- The last tab is MIX: WID CHO SLP DCK, the info line `ALSO ON MIXER`. Turn B (CHO) to 60; MIXER + CHO 1-4 shows track 3 at 60, and the hats sound wider. `____` +- Back on EDIT MIX, hold step 5 on GRID and turn A (WID) to 127: only that hit is wider. `____` +- Assign a macro to track 6's DCK with its top at 0 (PERFORM): turning it up, the bass stops + pumping under the kick; back at 0 it pumps as before. A scene storing DCK 0, morphed to: the + same. `____` +- Select track 1 (the duck's source), EDIT MIX: `SOURCE: NO DCK`. SAVE, reopen: every value and + the scene come back. `____` diff --git a/dsp/track.hpp b/dsp/track.hpp index 23963182..43897061 100644 --- a/dsp/track.hpp +++ b/dsp/track.hpp @@ -76,14 +76,28 @@ constexpr int kOscEnd = kOscFirst + kOscParams; // stays an index; nothing reads or writes them, and `track_param_real` tells them apart. constexpr int kScnParams = 4; constexpr int kScnFirst = 40; -constexpr int kTrackParams = kScnFirst + kScnParams; +constexpr int kScnEnd = kScnFirst + kScnParams; +// And a tenth: MIX, the track's mix settings as parameters -- WID CHO SLP DCK: the width, the +// chorus send, the slapback's level and the duck depth (0-100, kit_param_max). They were kit +// settings turned on MIXER only; as parameters a lock, a scene, a macro or a sound move them. +// The kit keeps its fields (KitTrack::width, chorus, slap, duck) as what KIT.BIN stores, and +// core/project.hpp's kit_mix_to_params / kit_mix_from_param keep the two in step. Not sound: +// the insert chain reads them, not the machine, so the prepare memo does not compare them. +constexpr int kMixParams = 4; +constexpr int kMixFirst = kScnEnd; +constexpr int kMixEnd = kMixFirst + kMixParams; +constexpr int kMixWidth = kMixFirst + 0; +constexpr int kMixChorus = kMixFirst + 1; +constexpr int kMixSlap = kMixFirst + 2; +constexpr int kMixDuck = kMixFirst + 3; +constexpr int kTrackParams = kMixEnd; constexpr bool track_param_real(int index) { return (index >= 0 && index < kOscEnd) || (index >= kScnFirst && index < kTrackParams); } enum class Page : uint8_t { - src = 0, fltr = 1, amp = 2, fx = 3, lfo = 4, arp = 5, asr = 6, osc = 7, scn = 10 + src = 0, fltr = 1, amp = 2, fx = 3, lfo = 4, arp = 5, asr = 6, osc = 7, scn = 10, mix = 11 }; constexpr int page_first(Page page) { return int(page) * kParamsPerPage; } @@ -97,11 +111,14 @@ static_assert(page_first(Page::osc) == kOscFirst, "the OSC page is the four byte static_assert(kOscParams == kParamsPerPage, "OSC is one page of four"); static_assert(page_first(Page::scn) == kScnFirst, "the SCN page is the four bytes after the hole"); static_assert(kScnParams == kParamsPerPage, "SCN is one page of four"); +static_assert(page_first(Page::mix) == kMixFirst, "the MIX page is the four bytes after SCN"); +static_assert(kMixParams == kParamsPerPage, "MIX is one page of four"); -// All of a track's parameters (32, the hole, then SCN's 4), as stored in a kit and overridden by +// All of a track's parameters (32, the hole, then SCN's 4 and MIX's 4), as stored in a kit and overridden by // locks. Values are 0-127; // each machine and the chain map them to physical units themselves, so the sequencer never -// needs to know what a parameter means. Machines read v[0..kParams), the ASR, OSC and SCN pages only. +// needs to know what a parameter means. Machines read v[0..kParams), the ASR, OSC and SCN pages only; +// the insert chain reads MIX. struct TrackParams { uint8_t v[kTrackParams]; diff --git a/tests/scenario_mixpage.sh b/tests/scenario_mixpage.sh new file mode 100755 index 00000000..ae08ccbc --- /dev/null +++ b/tests/scenario_mixpage.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +# The MIX page in the emulator: EDIT's last page, every machine's, WID CHO SLP DCK as parameters +# (dsp/track.hpp, kMixFirst). It draws on the C674x with the real font on KICK (track 1, the duck's +# source, so its info line says SOURCE: NO DCK) and on the drums and synths after it, while the +# beat plays inside the load target. The chain reads these four bytes instead of the kit's fields +# since the page came, so the load here should match scenario_factory.sh to within noise. +# +# PLAY -> the default beat +# EDIT, SELECT_LEFT -> from SRC one page left: MIX, logged "scr EDIT MIX" +# DOWN x7 -> tracks 2-8, MIX stays the page on each +# SELECT_RIGHT -> round to SRC +# +# What the page writes, and that a lock, a scene and a macro on it are heard, is the host tests' +# (engine_the_mix_page_..., engine_a_macro_on_wid_is_heard, ui_mix_is_every_machines_last_page_...). +# +# Keys (third_party/enaga/include/enaga/abi.h): F5 = 22 PLAY, F8 = 28 EDIT, SELECT_LEFT = 8, +# SELECT_RIGHT = 9, DOWN = 25. The first press comes late (tests/scenario_m1.sh). +set -euo pipefail + +cd "$(dirname "$0")/.." +# shellcheck source=tools/env.sh +source tools/env.sh + +CYCLES=900000000 + +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_mixpage.log" + +keys=(--key 22@300000000 --key 28@360000000 --key 8@400000000) +for i in 0 1 2 3 4 5 6; do keys+=(--key "25@$((440000000 + i * 40000000))"); done +keys+=(--key 9@760000000) + +echo "running the emulator for $CYCLES cycles: play, EDIT MIX on every track, round to SRC ..." +python3 -B tools/enaga_cached.py emulate "$STAGE" --cycles "$CYCLES" "${keys[@]}" \ + > "$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}') +check("scr EDIT MIX" in screens, "SELECT_LEFT from SRC reached MIX", f"screens={screens}") +check(screens and screens[-1] == "scr EDIT SRC", "SELECT_RIGHT went round to SRC", + f"screens={screens}") +# Seven DOWN presses change the track and not the page: no other EDIT page between MIX and SRC. +between = screens[screens.index("scr EDIT MIX") + 1:-1] if "scr EDIT MIX" in screens else [] +check(not any(s.startswith("scr EDIT") for s in between), "MIX stayed the page on every track", + 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. docs/BUDGET.md records cl6x as worth about 1.7x and the 60%") +print(" target depends on it. The unit decides.") + +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_app.cpp b/tests/test_app.cpp index bb6b16c2..7f4a178a 100644 --- a/tests/test_app.cpp +++ b/tests/test_app.cpp @@ -264,7 +264,7 @@ TEST(app_the_first_save_of_a_project_writes_all_ten_files) { project_file(path, "KIT.BIN"); CHECK_EQ(host.file_bytes(path), 1615); // 1076, LFO SLOW (12 + 8), SLAP (12 + 32), SCN (12 + 32), the widths (12 + 8), the chorus sends (12 + 8), the LFO layout (12 + 1), the arp settings (12 + 32), the choke groups (12 + 8), the mod slots (12 + 48), LFO TRIG (12 + 8), the filter layout (12 + 1), the LFO and arp (2 x (12 + 8 x 4)), SLC AUTO (12 + 8), ASR (12 + 32), the duck (12 + 12), OSC (12 + 32) project_file(path, "PERFORM.BIN"); - CHECK_EQ(host.file_bytes(path), 5773); // 2424, the LFO layout (12 + 1), the scenes' LFO (12 + 640), EQ (12 + 64), arp, ASR and OSC (12 + 640 each) + CHECK_EQ(host.file_bytes(path), 6425); // 2424, the LFO layout (12 + 1), the scenes' LFO (12 + 640), EQ (12 + 64), arp, ASR, OSC, SCN and MIX (12 + 640 each) } TEST(app_a_saved_project_reloads) { diff --git a/tests/test_engine.cpp b/tests/test_engine.cpp index afccf09a..82c83f8f 100644 --- a/tests/test_engine.cpp +++ b/tests/test_engine.cpp @@ -3961,6 +3961,88 @@ TEST(engine_width_on_a_grain_track_makes_the_machine_stereo) { pump(); } +// MIX (WID CHO SLP DCK, parameters 44-47): the mixer's four settings as parameters. A MIXER turn +// moves the byte, a parameter turn moves the kit's field, and DCK stops at 100 percent. +TEST(engine_the_mix_page_and_the_mixer_are_one_setting) { + Engine &engine = clean(); + const KitTrack &kt = engine.project().kit.tracks[2]; + CHECK_EQ(int(engine.params(2).v[kMixDuck]), int(kt.duck)); + strata::test::post_delta(Cmd::set_width, 2, 0, 0, 100); + strata::test::post_delta(Cmd::set_chorus, 2, 0, 0, 30); + strata::test::post_delta(Cmd::set_slap, 2, 0, 0, 20); + pump(); + CHECK_EQ(int(engine.params(2).v[kMixWidth]), int(kt.width)); + CHECK_EQ(int(engine.params(2).v[kMixChorus]), int(kt.chorus)); + CHECK_EQ(int(engine.params(2).v[kMixSlap]), int(kt.slap)); + CHECK_EQ(int(engine.params(2).v[kMixWidth]), 100); + + post(Cmd::set_param, 2, 0, kMixChorus, 70); + post(Cmd::set_param, 2, 0, kMixSlap, 0); + post(Cmd::set_param, 2, 0, kMixDuck, 120); + pump(); + CHECK_EQ(int(kt.chorus), 70); + CHECK_EQ(int(kt.slap), 0); + CHECK_EQ(int(kt.duck), 100); + CHECK_EQ(int(engine.params(2).v[kMixDuck]), 100); + CHECK_NEAR(engine.duck_depth(2), 1.0f, 0.0f); + + // A user sound does not carry them: they are the track's place in the mix. + CHECK(!user_sound_owns(engine.machine_id(2), kMixWidth)); + + post(Cmd::set_param, 2, 0, kMixWidth, 0); + post(Cmd::set_param, 2, 0, kMixChorus, 0); + post(Cmd::set_param, 2, 0, kMixDuck, kDuckDepthDefault); + pump(); +} + +// And as a parameter, a performance control moves it: a macro on WID widens a lone mono HAT, so +// its two sides differ, though the kit's WID stays 0. +TEST(engine_a_macro_on_wid_is_heard) { + Engine &engine = clean(); + const uint8_t was = engine.project().kit.tracks[2].machine; + post(Cmd::set_machine, 2, 0, uint8_t(MachineId::hat)); + post_macro_assign(0, 2, kMixWidth, 0, 127); + post(Cmd::set_macro, 0, 0, 0, 0); + pump(); + auto side_difference = [](int blocks) { + float diff = 0.0f; + for (int b = 0; b < blocks; b++) { + pump(); + const float *out = strata::test::last_block(); + for (int i = 0; i < 64; i++) { + const float d = out[2 * i] - out[2 * i + 1]; + diff += d < 0.0f ? -d : d; + } + } + return diff; + }; + post(Cmd::trigger_note, 2, 0, 60, 127); + CHECK_EQ(side_difference(20), 0.0f); + post(Cmd::set_macro, 0, 0, 0, 127); + pump(); + CHECK_EQ(int(engine.performed(2, kMixWidth)), 127); + CHECK_EQ(int(engine.project().kit.tracks[2].width), 0); + post(Cmd::trigger_note, 2, 0, 60, 127); + CHECK(side_difference(20) > 0.01f); + post(Cmd::set_macro, 0, 0, 0, 0); + post(Cmd::macro_clear, 0, 0, 0); + post(Cmd::set_machine, 2, 0, was); + pump(); +} + +// A scene morph on DCK: the depth the chain ducks by follows the sounding byte. +TEST(engine_a_scene_morph_on_dck_moves_the_duck) { + Engine &engine = clean(); + two_scenes_differing_in(3, kMixDuck, 0, 100); + post_u(Cmd::set_morph, kMorphScale); + pump(); + CHECK_EQ(int(engine.performed(3, kMixDuck)), 100); + post_u(Cmd::set_morph, 0); + post(Cmd::set_param, 3, 0, kMixDuck, kDuckDepthDefault); + pump(); + CHECK_EQ(int(engine.performed(3, kMixDuck)), int(kDuckDepthDefault)); +} + // SLAP (2026-11-29): a short hat with its echo on. Its echoes go on sounding after the hat's // voice is spent and its machine idle, and stop once the tail is over. TEST(engine_slap_echoes_ring_on_after_the_machine_stops) { diff --git a/tests/test_perform.cpp b/tests/test_perform.cpp index 4a6de979..37cda0a1 100644 --- a/tests/test_perform.cpp +++ b/tests/test_perform.cpp @@ -23,8 +23,8 @@ using namespace strata; constexpr uint32_t kSlack = 64; // 2424, then the LFO layout (12 + 1); the scenes' LFO (12 + 640), EQ (12 + 64), arp (12 + 640), -// ASR (12 + 640), OSC (12 + 640) and SCN (12 + 640, the last section). -constexpr uint32_t kPerformFileBytes = 5773; +// ASR (12 + 640), OSC (12 + 640), SCN (12 + 640) and MIX (12 + 640, the last section). +constexpr uint32_t kPerformFileBytes = 6425; uint8_t g_buffer[kPerformFileBytes + kSlack]; uint8_t g_alternate[kPerformFileBytes + kSlack]; @@ -883,11 +883,11 @@ TEST(perform_the_header_says_strata_and_the_version) { const uint32_t written = write_performance(); CHECK_EQ(int(g_buffer[0]), int(kMagic0)); CHECK_EQ(int(peek_u16(g_buffer, kVersionOffset)), int(kPerformVersion)); - CHECK_EQ(int(peek_u16(g_buffer, 6)), 9); // scenes, macros, the scenes' LFO, EQ, arp, ASR, OSC, the LFO layout, SCN + CHECK_EQ(int(peek_u16(g_buffer, 6)), 10); // scenes, macros, the scenes' LFO, EQ, arp, ASR, OSC, the LFO layout, SCN, MIX CHECK_EQ(peek_u32(g_buffer, 8), written - kHeaderBytes); CHECK_EQ(peek_u32(g_buffer, kCrcOffset), crc32(g_buffer + kHeaderBytes, written - kHeaderBytes)); - CHECK_EQ(section_at(g_buffer, kSectionPerformScenes), kHeaderBytes + 9 * kSectionEntryBytes); + CHECK_EQ(section_at(g_buffer, kSectionPerformScenes), kHeaderBytes + 10 * kSectionEntryBytes); CHECK(section_at(g_buffer, kSectionPerformMacros) > section_at(g_buffer, kSectionPerformScenes)); CHECK(section_at(g_buffer, kSectionPerformSceneLfo) > @@ -1136,8 +1136,8 @@ TEST(perform_a_payload_declared_one_byte_past_the_file_is_truncated) { TEST(perform_a_section_one_byte_longer_than_the_payload_or_a_short_macro_table_is_malformed) { fill_performance(); const uint32_t size = write_performance(); - // The LAST section, the scenes' SCN bytes, so one byte more runs past the payload. - const uint32_t last = section_entry_at(g_buffer, kSectionPerformSceneScn); + // The LAST section, the scenes' MIX bytes, so one byte more runs past the payload. + const uint32_t last = section_entry_at(g_buffer, kSectionPerformSceneMix); const uint32_t last_len = peek_u32(g_buffer, last + 8); poke_u32(g_buffer, last + 8, last_len + 1); refresh_crc(g_buffer); @@ -1420,11 +1420,11 @@ TEST(perform_a_file_from_before_the_lfo_loads_with_no_scene_storing_one) { fill_performance(); for (int t = 0; t < kTracks; t++) scene_set(g_scenes.scenes[0], t, kKitSoundParams, 77); const uint32_t size = write_performance(); - // Before the LFO there was no scenes' EQ, arp, ASR, OSC or SCN section, nor the LFO layout: - // drop all seven, last first. - const uint32_t sizes[7] = {5121u, 5108u, 4456u, 3804u, 3152u, 3076u, 2424u}; + // Before the LFO there was no scenes' EQ, arp, ASR, OSC, SCN or MIX section, nor the LFO + // layout: drop all eight, last first. + const uint32_t sizes[8] = {5773u, 5121u, 5108u, 4456u, 3804u, 3152u, 3076u, 2424u}; uint32_t old_size = size; - for (int k = 0; k < 7; k++) { + for (int k = 0; k < 8; k++) { old_size = drop_last_section(g_buffer, g_alternate); CHECK_EQ(old_size, sizes[k]); for (uint32_t i = 0; i < old_size; i++) g_buffer[i] = g_alternate[i]; @@ -1495,7 +1495,9 @@ TEST(perform_scenes_keep_their_arp_bytes_and_an_older_file_stores_none) { } // The file the LFO and kill EQ builds wrote: everything but the arp (and the ASR and OSC - // pages after it, and the LFO layout and SCN last of all) comes back. + // pages after it, and the LFO layout, SCN and MIX last of all) comes back. + drop_last_section(g_buffer, g_alternate); + for (uint32_t i = 0; i < 5773u; i++) g_buffer[i] = g_alternate[i]; drop_last_section(g_buffer, g_alternate); for (uint32_t i = 0; i < 5121u; i++) g_buffer[i] = g_alternate[i]; drop_last_section(g_buffer, g_alternate); @@ -1572,6 +1574,8 @@ TEST(perform_scenes_keep_their_osc_bytes_beside_asr_and_an_older_file_stores_non // A file from before the OSC page (and the LFO layout after it): ASR comes back, no scene // stores an OSC byte. drop_last_section(g_buffer, g_alternate); + for (uint32_t i = 0; i < 5773u; i++) g_buffer[i] = g_alternate[i]; + drop_last_section(g_buffer, g_alternate); for (uint32_t i = 0; i < 5121u; i++) g_buffer[i] = g_alternate[i]; drop_last_section(g_buffer, g_alternate); for (uint32_t i = 0; i < 5108u; i++) g_buffer[i] = g_alternate[i]; @@ -1592,7 +1596,7 @@ TEST(perform_scenes_keep_their_osc_bytes_beside_asr_and_an_older_file_stores_non perform_init(g_scenes, g_macros); uint8_t out[kTracks][kKitParams] = {}; - scene_set(g_scenes.scenes[0], 6, kKitParams - 1, 0); // CRV, the very last bit + scene_set(g_scenes.scenes[0], 6, kKitParams - 1, 0); // MIX's DCK, the very last bit scene_set(g_scenes.scenes[1], 6, kKitParams - 1, 100); scene_morph(g_scenes.scenes[0], g_scenes.scenes[1], kMorphScale / 2, out); CHECK_EQ(int(out[6][kKitParams - 1]), 50); @@ -1628,7 +1632,10 @@ TEST(perform_scenes_keep_their_scn_bytes_and_an_older_file_stores_none) { CHECK_EQ(scene_count(g_loaded_scenes.scenes[s]), scene_count(g_scenes.scenes[s])); } - // A file from before the page: the rest comes back, no scene stores an SCN byte. + // A file from before the page (and MIX after it): the rest comes back, no scene stores an + // SCN byte. + drop_last_section(g_buffer, g_alternate); + for (uint32_t i = 0; i < 5773u; i++) g_buffer[i] = g_alternate[i]; const uint32_t old_size = drop_last_section(g_buffer, g_alternate); CHECK_EQ(old_size, 5121u); for (int s = 0; s < kScenes; s++) scene_set(g_loaded_scenes.scenes[s], 2, kKitScnFirst, 3); @@ -1637,7 +1644,50 @@ TEST(perform_scenes_keep_their_scn_bytes_and_an_older_file_stores_none) { CHECK(scene_has(g_loaded_scenes.scenes[1], 4, kKitAsrEnd + 1)); for (int s = 0; s < kScenes; s++) { for (int t = 0; t < kTracks; t++) { - for (int p = kKitScnFirst; p < kKitParams; p++) { + for (int p = kKitScnFirst; p < kKitScnEnd; p++) { + CHECK(!scene_has(g_loaded_scenes.scenes[s], t, p)); + CHECK_EQ(int(g_loaded_scenes.scenes[s].values[t][p]), 0); + } + } + } +} + +TEST(perform_scenes_keep_their_mix_bytes_and_an_older_file_stores_none) { + // MIX (WID CHO SLP DCK, ids 44-47) has a section of its own after SCN's: four values and the + // HIGH half of the sixth mask byte per track, beside SCN's low half. + fill_performance(); + Scene &scene = g_scenes.scenes[2]; + scene_set(scene, 3, kKitMixFirst + 0, 96); // WID, unison + scene_set(scene, 3, kKitMixFirst + 3, 120); // DCK, past 100 percent: held at 100 + scene_set(scene, 3, kKitScnFirst + 1, 40); // SCN's SPD, the other half of the byte + CHECK_EQ(int(scene.values[3][kKitMixFirst + 3]), 120); + const uint32_t size = write_performance(); + CHECK_EQ(int(perform_read(g_loaded_scenes, g_loaded_macros, g_buffer, size)), + int(SerializeResult::ok)); + const Scene &loaded = g_loaded_scenes.scenes[2]; + CHECK(scene_has(loaded, 3, kKitMixFirst + 0)); + CHECK(!scene_has(loaded, 3, kKitMixFirst + 1)); + CHECK(!scene_has(loaded, 3, kKitMixFirst + 2)); + CHECK(scene_has(loaded, 3, kKitMixFirst + 3)); + CHECK(scene_has(loaded, 3, kKitScnFirst + 1)); + CHECK_EQ(int(loaded.values[3][kKitMixFirst + 0]), 96); + CHECK_EQ(int(loaded.values[3][kKitMixFirst + 3]), 100); + CHECK_EQ(int(loaded.values[3][kKitScnFirst + 1]), 40); + for (int s = 0; s < kScenes; s++) { + CHECK_EQ(scene_count(g_loaded_scenes.scenes[s]), scene_count(g_scenes.scenes[s])); + } + + // A file from before MIX was a page: SCN comes back, no scene stores a MIX byte, whatever + // the set it is read into held. + const uint32_t old_size = drop_last_section(g_buffer, g_alternate); + CHECK_EQ(old_size, 5773u); + for (int s = 0; s < kScenes; s++) scene_set(g_loaded_scenes.scenes[s], 5, kKitMixFirst + 1, 9); + CHECK_EQ(int(perform_read(g_loaded_scenes, g_loaded_macros, g_alternate, old_size)), + int(SerializeResult::ok)); + CHECK(scene_has(g_loaded_scenes.scenes[2], 3, kKitScnFirst + 1)); + for (int s = 0; s < kScenes; s++) { + for (int t = 0; t < kTracks; t++) { + for (int p = kKitMixFirst; p < kKitParams; p++) { CHECK(!scene_has(g_loaded_scenes.scenes[s], t, p)); CHECK_EQ(int(g_loaded_scenes.scenes[s].values[t][p]), 0); } diff --git a/tests/test_project.cpp b/tests/test_project.cpp index 422edd23..13eb2007 100644 --- a/tests/test_project.cpp +++ b/tests/test_project.cpp @@ -205,7 +205,7 @@ void fill_kit(Kit &kit) { // SCN at what a kit from before it loads (kKitScnDefault), so that the tests of // older files, which drop its section first, see the same kit; its own test // (kit_the_scn_page_round_trips...) fills it with values of its own. - if (p >= kKitScnFirst) track.params[p] = kKitScnDefault[p - kKitScnFirst]; + if (p >= kKitScnFirst && p < kKitScnEnd) track.params[p] = kKitScnDefault[p - kKitScnFirst]; } // From PERC on: the older-file tests drop SLAP's section, and a kit without it zeroes // the drum machines' pages (kit_a_v060_kit_zeroes_the_drum_pages_and_a_mono_wid has @@ -224,6 +224,8 @@ void fill_kit(Kit &kit) { std::memset(track.sample, 0, sizeof(track.sample)); const char *name = names[t]; for (int i = 0; name[i] != '\0' && i < kSamplePathBytes - 1; i++) track.sample[i] = name[i]; + // MIX's bytes are the width, chorus, slap and duck fields, as a load makes them. + kit_mix_to_params(track); } } @@ -472,8 +474,11 @@ TEST(project_init_empties_everything_and_lives_on_a01) { // TON's flat is 64, not 0 (D8): a blank synth track starts with its tone flat. const bool tone = p == kSlotTone && machine_has_voice_filter(g_source.kit.tracks[t].machine); // And SCN loads no scan, END and SPD set (kKitScnDefault), as a kit from before it. - const int want = tone ? kToneFlat - : (p >= kKitScnFirst ? kKitScnDefault[p - kKitScnFirst] : 0); + // MIX holds the fields' defaults (the duck's 35 percent). + const int want = tone ? kToneFlat + : p >= kKitMixFirst ? int(kit_mix_field(KitTrack{}, p - kKitMixFirst)) + : p >= kKitScnFirst ? kKitScnDefault[p - kKitScnFirst] + : 0; if (g_source.kit.tracks[t].params[p] != want) kit_set++; } if (g_source.kit.tracks[t].sample[0] != '\0') kit_set++; @@ -2275,7 +2280,12 @@ void drop_duck_section() { // What g_kit_source's parameter p of track t loads as from a file without the LFO layout (format // decision C): itself, but WAV and DST read as the bands they would have been. -int old_lfo(int t, int p) { return int(kit_lfo_from_band(p, g_kit_source.tracks[t].params[p])); } +// MIX's bytes are not in any parameter section: they are the loaded kit's width, chorus, slap +// and duck fields, which each test checks on its own. +int old_lfo(int t, int p) { + if (p >= kKitMixFirst) return int(kit_mix_field(g_kit_loaded.tracks[t], p - kKitMixFirst)); + return int(kit_lfo_from_band(p, g_kit_source.tracks[t].params[p])); +} // 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 @@ -2286,6 +2296,7 @@ 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 >= kKitMixFirst) return int(kit_mix_field(KitTrack{}, p - kKitMixFirst)); if (p >= kKitScnFirst) return int(kKitScnDefault[p - kKitScnFirst]); return p >= kKitAsrEnd && p < kKitOscEnd ? int(kKitOscLegacy[p - kKitAsrEnd]) : 0; } @@ -2454,7 +2465,7 @@ TEST(kit_the_lfo_and_arp_bytes_round_trip_and_are_clamped_on_the_way_in) { refresh_crc(g_kit_file); 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 = kKitSoundParams; p < kKitParams; p++) { + for (int p = kKitSoundParams; p < kKitScnEnd; p++) { // MIX is the fields' if (!kit_param_real(p)) continue; CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), int(kit_param_max(g_kit_loaded.tracks[t].machine, p))); @@ -4337,9 +4348,10 @@ TEST(kit_a_v060_kit_zeroes_the_drum_pages_and_a_mono_wid) { KitTrack &track = g_kit_source.tracks[t]; 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); + for (int p = kKitScnFirst; p < kKitScnEnd; p++) track.params[p] = uint8_t(1 + t); if (machine_is_fm(machines[t])) track.params[kKitScnFirst] = 2; // WAV: HALF track.width = 50; + kit_mix_to_params(track); } CHECK_EQ(int(kit_write(g_kit_source, g_kit_file, uint32_t(sizeof(g_kit_file)), nullptr)), int(SerializeResult::ok)); @@ -4358,16 +4370,22 @@ TEST(kit_a_v060_kit_zeroes_the_drum_pages_and_a_mono_wid) { const bool drum = t < 3; for (int p = 0; p < kKitParams; p++) { const bool asr = p >= kKitArpEnd && p < kKitAsrEnd; - const bool osc_or_scn = (p >= kKitAsrEnd && p < kKitOscEnd) || p >= kKitScnFirst; + const bool osc_or_scn = + (p >= kKitAsrEnd && p < kKitOscEnd) || (p >= kKitScnFirst && p < kKitScnEnd); // 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, 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 || p == kKitScnFirst + 1)); - CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), - zeroed ? 0 : int(g_kit_source.tracks[t].params[p])); + // MIX's bytes are the loaded fields (SLAP's level went with its section); WID's is + // checked below. + const int want = p >= kKitMixFirst + ? int(kit_mix_field(g_kit_loaded.tracks[t], p - kKitMixFirst)) + : (zeroed ? 0 : int(g_kit_source.tracks[t].params[p])); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[p]), want); } CHECK_EQ(int(g_kit_loaded.tracks[t].width), machine_is_poly(m) ? 50 : 0); + CHECK_EQ(int(g_kit_loaded.tracks[t].params[kKitMixFirst]), machine_is_poly(m) ? 50 : 0); } } diff --git a/tests/test_storage.cpp b/tests/test_storage.cpp index aa05f65f..80d99fd1 100644 --- a/tests/test_storage.cpp +++ b/tests/test_storage.cpp @@ -857,8 +857,8 @@ TEST(storage_every_file_of_a_project_round_trips_through_the_card) { CHECK_EQ(project_bytes(), 1081u); CHECK_EQ(host.file_bytes(card_path("KIT.BIN")), 1615); CHECK_EQ(kit_bytes(engine().project().kit), 1615u); - CHECK_EQ(host.file_bytes(card_path("PERFORM.BIN")), 5773); - CHECK_EQ(perform_bytes(), 5773u); + CHECK_EQ(host.file_bytes(card_path("PERFORM.BIN")), 6425); + CHECK_EQ(perform_bytes(), 6425u); for (int b = 0; b < kBanks; b++) { char name[12]; CHECK(bank_file_name(b, name, int(sizeof name))); @@ -1769,7 +1769,7 @@ TEST(storage_an_autosave_writes_every_file_and_leaves_the_project_dirty) { } CHECK_EQ(host.file_bytes(card_path("PROJECT.BIN", true)), 1081); CHECK_EQ(host.file_bytes(card_path("KIT.BIN", true)), 1615); - CHECK_EQ(host.file_bytes(card_path("PERFORM.BIN", true)), 5773); + CHECK_EQ(host.file_bytes(card_path("PERFORM.BIN", true)), 6425); // Eleven files and SETTINGS.TXT, which carries the counter a later start compares. CHECK_EQ(host.saves() - saves_before, kFileN + 1); diff --git a/tests/test_ui.cpp b/tests/test_ui.cpp index c33d4cd7..90776324 100644 --- a/tests/test_ui.cpp +++ b/tests/test_ui.cpp @@ -894,9 +894,9 @@ TEST(ui_the_parameter_page_decides_which_parameter_an_encoder_writes) { // The pages wrap, so the four of them are reachable in either direction. key(ENAGA_KEY_SELECT_LEFT); CHECK_EQ(UiProbe::param_page(app), int(Page::src)); - // KICK has nine of the pages (its ENV slot is PNCH, its OSC slot TAIL, its SCAN slot TAPS): - // the keys step over the hole. - for (int i = 0; i < 9; i++) key(ENAGA_KEY_SELECT_LEFT); + // KICK has ten of the pages (its ENV slot is PNCH, its OSC slot TAIL, its SCAN slot TAPS, + // and MIX): the keys step over the hole. + for (int i = 0; i < 10; i++) key(ENAGA_KEY_SELECT_LEFT); CHECK_EQ(UiProbe::param_page(app), int(Page::src)); // And a lock follows the same page. The step page is not open and the mode is GRID, but @@ -6079,7 +6079,8 @@ TEST(ui_scan_is_the_wave_pairs_ninth_page_and_names_its_modes) { app.on_key(ENAGA_KEY_SELECT_RIGHT, true); app.on_key(ENAGA_KEY_SELECT_RIGHT, false); CHECK(UiProbe::param_page(app) != int(Page::scn)); - CHECK(UiProbe::param_page(app) < int(Page::osc) + 1); + CHECK(UiProbe::param_page(app) < int(Page::osc) + 1 || + UiProbe::param_page(app) == int(Page::mix)); } CHECK(!screen_has(app, "SCAN")); // no tab for a page it does not have @@ -6130,6 +6131,50 @@ TEST(ui_scan_is_the_wave_pairs_ninth_page_and_names_its_modes) { CHECK(screen_has(app, "MOD")); } +// The MIX page: every machine's last, the mixer's WID CHO SLP DCK as parameters. Reached by the +// keys on a drum as on a synth, every value fits, and a turn there is the MIXER's setting. +TEST(ui_mix_is_every_machines_last_page_and_turns_the_mixer_settings) { + Strata &app = fresh(); + post_track(Cmd::set_machine, 0, uint8_t(MachineId::snare)); + pump(4); + key(ENAGA_KEY_F8); // EDIT, track 1 + goto_edit_page(app, Page::src); + bool reached = false; + for (int i = 0; i < kEditPages && !reached; i++) { + key(ENAGA_KEY_SELECT_LEFT); // one step left of SRC: the last page + reached = UiProbe::param_page(app) == int(Page::mix); + } + CHECK(reached); + pump(); + check_layout(app, "EDIT MIX, SNARE"); + CHECK(screen_has(app, "MIX")); + CHECK(screen_has(app, "WID")); + CHECK(screen_has(app, "CHO")); + CHECK(screen_has(app, "SLP")); + CHECK(screen_has(app, "ALSO ON MIXER")); + CHECK(screen_has(app, "SOURCE: NO DCK")); // track 1 is the duck's source + + app.on_encoder(1, +40); // B: CHO + pump(); + CHECK_EQ(int(app_engine().project().kit.tracks[0].chorus), 40); + CHECK_EQ(int(app_engine().params(0).v[kMixChorus]), 40); + for (int b = 0; b < 128; b++) { + for (int i = 0; i < kMixParams; i++) post_cmd_track_param(0, uint8_t(kMixFirst + i), uint8_t(b)); + pump(); + check_layout(app, "EDIT MIX, every value"); + } + for (int i = 0; i < kMixParams; i++) post_cmd_track_param(0, uint8_t(kMixFirst + i), 0); + post_cmd_track_param(0, uint8_t(kMixDuck), kDuckDepthDefault); + post_track(Cmd::set_machine, 0, uint8_t(MachineId::va_poly)); + pump(4); + post_cmd_track_param(0, uint8_t(kMixWidth), 96); + pump(); + CHECK(screen_has(app, "U96")); // unison on a POLY track + check_layout(app, "EDIT MIX, VA POLY"); + post_cmd_track_param(0, uint8_t(kMixWidth), 0); + pump(); +} + TEST(ui_osc_is_edits_eighth_page_and_names_its_waves_and_modes) { Strata &app = fresh(); post_track(Cmd::set_machine, 0, uint8_t(MachineId::snare)); // a drum with no OSC page @@ -6137,7 +6182,7 @@ TEST(ui_osc_is_edits_eighth_page_and_names_its_waves_and_modes) { key(ENAGA_KEY_F8); // EDIT, track 1 goto_edit_page(app, Page::osc); CHECK_EQ(int(Page::osc), int(Page::scn) - 3); // the hole's two pages between - CHECK_EQ(int(Page::scn), kEditPages - 1); + CHECK_EQ(int(Page::scn), kEditPages - 2); // then MIX, the last check_layout(app, "EDIT OSC, a drum"); CHECK(screen_has(app, "NOT ON THIS MACHINE")); CHECK(!screen_has(app, "A WAV")); // no knob of the VA's diff --git a/tests/test_usersounds.cpp b/tests/test_usersounds.cpp index 42f45cc9..f7a554f7 100644 --- a/tests/test_usersounds.cpp +++ b/tests/test_usersounds.cpp @@ -227,7 +227,7 @@ TEST(usersounds_slots_store_rename_delete_and_count) { for (int p = 0; p < kKitParams; p++) CHECK_EQ(int(bank.slots[2].params[p]), int(kit_param_max(p))); } -TEST(usersounds_loading_writes_every_parameter_and_never_the_hole) { +TEST(usersounds_loading_writes_every_parameter_and_never_the_hole_or_mix) { for (int m = 0; m < int(MachineId::count); m++) { const uint8_t machine = uint8_t(m); UserSound sound; @@ -241,8 +241,9 @@ TEST(usersounds_loading_writes_every_parameter_and_never_the_hole) { const bool ok = user_sound_apply(machine, sound, track); CHECK_EQ(ok, user_sounds_supported(machine)); for (int p = 0; p < kKitParams; p++) { - // Roland, 2026-11-28: all of a sound -- FX, LFO and ARP too. Never the hole. - const bool owns = ok && kit_param_real(p); + // Roland, 2026-11-28: all of a sound -- FX, LFO and ARP too. Never the hole, and + // never MIX, the track's place in the mix rather than its sound. + const bool owns = ok && kit_param_real(p) && p < kKitMixFirst; CHECK_EQ(user_sound_owns(machine, p), owns); CHECK_EQ(int(track[p]), int(owns ? sound.params[p] : before[p])); } @@ -537,7 +538,7 @@ TEST(usersounds_as_was_takes_back_all_of_a_user_sound_and_its_kit_settings) { post_extras(4, extras); pump(2); for (int p = 0; p < kTrackParams; p++) { - if (kit_param_real(p)) CHECK_EQ(int(e.params(4).v[p]), clamped(p, sound[p])); + if (kit_param_real(p) && p < kMixFirst) CHECK_EQ(int(e.params(4).v[p]), clamped(p, sound[p])); } CHECK(user_sound_extras_equal(user_sound_extras_of(e.project().kit.tracks[4]), extras));