diff --git a/public/octatrack-modules/usb-audio-out-tracks-main-cue/0.4.3-experimental.mwrm b/public/octatrack-modules/usb-audio-out-tracks-main-cue/0.4.3-experimental.mwrm new file mode 100644 index 0000000000..87fc712b7a Binary files /dev/null and b/public/octatrack-modules/usb-audio-out-tracks-main-cue/0.4.3-experimental.mwrm differ diff --git a/scripts/machine-modules.mjs b/scripts/machine-modules.mjs index 1c7412de41..a7733bcc25 100644 --- a/scripts/machine-modules.mjs +++ b/scripts/machine-modules.mjs @@ -54,7 +54,7 @@ export function unlistedPackages(root){ if(!existsSync(rows))return // a repository without USB packages, such as a minimal test fixture const manifest=JSON.parse(readFileSync(rows,'utf8')) walk(manifest.packages) - for(const key of ['configurable', 'configurable-0.4.1', 'configurable-0.4', 'configurable-0.3', ...USB_AUDIO_LAYOUTS.map(layout=>layout.id)]){ + for(const key of ['configurable', 'configurable-0.4.2', 'configurable-0.4.1', 'configurable-0.4', 'configurable-0.3', ...USB_AUDIO_LAYOUTS.map(layout=>layout.id)]){ const path=manifest.usbAudio?.[key]?.path if(typeof path==='string' && path.endsWith('.mwrm'))named.add(path) } diff --git a/sdk/approvals/usb-audio-out-tracks-main-cue-build-approval.json b/sdk/approvals/usb-audio-out-tracks-main-cue-build-approval.json index 89299531fa..56bdeed6e8 100644 --- a/sdk/approvals/usb-audio-out-tracks-main-cue-build-approval.json +++ b/sdk/approvals/usb-audio-out-tracks-main-cue-build-approval.json @@ -1,10 +1,10 @@ { "kind": "owner-approved-update", "id": "usb-audio-out-tracks-main-cue", - "version": "0.4.2-experimental", - "sourceSha256": "0999bbb9d4b86aadfece80c13c0f1480f5eec9c89ee097a70ddab2463ce18b19", + "version": "0.4.3-experimental", + "sourceSha256": "860ffa3425d3ae25122ddfbf8cd6b1d9659e3051f260d329cc667c17a47de11e", "approvedBy": "repeat98", - "approvedOn": "2026-11-27", + "approvedOn": "2026-11-30", "waived": [ "current-build-hardware", "chip-worst-case-cycles", @@ -12,6 +12,6 @@ "release-documentation" ], "retainedUiVersion": "0.4.0-experimental", - "ownerStatement": "I approve USB Audio 0.4.2-experimental: it fixes the #2263 buzz on macOS and costs less CPU than 0.4.1; tested on my MKII on 26-27 November 2026.", - "reason": "#2263: on macOS, 0.4.1's adaptive input and asynchronous recording slid the Mac's I/O buffer 2.6 frames a second until it buzzed; 0.4.2 sends the recording on the host's clock while the host plays in and trims the drift on the unit. Main + Cue now does the built-in's work (once-a-frame flag, the built-in's copy) and the POST gain history runs only for POST. Owner's MKII, macOS: 10 minutes clean; a Main + Cue recording's own cost about half of 0.4.1's (16 to 7.6 points of the frame interrupt in one scene), then 1.2 points and 9 of the longest frame less with the built-in's copy (A/B in one scene); every USB AUDIO setting changed idle, recording and playing in on 0.8.2 with no USB incident; the release on the flashed 0.8.2 installed, recorded and rolled back. Windows after the release, on the owner's PC (owner, 27 November 2026). Not run: 20 channels, an MKI, a Keep and a power cycle. Package SHA-256 c2597a32fa3d863490d17e728a7c7a40b2c7dc147e661df77ff62e94b5bb12db." + "ownerStatement": "I approve USB Audio 0.4.3-experimental: it costs almost nothing at rest, records cheaper than 0.4.2 in lighter projects and no dearer in busy ones, and the release ran ten minutes on my MKII on macOS with no buzz (30 November 2026).", + "reason": "Recording costs less CPU and almost nothing at rest: a packet that is one run of ring words is copied with moveml, the producer skips the sixteen track words whenever no packet sends one, and the frame hook returns before its register save while no computer streams; a change that starts sending tracks without a reconnect sends them silent for one ring lap. Owner's MKII, 0.8.4 twin 16c87945: recording MAIN 46.7 to 37.4 % of the frame interrupt, with Windows playing in 50.7 to 40.0 %, 16 channels 56.7 to 50.3 %, installed at rest +0.1 over the base; the audio the same as 0.4.2's; Windows 11 duplex clean. Against the built-in MAIN + CUE on twins of the same 0.8.5 source in one busy scene (C02, DELAY on every track), recording with INPUTS OFF: 3.1 % of a frame longer and 3.6 idle points less; with INPUTS AB both 0.4.2 and 0.4.3 record at about 51 % against the built-in's 41 %, longest frames up to 104-105 %, no late entry wait. The release itself ten minutes on macOS playing into INPUTS AB while recording: no buzz (sidebands -62 to -75 dB). Not run: 20 channels, INPUTS ABCD, POST LEVEL, an MKI, a Keep and a power cycle. Package SHA-256 3c3c996d2789f4aa96526628c5e794c4b52c056b19615499307b42092a87fb79." } diff --git a/sdk/catalog.json b/sdk/catalog.json index e9593f8fbe..c98ab37467 100644 --- a/sdk/catalog.json +++ b/sdk/catalog.json @@ -84,7 +84,7 @@ }, { "id": "usb-audio-out-tracks-main-cue", - "version": "0.4.2-experimental", + "version": "0.4.3-experimental", "addedAt": "2026-10-01T09:19:37Z" }, { diff --git a/sdk/machines/octatrack/module-adapters/usb-audio-input-reconstruction.json b/sdk/machines/octatrack/module-adapters/usb-audio-input-reconstruction.json index fe5f4a5ed6..9b6d9fd800 100644 --- a/sdk/machines/octatrack/module-adapters/usb-audio-input-reconstruction.json +++ b/sdk/machines/octatrack/module-adapters/usb-audio-input-reconstruction.json @@ -1,13 +1,13 @@ { "schema": 1, - "imageSha256": "758a077729ae281527efe2b37fe68b407a3837eaa737dd12bb801bae86c6ec9f", + "imageSha256": "098ae421cbffeb2e43aea9ba5d34ed2ae9a8b23a75e2c2f2967271708a67eddb", "sources": { - "generatedAssembly": "cf7a8f950ddd6dda12030a279ff98e0b1add646e4e9d9b90f381f399bf8d7427", - "sdk/machines/octatrack/module-adapters/usb_audio_settings.c": "e893cec8f8054a39d53f96124667bd44639122e5c338d5f180d23ce9e0e97f89", + "generatedAssembly": "e8fc3b62ba5070b01d4170323d60424ab0389d6834b80c21835d1a9c24a548a9", + "sdk/machines/octatrack/module-adapters/usb_audio_settings.c": "9ad8bba4c2895411d7059757554125f9cd0d0e2d145a0e68ebefbd96cf0b7568", "sdk/machines/octatrack/include/modwerk_events.h": "d669041baeaa2d9bf3b0fb5dbf365ebf28f14903ff24377261c17f7c5eb41981", "sdk/octatrack/modules/usb-audio-out-tracks-main-cue/usb_audio_input_trim.c": "6b128ab96ae73b136afb9ccf3acfb4e9d21168b5452e5f835b7588f80364cba0", "sdk/octatrack/modules/usb-audio-out-tracks-main-cue/usb_audio_output_trim.c": "91aff3f0353b0f10d4f17f68d8ca01df214408cd55a1d058f40012fe7de07ed0", - "generatedSettings": "745826397f23921738e246bb4c2bad60a174a91e59a70949d9e48c44852854b2" + "generatedSettings": "9abcf68212cc7aaa141684fb965b2d976d5206c5d2ff0d81eb4fba9bdf600a29" }, "copies": [ { @@ -18,21 +18,21 @@ "purpose": "Authored audio_pkt_build + 608 in the USB Audio image" }, { - "offset": 3562, + "offset": 3514, "length": 6, "address": 1073863924, "sha256": "868378f30d4ed1251a28851782180b919dbfbd18ea839b594142244f6e06fb8a", "purpose": "Authored uac2_set_done + 52 in the USB Audio image" }, { - "offset": 3568, + "offset": 3520, "length": 10, "address": 1073864298, "sha256": "c1ed73406504f0066c561fa89bfd547fa1c6825d89a28c3442c7997413e0b84c", "purpose": "Authored uac2_set_done + 58 in the USB Audio image" }, { - "offset": 5014, + "offset": 5140, "length": 12, "address": 1073858896, "sha256": "adf82a9ab72faf6ad2a911fa873acbf3195bd4a8a4a73771edb96a383405204c", diff --git a/sdk/machines/octatrack/module-adapters/usb-audio-reconstruction.json b/sdk/machines/octatrack/module-adapters/usb-audio-reconstruction.json index 7ba1446f03..f765f1af11 100644 --- a/sdk/machines/octatrack/module-adapters/usb-audio-reconstruction.json +++ b/sdk/machines/octatrack/module-adapters/usb-audio-reconstruction.json @@ -1,9 +1,9 @@ { "schema": 1, - "imageSha256": "53a60634a7c3831961c7e99959f454882f07b94f185f45fe43364995462835ca", + "imageSha256": "965a21930d283d2be59561539062d3654dd470933a774e54a294ec6d3e9bbf17", "sources": { - "generatedAssembly": "5b10045507818c7ecfa8addf0db483351854510e7ed61d3242e378b7a8c46095", - "sdk/machines/octatrack/module-adapters/usb_audio_settings.c": "e893cec8f8054a39d53f96124667bd44639122e5c338d5f180d23ce9e0e97f89", + "generatedAssembly": "486a928d2c158dc8dd1684b6ea723778d3b3f5e7b0a729db07f62e0cb9494b86", + "sdk/machines/octatrack/module-adapters/usb_audio_settings.c": "9ad8bba4c2895411d7059757554125f9cd0d0e2d145a0e68ebefbd96cf0b7568", "sdk/machines/octatrack/include/modwerk_events.h": "d669041baeaa2d9bf3b0fb5dbf365ebf28f14903ff24377261c17f7c5eb41981" }, "copies": [ @@ -15,14 +15,14 @@ "purpose": "Authored audio_pkt_build + 556 in the USB Audio image" }, { - "offset": 3368, + "offset": 3320, "length": 6, "address": 1073863924, "sha256": "868378f30d4ed1251a28851782180b919dbfbd18ea839b594142244f6e06fb8a", "purpose": "Authored uac2_set_done + 52 in the USB Audio image" }, { - "offset": 3374, + "offset": 3326, "length": 10, "address": 1073864298, "sha256": "c1ed73406504f0066c561fa89bfd547fa1c6825d89a28c3442c7997413e0b84c", diff --git a/sdk/machines/octatrack/module-adapters/usb_audio_configurable.py b/sdk/machines/octatrack/module-adapters/usb_audio_configurable.py index d066ef58af..095ae7dba7 100644 --- a/sdk/machines/octatrack/module-adapters/usb_audio_configurable.py +++ b/sdk/machines/octatrack/module-adapters/usb_audio_configurable.py @@ -61,39 +61,21 @@ def configure_source(text): moveal %sp@+,%a4 bra .Lstems_done .Lpre_words: - | MAIN + CUE sends no track word: its sixteen stores a frame are skipped. Only there: it is the one layout with - | a profile of its own (two pairs), so leaving it re-enumerates and the stream restarts on fresh slots. In a - | layout that can start sending a track without that (ALL from MAIN + CUE ONLY, TRACK 8 from MAIN), the packets - | would first carry the ring's words from before. - tstb mwua_main_cue | set once a frame, below the speed check + | No packet needs a track word (MAIN, MAIN + CUE): the sixteen stores a frame are skipped. + | mwua_begin_frame decides it once a frame; after a change that starts sending a track without a + | reconnect (TRACK 8 from MAIN), mwua_tracks_stale sends that track silent for one ring lap, so the + | packets never carry the ring's track words from before. + tstb mwua_no_tracks beqs .Lstems_store lea %a3@(64),%a3 | past the slot's track words, left as they were bra .Lstems_done .Lstems_store: ''' + loop + '.Lstems_done:\n' + text[end:] - # MAIN + CUE at high speed does the built-in's work (owner's MKII, 27 November 2026: recording cost 4 points of - # the frame interrupt more than the built-in's code, mostly the routed C copy). mwua_main_cue holds only when the - # copy's routes are Main then Cue: two pairs, words 16-19 sent and the first pair Main (mwua_fs_pair is route[0]). - text = checked(text, ''' seq %d1 | d1 = 0xff at high speed - moveal %d1,%a1 | a1 != 0: skip the sum this block -''', ''' seq %d1 | d1 = 0xff at high speed - moveal %d1,%a1 | a1 != 0: skip the sum this block - moveq #0,%d0 | mwua_main_cue, for the producer and the packet copy - tstl %d1 - beqs .Lmc_flag - mvzb mwua_pairs,%d1 - subql #2,%d1 - bnes .Lmc_flag - movel mwua_sent_words,%d1 - cmpil #0xf0000,%d1 - bnes .Lmc_flag - mvzb mwua_fs_pair,%d1 - subql #8,%d1 - bnes .Lmc_flag - moveq #1,%d0 -.Lmc_flag: - moveb %d0,mwua_main_cue -''') + # A packet that is one run of consecutive ring words (MAIN, MAIN + CUE, TRACK 8, the sixteen tracks) is + # copied at high speed as the built-in copies it: mwua_begin_frame sets mwua_run_words (2, 4 or 16) and + # mwua_run_off, and the packet copy moves those words alone (owner's MKII, 27 November 2026: MAIN + CUE's + # recording cost 4 points more through the routed C copy; 30 November 2026, Windows: MAIN's 17.9 points + # of the frame interrupt fell to 6.6 with this and the skipped track stores). text = checked(text, ' movel %d4,aud_produced\n.endif\n', ''' movel %d4,aud_produced tstb mwua_post beqs .Lpost_gate_done @@ -154,12 +136,14 @@ def configure_source(text): mulu.l %d1,%d6 1: rts mwua_route: | a0 dTD, a3 buffer, a5 wrap, a6 slot + tstb mwua_tracks_stale | tracks stored again less than a lap ago: the copy that sends them silent + bnes 3f tstb aud_hs beqs 1f tstb mwua_direct bne audio_copy80 - tstb mwua_main_cue - bne mwua_copy_main_cue + tstb mwua_run_words + bne mwua_copy_run moveq #0,%d1 bras 2f 1: moveq #1,%d1 @@ -169,28 +153,63 @@ def configure_source(text): movel %a2,%sp@- movel %a1,%sp@- bsr mwua_copy - moveal %sp@,%a1 +5: moveal %sp@,%a1 movel %sp@(8),%d4 lea %sp@(16),%sp moveal %sp@+,%a0 bsr mwua_packet_bytes addal %d6,%a1 rts -mwua_copy_main_cue: | d0 frames from a2 to a1: each slot's words 16-19, as the built-in copies them - lea %a2@(64),%a2 | (clobbers d1-d4, as audio_copy16 does at the same call) +3: moveq #0,%d1 + tstb aud_hs + bnes 4f + moveq #1,%d1 +4: movel %a0,%sp@- + movel %d1,%sp@- + movel %d0,%sp@- + movel %a2,%sp@- + movel %a1,%sp@- + bsr mwua_copy_fresh + bras 5b +mwua_copy_run: | d0 frames from a2 to a1: mwua_run_words words of each slot from byte + mvzb mwua_run_off,%d1 | mwua_run_off (clobbers d1-d4, as audio_copy16 does at the same call) + addal %d1,%a2 tstl %d0 - beqs 2f -1: moveml %a2@,%d1-%d4 + beqs 9f + mvzb mwua_run_words,%d1 + subql #4,%d1 + beqs 4f + bmis 2f +1: moveml %a2@,%d1-%d4 | the sixteen track words: 64 bytes a frame moveml %d1-%d4,%a1@ + moveml %a2@(16),%d1-%d4 + moveml %d1-%d4,%a1@(16) + moveml %a2@(32),%d1-%d4 + moveml %d1-%d4,%a1@(32) + moveml %a2@(48),%d1-%d4 + moveml %d1-%d4,%a1@(48) lea %a2@(80),%a2 - lea %a1@(16),%a1 + lea %a1@(64),%a1 subql #1,%d0 bnes 1b -2: rts + rts +2: moveml %a2@,%d1-%d2 | one pair: 8 bytes a frame + moveml %d1-%d2,%a1@ + lea %a2@(80),%a2 + addql #8,%a1 + subql #1,%d0 + bnes 2b + rts +4: moveml %a2@,%d1-%d4 | two pairs: 16 bytes a frame + moveml %d1-%d4,%a1@ + lea %a2@(80),%a2 + lea %a1@(16),%a1 + subql #1,%d0 + bnes 4b +9: rts .bss .balign 4 mwua_gain: .space 4 -mwua_main_cue: .space 1 ''' return text @@ -207,6 +226,28 @@ def source(root, module, layout, functions, load, sine_curve, package_hooks, *, text = configure_source(text) text = package_hooks(text) text = checked(text, ' jsr audio_frame_shim', ' jsr mwua_begin_frame\n jsr audio_frame_shim') + # At rest the hook returns before it saves a register: no stream asked for, none to tear down, the idle + # bookkeeping done (aud_closed) and no POST gain history to follow. It cost 0.6 points of the frame interrupt + # every block with no computer streaming (owner's MKII, 30 November 2026). The first block a host asks for + # takes the whole path, mwua_begin_frame's snapshot first. + text = checked(text, '''mwua_frame: | ev_usb_frame: the producer, which uses every register + lea %sp@(-44),%sp +''', '''mwua_frame: | ev_usb_frame: the producer, which uses every register + tstb usbaudio_alt + bnes .Lmwua_frame_work + tstb aud_running + bnes .Lmwua_frame_work + tstb mwua_post + bnes .Lmwua_frame_work + tstb aud_force + bnes .Lmwua_frame_work + tstb aud_closed + beqs .Lmwua_frame_work + moveq #0,%d0 | at rest + rts +.Lmwua_frame_work: + lea %sp@(-44),%sp +''') # Reuse the licensed fixed-clock SET_CUR handler as an ev_usb_control # callback. d2 is callee-saved and carries the verified request length. start = text.index('.Lctrl_set:\n') diff --git a/sdk/machines/octatrack/module-adapters/usb_audio_package.py b/sdk/machines/octatrack/module-adapters/usb_audio_package.py index d8bfdc9ac2..20ba118773 100644 --- a/sdk/machines/octatrack/module-adapters/usb_audio_package.py +++ b/sdk/machines/octatrack/module-adapters/usb_audio_package.py @@ -493,7 +493,8 @@ def build(layout, cross='m68k-elf-', *, release=False, capture=None, stock=None, dict(event='ev_usb_bus_end', fn='mwua_bus_end', order=50), dict(event='ev_usb_control', fn='mwua_control', order=50), dict(event='ev_usb_frame', fn='mwua_frame', order=50), dict(event='ot_settings', fn='mwua_setting', order=50)] hooks = loader.subscribe([loader.NONE] * len(loader.HANDLERS), entries, symbols) - # Inventory kind 10 is the configurable package whose recording follows the host's + # Inventory kind 11 is the configurable package that copies runs of ring words and rests with no stream + # (0.4.3), 10 the one whose recording follows the host's # clock while the host plays in (0.4.2), 9 the one with USB input on an adaptive # endpoint (0.4.1), 8 the one with an asynchronous input endpoint (0.4.0), 7 the # output-only one (0.3.0). Kinds 1-6 identify the older fixed layouts. The site @@ -554,7 +555,7 @@ def build(layout, cross='m68k-elf-', *, release=False, capture=None, stock=None, raise ValueError('The installed image differs from the compiled module.') data = loader.package(image, bss, hooks, offsets, sites, name=MODULE, hashed=True, title=TITLE, abi=8, copies=copies, fills=fills, - layout=(10 if input_port else 7) if layout is None else functions.AUDIO_LAYOUTS[layout] + 1) + layout=(11 if input_port else 7) if layout is None else functions.AUDIO_LAYOUTS[layout] + 1) if release and stock: packages = load('usb_audio_package_scan', HERE.parent / 'elekloader/module_packages.py') scanner = load('usb_audio_image_scan', HERE.parent / 'elekloader/check_stock_free.py') diff --git a/sdk/machines/octatrack/module-adapters/usb_audio_settings.c b/sdk/machines/octatrack/module-adapters/usb_audio_settings.c index bb8a9ed2a0..975c3312ac 100644 --- a/sdk/machines/octatrack/module-adapters/usb_audio_settings.c +++ b/sdk/machines/octatrack/module-adapters/usb_audio_settings.c @@ -151,12 +151,23 @@ uint8_t mwua_post, mwua_off, mwua_fs_sum = 1, mwua_fs_pair = SUM, mwua_pairs = 1 /* The ring words a high-speed packet sends (bits 2p and 2p+1 for pair p): the recording's drift trim * (usb_audio_output_trim.c) interpolates only those. */ uint32_t mwua_sent_words = 0xfffffu; -static uint8_t route[10]; +/* mwua_no_tracks: no packet at either speed needs a track word, so the producer skips its sixteen track stores a + * frame. mwua_run_words: a high-speed packet is one run of consecutive ring words (2: Main, track 8 or one pair; + * 4: Main then Cue or two pairs; 16: the eight tracks), copied without the routes from byte mwua_run_off of + * each slot. 0: the routed copy. mwua_tracks_stale: the producer stores track words again after skipping them, + * and the ring still holds older ones for one lap: the packet copy then sends those tracks silent + * (mwua_copy_fresh), never words from before. */ +uint8_t mwua_no_tracks, mwua_run_words, mwua_run_off, mwua_tracks_stale; +#define RING_BLOCKS 64u /* layouts/usbaudio.s AUD_FRAMES / 16: one lap of the ring */ +static uint8_t route[10], fresh = RING_BLOCKS; static uint32_t last; void mwua_begin_frame(void) { unsigned profile = mwua_active; uint32_t w = configuration[profile]; + /* Blocks the producer has stored track words since it last skipped them (it follows mwua_no_tracks). */ + if (mwua_no_tracks) fresh = 0; else if (fresh < RING_BLOCKS) ++fresh; + mwua_tracks_stale = !mwua_no_tracks && fresh < RING_BLOCKS; if (w == last) return; last = w; unsigned l = layout(w), mode = w & 3u; @@ -174,17 +185,36 @@ void mwua_begin_frame(void) mwua_fs_sum = mwua_fs_pair == SUM; mwua_direct = profile == USB20 && mode == 0; mwua_sent_words = mwua_direct ? 0xfffffu : sent; + mwua_no_tracks = !mwua_direct && !mwua_post && !(sent & 0xffffu) && mwua_fs_pair >= 8u && !mwua_fs_sum; + mwua_tracks_stale = !mwua_no_tracks && fresh < RING_BLOCKS; + unsigned run = 0, i = 1; + if (!mwua_direct && route[0] < SILENCE) { + while (i < mwua_pairs && route[i] == route[0] + i) ++i; + if (i == mwua_pairs && (i == 1u || i == 2u || i == 8u)) run = 2u * i; + } + mwua_run_words = (uint8_t)run; + mwua_run_off = (uint8_t)(run ? 8u * route[0] : 0u); } /* Source words already have the UAC2 byte order. The assembly reader splits * a wrapped ring into two straight runs and calls this for each. */ -void mwua_copy(uint32_t *dst, const uint32_t *src, unsigned frames, unsigned full_speed) +__attribute__((always_inline)) static inline void copy(uint32_t *dst, const uint32_t *src, unsigned frames, unsigned full_speed, unsigned fresh_only) { unsigned pairs = full_speed ? 1u : mwua_pairs; for (unsigned frame=0; frameH', data, 66)[0], 7) - # The duplex package is the published one: its own kind, so the site replaces 0.3.0, 0.4.0 and 0.4.1 with it. - self.assertEqual(struct.unpack_from('>H', builder.build(None, usb_input=True)[0], 66)[0], 10) + # The duplex package is the published one: its own kind, so the site replaces 0.3.0, 0.4.0, 0.4.1 and 0.4.2 with it. + self.assertEqual(struct.unpack_from('>H', builder.build(None, usb_input=True)[0], 66)[0], 11) self.assertLess(facts['image'] + facts['bss'], 128 * 1024) hook_count = struct.unpack_from('>I', data, 20)[0] hook_index = next(e['index'] for e in events.load()['events'] if e['event'] == 'ot_usb_functions') @@ -100,22 +107,26 @@ def test_the_configurable_producer_skips_what_its_layout_does_not_send(self): for call in (' bsr post_frame\n', ' bsr post_emac_leave\n', ' bsr post_emac_leave\n'): for at in [i for i in range(len(text)) if text.startswith(call, i)]: self.assertIn('tstb mwua_post', text[max(0, at - 160):at], call) - # MAIN + CUE does the built-in's work: once a frame the producer sets mwua_main_cue, only at high speed, in - # the two-pair profile, with words 16-19 sent and Main first; the track stores and the routed copy test it. - flag = text.split(' moveal %d1,%a1 | a1 != 0: skip the sum this block\n', 1)[1] - flag = flag.split(' moveb %d0,mwua_main_cue\n', 1)[0] - for test in ('tstl %d1', 'mvzb mwua_pairs,%d1\n subql #2,%d1', 'cmpil #0xf0000,%d1', - 'mvzb mwua_fs_pair,%d1\n subql #8,%d1', 'moveq #1,%d0'): - self.assertIn(test, flag) + # The bus-only layouts do the built-in's work: mwua_begin_frame (C) sets mwua_no_tracks and mwua_run_words + # once a frame; the track stores and the routed copy test them, and the copy moves Main or Main and Cue. + self.assertNotIn('mwua_main_cue', text) skip = text.split('.Lpre_words:\n', 1)[1].split('.Lstems_store:\n', 1)[0] - for test in ('tstb mwua_main_cue', 'lea %a3@(64),%a3'): + for test in ('tstb mwua_no_tracks', 'lea %a3@(64),%a3'): self.assertIn(test, skip) route = text.split('mwua_route:', 1)[1].split(' bsr mwua_copy\n', 1)[0] - self.assertLess(route.index('tstb aud_hs'), route.index('bne mwua_copy_main_cue')) - self.assertLess(route.index('bne audio_copy80'), route.index('bne mwua_copy_main_cue')) - copy = text.split('mwua_copy_main_cue:', 1)[1].split('rts', 1)[0] - for test in ('lea %a2@(64),%a2', 'moveml %a2@,%d1-%d4', 'moveml %d1-%d4,%a1@', 'lea %a2@(80),%a2', - 'lea %a1@(16),%a1'): + self.assertLess(route.index('tstb aud_hs'), route.index('bne mwua_copy_run')) + self.assertLess(route.index('tstb mwua_tracks_stale'), route.index('tstb aud_hs')) + self.assertIn('bsr mwua_copy_fresh', text.split('mwua_route:', 1)[1].split('mwua_copy_run:', 1)[0]) + self.assertLess(route.index('bne audio_copy80'), route.index('bne mwua_copy_run')) + # At rest the frame hook returns before its register save, and only then. + frame = text.split('mwua_frame:', 1)[1].split(' moveml %d2-%d7/%a2-%a6,%sp@\n', 1)[0] + for test in ('tstb usbaudio_alt', 'tstb aud_running', 'tstb mwua_post', 'tstb aud_force', + 'tstb aud_closed\n beqs .Lmwua_frame_work\n moveq #0,%d0 | at rest\n rts'): + self.assertIn(test, frame) + copy = text.split('mwua_copy_run:', 1)[1].split(' .bss', 1)[0] + for test in ('mvzb mwua_run_off,%d1', 'addal %d1,%a2', 'moveml %a2@,%d1-%d2', 'moveml %d1-%d2,%a1@', + 'addql #8,%a1', 'moveml %a2@(48),%d1-%d4', 'moveml %d1-%d4,%a1@(48)', 'lea %a1@(64),%a1', + 'moveml %a2@,%d1-%d4', 'moveml %d1-%d4,%a1@', 'lea %a2@(80),%a2', 'lea %a1@(16),%a1'): self.assertIn(test, copy) def test_the_setting_offers_main_and_cue_only_in_the_twenty_channel_layout(self): diff --git a/sdk/tests/usb_audio_runs_test.c b/sdk/tests/usb_audio_runs_test.c new file mode 100644 index 0000000000..2a9e8ff8de --- /dev/null +++ b/sdk/tests/usb_audio_runs_test.c @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later + * USB Audio 0.4.3's packet runs, skipped track stores and silent lap (usb_audio_settings.c), on the host. + * Compiled and run by test_usb_audio_package.py. */ +#include +#include +#include "../machines/octatrack/module-adapters/usb_audio_settings.c" + +volatile uint8_t mwua_requested, mwua_active; +static uint32_t input[3*20], output[3*20]; +static uint32_t select_option(uint32_t saved, const char *field, const char *option) +{ + struct modwerk_choice_page group = {0}, page = {0}; + audio_page(saved, MODWERK_SETTING_FIELDS, &group); + for (unsigned i=0; i kind === 'configurable' || kind === 'configurable-0.4.1' || kind === 'configurable-0.4' || kind === 'configurable-0.3' +export type UsbAudioPackageKind = UsbAudioLayout | 'configurable' | 'configurable-0.4.2' | 'configurable-0.4.1' | 'configurable-0.4' | 'configurable-0.3' +export const isConfigurable = (kind?: UsbAudioPackageKind) => kind === 'configurable' || kind === 'configurable-0.4.2' || kind === 'configurable-0.4.1' || kind === 'configurable-0.4' || kind === 'configurable-0.3' export type UsbAudioConfiguration = { version: typeof USB_AUDIO_VERSION; layout: UsbAudioLayout; destination: 'computer' | 'outbox'; outboxPairs: number[] } export function usbAudioLayout(id: UsbAudioLayout) { return USB_AUDIO_LAYOUTS.find(layout => layout.id === id)! } export function usbAudioPreset(destination: UsbAudioConfiguration['destination']): UsbAudioConfiguration { diff --git a/src/engine/assets/module-build.json b/src/engine/assets/module-build.json index c3928b8107..12de20feee 100644 --- a/src/engine/assets/module-build.json +++ b/src/engine/assets/module-build.json @@ -1,9 +1,9 @@ { "schemaVersion": 1, "kind": "source-packages", - "sourceCommit": "d98c48c0653ae5b13d599678903bde120ba0d729", + "sourceCommit": "df370ef5782977c57476e4569ee1290dca583957", "nativeRevision": "b8deefc88b2c3e5f3c6158e364eb741df1924e1d", - "sourceTreeSha256": "543e57f9c1cc7dcf9975cecc05314bd5dda4130226169b7fc1521934cabff80f", + "sourceTreeSha256": "9360708bd68278e77a2cf69835c6bb92aced0836810e9fb431933183ca7b2e0b", "compilerSha256": "0d5ec1690380c1ad4e45371c91f676a07bdb5fd6ec6949f70ff2d460b50caa0a", "moduleVersions": { "miniverb": "0.2.3-experimental", @@ -22,7 +22,7 @@ "midiverb": "0.2.0-experimental", "ringbank": "0.1.0-experimental", "analog-bassdrum": "0.1.7-experimental", - "usb-audio-out-tracks-main-cue": "0.4.2-experimental", + "usb-audio-out-tracks-main-cue": "0.4.3-experimental", "quantizer": "0.1.5-experimental", "synth": "0.1.5-experimental", "previewvol": "0.1.2-experimental", @@ -83,7 +83,7 @@ }, "requested-packages.json": { "bytes": 1470741, - "sha256": "5e1c875c941a1fbcb1f9048ddfc7a97115b8b8b8177bd22f1ed9d81069b4b4c0" + "sha256": "fc81e72e99971cf7e67d46953c5823955877adb0fdac8a83cfede178594f8713" }, "utility-packages.json": { "bytes": 11735, @@ -91,7 +91,7 @@ }, "usb-audio-packages.json": { "bytes": 736377, - "sha256": "2d03830655d683e1b2af7ba76e1bd5e86c09291a0139abfa094f6225ae1895a3" + "sha256": "5146f554f9705b06d9f1e024c030016120ca47326ff91114d3820d5cd9ceb0d4" } }, "approval": null, diff --git a/src/engine/assets/octatrack-module-packages.json b/src/engine/assets/octatrack-module-packages.json index b070facd82..11954a5bfe 100644 --- a/src/engine/assets/octatrack-module-packages.json +++ b/src/engine/assets/octatrack-module-packages.json @@ -933,6 +933,20 @@ ], "usbAudio": { "configurable": { + "name": "USB Audio", + "version": "0.4.3-experimental", + "path": "octatrack-modules/usb-audio-out-tracks-main-cue/0.4.3-experimental.mwrm", + "bytes": 22564, + "sha256": "3c3c996d2789f4aa96526628c5e794c4b52c056b19615499307b42092a87fb79", + "abi": 8, + "features": 131, + "sites": 3, + "copies": 4, + "fills": 0, + "installPresets": true, + "requiredBase": "ddb56b72d1ac0b606f5969bc4984b6b22662e87d1b1d56a480ef0da1aac53b49" + }, + "configurable-0.4.2": { "name": "USB Audio", "version": "0.4.2-experimental", "path": "octatrack-modules/usb-audio-out-tracks-main-cue/0.4.2-experimental.mwrm", diff --git a/src/engine/assets/requested-packages.json b/src/engine/assets/requested-packages.json index a523c732fe..5af5a4fe9e 100644 --- a/src/engine/assets/requested-packages.json +++ b/src/engine/assets/requested-packages.json @@ -74,7 +74,7 @@ { "label": "usbaudio", "moduleId": "usb-audio-out-tracks-main-cue", - "version": "0.4.2-experimental", + "version": "0.4.3-experimental", "key": "USB AUDIO OUT TRACKS MAIN CUE", "author": "markandrus", "nativeAuthor": "markandrus/octemu", @@ -97,7 +97,7 @@ { "label": "usbmidi_rx", "moduleId": "usb-audio-out-tracks-main-cue", - "version": "0.4.2-experimental", + "version": "0.4.3-experimental", "key": "USB AUDIO OUT TRACKS MAIN CUE", "author": "markandrus", "nativeAuthor": "markandrus/octemu", diff --git a/src/engine/assets/usb-audio-packages.json b/src/engine/assets/usb-audio-packages.json index 2163cced8f..9aa8652a33 100644 --- a/src/engine/assets/usb-audio-packages.json +++ b/src/engine/assets/usb-audio-packages.json @@ -1,6 +1,6 @@ { "schema": 1, - "version": "0.4.2-experimental", + "version": "0.4.3-experimental", "revision": "b8deefc88b2c3e5f3c6158e364eb741df1924e1d", "upstreamRevision": "7b2984c859732ae6c797ae49c7d61d250b1b6519", "sources": { diff --git a/src/engine/elekloader/module-set.ts b/src/engine/elekloader/module-set.ts index 101e71e288..e2364812a1 100644 --- a/src/engine/elekloader/module-set.ts +++ b/src/engine/elekloader/module-set.ts @@ -43,10 +43,10 @@ export interface RuntimePackageManifest { usbAudio?: Partial> } /** The layout number a USB Audio package carries (usb_audio_package.py: its source's layout define, plus one). */ -export const usbAudioLayoutNumber = (kind: UsbAudioPackageKind) => kind === 'configurable' ? 10 : kind === 'configurable-0.4.1' ? 9 : kind === 'configurable-0.4' ? 8 : kind === 'configurable-0.3' ? 7 : usbAudioLayout(kind).define + 1 +export const usbAudioLayoutNumber = (kind: UsbAudioPackageKind) => kind === 'configurable' ? 11 : kind === 'configurable-0.4.2' ? 10 : kind === 'configurable-0.4.1' ? 9 : kind === 'configurable-0.4' ? 8 : kind === 'configurable-0.3' ? 7 : usbAudioLayout(kind).define + 1 const USB_AUDIO_SETTING_KEY = 0x8c3a257f // settings.c st_key("USB AUDIO") const LAYOUT_BY_NUMBER = new Map(USB_AUDIO_LAYOUTS.map(item => [item.define + 1, item.id])) -for (const kind of ['configurable', 'configurable-0.4.1', 'configurable-0.4', 'configurable-0.3'] as const) LAYOUT_BY_NUMBER.set(usbAudioLayoutNumber(kind), kind) +for (const kind of ['configurable', 'configurable-0.4.2', 'configurable-0.4.1', 'configurable-0.4', 'configurable-0.3'] as const) LAYOUT_BY_NUMBER.set(usbAudioLayoutNumber(kind), kind) export class BaseUpdateRequired extends ModuleSetError { constructor(message = 'Update to the latest Modwerk base to sync this set.') { super(message) } } diff --git a/src/engine/elekloader/usb-audio-package.test.ts b/src/engine/elekloader/usb-audio-package.test.ts index 63dd602a16..34f33b0bce 100644 --- a/src/engine/elekloader/usb-audio-package.test.ts +++ b/src/engine/elekloader/usb-audio-package.test.ts @@ -36,11 +36,11 @@ describe('USB Audio as a module package', () => { for (const layout of ['tracks', 'master', 'main-cue'] as const) { const result = await catalogue.prepare(set(layout), empty, fetched, capable) expect(result.changes[0].data).toEqual(data('configurable')) - expect(catalogue.review(set(layout), on(10), capable).needsSync).toBe(false) + expect(catalogue.review(set(layout), on(11), capable).needsSync).toBe(false) } const migration = await catalogue.prepare(set('main'), on(5), fetched, capable) expect(migration.changes[0]).toMatchObject({ data: data('configurable'), undo: data('main'), reconnects: true }) - const removal = await catalogue.prepare(set(), on(10), fetched, capable) + const removal = await catalogue.prepare(set(), on(11), fetched, capable) expect(removal.changes[0].undo).toEqual(data('configurable')) }) it('replaces the output-only 0.3.0 package on the unit, with that package as the Undo', async () => { @@ -53,7 +53,7 @@ describe('USB Audio as a module package', () => { }) it('replaces 0.4.0, whose input endpoint Windows refuses, with that package as the Undo', async () => { const { catalogue, fetched, data, on } = audioCatalogue(['configurable-0.3', 'configurable-0.4', 'configurable']) - expect([on(7), on(8), on(10)].map(inventory => inventory.usbAudioLayout)).toEqual(['configurable-0.3', 'configurable-0.4', 'configurable']) + expect([on(7), on(8), on(11)].map(inventory => inventory.usbAudioLayout)).toEqual(['configurable-0.3', 'configurable-0.4', 'configurable']) expect(catalogue.review(set('main'), on(8), capable)).toMatchObject({ needsSync: true, updates: [USB_AUDIO_MODULE], problem: undefined }) const update = await catalogue.prepare(set('main'), on(8), fetched, capable) expect(update.changes).toEqual([{ module: 'USB Audio', data: data('configurable'), undo: data('configurable-0.4'), replaces: true, reconnects: true }]) @@ -61,11 +61,19 @@ describe('USB Audio as a module package', () => { }) it('replaces 0.4.1, whose recording buzzed on a Mac playing in, with that package as the Undo', async () => { const { catalogue, fetched, data, on } = audioCatalogue(['configurable-0.3', 'configurable-0.4', 'configurable-0.4.1', 'configurable']) - expect([on(7), on(8), on(9), on(10)].map(inventory => inventory.usbAudioLayout)).toEqual(['configurable-0.3', 'configurable-0.4', 'configurable-0.4.1', 'configurable']) + expect([on(7), on(8), on(9), on(11)].map(inventory => inventory.usbAudioLayout)).toEqual(['configurable-0.3', 'configurable-0.4', 'configurable-0.4.1', 'configurable']) const update = await catalogue.prepare(set('main'), on(9), fetched, capable) expect(update.changes).toEqual([{ module: 'USB Audio', data: data('configurable'), undo: data('configurable-0.4.1'), replaces: true, reconnects: true }]) expect((await catalogue.prepare(set(), on(9), fetched, capable)).changes[0].undo).toEqual(data('configurable-0.4.1')) }) + it('replaces 0.4.2 with the cheaper 0.4.3, that package as the Undo', async () => { + const { catalogue, fetched, data, on } = audioCatalogue(['configurable-0.4.1', 'configurable-0.4.2', 'configurable']) + expect([on(9), on(10), on(11)].map(inventory => inventory.usbAudioLayout)).toEqual(['configurable-0.4.1', 'configurable-0.4.2', 'configurable']) + expect(catalogue.review(set('main'), on(10), capable)).toMatchObject({ needsSync: true, updates: [USB_AUDIO_MODULE], problem: undefined }) + const update = await catalogue.prepare(set('main'), on(10), fetched, capable) + expect(update.changes).toEqual([{ module: 'USB Audio', data: data('configurable'), undo: data('configurable-0.4.2'), replaces: true, reconnects: true }]) + expect((await catalogue.prepare(set(), on(10), fetched, capable)).changes[0].undo).toEqual(data('configurable-0.4.2')) + }) it('numbers each layout by its source define plus one', () => { expect(['tracks-main-cue', 'tracks', 'master', 'main-cue', 'main', 'tracks-post'].map(layout => usbAudioLayoutNumber(layout as UsbAudioLayout))).toEqual([1, 2, 3, 4, 5, 6]) })