History#
How SwiftBrowser got here, phase by phase, oldest first. What works today is summarized in Compatibility; how to use it is in Getting started.
Phases 1 to 4#
Phase 1 proved the pipeline, Phase 2 added navigation, lists, input and observation, Phase 3 added the layout engine, animation, sheets and Dynamic Type. Phase 4 adds:
TabViewwithtabItemandtag, drawn with an iOS tab bar; every tab stays mounted so its state survives switching.Picker(segmented and menu styles) andForm, plus list styles.- Value-based navigation:
NavigationStack(path:),NavigationPath,navigationDestination(for:)andNavigationLink(value:), with programmatic pushes and pops through the path binding. - Swift concurrency on Wasm: a host-driven executor so
Task,.task,Task.sleepandContinuousClockrun and their state changes reach the screen. Headless snapshots drive it with a virtual clock. GeometryReaderwith the laid-out size reported back from the renderer.- A fourth example,
Examples/Settings, exercising all of it.
Phase 5: a real app (Food Truck, step 1)#
Examples/FoodTruck: Apple's Food Truck sample, vendored and trimmed (its README lists every change). The donut model, orders, cities and the Truck / Orders / Donuts screens run; the store, weather, maps, charts and widgets do not.- Foundation on Wasm: apps link
FoundationEssentials(Date, Calendar, Decimal) plusSources/FoundationLite, which suppliesformatted()and friends without Foundation's 40 MB of ICU data (docs/architecture.md). - Asset catalogs:
Image("name")andColor("name")read*.xcassetsunder the example, served and bundled byWeb/plugins/asset-catalogs.ts(one PNG per image set, light/dark color sets, custom symbol sets). - Combine-style observation:
ObservableObject,@Published,@StateObject,@ObservedObject,@EnvironmentObject. .aspectRatio/.scaledToFit/.scaledToFill,.id,.compositingGroup,Image.resizable()for catalog images,.offsettransitions,Animation.spring(response:dampingFraction:).
Phase 6: Food Truck, step 2#
- The app-level screens of Apple's sample run from their own sources: the sidebar, Truck cards (brand header, orders, donuts, social feed), the donut gallery grid and editor, orders with sections and badges, the completion sheet with the donut box, the social feed with flow-layout tags.
- Custom
Layout: the renderer measures the subviews (min, ideal, max) and sends the proposal to Swift, which runssizeThatFits/placeSubviewsand returns frames plus its own min / ideal / max, so nested layouts measure each other correctly; one frame of latency, likeGeometryReader. Grid/GridRow,LazyVGrid,Gauge,Menu,.toolbar,.searchable,.onChange,TimelineView,LabelStyle,.overlay/.backgroundwith views and shapes,ShapeStyle(hierarchical levels, linear and radial gradients,Color.gradient, materials),.offset/.rotationEffect/.scaleEffect/.shadow/.clipped/.position,.badge,.listRowInsets,.tint,.imageScale,.onTapGesture,.sheet(item:), asymmetric transitions,@ScaledMetric,LocalizedStringKey.
Phase 7: Food Truck, step 3#
- Swift Charts: a
Chartsmodule withChart,BarMark,LineMark,AreaMark,RectangleMark,PointMark,RuleMark, axes (AxisMarks, grid lines, ticks, text or view labels), legends, scales and date bins. Swift maps data to unit coordinates; the renderer measures labels, lays out the plot and draws the marks as SVG. Sales History, Top 5 and the Truck weather card run from Apple's sources. NavigationSplitViewwithList(selection:): a stack on phones, two columns from 700 pt (the renderer reportshorizontalSizeClass); tablets now fill the viewport instead of showing the phone bezel.ViewThatFits,.hidden(), gradient.mask, shadowed shape styles, two-toneforegroundStyle, and the City panel (parking showcase on a drawn map, weather and parking cards).
Phase 8: interaction#
- Gestures:
DragGesture,LongPressGesture,TapGesturewith.gesture/.highPriorityGesture/.simultaneousGesture,.onLongPressGesture,allowsHitTesting; the renderer tracks pointers and streamsdragevents once per frame. - Lists:
swipeActions(tints, destructive, full swipe),contextMenu,onDelete/onMovewith swipe to delete,EditButtonandeditModewith the minus / selection circles,List(selection:)on tagged rows for single and multi-selection,refreshablepull to refresh, swipe-back navigation. - Presentation:
alert(iOS alert card),confirmationDialog(action sheet),fullScreenCover. - Controls:
Stepper,Slider,DatePicker(native pickers behind compact capsules),TextEditor,Text(_:format:)andTextField(_:value:format:)with FoundationLite's.currency/.number. - Effects:
rotation3DEffect,blur, realignoresSafeArea,repeatCount/repeatForeveranimations,Binding.animation,ViewModifier,scenePhase, the accessibility environment. - The driver is
Examples/HackingWithSwift: five of Paul Hudson's 100 Days of SwiftUI projects (Guess the Flag, BetterRest, Animations, iExpense, Hot Prospects, Flashzilla) running from their sources.
Phase 9: incremental rendering#
- Swift: a state change re-runs only the bodies that depend on it. Each
mounted view tracks its own
@State,@Observablereads and observed objects; clean subtrees are skipped whole and their cached elements reused, and the reconciler skips unchanged subtrees by identity instead of diffing them. - Web: the layout pass lives across commits. Only the subtrees an op touched (and their ancestors) are measured and placed again; the DOM pass visits only what changed.
- On Food Truck's 20 fps header: Swift ~24 ms → ~2 ms per tick, renderer ~5 ms → ~1.5 ms per commit, main thread ~36% → ~6% busy. Protocol unchanged.
Phase 10: bring your own app#
npx @swiftbrowser/cli dev ~/Projects/MyAppruns an iOS app from its Xcode project (project.pbxproj, Xcode 16 synchronized folders included) or a folder of sources:doctorinstalls the toolchain pieces,checkreports the imports and compiles against the shim in seconds,devserves it with rebuild on save,buildwrites a static site. Seepackages/cli/README.md.- The project is never modified: a staging SwiftPM package under
<project>/.swiftbrowser/holds a copy of the sources adjusted for the shim (import SwiftUIgains the Foundation modules Apple's SwiftUI re-exports,import Foundationbecomes FoundationEssentials + FoundationLite,#Previewblocks are blanked,SWIFTBROWSERis defined), with line numbers intact. - Foundation measured: the wasm SDK's full Foundation adds about 42 MB (36 MB
of ICU data) as soon as anything from it is used; FoundationEssentials adds
4 MB. Lean mode is the default, and FoundationLite grows with what apps need
(
UserDefaults,Timer.publish+onReceive, format styles,IndexSet,CharacterSet). - Full Foundation made viable:
--foundation fulltrims ICU's 34 MB data package to the project's"locales"(English by default, 5.6 MB) and links it in the SDK's place through a data-only target of the staged package, so an app that formats dates and currency with the real Foundation is 19 MB (6.6 MB gzipped) instead of 47 MB (18.5 MB). - npm packages:
@swiftbrowser/cli,@swiftbrowser/web(the renderer and dev server, now with an app registry),@swiftbrowser/xcodeproj(a dependency-free Xcode project reader) and@swiftbrowser/swift(the Swift package, so the CLI builds against the shim version it ships with). - Acceptance:
checkover all nineteen Hacking with SwiftUI projects, run from their Xcode projects unchanged. Five compile today (Guess the Flag, Views and Modifiers, Animations, iExpense, Flashzilla); the rest stop at a named gap: unsupported frameworks (SwiftData, Core ML, Core Image, PhotosUI, StoreKit) or shim API still missing (@FocusState,Path/InsettableShape,Bundle,onSubmit,scrollTargetBehavior,visualEffect,accessibilityInputLabels). CI runs the CLI on six of them.
Phase 11: the real Foundation by default#
- The CLI now builds against the wasm SDK's own Foundation (swift-corelibs)
unless asked for
--foundation lean:DateFormatter,NumberFormatter,NSString, locale-awareformatted(),Measurement,NSRegularExpressionandUserDefaultscompile as on iOS. With ICU's data trimmed to English (4.7 MB) a small app is 18 MB, 4.6 MB over the wire with brotli; lean stays for apps that must be small (4.5 MB, 1.2 MB brotli). FoundationBridge, a new module of the Swift package, is the shim's glue to the real Foundation:IndexSetforonDelete/onMove,DateforDatePicker, Foundation'sFormatStyles inText(_:format:)andTextField(_:value:format:), and theTimer+RunLoopthat corelibs Foundation does not have on WASI (Timer.publish+onReceiveincluded). The shim itself still never imports Foundation. The names both declare (CGFloat,CGPoint,CGSize,CGRect,Timer,RunLoop) are settled by typealiases in a file the CLI generates into the app.FoundationLiteis the lean mode's module; itsTimerand the bridge's share one executor-driven core in the shim (_IntervalPublisher,_ExecutorTimer), and a scheduled timer now lives until it fires, as Foundation's does.- CI builds the six examples and two Hacking with SwiftUI projects in both modes and runs them headless; the lean builds keep the op-stream snapshots.
- The app follows the viewer: the browser's time zone, and its language when
the module ships that language's data (else the first shipped one), with
?locale=to try another. swift-foundation hard-codesen_001on WASI, so the CLI redirects that function to FoundationBridge at link time. UserDefaultspersists: the module sends its defaults as adefaultsop, the page keeps them in localStorage per app and hands them back at launch.Bundle.mainworks: the target's Copy Bundle Resources are served next to the module and mounted at/bundlein the WASI filesystem beforemain, sourl(forResource:withExtension:)+Data(contentsOf:)read them. Both classes live in_FoundationCommon, shared by FoundationLite and the bridge.
Phase 12: the rest of the Hacking with SwiftUI list#
- The survey's remaining gaps, closed:
@FocusStatewith.focused(_:)and.focused(_:equals:)(the field'sfocusedprop;focusevents back),.onSubmitand.submitLabel(submitevents on Enter,enterkeyhint),.preferredColorScheme(a root update the page applies as its theme),navigationTitlewith aBindingorText,.accessibilityInputLabels,.scrollTargetBehavior+.scrollTargetLayout()(CSS scroll snapping on the target stack's children),.containerRelativeFrame(an affine size against the nearest container: the screen or the scroll viewport),.visualEffect(its effects apply once with an empty proxy; the browser does not report frames per scroll step),@Environment(Type.self)with.environment(_:)for@Observableobjects,dynamicTypeSize(_ range:),Angle / Double,.scrollBounceBehavior, and aUITextCheckerstand-in that passes every word (full mode). - CLI:
import Foundationalso imports Observation, as Apple's does (an@Observablemodel in a Foundation-only file compiles), and file references whose case differs from the disk are repaired (a project made on macOS). - Twelve of the nineteen Hacking with SwiftUI projects now compile unchanged
(WeSplit, Guess the Flag, Views and Modifiers, WordScramble, Animations,
iExpense, Moonshot, Navigation, AccessibilitySandbox, Flashzilla,
LayoutAndGeometry, SnowSeeker). The rest wait on frameworks: SwiftData (11,
12, 16), Core ML (4), Core Image / PhotosUI / StoreKit (13), MapKit /
Core Location (14), and networking (
URLSession,AsyncImage; 10).
Phase 13: networking#
The browser is the network. URLSession (data(from:), data(for:),
upload(for:from:), dataTask(with:completionHandler:)), URLRequest,
URLResponse / HTTPURLResponse and URLError exist in both Foundation
modes and run over the page's fetch: a request becomes a request op the
page performs and answers with a response event, and the awaiting task
resumes through the executor. AsyncImage (all three initializers,
AsyncImagePhase) asks the page to decode the picture and shows an <img>
the browser already has. Cross-origin servers must allow the page (CORS), as
for any web app. Headless runs answer from SB_RESPONSES fixtures, so an
app's network paths snapshot deterministically. Cupcake Corner (project 10)
is the thirteenth Hacking with SwiftUI project to run unchanged, and the new
Examples/CupcakeCorner.
Phase 14: one Foundation#
Lean mode is gone. Every app links the wasm SDK's Foundation with its ICU
data trimmed to the app's languages, the way the CLI has built apps by
default since Phase 11; 4 of the 13 Hacking with SwiftUI projects that run
today compiled in lean mode, and each new Foundation API an app touched had to
be re-implemented in FoundationLite. With one Foundation the shim imports it
directly: onDelete takes an IndexSet, DatePicker a Date,
Text(_:format:) a FormatStyle, and the three protocols that stood in for
them, FoundationLite, _FoundationCommon and the bridge's conformance layer
are deleted. FoundationBridge keeps what corelibs Foundation lacks on WASI:
Timer and RunLoop, a persisting UserDefaults, Bundle, URLSession,
AsyncImage, the viewer's Locale. The examples are now built through the
CLI like any app (scripts/build-wasm.sh), their sources say
import Foundation and nothing else, and the headless snapshots are recorded
in en_US with ICU's formatting. --foundation and "foundation" in
swiftbrowser.json are accepted and ignored with a warning. A small app is
18 MB, 4.6 MB over the wire with brotli.
Phase 15: smaller modules#
Where the 18 MB went, and why the linker cannot drop more, is in
docs/ops-protocol.md, "Phase 15": the app is 6 kB of it; the rest is the
standard library, Foundation, ICU and their protocol conformances, which stay
reachable through dynamic casts. What shrank: the ICU trimming also drops the
legacy character-set converters, StringPrep profiles and spoof-checker data
(0.8 MB), "collation": false drops the collation tables (0.9 MB) for apps
that never compare strings in a locale, wasm-opt runs -Oz (as fast as -Os
here, 1.3% smaller) and the Swift driver's autolink record is removed
(108 kB). Counter: 17.4 MB (4.5 MB brotli), from 18.4 MB (4.6 MB). Loading
the ICU data from a content-named file beside the module, which every app on
a site shares and an update never re-downloads, was built and measured too
(13.6 MB module plus a 3.9 MB file) and parked on the icu-sidecar branch:
for a single-app site it saves a fifth of each update's download at the cost
of a second file the module cannot start without.
Phase 16: skipping unchanged views#
A body that re-runs no longer re-runs every view below it. Like SwiftUI, the runtime compares each child's new view value and the environment it receives with last time's, and skips the child and its subtree when they are the same (docs/ops-protocol.md, "Phase 16", has the rules; a closure or binding always counts as a change). In Food Truck a new order re-rendered the whole Truck screen, a task long enough to stall the animated truck header; now only the orders card and what changed in it re-run.
Phase 17: cheaper passes#
Each render pass does less (docs/ops-protocol.md, "Phase 17"). The runtime
works out once per view type which of its protocols the type conforms to,
instead of two dozen dynamic casts per node per pass. A chain of modifiers no
longer doubles its work with every modifier. A screen hoists its toolbar items
only from elements that are new. The renderer no longer reads every updated
element's computed style in passes that cannot animate, and it reads the
screen size only after a resize. Food Truck's Truck screen, with its header
animating, takes about 95 ms of script per second instead of about 140. The
new-order task's longest piece drops from 55–74 ms to 50–55 ms. Two
behaviors were fixed along the way: a modifier inside an if was applied
twice, so onAppear and .task ran twice. A long modifier chain took time
exponential in its length; thirty .paddings never finished rendering.
Phase 18: SwiftData on IndexedDB#
import SwiftData works: @Model, ModelContainer, ModelConfiguration,
ModelContext (insert, delete, delete(model:where:), fetch with a
FetchDescriptor, fetchCount, save, rollback, autosave), @Query (sorted,
filtered, made in init from a view's inputs), #Predicate, SortDescriptor,
@Attribute(.unique), @Relationship with its delete rules and inverse
(declared or inferred), @Transient, Codable attribute types and
.modelContainer / .modelContext on views and scenes. The models live in
memory while the app runs; the page keeps them in IndexedDB, one database per
app, reads it before the module starts (SB_SWIFTDATA) and writes every save
back (a swiftdata op), so the data survives reloads and new builds. The main
context saves at the end of each event that changed it.
@Model is a real macro that expands as Apple's does (Sources/SwiftDataMacros,
on swift-syntax 604, which SwiftPM downloads prebuilt for Swift 6.4), so an app
links SwiftData only when it imports it. #Predicate gets SwiftData's copy of
Foundation's macro, which also accepts localizedStandardContains,
localizedCompare and caseInsensitiveCompare (the open-source macro rejects
them). Bookworm and SwiftDataProject (Hacking with SwiftUI 11 and 12) now run
from their Xcode projects unchanged, fifteen of the nineteen, and
Examples/Bookshelf exercises all of it. docs/ops-protocol.md, "Phase 18", has
the details.
Smaller additions: sharing, empty states, framework stand-ins#
ContentUnavailableView(title and symbol or image, description, actions,.searchand.search(text:)), built from the shim's own views.ShareLink(one item or several,String,URLand asset-catalogImageitems,SharePreview, subject and message) asks the page to share through the Web Share API. Where the browser has none or refuses, it downloads instead: an image as its file, text and links as a.txt. A share the viewer dismisses downloads nothing (docs/ops-protocol.md, "Sharing").Three Apple frameworks, as far as apps usually use them:
import StoreKit:@Environment(\.requestReview)andSKStoreReviewController.requestReview()do nothing (there is no store page to review).import CoreLocation:CLLocationCoordinate2Dis a plain struct, with no location services behind it.import LocalAuthentication: anLAContextwhose every policy can be evaluated and whose every evaluation succeeds. An app that locks content behind Face ID opens as if the viewer had authenticated.
Each is a small module the CLI links only into apps that import it.
Examples/Galleryhas a Sharing screen.
Phase 19: the app's files#
An app gets an iOS-like home directory that the page keeps across launches.
URL.documentsDirectory, URL.applicationSupportDirectory,
URL.cachesDirectory and URL.libraryDirectory (which corelibs Foundation does
not declare) point into it, and so do FileManager.urls(for:in:), so
Data.write(to:), Data(contentsOf:), String(contentsOf:) and FileManager
work as on a phone. Data.WritingOptions.atomic, which corelibs marks
unavailable on WASI, is accepted (writes there are always in place). The page
mounts the home at /data from the app's IndexedDB database
(sb-files:<App>) and, after any event that wrote to a file, saves what changed;
/tmp is a separate mount nothing keeps; ?files=reset starts with an empty
home. Headless runs map the home to a directory (SB_FILES_DIR).
Examples/Journal keeps its entries in Documents the way Hacking with
SwiftUI's BucketList does. docs/ops-protocol.md, "Phase 19", has the details.
Core ML for small Create ML models#
import CoreML works for the models Create ML makes from tables: linear and
logistic regressions, boosted trees, random forests and decision trees, with
the feature engineering their pipelines wrap them in (one-hot encoders,
imputers, normalizers, scalers, vectorizers). Xcode turns each .mlmodel of
a target into a Swift class; the CLI does the same when it stages the app. It
reads the model's protobuf (a small wire-format reader, no dependency),
checks every model in it is one the browser can run, and generates the class
with Xcode's API (init(configuration:), prediction(<inputs>),
prediction(input:), predictions(inputs:), load, model,
urlOfModelInThisBundle) and the model's specification embedded as JSON. A
new CoreML module (MLModel, MLModelConfiguration, MLFeatureProvider,
MLFeatureValue, MLDictionaryFeatureProvider, MLMultiArray,
MLModelDescription, MLModelError) evaluates it, synchronously and in
double precision; it is linked only into apps that have a model or import
CoreML. A model of another kind (a neural network, an ML program, an image or
text model) stops the build with its type named. BetterRest (Hacking with
SwiftUI 4) now runs from its Xcode project unchanged, sixteen of the
nineteen: at its defaults SleepCalculator predicts 8 h 21 min 48 s of sleep
and the alert says 10:38 PM, which CI checks headless. docs/ops-protocol.md,
"Core ML models", has the details.
Photos picker#
import PhotosUI works: PhotosPicker (one item or several, with
maxSelectionCount, a PHPickerFilter such as .images, .videos,
.any(of:) or .not(_:), a photoLibrary, a label or a title) and
.photosPicker(isPresented:selection:). The browser's file chooser stands in
for the photo library. A tap on the picker sends a pickFiles request, and
the page opens an <input type="file"> within that same tap, since browsers
only show a chooser while the user is tapping. The page answers with every
picked file's bytes. PhotosPickerItem is Hashable, and
loadTransferable(type: Data.self) returns the bytes at once.
loadTransferable(type: Image.self) shows the picture. A dismissed chooser
leaves the selection as it was. supportedContentTypes are UTTypes from a
small UniformTypeIdentifiers module. Headless runs answer picks from
SB_RESPONSES fixtures. A task an onChange(of:) action starts during a
render, such as one loading the picked item, now runs right away instead of
at the next event. docs/ops-protocol.md, "Photos picker", has the details,
and Examples/PhotoPicker uses all of it. Instafilter (Hacking with SwiftUI
project 13) also uses Core Image and @AppStorage, both below.
Bitmaps and Core Image#
UIImage, CGImage and import CoreImage (with CoreImage.CIFilterBuiltins)
work as Hacking with SwiftUI's Instafilter (13) and Hot Prospects (16) use
them: UIImage(data:) from an image file's bytes, CIImage(image:), the
built-in filters sepiaTone, crystallize, edges, gaussianBlur,
pixellate, unsharpMask and vignette (typed, or by name with
setValue(_:forKey:) and inputKeys), qrCodeGenerator (byte mode, error
correction L, M, Q or H), CIContext().createCGImage(_:from:),
UIImage(cgImage:) and Image(uiImage:) with .interpolation(.none).
ShareLink shares such an image as a PNG.
Swift never holds the pixels. A UIImage or CIImage is a recipe: the file's
bytes (or a pixel buffer, for a QR code) plus the filter steps to run, which
the page carries out on a canvas at the size the image is shown
(Web/src/imageOps.ts, in plain TypeScript). UIImage(data:) stays synchronous,
as on iOS, because Swift only reads the size from the file's header (PNG,
JPEG with its EXIF rotation, GIF, WebP, BMP, HEIC, AVIF). The QR code
generator makes its modules in Swift. UIImage and CGImage live in the shim,
since SwiftUI re-exports them on iOS; Core Image is a module of its own, linked
only into apps that import it, like the stand-ins above. Examples/Filters
runs Instafilter's processing code on a bundled photo next to Hot Prospects'
QR code. docs/ops-protocol.md, "Bitmaps and Core Image", has the protocol and
each filter's formula.
Swift packages, notifications and a code scanner#
- An Xcode project's Swift package dependencies now reach the build. The CLI
used to drop them (an app importing one failed with "no such module"); now
each remote package becomes a real SwiftPM dependency of the staging package
with the version rule the project records (local packages by path), so a
pure-Swift package that builds for WASI is fetched and compiled in. Packages
that cannot work in the browser are replaced by a SwiftBrowser module of the
same name instead;
checksays which way each package went (docs/ops-protocol.md, "Swift package dependencies"). import CodeScanner(Paul Hudson's camera package) gets such a stand-in:CodeScannerViewwith the package's whole initializer,ScanResult,ScanError,ScanModeandAVMetadataObject.ObjectType. It shows what the package shows in the iOS simulator, a screen that sends back thesimulatedData, and where the browser hasBarcodeDetectorand a camera (Chrome on Android and macOS) it can scan for real (docs/ops-protocol.md, "Code scanning").import UserNotificationsworks over the browser's Notification API: authorization and settings, time-interval and calendar triggers (repeating too), pending and delivered requests, the badge. The app schedules its own timers and the page shows each notification as it comes due, so they are delivered only while the page is open (docs/ops-protocol.md, "Notifications").Examples/HotProspectsis Hacking with SwiftUI project 16 without its Me tab: scan the simulated QR code, swipe for "Remind Me", and the notification appears five seconds later. With Core Image and@AppStorage(below) the project itself builds unchanged, Me tab and all.
@AppStorage#
@AppStorage("key") var value = default reads and writes UserDefaults, so
it is kept across launches like the rest of the app's defaults (Phase 11's
defaults op, in localStorage). It takes what SwiftUI's does: Bool, Int,
Double, String, URL, Data and Date, RawRepresentable enums over
Int or String, their optional forms (@AppStorage("key") var value: String?, where nil removes the key) and store:. A read registers with the
observation tracking each body runs under, and every write to the key,
through any @AppStorage or through UserDefaults.set, re-renders the
views that read it, and only them. With it Instafilter (13) and Hot
Prospects (16) build from their Xcode projects unchanged: eighteen of the
nineteen Hacking with SwiftUI projects, all but Bucket List (14, MapKit).
CI runs Hot Prospects headless: a name typed into the Me tab is saved, its
QR code is made again, and a relaunch shows the name.
That run found a runtime bug: state an onChange(of:) action set while its
body ran (Hot Prospects' updateCode) re-ran the body in the next pass but
never reached the page when the view sat below a clean ancestor, such as a
tab of a TabView. The pass that marked it cached the ancestors' elements
again afterwards; the reconciler now drops the cache of every node it
re-enters.
Swift packages that import SwiftUI#
Package dependencies reached the build in "Swift packages, notifications and
a code scanner", but only a package that never imports SwiftUI compiled:
SwiftPM builds a dependency as its manifest says, and on iOS import SwiftUI
needs no dependency, so it failed with "no such module 'SwiftUI'". The CLI
now builds such a package from a copy in the staging folder: the app's
source adjustments, the alias file in each target that imports a shim
module, and lines appended to its manifest that link the shim and define
SWIFTBROWSER. Packages that depend on a copied one are copied too and
pointed at it (docs/ops-protocol.md, "Packages that import SwiftUI").
The first real package through it, SwiftUI-Shimmer,
needed two things packages use more than apps: \.layoutDirection and
DispatchQueue.main.asyncAfter (the WASI SDK has no Dispatch; FoundationBridge
now has a main-actor one). Its PreviewProvider struct is blanked like a
#Preview block. packages/cli/test/fixtures/Packages (two local packages,
one depending on SwiftUI-Shimmer) is built and run headless in CI.
The frameworks under SwiftUI, and the real Nuke#
Nuke is Swift, but Swift written against UIKit
images, ImageIO decoding, Core Graphics drawing, Combine, CryptoKit, os and
the Objective-C runtime. A stand-in with Nuke's API came first; the shim now
has those frameworks instead, and Nuke 13.2.0 builds from its own sources,
unchanged, and runs: its DataLoader downloads over fetch, its decoder
reads CGImageSource, its resize processor draws in a CGContext, and the
page runs what was drawn as two new recipe steps (place, roundedClip).
The modules: UIKit (UIImage, UIColor, UIScreen, and its view classes
as declarations that never reach the screen), CoreGraphics, ImageIO, Combine
(OpenCombine, with the shim's ObservableObject), CryptoKit (the hashes), os
(lock, logs), and empty AVKit and AVFoundation. FoundationBridge gained
OperationQueue, Dispatch work items and groups, delegate-driven
URLSession tasks, URLCache and the rest of URL loading's types, the
Objective-C runtime's associated objects and autoreleasepool; the
generated alias file brings them to files that import only Foundation. The
staging rewrites three things Linux's Swift does not have: submodule imports,
@objc optional delegate calls, and ProcessInfo's physical memory (0 on
WASI). SwiftUI gained withTransaction and .onDisappear
(docs/ops-protocol.md, "The frameworks under SwiftUI").
packages/cli/test/fixtures/NukeApp (the app and a package of avatars, both
over Nuke 13.2.0) runs headless in CI with the pictures' bytes.
Starting a new app#
Every command so far took an app that already existed. swiftbrowser init
writes one: the project Xcode 16's iOS App template makes (<Name>.xcodeproj,
objectVersion 77, one target for iOS 18, its sources a synchronized folder
<Name>/ with the app, a ContentView and an asset catalog), plus a
.gitignore and a README. The template is a pure module
(packages/cli/src/template.ts) whose object ids are hashes of the name, so
the same name always gives the same project. Its tests read the project back
with @swiftbrowser/xcodeproj and resolve it as the CLI does; CI checks a
fresh one on Linux and builds one with xcodebuild for the iOS Simulator on
macOS.
Later, the template gained a unit-test target, as Xcode's does with "Include
Tests": <Name>Tests, hosted by the app, with a Swift Testing test of
ContentView and a shared scheme for ⌘U. swiftbrowser test runs such tests
outside Xcode. It stages the app and its unit-test targets as SwiftPM test
targets, builds them for WebAssembly against the kit (debug, about ten
seconds), and runs each test module under Node's WASI: first XCTest, then
Swift Testing, each only if some test imports it.
Gifu, frame by frame#
Gifu's GIFImageView was a stand-in that kept the GIF as its image, which the
page drew as a still picture. Gifu 4.0.1 now builds from its own sources and
animates as on iOS, with three things it needed. Image I/O reads an animated
GIF's frames, delays and loop count without decoding it, and an image of
frame n is a recipe that names the frame; the page composes it with a GIF
decoder of its own (Web/src/gif.ts), the same in every browser. A layer's
setNeedsDisplay() calls its view's display(_:), and a layer is displayed
before its view is first drawn, so the image view shows each frame Gifu gives
it. And a display link runs a timer only while it is unpaused. Gifu builds in
Swift 6 mode (it ships a Package@swift-6.0.swift), which rejects naming a
main-actor method of a class that is not Sendable unapplied, so the staging
binds such a method to its target in a closure where #selector names it
(docs/ops-protocol.md, "Animated GIFs"). packages/cli/test/fixtures/GifuApp,
with Ice Cubes' GifView, runs headless in CI.
CodeScanner over capture sessions#
CodeScanner was a stand-in module with the package's API that showed the
simulator's screen: "Send Simulated Data", plus a camera button where the
browser has BarcodeDetector. The real package (2.5.2) now builds from its
own sources, on its device branch, over a small capture API in AVFoundation:
a session whose startRunning() asks the page to scan (a scanner host
request), a metadata output whose delegate gets the code as an
AVMetadataMachineReadableCodeObject, a photo output that delivers the
camera frame the code was read in, the page's two cameras as devices, and a
preview layer that offers to scan again. The page opens its camera over the
page where it can read codes and asks the viewer to type the code where it
cannot. UIKit gained UIButton (drawn as a Button), layout guides,
touches to override, supported orientations and presentation delegates;
Core Image a CIDetector that finds nothing (it is synchronous); the
delegate protocols are main-actor isolated, so a view controller conforms in
Swift 6.
A folder of sources can now depend on Swift packages: swiftbrowser.json's
packages (a URL with a rule, or a path, and products), which
Examples/HotProspects uses for CodeScanner. Headless runs answer scan
from SB_RESPONSES, and event scripts take wait:<ms> to run the work an
event queued before the next one (CodeScanner starts its session on a later
turn of the queue). See docs/ops-protocol.md, "Code scanning".
MapKit#
Bucket List (Hacking with SwiftUI 14) was the one project check stopped:
MapKit had no counterpart. A stand-in module now has its SwiftUI API, drawn
without map data: Map shows its region as a surface with a grid of
latitude and longitude lines, and places Annotation, Marker and the
overlays where they are on it, in Web Mercator; it does not pan or zoom.
MapReader converts a tap's location to a coordinate, so onTapGesture
with a location now asks the page for the point of the click. All twenty
projects build from their Xcode projects unchanged, and CI checks them all.
That run found a runtime bug: a sheet or alert bound into an @Observable
model ($viewModel.selectedPlace) never presented, because the runtime read
the binding outside the observation tracking of the node's children. See
docs/ops-protocol.md, "MapKit".
Making MapKit importable broke the Ice Cubes deploy: SwiftUI-Introspect
compiles its Map support under #if canImport(MapKit), and that names
UIKit's MKMapView, which the stand-in did not have. It now has one, a
UIView that keeps its region and settings and draws nothing.
Backyard Birds#
Apple's Backyard Birds sample builds from its Xcode project unchanged and
runs: its backyards drawn from layered PDF artwork, birds tinted part by part
with colorMultiply, SwiftData data generation with a model actor, the tab
layout the iPhone gets. What it took, in the CLI: dynamic library products
built as automatic ones, the packages' asset catalogs on the page, Xcode's
generated asset symbols, and PDF images rendered to PNGs at 3× with pdf.js
at build time. In the shim: .layoutValue reaching custom layouts (every
layer of a backyard was placed as the key's default), styles of an app's own
(resolve(in:)), iOS 17's stroked shapes, fill styles, content margins,
PhaseAnimator, @ModelActor, keys bridged from UIKit traits, and
.background() painting the background style in context. See
docs/ops-protocol.md, "Backyard Birds".
Food Truck#
Apple's Food Truck sample builds from its Xcode project unchanged, with its
FoodTruckKit package; Examples/FoodTruck, the trimmed copy from before,
stays for the snapshot and e2e tests. What it took: Canvas, its renderer
recorded against a GraphicsContext and drawn as SVG (the animated brand
header); Table, drawn as a list with sortable column titles in a regular
width; stand-ins for WeatherKit (requests throw, as for an app without the
capability), passkey and password requests (each ends in .notHandled:
WebAuthn answers only for the page's own domain), the Ice Cubes MKMapView
now drawing the SwiftUI map at its region and CLLocation; @SceneStorage;
drop shadows on shape styles, ScaledShape, attributed-string run attributes, Measurement.formatted,
SiriTipView, StoreKit's message action and chartPlotStyle. See
docs/ops-protocol.md, "Food Truck".
Builds that compile the app only#
Every first build of an app used to compile all of SwiftBrowser with it, and
swift-syntax from source too (its macro target linked os, which kept SwiftPM
from using the prebuilt release): a cold Counter build took 528 s. With the
macro on swift-syntax alone it took 100 s, and with kits 6 s. The CLI now
compiles the shim once per version into a kit in its cache (every module and
an archive of each one's objects), and stages each app against a package in
the kit with SwiftBrowser's products, whose targets link those archives
(packages/cli/src/kit.ts). wasm-opt uses every core as well (8 MiB stacks
for musl's threads), 106 s for Ice Cubes where one thread took 300 s. See
packages/cli/README.md.
Reordering rows, drag and drop#
ForEach.onMove reorders for real: in edit mode a movable row gets the grip
iOS draws at its trailing edge, outside it a long press lifts the row, and
the row follows the finger among its neighbours, which slide out of its way,
settling into its slot before Swift hears move with the child index it
goes before; the runtime maps that to the ForEach's offsets, so rows in a
section with a header or static rows land right. .draggable and
.dropDestination, and onDrag / onDrop with item providers, drag and
drop within the app: a copy of the view follows the pointer and the
destination under it hears entered, exited and performed; the payload
never leaves Swift. Text, links and files dragged in from the desktop reach
a destination that accepts their type as transfer contents. See
docs/ops-protocol.md, "Reordering rows" and "Drag and drop".
Liquid Glass presses and toolbar springs#
Two of iOS 26's bar behaviours. Pressing a bar button swells the Liquid
Glass under it, a little larger and brighter, until the finger lifts and it
springs back; a bar group whose items come or go grows or shrinks its
capsule with a spring while the items slide, the new one scaling in and the
old one out. The press is a small controller (Web/src/press.ts) that marks
the glass under the pressed control from the pointer down to the pointer
up, lifting the mark while the pointer strays, with the stylesheet drawing
the swell and the spring back. The group changes are the Animator's: a bar
toolbar whose items changed is an implicit animation root with a spring of
its own, in a pass that animates nothing else, so the capsule's frame, its
items and the bottom bar's glass capsules (chrome, reported to the Animator
as frame changes) tween as withAnimation would tween them; the commit's
own animation wins when there is one. A group that only moves, when the
screen resizes, still jumps (docs/ops-protocol.md, "toolbar in a
navscreen"). The bottom bar's capsules were first matched to the engine's
rects by index, so removing the middle of three groups slid its capsule
over the last one's while that one scaled out; a capsule now knows the
toolbars drawn on it and goes with them.
Two more came from the Swift side. The runtime hoists a screen's toolbar
elements out of the content and the reconciler matched them by position, so
when the leading and trailing groups went away and the bottom group gained
a button, the leading group's element was updated to the bottom placement
(the capsule flew down the screen) and the bottom group's items landed in
it. Hoisted groups are now keyed by the .toolbar they came from, their
place in its content (through if/else branches) and their placement,
and the search field likewise, so each group keeps its element and animates
as itself; the page treats a placement change from any host as a group
leaving and another arriving. The press, too, now swells the whole group
as iOS does, a bottom group's toolbars along with their capsule, and a
glass-styled button in a group presses the group rather than itself.
A Play item swapped for a Stop item in an if/else still lost its
capsule, as the two branches were keyed apart; and the navigation bar
drew every ToolbarItem as a circle of its own, 8 apart, where iOS 26
(Examples/Fidelity topbar*, measured in the simulator) puts adjacent
items of one placement on a shared capsule, their 44 slots 12 apart and
the capsule a point past them, capsules 12 apart and split only by a
ToolbarSpacer, and lays trailing capsules out in content order with the
last at the edge. The branches now share a key, so the item changes in
place, and the bar's capsules are runs of adjacent toolbars, chrome like
the bottom bar's (leadingGlass0 …, trailingGlass0 …, drawn as
.sb-bar-glass and known by the toolbars on them), so a swapped item
keeps its capsule whatever its element, and a press swells the run.
Tabular digits#
.monospacedDigit()on a view, aFontor aTextis a font field (monospacedDigit: true) the page draws asfont-variant-numeric: tabular-nums, set beside thefontshorthand (which resets it) on text elements and rich-text runs, and inherited by the DOM inside a styled box. It rides along like a weight modifier: a font set further in keeps it until one saysfalse. A canvas cannot apply the variant, so the measurer counts each digit of a tabular font as the font's widest digit, which is the width a tabular figure takes.
Browser history#
- The browser's back pops the app (
Web/src/browserHistory.ts): pushing a screen or presenting a sheet adds a history entry, and the browser's back (a phone's edge swipe, the toolbar button) pops or dismisses it through the same tap the bar's back button sends, so the app's state stays the source of truth. The app popping on its own takes the history back with it; forward returns to the matching entry instead of re-pushing. Depth is read from the DOM after each commit (the sheets, plus the pushed screens of every visible stack), so it holds for tabs, split views and stacks inside sheets. A two-column split view's sidebar selection is an entry too: moving it to another row adds one, and back or forward taps the row the entry recorded. While it is on the renderer's own edge swipe ignores touch: the browser's swipe (Safari's, Android's back gesture) is the swipe back; a mouse drag from the edge still pops. Everypopstatethe browser makes also keeps the page repainting for 5 s (Renderer.keepRepainting, a 1 px box alternating two near-identical colors): Safari's swipe shows a snapshot of the entry and, once its own animation ends, hides the live page until a new frame is committed, so a pop that had finished animating sat under the snapshot, a still image taking the touches unseen, until Safari's 3 s watchdog removed it. The painting runs through that watchdog: measured on an iPhone, 1.5 s of it removed the stall but a touch in progress still froze once at the 3 s mark, and 5 s left nothing. A back the browser makes waits for the app's pop to land (up to 1 s per level) before it reads a commit as anything else: a compact split view clears its sidebar selection on one commit and drops the detail on a later one when the app's selection binding is asynchronous, and the commit between, still showing the detail, was read as a new push. The entry pushed then (and thehistory.go(-1)that undid it once the pop landed) ran inside Safari's swipe, which kept its snapshot up for its whole 3 s watchdog. An entry is pushed at the renderer'ssb:precommit, before the layout that first holds the pushed screen: Safari sizes the entry being left from the page's last layout at the push (its snapshot's render tree size, more than half of which the page must have again before the snapshot comes down after a swipe back to it), so a push after that layout counted the pushed screen into the entry it covers, and a root lighter than the screen over it (Amindia's sidebar under its Queue) stayed under the snapshot until the 3 s watchdog after every swipe back; the module reads style, never layout, so nothing forces one before the push. On the examples page always; in an island by default, off with<SwiftUIView history={false}>/mount(..., { history: false }). The URL is never touched.
Default scroll anchor#
.defaultScrollAnchor(_:)(Web/src/scrollAnchor.ts): a scroll view opens with that point of its content in view (.bottom: the end, as a chat on its latest message) and keeps it when a pass changes the content's or the viewport's size while the viewer is at it; a viewer who scrolled away is left where they are. Before it, a chat had to callproxy.scrollToon every change, which pulled a reader back down whenever a line arrived.defaultScrollAnchor="bottom"in React.
Scroll position#
.scrollPosition(id:anchor:)reads back (Web/src/scrollPosition.ts): setting the binding scrolled to the view with that.idalready (now the value it opens with too); now the viewer's scrolling sets it as well. The scroll view carriesreportsPosition, and when its scrolling settles the page sendsscrollpositionto the.idview at the anchor point (the leading edge unless the anchor says otherwise), once per change of target, and the binding takes that id without scrolling to it. A paged week of a calendar learns which week the viewer swiped to and can shift its window.scrollPosition={[id, setId]}in React.- An animated
scrollToof a snapping scroll view runs as a swipe's page does (TouchPaging.animateTo,ScrollContext.animateScroll):withAnimation { proxy.scrollTo(...) }on a paging or view-aligned scroll view handed the browser a smooth scroll with mandatory snapping on, and Safari snapped it again after the slide, half a page off, on a calendar whose chevrons page it (a swipe, driven by the touch pager, never did). It now runs as the touch pager's run does: the snap off, the last frame writing the offset, the snap back on, the position reported once at rest. Fidelity's month pager has the chevrons.
Long menus#
- A menu taller than the screen scrolls (
renderer.openMenu): a picker's popover was as tall as its rows, so one of every hour ran off the bottom of a phone with no way to reach the rest. It now takes the roomier side of its anchor, as tall as that room, scrolls inside and opens with its checked row in view.
A scroll command's axes#
scrollTocan name its axes (ScrollToCommand.axes): a scroll command moved every scrolling ancestor, so a horizontal pager's.scrollPosition(id:)inside a list also pulled the list to the page's top, on opening and at every page..scrollPositionnow scrolls on its scroll view's axes only, and React'sproxy.scrollTo(id, anchor, { axes })can ask the same.
Pages the width of their scroll view#
containerRelativeFramepages came out the size of the first measurement: a stack measures a flexible scroll view at zero, at its ideal and at its final width, and the engine memoized a page's plan by its proposal alone, so a page sized by the container kept the width of whichever measurement came first (zero beside a fixed column, the screen under a list). The memo and placement keys now carry the container, and a scroll view places its content under the context it measured it in. A pager of.containerRelativeFrame(.horizontal)pages with.scrollTargetBehavior(.paging)snaps on page boundaries without the app measuring anything.- A finger on a
.scrollPositionscroll view holds its report: a pause in a drag counted as a settled scroll, so the page under the finger was reported and an app re-centring on it moved the content under the finger. The view reports once the finger lifts and the scroll settles. - A snapping view reports from a snap point only: a trackpad swipe
ends, the browser's snap animation has not begun, and the 120 ms settle
found the view a few pixels into the page behind, so the page was
reported and the app re-centred on it with a jump, while the animation
that followed could carry the view a page further. A view with
scrollTargetBehaviorthat settles off its snap points now waits (up to six settles) for the animation to land it on one, so the page reported is the one the browser snapped to, after its animation. - A finger pages a
.pagingscroll view as iOS does: CSS snapping chooses by the projected end of the fling, so a short flick fell back to the page it left, where aUIScrollViewwith paging goes a page on for any flick and needs half a page of a slow drag otherwise. The browser is kept off the paging axis under a finger (touch-action), the page follows the finger and runs, eased, to the page a flick or a slow release chooses (Web/src/touchPaging.ts). Wheel and trackpad scrolling stay native. - The run to a page stopped short on iOS: Safari pans a scroll view
under a finger whatever
touch-actionsays, and the run ended itself whenever the offset it read back differed from its last write, taking Safari's pan (or a trailing read) for another writer, so a drag's release left the page a few pixels off and a flick sometimes did. A drag of ours now cancels the browser's touch moves, and the run writes every frame to the end; only an app's ownscrollTocommand ends it early. The first move decides the drag's direction (3 px in, under Safari's threshold for a pan of its own): a move left to the browser let it begin a vertical pan, after which it cancelled the touch, and a drag back ended in a run to the nearest page from wherever the finger was. And a drag that began between a page's report and the app's re-centring on it was cut by the re-centre's scroll command: the drag now carries on across scroll commands, the page under the finger found again after them and the offset moved by what it moved. And a quick swipe starting on a button inside the pages (a calendar's days) could be Safari's: the button'stouch-action: manipulationlet it pan the view itself; nothing inside a paging view widens the pans allowed along its axis now.
Rows under the bar#
- A row scrolled under the bar painted over its title (styles.css
.sb-listrow): the row's swipe content sits atz-index: 1so it covers the swipe actions, and with no stacking context between it and the bar (alsoz-index: 1) the later row won. Each row (andswipeActionsbox) is now its own stacking context, so the bar, and its edge effect, stay over the content.
The keyboard in a React island, and under a search field#
- A
fillisland follows the keyboard (mount'skeyboard, on by default forSwiftUIView fit="fill"): the keyboard watcher lived in the page's own boot, so an app mounted through React never told the engine about the keyboard and Safari panned the page to the field instead, taking the bar off the top and the list's end under the keyboard. - A bottom search field rises above the keyboard (
placeNavScreen): it stayed at the screen's bottom, covered, while the content stopped above the keyboard. Now it docks on the keyboard as iOS 26 does, and the list keeps clearing it.
The keyboard#
- The on-screen keyboard is a bottom inset (
Web/src/deviceMode.tswatchKeyboard,renderer.setKeyboard,LayoutEnvironment.keyboard): in device mode the page measures the keyboard as the layout viewport's height less the visual viewport's, undoes the browser's pan to the focused field, and the engine lays the screen out above the keyboard as iOS does: a chat's composer in asafeAreaInsetrises with it and its scroll view, shorter now, keeps the last message in view throughdefaultScrollAnchor(.bottom); a tab bar or bottom toolbar under the keyboard stays put, covered..ignoresSafeArea's regions are honoured:.keyboard(in the default.all) is thestyledhintignoresKeyboard, whose box runs under the keyboard and whose root keeps the keyboardless height;.containeralone leaves the keyboard inset. Before this the browser panned the whole app up by the keyboard's height, taking the navigation bar off the top of the screen. Fidelity'schatscreen is the reference.
Hosts in list rows#
- A host in a list row keeps to the row's content frame: the row element
is the whole row (the card's width, the row's padding), and the host's
content was positioned at the element's origin and sized to it, so DOM
content that fills its box (an image preview with
height: 100%) ran into the row's padding and drew short of the box it was measured for. The content element now goes back into the engine's frame (Web/src/hostInset.ts), as a text row's text does.
Large title items and scroll visibility#
ToolbarItem(placement: .largeTitle)(iOS 26): the items take the large title row in place of the title's text, as a logo beside a project's name does. The page keeps the toolbar in the large title element, so it scrolls with the screen's list as the title does, and the bar shows the title once the row has gone under it; while the title is inline the items are hidden. React has it asplacement="largeTitle"..onScrollVisibilityChange(threshold:_:)(iOS 18): a view hears when the share of it inside its scroll view's visible area crosses the threshold, the area below a bar the view scrolls under, as content under a bar is not in view. The page checks after each layout and once a frame while scrolling (Web/src/scrollVisibility.ts); React has it as theonScrollVisibilityChangemodifier. An inline title given to an empty bar fades in, as a collapsing large title's does.
Segmented pickers in the navigation bar#
- A segmented
Pickeras a bar item now looks as iOS 26 draws it (Examples/Fidelitytopbarsegmented, measured in the simulator): the control is the 44-tall glass capsule itself, with no track inside it, 15pt regular labels and a 36-tall gray selection pill inset 4 with no shadow. It was a 32-tall track with a raised white thumb inside a second capsule. It is never wrapped in the item's shared glass, and sits 16 from the next capsule. .sharedBackgroundVisibility(_:)on toolbar content takes effect:.hiddendraws the item without the bar's shared glass, as a run of its own. React has it assharedBackgroundVisibilityonToolbarItem.
Web images and file imports in React#
AsyncImage webInteractions(React only): a remote picture keeps the browser's own image interactions, a long press's Save / Share / Copy on iOS, dragging it out and the right-click menu. Images stay inert by default, as SwiftUI's are.fileImporterin React: the browser's file chooser, opened from the tap that setsisPresented, handingonCompletionthe chosenFiles. Swift's.fileImporteralready worked; the compatibility table now says so.- Text input hints:
.keyboardType,.textContentType,.textInputAutocapitalizationand.autocorrectionDisabled(Swift and React) set the input'sinputmode,autocomplete,autocapitalizeandautocorrect; they were accepted and ignored. Chart yAxisFormatin React: the numeric axis's label text, as.chartYAxis { AxisMarks(format:) }sets it ($0.05for a cost).
One animation for a browser back#
- A pop the browser has already animated plays once. After Safari's
back swipe the renderer slid the popped screen out again and slid the
uncovered one back from the left, a second pop over the first. A back
within 2 s of a touch at a side of the page (the swipe's first touch,
which Safari hands the page before it takes the gesture; Android's back
gesture likewise) now goes at once, and the screen below takes its place
without a transition (
Renderer.popWithoutAnimation); the browser's back button touches nothing on the page, so its pop still slides, as the bar's back button and the app's own pops do. A leaving bar group's clone (iOS 26's own transition for a group that comes or goes,implicitToolbars) goes with its screen: an app that swaps its detail's content for a placeholder a commit before the screen is popped (Amindia's split view, as its selection clears) left the clone of the detail's trailing group fading over the uncovered screen's button for the bar spring's half second. The renderer drops the exit clones of what left any element it removes (Animator.dropExitClonesIn).
A native app in a page#
swiftbrowser-native site(swiftbrowser native site): a SwiftBrowser Native app as a static site the web renderer runs. The round trip's module (Native/RoundTrip: the native views compiled for WebAssembly against the shim, with the host's JavaScript as the engine) was a test; it is now what@swiftbrowser/nativeships underwasm/(the release workflow builds and optimizes it), andsitewrites it, the app's bundle (/bundle/app.js, which the module reads at launch) and the page as one directory, the layoutswiftbrowser buildwrites. The page's loader gives a module that importssb_nativethe host (Web/src/nativeHost.ts, moved from the native package, which re-exports it); the bundle runs at the page's global scope, so the browser's ownfetch, timers and storage serve it.--basebuilds a site for a path inside another (Amindia serves its native app at/native/);SiteOptions.basein@swiftbrowser/web. TheNativeworkflow builds the Fidelity example's site and opens it in Chromium (scripts/native-site-check.mjs).- Split navigation natively: SwiftBrowser Native draws
navsplitas aNavigationSplitViewof the sidebar's and the detail's stacks, withsidebarVisibleas the column visibility and the toggle'stapsent to the app. A split view's detail column is the stack itself (NavigationStackElement.stack), which the shim recognizes as one; a view around it would be wrapped in another stack and flattened, its path with it.
The native views draw what Amindia's screens need#
Drawn in the browser (swiftbrowser-native site, over Amindia's screens),
SwiftBrowser Native showed its gaps at once; each is now drawn, natively
and in the page alike:
- Charts: the protocol's
chartarrives resolved (marks as unit rects of the plot, axis grid lines, ticks and formatted labels, the legend), soChartElementdraws it with paths and texts along the web renderer's layout rules: the legend row, the axis bands as wide as their labels, the plot in what remains; rect, line, area, point and rule marks;chartitemannotations against their mark's rect and axis label views at their tick. No Swift Charts involved, which keeps it the same against the shim. - Inspector:
inspectoris.inspector(isPresented:)over the content's elements with theinspectorpanelas its column (inspectorColumnWidthfrom the panel content's hint). - Scroll targets: a
scrollview'ssnapis its target behavior, a stack'sscrollTargetits target layout,reportsPositionis.scrollPosition(id:)(a newscrollpositionevent with the marked element at the anchor once the view settles), ascrollIDstyle marks the element with its own id, and a reader'sscrollTohint, newest serial first, scrolls the view to the element it names. containerRelativeFrame: the style hint'sa × container + bper axis, as the modifier's closure overload. Amindia's calendar, whose week pages are container-relative, had its day columns at their intrinsic width.- A frame fixed on one axis and flexible on the other (
{ maxWidth: "infinity", height: 1 }, a rule across the width) was drawn as the flexible form alone, its height dropped: the calendar's hour rules filled their rows and the rows shrank to their labels. Per axis, a fixed length now wins over a min/max, as the web layout engine resolves it:.frame(height: 1).frame(maxWidth: .infinity). - Large-title toolbar items go beside the large title against the shim
(its
.largeTitleplacement); SwiftUI has no such placement, so the bar's trailing edge there, as before. - Named images in a page:
swiftbrowser-native site --catalog <dir.xcassets>(repeatable) publishes the app's catalog with the site, soImage(name)draws there; the page resolves the catalog's paths under the site's base path, which it did not.
Workers for a JavaScriptCore app#
Amindia draws its card previews with satoru (HTML to PNG in WebAssembly)
in a Web Worker; the native app had no worker, and no WebAssembly was
assumed of a bare JSContext. A probe (.github/workflows/jsc-wasm.yml)
settled the second: the engine runs wasm in a bare context on every iOS
since 17 with its JIT, and on a device, where a third-party app has none,
from iOS 18.5 in its interpreter and with SIMD from iOS 26.2; satoru's
module, inlined as a 10 MB base64 literal, decodes, compiles and draws in
under two seconds there. The probe also showed that an async
WebAssembly.instantiate settles its promise from the thread's run loop,
which a probe that only slept never saw.
So createWorker(name): a second JSContext in a JSVirtualMachine of
its own on a thread with a run loop (WorkerHost.swift), the runtime's
globals, and postMessage both ways as text with typed arrays and errors
encoded, since values cannot cross virtual machines. swiftbrowser-native build --worker <name>=<entry> writes the bundle beside app.js; site
publishes it for the page's own Worker, so the app's code is the same in
all three places. The workers' tests run on a Mac (swift test in
Native/): messages posted before the script ran arrive in order, a timer
fires, a wasm module instantiates asynchronously, an uncaught error is
reported.
The URL the app is opened with#
A magic-link sign-in from the iOS app signed Safari in, not the app: the
link opened in the browser, whose cookie the app's URLSession never sees.
A universal link opens the app instead, when the site's
apple-app-site-association names the path and the app's entitlements
name the domain; SwiftUI's onOpenURL has it, and now NativeApp.open(url:)
passes it to the bundle's __sbOpenURL, which onOpenURL from
@swiftbrowser/native delivers to listeners. A link that launched the app
waits for the bundle and then for the first listener, which a test covers
on a Mac. The app spends the token with its own fetch, so the session
cookie lands in the app.
On the phone the link opened the app and nothing happened: the built
script carried the package twice. swiftbrowser-native build bundled the
runtime on its own and prepended it, so the app's half had a copy of
openURL.ts of its own, whose listeners the runtime's __sbOpenURL never
reached (the same for a worker's messages). The runtime is now injected
into the app's build, one graph, and a bundle test opens a URL into an app
built from a fixture.
A toolbar item placed largeTitle (a logo beside the project's name) went
to the bar's trailing edge on iOS, next to the app's own buttons, since
SwiftUI had no such placement when the renderer learned it. iOS 26 has one,
which takes the large title's place while it shows, and the renderer uses
it there.
In the iOS app no remote picture appeared. AsyncImage from
@swiftbrowser/react loads the image with the page's Image first, to
learn its size, and only then hands the renderer its URL; JavaScriptCore has
no Image, so it waited forever. In a SwiftBrowser Native app it now sends
the URL at once, and SwiftUI's own AsyncImage loads it.
The project's logo, found on its website, was an SVG, and the iOS app drew
nothing for it: SwiftUI's AsyncImage decodes bitmaps, and iOS has no
public SVG decoder. A remote image that AsyncImage cannot decode now goes
to SwiftDraw, a Swift SVG parser and
renderer and the native package's first dependency (Apple platforms only;
the round trip's page draws SVG itself), which draws it as vectors.
On the phone a card preview took ten seconds, not the two the probe had
measured: the probe ran on a Mac and in the simulator, where JavaScriptCore
compiles, and an iOS app's own JavaScriptCore may not (no entitlement allows
it; only Apple's processes map executable memory), so satoru's WebAssembly
ran in the interpreter. WebKit's web content process is one of Apple's, so
a worker can now run there: createWorker(name, { engine: 'webview' }) loads
the same bundle into a hidden WKWebView, with the worker bridge written in
JavaScript over the page and its fetch still through the app's
URLSession. The web view sits behind the window's content, since iOS
suspends the process of one outside a window.
On the phone the calendar's pagers misbehaved: the days never snapped,
swiping never changed the title, the chevrons moved once, and every event
card had a chevron. A test now hosts the renderer in the iOS Simulator and
drags it, beside plain SwiftUI drawn the same way, and showed three faults.
A styled element drew its child through a ForEach, so SwiftUI named
each scroll target by the innermost element's id, which no position
binding knew. Every stack carried .scrollTargetLayout(isEnabled: false),
and one around a scroll view (the calendar's list row) turned off the
layout inside it, so nothing snapped or reported. And a programmatic
scrollTo set the position without telling the app. On iOS 18 the scroll
view now reports the target it settled on, after a drag or a scrollTo.
A link inside a row's content lost its chevron, and a list's selectable
rows became its selection, so a sidebar row takes a tap across its width.
A "View on Bluesky" link did nothing in the iOS app: Link and a link in
Text opened their URL with the page's window.open, and JavaScriptCore
has no window. They now go to the bridge's openURL, the system opener,
when there is one.
One bar through a push or pop#
- The bar's items stay in the bar. The web renderer draws each screen's
navigation bar as part of the screen (the back and More circles, the glass
capsules, the
leadingandtrailingitems on them), and a push or pop slides the screen whole, so its bar slid with it. iOS 26 draws one bar and morphs it through navigation. The renderer now does the same (Web/src/barMorph.ts): at the commit that holds a push or pop it puts an overlay on the stack with clones of both screens' bar parts, hides the parts themselves, and tweens the clones over the slide: a capsule both screens have changes shape from the one's to the other's, the leaving screen's items scale and fade out as the arriving screen's scale and fade in (the bar's own transition for an item that comes or goes), an item both draw the same at the same place stays as it is, and the back button appears or goes with the depth. A swipe back scrubs the same morph with the drag, and the release plays it on to the pop or back to the start. The titles still travel with their screens, as the content does. The bottom toolbar is left as it was: its screen slides it.
Images cached in a native app#
- A remote image is fetched and decoded once. The native package drew
URL images with SwiftUI's
AsyncImage, which keeps no decoded images and loads through the system's small default URL cache: a feed's photos were fetched again as the cache turned over, and every row that scrolled back on screen decoded its image again behind a placeholder. The package now has an image loader of its own (Native/Sources/SwiftBrowserNative/Views/Kinds/ImageLoader.swift): the bytes go through a URL cache sized for images (32 MB in memory, 256 MB on disk, kept across launches for as long as the server's cache headers allow), the decodes stay in memory (anNSCachecosted in bytes, up to an eighth of the device's memory and 256 MB at most, evicted under pressure), and a resizable image is decoded through ImageIO's thumbnail path no larger than the box its layout gives it, on a ladder of sizes, again larger only when the box outgrows the decode. Views asking for the same image at once share one load. The SVG fallback loads through the same session. - A native app's
AsyncImageshows its placeholder. React'sAsyncImagehasplaceholderandfailure, which the page shows while it loads the picture to learn its size; in a native app it sent the image element at once and showed neither, so a feed's rows had no box to hold their place and no spinner. The runtime now has anImageover the bridge'sprobeImage, which reads the size from the picture's header through the image loader and keeps the bytes for the element that follows, so the component takes the page's path natively too.loadingIndicatorgoes over the placeholder once a load has run for 300 ms, for a big picture on a slow connection and never for one from the cache. The shell configures the caches at launch (ImageCache.configure(_:): the sizes, where the bytes live, the session the pictures load with) and empties them at a sign-out (ImageCache.clear()). - The shim keeps up. The loader is Apple platforms' own (ImageIO
decodes), and the round trip's shim build of the native package showed
what the shim lacked of the APIs it uses:
onGeometryChange(for:of:action:)(iOS 18) is now a shim modifier, azstackthat reports its size like an anchor preference's, running its action when the transformed value changes; and the native package's shim build aliasesURLCacheandCachedURLResponseto the bridge's, as an app's staged Foundation already does.NSCacheneeds nothing: the SDK's Foundation has it on WASI. - A loading
AsyncImagekeeps its box. React'sAsyncImagereturned its placeholder bare while the picture loaded, and nothing without one, so the modifiers written on the image (its frame, aspect ratio, corner radius) applied only once the picture arrived: a row's 72×48 thumbnail took no space until then and the text beside it jumped when it landed (Amindia's screenshot rows). As a SwiftUIAsyncImage's modifiers apply in every phase, they now wrap the placeholder, the failure view and, with neither, an empty stack, so a framed image holds its box from the first pass. - A native
toolbarelement's items all show. The protocol'stoolbarholds the items of one placement run (two buttons in a trailing one, as Amindia's Media generation screen has Discard and Save), which the page lays out side by side. The native renderer put the element's children in oneToolbarItem, and iOS 26 shows only the first of them: Save was missing. Each element is now aToolbarItemGroupof its children, one item each. - A tap into a native text field is not an edit. SwiftUI writes a
TextField's binding on a focus and a commit with the text the field already has, and the native renderer sent every write as atextevent: an app that takes atextas an edit showed its Discard button as soon as a field was tapped (Amindia's settings screens). The field's and the editor's bindings now sendtextonly when the text changed, as the page's renderer does.
A Freeform clone in the Showcase#
Native/Examples/Showcase is an app of whole examples, each a clone of one
of Apple's, written with @swiftbrowser/react and drawn by SwiftBrowser
Native. The first is Freeform: a gallery of boards (each a thumbnail of its
canvas, saved in localStorage, which the native runtime keeps on the
device) and a board's canvas of sticky notes, shapes, text boxes and pen
strokes on dotted paper (a grid fixed to the board, thinned or filled in by
halves as it zooms so the dots stay 18 to 72 points apart), with undo and
redo, panned with a finger and zoomed with two.
- One gesture for the canvas. The items carry no gestures of their own. The canvas is one view with one drag of no minimum distance and a pinch, and the app finds what a touch landed on itself (the topmost item whose box holds it): a tap selects, a drag moves the item it began on, resizes from the selection's handle, pans from empty space, or draws while the pen is on. A view that moves under its own drag changes the drag's coordinate space, and the native gesture view hit-tests its un-offset frame; one gesture on a view that never moves keeps every touch in one space on every renderer.
- Two-finger gestures natively. The native
gestureelement answered drags and long presses only;magnifyandrotate(React'smagnifyGestureandrotateGesture) were ignored, so nothing on a phone could zoom. They are nowMagnifyGestureandRotateGesture, attached withsimultaneousGestureso a one-finger drag on the same view does not keep the pinch from starting, and they send thepinchevents the page sends. A pinch also says where the fingers' midpoint is now (location, beside SwiftUI'sstartLocation; natively from aSpatialEventGestureon iOS 18 and later), and the board keeps the point that began between the fingers between them, so two fingers zoom and pan at once. - Strokes keep their caps and joins. The native shape drew its stroke
with a width and a dash only; a stroke's
lineCap,lineJoin,miterLimitanddashPhase, which the page draws, now reach SwiftUI'sStrokeStyle, so a pen line ends round. - Writing on the canvas. A selected note or text box tapped again (or
one just added) becomes a focused
TextFieldwhere it sits, in its own font and ink, with Done in the toolbar; a tap on the canvas or dismissing the keyboard ends it, and a text box left empty goes. The web renderer's fields took the primary label color whatever.foregroundStylesaid; they now inherit it, as SwiftUI's do. - On the web and on a phone. The same app is a web page
(
js/web): mounted with@swiftbrowser/reactin the iPhone frame on a desktop and full screen on a phone, deployed byshowcase.ymlto its own Pages project.showcase-ios.ymlarchives the Xcode project for ad hoc distribution and deploys an install page, the IPA and its manifest to the project'siosalias. Its profile is made fresh on every build through the App Store Connect API (.github/scripts/adhoc-profile.mjs) with every device the team has registered, so a new phone needs no hand-edited profile. The web renderer gained the few symbols the app uses that it lacked (scribble.variable,character.textbox,pencil.tip.crop.circle).
Reminders in the Showcase#
The Showcase's second example is Reminders (Native/Examples/Showcase/js/src/reminders):
the smart lists as tiles with their counts (Today, which takes what is
overdue too, Scheduled by day, All by list, Flagged, Completed), My Lists
with their counts and a context menu, and a list's reminders to check off,
write in place (Return starts the next one; one left without a title
goes), flag or delete with a swipe, and move with a long press. A reminder
checked off stays where it was until the list is opened again, so a tap by
mistake can be undone. Its details and a list's name, color and symbol are
edited in sheets, and search covers every reminder. The model
(reminders/model.ts) is pure and tested; the store keeps it in
localStorage.
- A link row's badge before its chevron.
NavigationLink { Label(…).badge(3) }drew› 3: the row reserved the badge's room at its trailing edge, after the link's chevron. The two trade places,3 ›, as iOS draws a mailbox's count, through a deletable row and a context menu around the link. - A swipeable row's badge. The badge was drawn on the row under the layer a deletable row's content slides on, so it was hidden; it is part of that content now.
- The web renderer maps
flag.slashandflag.slash.fill.
Freeform's pen as a button toggle#
The pen showed it was on only by its symbol filling in. iOS marks a tool in
use with Toggle(…).toggleStyle(.button); measured in the iOS 26.2
simulator (Native ToolbarToggleTests, with screenshots from
scripts/bar-probe), in a bottom bar it is a 66×50 item in a 254×60
capsule, 24 wider and 12 taller than the plain bar, the same off and on, so
turning the pen on moves nothing; while on, a pill of the accent at 18%
(25% in the dark) sits behind a symbol in the accent.
toggleStyleeverywhere..toggleStyle(.automatic | .switch | .button)in the SwiftUI shim,toggleStylein@swiftbrowser/react(a view environment value, aspickerStyleis), astyleprop ontoggle(absent forautomatic), and the native renderer applying it to SwiftUI'sToggle.- The web renderer's button toggle. No switch: the toggle is a button in the tint, sized as a bordered button, its faint fill drawn only while on; a tap, Enter or Space flips it. In a bottom bar it takes the measured slot and pill, its capsule 60 tall about the bar's center, off in the bar's label color and on in the app's accent.
- Bar capsules are capsules at any height. The glass under bar items had a fixed radius (22 in the navigation bar, 24 in the bottom bar), right only for the 44 and 48 heights; a 60-tall capsule around a button toggle had flat-looking ends. Their ends are now half their height, whatever it is.
- A board opens fitted. The board fitted itself to its items in an
effect after the canvas's size had come back through another one, so
opening it showed two frames at 100% before the fitted zoom. Until it has
a view of its own, the canvas is now drawn fitted to the size its
GeometryReaderreads in that same render. - On-screen tests one at a time. The bar measurements' suites put
windows on screen and turn the main run loop for several seconds, and
Swift Testing ran them beside the scroll tests on the main actor (each
suite serialized only within itself): the scroll strip's reports came
late or not at all, twice. Every suite that shows a window is now nested
in one serialized
OnScreensuite. - The pen is the toolbar's own toggle. The button toggle's 66×50 pill
made the bar 24 wider; a plain
Togglein a toolbar keeps a button's slot and, while on, fills a 42×36 pill under the symbol with the accent (iOS 26.2), so the pen is one now, its symbol white while on (iOS's own light accent on the pill all but vanishes). The web renderer drew a switch for a toggle in a bar; it now draws the bar's toggle: the switch's element becomes the pill (still the focusable button),.toggleStyle(.switch)keeps the switch, and.buttonkeeps its measured slot.
Notes in the Showcase#
A third example beside Freeform and Reminders (Native/Examples/Showcase/js/src/notes):
- Folders. All iCloud, Notes, yours and Recently Deleted, with their counts; a folder is made or renamed in a sheet and deleted from its context menu or by a swipe, its notes going to Recently Deleted.
- Notes by date. A list is pinned notes on top, then the rest newest first under Today, Yesterday, Previous 7 Days, Previous 30 Days, the months of this year and the years before; each row its title (the first line), its date (the time today, the weekday this week) and the text after the title. Swipe to pin or delete; the context menu moves a note.
- Writing. A note is a
TextEditorunder the date it changed; a new one opens writing, an empty one goes when it is left, and compose in a note starts the next in its place on the stack. - Recently Deleted keeps a note 30 days, read-only until it is recovered (to Notes if its folder went); Delete All empties it.
- Search at the top of the folders and of each list.
- The web renderer maps
pin.slash.fill.
Voice Memos and recording from the microphone#
Nothing could record: there was playback (useAVPlayer, AudioPlayer) and
no microphone. Now:
useAudioRecorder()(@swiftbrowser/react):record,pause,resume,stop(the recording'surlandduration),cancelanddiscard(url), withstatus,time, the input'slevelstwenty times a second for a waveform, anderror(permission: …when the microphone is refused).- On a page (Web/src/audioRecorder.ts, the environment's
audioRecorder):getUserMediaandMediaRecorder(AAC in MP4 where the browser has it, else Opus), anAnalyserNodemetering the input from -50 dB, and the sound kept as adata:URL, so it can be stored with the app's data and plays in the page's media element. - Natively (the
audioRecordhost request, AudioRecorderBridge.swift):AVAudioRecorderrecording AAC intoDocuments/Recordings, metered withaveragePower(forChannel:)on the same scale, the session set to play back through the speaker; the app's Info.plist namesNSMicrophoneUsageDescription. iOS moves an app's container when it is installed again, so the video element (anddiscard) find a file URL under an oldDocumentsat the same path under today's. - Voice Memos in the Showcase (
js/src/voicememos): All Recordings, newest first; a recording opens in its row with its waveform, a scrubber, the times, 15-second skips, play and pause and delete; the record panel grows while recording with the name, the time to the hundredth and the live waveform, pause and resume, stop and discard. Swipe or the context menu renames or deletes one. - The web renderer maps
gobackward.10/15/30,goforward.10/15/30(the arrow without its number) andrecord.circle. - The native app template takes
infoPlistkeys (INFOPLIST_KEY_build settings); the examples' extras are inNative/Examples/projects.json, which the generator and its test both read.
Books in the Showcase#
A Books clone (Native/Examples/Showcase/js/src/books), its library the
openings of five public-domain books as samples (Pride and Prejudice,
Alice's Adventures in Wonderland, Moby-Dick, The Adventures of Sherlock
Holmes, The Great Gatsby), their covers drawn from each book's colors:
- The library: the book being read on top with its progress, the time left in its chapter and Continue; then the covers in a grid, All, Reading, Want to Read or Finished.
- A book's page: cover, title, author, Read Sample or Continue (with how far), Want to Read, what it is about, and its contents; the menu marks it finished or unread.
- The reader scrolls the text in a serif, as Books does with Scroll on:
it opens where the book was left (
scrollPositionon the paragraph at the top; a chapter's heading names the chapter's start) or at a chapter from the contents, and the end of the sample in view reads as 100%. "Aa" sets the text size and the theme (Original, Quiet, Paper, Night); under the text, the chapter, the minutes left in it and how far through.
Keynote, Numbers and Pages in the Showcase#
Clones of the three iWork apps (Native/Examples/Showcase/js/src/keynote,
numbers and pages), each a gallery of its files with samples on first
launch, kept in localStorage, their models pure and tested in js/test:
- Keynote: decks shown as their first slides, six themes. A deck shows its slide at 16:9 over a navigator of thumbnails (tap, long press to move, swipe to delete, skip or duplicate) and adds slides from eight layouts, text boxes and shapes. As Freeform's canvas does, the slide is one drag: a tap selects, a second tap writes in place, a drag moves an item with yellow guides snapping it, the handle resizes. Text boxes are sized, bolded, aligned and bulleted, items recolored, and every edit can be undone. Play shows the slides full screen from the current one, leaving out skipped ones, with each slide's transition (Dissolve, Push, Move In, Zoom) and Magic Move between a slide and its duplicate.
- Numbers: spreadsheets from templates (Blank, Personal Budget, Trip
Planner, Grade Book) with sheet tabs. A table's letters, numbers and
headers stay in view while it scrolls both ways; one drag selects a
cell, row, column or range, extends it by its handle, resizes a column
or pans. The entry bar writes in the selected cell, and a formula picks
its references from taps on the table. The formula engine
(
numbers/formula.ts) reads numbers, text, references, ranges,+ - * / ^andSUM,AVERAGE,MIN,MAX,COUNT, recalculates what depends on a change, reports#REF!,#DIV/0!and cycles, and keeps formulas on their cells as rows and columns come and go. Number, currency and percentage formats, quick totals, the selection's sum, average, min, max and count, and charts of a selection. - Pages: documents from templates (Blank, Letter, Report, Recipe, Essay) on paper pages over gray, with page numbers and page breaks. Every paragraph is written in place in its style (title, headings, body, lists by level, quote, caption); Return splits a paragraph into its style's next, and steps out of a list from an empty item. Words take bold, italic, underline, strikethrough and color from a bar or the paintbrush sheet, which also sets alignment, indent, the document's font, and moves or deletes blocks. Image placeholders and dividers, find and replace, a word, character, paragraph or page count, and undo of a run of typing at once.
What they needed:
- Rich text editors:
TextEditoreditsAttributedText(runs of bold, italic, underline, strikethrough and color) with aselectionbinding, natively through iOS 26's attributedTextEditor(text:selection:)and on the web through an editable box of a span per run (Web/src/richEditor.ts); the protocol gainsruns,selectionand aselectionevent (ops protocol)..scrollDisabledmakes an editor as tall as its lines, the native editor honours a bound focus, and on the web a button press no longer takes the focus from a field, as on iOS. - Grouped bars:
BarMark'spositionBy(.position(by:)) puts bars of onexside by side. - The web renderer puts a leaving copy (an exit or a text transition)
in the sheet it left, so a slide leaving a full-screen cover is seen;
paints a plain list's row with its
listRowBackground; passes a tap at a pushed screen's back-swipe edge to an immediate drag under it; and drawsincrease.indentanddecrease.indent.
Books turns pages, and scroll transitions drawn by the renderer#
Books' reader turns pages as Books does: a swipe slides the page off over the next, which comes out from under it, shaded and moving less (a tap on the right turns forward, on the left back). Scrolling View in the "Aa" menu keeps the scrolling reader; the Night and Quiet themes turn the bars dark.
- Pages cut from what is drawn. The text is laid out out of sight at the
page's width, each heading and paragraph reporting its height and two
probes the height of a line and the step to the next;
paginate(js/src/books/pages.ts) cuts each chapter before the first line that does not fit, keeps a heading with its paragraph, and a page shows its window onto the chapter, clipped. Over the text, the pages left in the chapter; under it, "12 of 31". A page stands for the first paragraph that starts on it, so the reader reopens on it; the text size measures again and keeps the place. scrollTransitionis drawn by the renderer. It was React measuring the view's frame on every scroll step and answering with an effect (a round trip per frame, behind the finger natively). The closure now runs once per phase and the three effects go out as ascrollTransitionstyle: the page interpolates them in each scroll event (Web/src/scrollTransition.ts, from laid-out positions, so the effect's own offset never feeds back), SwiftBrowser Native hands them to SwiftUI's.scrollTransition, and the SwiftUI shim, which drew only the identity phase, sends all three.zIndexorders siblings only on the page. A negative index sent the box behind its scroll view's content, out of reach of taps; the stack a zIndexed box is in now stacks its children on its own (isolation: isolate), and the modifiers' boxes between pass the index through.scrollIndicators="hidden"on a ReactScrollView(the pager's) sendsshowsIndicators: false, which SwiftBrowser Native already drew.- A finger pages a scroll view with no target layout. The page's touch
pager took the content's children for pages, which for content that is
one stack was a single page: a drag let go anywhere stayed there. With
nothing marked, it now pages by the viewport's length, as SwiftUI's
.pagingdoes.
Custom shapes and players' positions natively, and Freeform's bar on a phone#
- SwiftBrowser Native reads SVG path data. A custom shape's path (React's
Shapewith apath, the shim's customShapes) comes as SVG path data, which SwiftBrowser Native handed to SwiftUI'sPath(_:); that reads onlyPath.description's form, so every custom shape drew nothing: Freeform's ink, its dotted paper and its star.SVGPath(SwiftBrowserProtocol) parses the data (every command, relative forms, arcs as cubic curves) andPath(svg:)builds the path from it, in the round-trip build too. - Freeform keeps five items in its bottom bar. A selection's Duplicate and Delete were a sixth item, which ran the bar off a phone's width; they are a section of the color menu now, under the selection's colors.
- A React player's position reaches it natively. SwiftBrowser Native
installed its periodic time observer when the
reportinterval changed, and before any applyapplied?.reportis nil, as is the interval of an app that sends none (@swiftbrowser/react's players): notimeevents while playing, so Voice Memos' scrubber and times stood still. The first apply now installs it whatever the interval.
The gaps the iWork clones found#
Keynote, Numbers and Pages each worked around something SwiftUI gives an app for free. This fills those gaps, each proven by the clone dropping its workaround (ops protocol has the wire details).
- Focus across a submit. A field's
focusedbinding is also SwiftUI's enum form:focused={[field, setField]} focusedValue="password"is.focused($field, equals: .password), one binding shared by the fields that clears only while the value is still the field's, so a submit handler that keeps the focus or moves it on wins over the keyboard's dismissal reported after. SwiftBrowser Native reads the prop back after dispatchingsubmitand holds the focus against the resign that follows Return; the web renderer scrolls a field the app focuses into view from the layout's frames (again as the keyboard grows), as SwiftUI does for a field@FocusStatefocuses. Numbers no longer remounts its entry field per cell to survive Return, Reminders' rows share one focus binding, and Pages no longer callsscrollTofor the block it focuses. - What a scroll view can say. Numbers' table was a hand-rolled pan:
one drag over the whole grid, inertia from
velocity * 0.3withwithAnimationand a timeout, four clipped panes offset by the scroll, because a scroll view could not be read or set. It is now aScrollView(.both)holding the body, so panning, flicking and bouncing are the scroll view's own, with the letters, numbers and frozen header row and column laid over it and moved by the offset the view reports. What that took:onScrollGeometryChange(ascrollgeometryevent after each layout and once per frame while scrolling, thefor:transform run app-side so an app that watches a size is not rendered per frame), ascrollPositionbound to a point andproxy.scrollTo({ x, y })(ascrollOffsetcommand carried out once per serial, which restores each sheet's offset),pinnedViewson the lazy stacks and grids (the renderer holds each section's header at the edge until the next pushes it out;LazyVStack(pinnedViews:)natively),withAnimation's completion (a serial on the commit, answered byanimationcompletewhen the pass's animations end, or SwiftUI's own completion natively),onGeometryChangein place of a size-reporting child and an effect, and a tap that says where it landed. - An undo manager.
useUndoManager()is the window's manager with NSUndoManager's rules:registerUndo(name, undo)after a change, an undo's inverse registering as its redo while undoing, a new registration dropping what could be redone, registrations in one event undoing as one,beginGrouping/endGrouping, and akeythat joins a run of keystrokes, withcanUndo,canRedoand the action names re-rendering the toolbar. The stack lives in JavaScript (its closures do, andcanUndomust change in the pass that registered them); the system is told what it can do through one more host of the renderer's environment: ⌘Z and ⇧⌘Z on a page while no text input has the focus, and in SwiftBrowser Native the window'sUndoManagermirroring the stack with a proxy action per side (UndoBridge.swift), so shake to undo, the three-finger swipe and the Edit menu work. Freeform, Keynote, Numbers and Pages edit throughuseUndoableState(js/src/shared/undoable.ts) instead of four copies of aHistory. - Gestures that compose.
DragGesture(coordinateSpace:)(.local,.global,.named),.simultaneousGestureand.highPriorityGesture,.onTapGesture(count:)and.contentShape: thegestureelement gainscoordinateSpaceandmode,tapgestureacount,styledacontentShape. On the web a high-priority gesture is asked before the wrappers inside it, a simultaneous one begins on its own distance and hears the pointer beside whoever owns it, a double tap counts clicks while a single tap beside it waits the interval as iOS does, and a content-shaped box takes input across its area; natively they are the modifiers themselves. Keynote's slide, one drag hit-testing its items by geometry under a near-invisible rectangle, now gives each item a press that selects, a double tap that writes, a drag in the slide's named space with the guides and a long-press menu, and Magic Move crossfades a text that changed (contentTransition) instead of swapping it. - Two shim gaps the Native views had guarded around.
AttributedString.backgroundColorjoins the SwiftUI attributes of the shim's attributed strings, andText(AttributedString)draws it as the run'sbackground, the color the rich text editors already send and the renderer already painted.withAnimation(_:completionCriteria:_:completion:)withAnimationCompletionCriteriareaches the shim: the open transaction carries the completion, the pass that draws its changes stamps itscommitwith one serial (removedonly when every completion of the pass asked for it), and the closures wait under that serial for the page'sanimationcomplete; a body that changed nothing runs its completion after the event that made it. Headless scripts answer a commit withanimationcomplete:3. The Native text element and the commit completion build against the shim unguarded. - Editors, bars and alerts for a word processor.
TextFieldandTextEditortakeonDeleteBackward(Backspace with nothing selected at offset 0 deletes nothing and the app hears it; natively, SwiftUI giving no hook, the editor's background finds theUITextVieworUITextFieldbehind it and a swizzleddeleteBackward()runs the handler at the start). A run hasbackgroundColorand its ownfont, on the web editor's spans and in the nativeAttributedStringboth ways.ToolbarItemGroup(placement: .keyboard)is SwiftUI's own natively and a bar above the keyboard on the page while a text input of the screen is focused..alert { TextField(...); Button(...) }draws the fields in the card between the message and the buttons.measureText(text, font, width)answers synchronously from the renderer's typography on the web and fromNSAttributedString's bounding rect natively. Pages merges a paragraph into the one before on Backspace, highlights its finds behind the live text, puts its format bar on the keyboard, paginates from measurements instead of a characters-per-line guess, and renames in an alert, as Keynote now does too (js/src/shared/renameAlert.tsx).
Freeform's notes keep their lines as the board scales#
A note's text (and a text box's) was laid out at each zoom in a font sized
to it, and glyphs do not widen in proportion to the size, so the lines
broke anew as the board scaled: the text reflowed under a pinch. It is now
laid out once at the item's own size and scaled to the zoom
(scaleEffect, anchored top leading), as a canvas app draws text, and the
editors likewise, so starting to write in a note moves no line either.
Notes writes rich text#
Notes' editor is the rich TextEditor, as Pages' paragraphs are: a note
keeps its plain body (titles, previews and search read it) and its runs
(js/src/notes/format.ts).
- Formatting. While writing, the bar over the keyboard sets the lines' style (Title, Heading, Subheading, Body, Monostyled: a run font over the whole line), the selection's (else the word's) bold, italic, underline and strikethrough, and makes the lines a bulleted list.
- Writing as Notes does. A new note's first line is its Title; a return starts a Body line, whatever the line it left; a return on a list item starts the next item, and one on an empty item ends the list. A note saved before has its first line in Title.
- While writing, the format bar takes the bottom, as the keyboard covers Notes' bar.
Numbers' short sheet in the native app#
A sheet shorter than the screen opened in the native Numbers with its body
92 points below its frozen header row: the row numbers, the frozen column
and the cells all a gap down, the gap the height of the tabs row and the
entry bar. It was none of them. SwiftUI centers content smaller than a
scroll view that scrolls both ways along the vertical axis, and reports the
centering as a negative contentOffset (half of the 184 points the 378-point
sheet fell short of its 562-point view), which the panes followed; the page
puts such content at the origin (the scrollview layout row). SwiftBrowser
Native now sets the alignment anchor of a two-axis scroll view to top
leading (.defaultScrollAnchor(.topLeading, for: .alignment), iOS 18), and
hands an app's defaultScrollAnchor to SwiftUI, which it had let fall.
Numbers' scroll content is also never smaller than its view, as Numbers'
own: the table with room past it, or the view, whichever is larger.
The shim catches up with the renderer#
The iWork clones were React apps, and what the renderer learned for them (#255, #258, #259) a Swift app compiled with the shim could not yet ask for. Four pieces of parity, each on its own branch and merged here:
- Scrolling.
ScrollPosition(iOS 18) with.scrollPosition(_:anchor:)reaches the shim: an id goes through the reader as.scrollPosition(id:anchor:)'s does, a point or an edge is ascrollOffsetcommand on the scroll view (a new serial perscrollTo, so asking for the same offset twice scrolls twice; an edge is 0 or an offset the browser clamps to the end), and the page'sscrollpositionreport sets the binding to that id withisPositionedByUser..onScrollGeometryChange(for:of:action:)marks the scroll viewreportsGeometryand runs the transform on eachscrollgeometryevent, the action only when the answer changes, so a view watched for its content size costs nothing per frame of a scroll; arefreshablescroll view hears both events through one handler.LazyVStack,LazyHStack,LazyVGridandLazyHGridemitpinnedfor theirpinnedViews, and aSection("Title")in a pinning stack gets its string header as asectionheaderview so the page has a box to hold at the edge..scrollDisabled(_:)is thescrollDisabledstyle, and the Native style modifier builds against the shim unguarded. - Gesture composition.
.highPriorityGestureand.simultaneousGestureput theirmodeon thegestureelement,.onTapGesture(count:)andTapGesture(count:)theircounton thetapgesture, and.contentShapeis thecontentShapehint for any shape.DragGesture(coordinateSpace:)stops being ignored:.globaland.namedask the page for the root's coordinates, and.coordinateSpace(name:), until nowreturn self, is the same frame-reportingzstackthe React package emits. The runtime hands each named space's frame down through the environment as one object, filled from thegeometryevents' origin, and a drag in that name subtracts it as each event arrives, so a canvas that scrolled under a finger costs no pass and a subtree under a space is still skipped as unchanged. The headlessgeometryevent takes the origin after@. - Undo. A SwiftUI app compiled with the shim had no
UndoManager: swift-corelibs Foundation has none on WASI (or Linux), so@Environment(\.undoManager)did not exist and the page's ⌘Z went nowhere, while a React app haduseUndoManager(). The shim now declares the class withNSUndoManager's rules (registrations in one event form one group, closed when the runtime's turn ends as the run loop's end closes Apple's; explicit groups span events and nest; an inverse registered while undoing lands on the redo stack) and FoundationBridge re-exports it for files that import only Foundation, with the selector form over itsSelector. The runtime keeps one manager per app in every view's environment and tells the page what the stacks can do through anundohost request nobody waits for, sent only when that changed; the page hands it to the undo host that already served React and, from the first, binds ⌘Z and ⇧⌘Z, which return asundoandredoevents (bareundo/redolines in event scripts). - Text editors.
TextEditor(text:selection:)reaches the shim twice over: with iOS 18'sTextSelectionon aString, and with iOS 26'sAttributedTextSelectionon anAttributedString, the rich editor (Sources/SwiftUI/API/TextSelection.swift, Sources/FoundationBridge/RichTextEditor.swift). A bound selection travels as thetexteditor'sselectionin UTF-16 offsets, the editor'sselectionevents set the binding, a selection the app sets moves the caret, and one that selects nothing sends what the editor last reported, so nothing moves. The rich editor sends the string'srunsasText(AttributedString)draws them, size, weight and design of a run's ownfontincluded; the viewer's typing arrives as plaintextand takes the attributes of the characters it replaced, else of the one before it, as@swiftbrowser/react'sreplacingCharactershas it; and arunsevent (the native editor's Bold, Italic or Underline) is written back over the string's attributes, run by run, bold as the run'sfontweight or the strong-emphasis intent, underline and strikethrough as the SwiftUI attributesunderlineStyleandstrikethroughStyle, which join the shim's attributed strings. ATextFieldamong an alert's actions was already atextfieldchild of thealert; the tests now say so.
The keyboard bar floats natively#
The native format bars of Notes and Pages sat flush on the keyboard, in
SwiftUI's .keyboard placement (the input accessory view, a bar across the
screen), where the system's Notes on iOS 26 floats a glass capsule 48 tall,
inset 10 from the sides, 10 above the keyboard. SwiftBrowser Native draws a
screen's keyboard toolbars that way on iOS (KeyboardBar.swift): a
bottom safe-area inset of the screen's content, so the content stops above
it as it does above the page's bar, shown while the keyboard is up and gone
with it, the toolbars' items in one row with the spacers between them.
The page's keyboard bar floats too#
The page drew the keyboard toolbars as the bar iOS drew before 26: 44
tall across the screen, a hairline on top, flush with the keyboard. It is
now the capsule the native renderer draws (the section before this one): 48
tall on the bar's glass, 10 in from the screen's sides, 10 above the
keyboard the page measured or above the bottom safe area when it measured
none, the items from its 16 margin. The content stops above the capsule,
as it stopped above the bar.
A native GeometryReader reports with nothing in it#
SwiftBrowser Native's geometry element hung its size report on its
children: a reader whose content renders nothing (a React component that
returns null, measuring what it is the background of) had no view for the
modifier to run on, and never reported. Books measures its pages with such
readers, so its paged reader stayed blank on iOS. The report now hangs off
a clear view filling the reader, the children at its top leading corner as
before (GeometryTests).
Numbers' headers scroll in the frame of the cells, natively#
SwiftBrowser Native sent a scroll view's geometry a turn after SwiftUI's
onScrollGeometryChange action, as it sends a geometry reader's frame
(measured during layout, where a pass of the app's must not land). SwiftUI
had drawn the scrolled cells by then, and the app's pass, which moves
Numbers' frozen headers by the offset, drew in the next update: the headers
trailed the cells by a frame. The scroll geometry goes in the action now,
where a @State set is drawn in the same update, as the page already got
by sending it in the animation frame of the scroll, before painting.
Voice Memos' scrubber moves with the sound#
The native player reported its position four times a second (a periodic
time observer every 0.25 s, the page's timeupdate pace), and the Voice
Memos scrubber hopped by it, where the system's glides. The protocol's
report interval had no way in from an app: useAVPlayer(url, { report })
puts it on the player's video, the native observer's floor is a frame
(it was 0.05 s), and the page's frame loop fires on an interval a
millisecond short, so a report of a frame comes every frame. Voice Memos
asks for one.
Voice Memos' scrubber is a bar, not a slider#
The scrubber was a Slider, a thumb on a track, where Voice Memos' is a
bar: the played part in the label color over a faint track, no thumb,
7 points thin until a finger lands on it and 17 while it is held, the
finger's place the position. The Showcase draws it so (Scrubber in
js/src/voicememos/VoiceMemos.tsx): two capsules in a stack the width of
the row, a drag gesture of no minimum distance mapping its location to a
time, and the height animated on the drag's start and end; the player's
reports wait while the finger holds the position. Its played part and the
waveform's are the label color: a shape filled with primary is the
system fill on the page.
Voice Memos edits a recording, and the recorder trims#
A recording could be made, played and deleted, not cut. The open row's menu gets Edit Recording, which opens the recording in a sheet as Voice Memos' Edit Recording does: the whole waveform in a panel, its few dozen bars interpolated across the width and mirrored about the middle with a dotted line where it is silent, a blue playhead the finger drags that follows the sound, a ruler labelled every second (every 5, 10, 30 seconds and up when a long recording's labels would collide), the position to the hundredth, skip and play. The sliders button starts a trim: two yellow handles mark a selection, an overview strip under the ruler shows where it falls, play plays the selection alone, and the bottom row keeps it (Trim) or cuts it out (Delete). The sheet only draws and asks; the recorder cuts the sound.
useAudioRecorder().trim(url, keep) (@swiftbrowser/react) makes a new
recording out of the parts of one: keep is [{ start, end }] in
seconds, in order, so one range trims to it and two parts around a range
delete it; the original is left as it was, for the app to discard when
it no longer wants it. On a page (Web/src/audioRecorder.ts)
MediaRecorder cannot encode what is not playing, so the cut is the Web
Audio API's: the data: URL is decoded on an OfflineAudioContext, the
kept frames are copied in order (clamped to the recording, sorted,
overlaps merged) and written as 16-bit PCM WAV, a data:audio/wav URL
the media element plays; without Web Audio it fails unsupported: ….
Natively (the audioRecord request's trim action,
AudioRecorderBridge.swift) the kept ranges go into an
AVMutableComposition, exported with AVAssetExportSession as AAC to a
new file in Documents/Recordings, answered { url, duration, type } as
stop answers; only a file in Recordings may be cut, as only one may be
discarded. The pure parts, the ranges and the WAV, are tested on their
own, and docs/ops-protocol.md gains the audioRecord request in full. On
success the memo takes the new sound, length and waveform (trimWaveform
cuts the bars as the sound was cut), the old sound is discarded and the
player starts over; on failure the sheet says why in red.
The trim's handles under one finger, and the page's waveform#
Trying the detail sheet on a phone found three things. Its trim handles
had a drag gesture each, laid over the panel's own, and the two renderers
settled the contest differently: the page gave the finger to the handle,
the native app to the panel, so nothing natively moved a handle; and the
overview strip took no finger at all. Each surface has one gesture now,
which decides from where the finger landed what it took hold of: a handle
within reach, else the playhead; the strip's box by an end to resize it,
in the middle to slide the selection along. (A leftward drag had also come
to nothing on the page, its travel clamped to zero by the helper that
clamps a position; the travel is its own now.) The trim's buttons say
Trim and Delete in words, the symbols alone not saying. And a recording
made on the page read as silence on the phone: Safari starts an
AudioContext made after the microphone prompt, outside the tap,
suspended, and its analyser then reads nothing; the context is made in the
tap now, before the prompt, resumed, and asked again should the browser
have suspended it anyway.
A recording the page holds is decoded before it plays#
Playing a memo on an iPhone, the position set off and then held for a
third of a second while the sound caught up: Safari runs the media
element's clock from play() while it decodes the source and brings up
the audio hardware, then holds the clock until the sound is out. The page
had kept every media element at preload="metadata" until it played, so
the decode fell inside that gap. A source the page already holds (a
data: or blob: URL, every voice memo) is decoded as soon as it is
set, which costs nothing to fetch; a remote video is still fetched ahead
only once it plays. What remains of the hold is the hardware's own start.
The page's frame reports ride over a held media clock#
With the decode out of the way (the section before), a memo on an iPhone
still stuttered once, smaller: a tenth of a second or so after the sound
set off, its position held for three frames while the sound played on.
That is Safari resyncing the media element's clock with the audio
hardware's, and a playhead on the clock alone must hold with it. The
page's frame reports (report) are the clock smoothed now: between its
updates the position advances with the page's clock at the playback rate,
and is pulled toward the media clock over a third of a second, so a hold
passes unseen and the drift it leaves closes gently, never backwards; a
jump of more than half a second, a seek, is taken at once, and a seek, a
pause, a new source or the end starts the smoothing afresh. The timeupdate
reports, and the native observer, are as they were.
Native scroll transitions are linear#
SwiftBrowser Native handed an interactive scroll transition to SwiftUI's
.interactive, whose progress is eased in and out; the protocol draws it
linearly (the page does), and the eased curve outran the scroll mid-way, so
an offset of most of a view's length ran backwards for a moment: Books'
page coming out from under the one turning moved the wrong way mid-drag.
It is .interactive(timingCurve: .linear) now.
useAppStorage in @swiftbrowser/react#
Every Showcase app kept its state the same way: a load() reading a key
from localStorage with a fallback to its samples, a useState of that,
and an effect writing the JSON back after each change, eight copies of
twenty lines, each swallowing a full page's storage in its own way. The
Swift side has @AppStorage for this (and SwiftBrowser Native gives the
page a localStorage on the device), the React package had nothing.
useAppStorage(key, default) is that property wrapper: the value under a
key as JSON, useState's shape, the default (or a function making it)
while nothing is stored, undefined removing the key as nil does, and one
cache per key that every reader subscribes to, so the views that read a key
all follow a write through any of them, as the shim's observation of a
defaults key does. A decode option migrates what an older version saved
(Notes purges its deleted notes on load, Books fills in fields added since),
onError hears of a write the storage refused while the app keeps the value
for the session (Voice Memos' "storage is full" line), another tab's writes
arrive through the window's storage event, and a page without
localStorage keeps the values in memory. The eight stores are the hook
and their own extras now.
fileManager in @swiftbrowser/react#
A Swift app on the web has had an iOS-like home for a while (/data in
IndexedDB, "Phase 19"), and a SwiftBrowser Native app has its sandbox;
a React app had neither, so the Showcase's recordings sat as data: URLs
in localStorage, a few minutes of them filling a page's five megabytes,
and a trimmed memo of over a minute could not be saved at all. fileManager
is FileManager.default with URL.documentsDirectory and its siblings for
the React package, over one more field of the host request environment,
files: on a page the same home and database a Swift app of that name has
(mount's app option names it), with /tmp in memory; natively the
sandbox through files host requests and the bridge's appDirectories().
Paths are file: URLs; the calls are Swift's, asynchronous on both sides
since the page's storage is, the one departure. Failures say their kind
first (notFound:, exists:, isDirectory:, notDirectory:,
unsupported:), and the web host is the reference the native one follows,
tested over rows in memory. A video or image element given a file:
URL now loads it: the renderer asks the files host for an object URL of the
bytes (one per file, revoked when the file changes) and sets the element's
source when it has it, so an app hands a player the file's URL as it would
natively. The recorder and Voice Memos move onto it next.
The page's recordings are files#
With fileManager in place (the section before), the page's recorder
keeps a recording the way the native app always has: stop writes the
sound into the app's Documents/Recordings through the files host, named
by a UUID and its type's extension, and answers the file's URL; discard
deletes the file; trim reads the file, cuts, and writes a new .wav
beside it. Voice Memos changes no line: its store keeps the URL as before,
the player gets a file: URL the renderer loads through the files host,
and a memo made before this, a data: URL in localStorage, still plays
and trims (its trim lands in a file). What the page's five megabytes of
localStorage held, minutes of base64 audio and a trimmed memo that could
not be saved past a minute, is in IndexedDB now, where the quota is the
disk's. A page that keeps no files, or a write the storage refuses, still
answers a data: URL, so the sound is never lost to a missing store.
The iWork thumbnails are the documents, shrunk#
Pages', Keynote's and Numbers' galleries drew their thumbnails in fonts
shrunk to the thumbnail's scale, and glyphs do not narrow in proportion, so
a page's lines broke where the document's do not: titles wrapped and
truncated ("Lemon Ricotta P…"). A thumbnail is now the real thing laid out
at its own size (a page's first page, a slide at 1920 × 1080, a sheet's top
left at the table's row height, widths and font) and scaled down
(js/src/Shrunk.tsx), as Freeform's notes are.
A thumbnail is tapped as a whole, and a bold run keeps its text's size#
The iWork thumbnails took no taps at all on SwiftBrowser Native: Shrunk
turned hit testing off over the whole thumbnail, and a button's label
whose every view ignores taps leaves nothing to tap. Only the shrunk
content ignores them now, and the thumbnail's frame takes them whole
(contentShape), so a thumbnail opens its document on both renderers.
And a run of rich text with only a weight (a <Text bold> inside a
Text, Pages' "18%") was set in the body font at that weight on
Native, 17 points whatever the text around it was; it takes the weight
over its text's own font now (fontWeight, fontDesign), as a styled
view's weight-only font already did.
Pages' thumbnails take taps on Native#
The last change made Shrunk's frame take taps, but Pages' thumbnail
turned hit testing off around the whole page (from before it was shrunk),
so on SwiftBrowser Native the gallery button's label still had nothing to
tap but the title under it. Neither turns it off now: the shrunk content
is still only text and shapes, and the frame takes taps whole.
One command for an app on both sides#
swiftbrowser native init laid out the Xcode project and a js/
project, with src/index.tsx as the iOS entry; the web half of the same
app, which the Showcase has had for a while, every new app had to copy by
hand. The command writes it now: web/index.html and
web/main.tsx (the iPhone frame on a desktop, full screen on a phone,
following the page's theme toggle and the system's appearance, mounting
the app with its name so its files have a database from day one), a Vite
config, dev:web and build:web scripts, and @swiftbrowser/web as a
dependency beside react and native. The app is src/App.tsx; the two
entries only mount it. The layout is React Native's: the npm project is
the app's root (package.json, src/, web/), the Xcode target's folder
is ios/ beside them rather than one named after the app, and the js/
folder is gone, so a project reads as its halves and npm install runs
where the project is. The examples moved with it. The generator is the examples' too,
so the layout is exercised by their builds and the init tests rather than
kept in a starter repository that would rot.
The environment's fetch is a function type#
HostRequestEnvironment.fetch was typeof fetch. Under Bun's types the
global fetch also carries fetch.preconnect, so the renderer's own
(input, init) => fetch(input, init) was not one, and an app that
type-checks with @types/bun (Amindia) failed inside @swiftbrowser/web's
sources. It is FetchLike now, the call alone, as are the blocked-hosts
and CORS-proxy wrappers' parameters and results.
Reachability and the scene phase#
Two environment facts an app of either side wants, now on both:
navigator.onLinein the native runtime is the network path's status fromNWPathMonitor(Host/ReachabilityBridge.swift, the bridge'sonline(); the monitor starts on the first read), where it was a constanttrue. A change comes to__sbOnline(bool)and fires theonlineandofflineevents on the global (addEventListener,ononline,onoffline), where a page'swindowtakes them. Hosts without the Network framework (Linux, the round trip) leave the app online.useScenePhase()in @swiftbrowser/react:active,inactiveorbackground, from theEnvironment.mount(soSwiftUIViewtoo) reads it from the document's visibility and the window's focus, the rule the page already applied for Swift'sscenePhase(Web/src/scenePhase.tsnow, shared), andrunforwards the phaseNativeRootViewhas sent all along. The Showcase's Notes and Reminders refresh their dates when the phase turnsactive, as a minute timer may not have run in the background.
The screen wake lock#
navigator.wakeLock.request('screen') in the native runtime
(packages/native/src/wakeLock.ts): the screen stays awake while any
WakeLockSentinel is held, through the bridge's wakeLock(active), which
sets UIApplication.isIdleTimerDisabled (an IOPMAssertion against display
sleep on macOS) and lets go with the last sentinel, or with the bridge. A
native sentinel stays held in the background, where the system owns the
screen, unlike a page's, which the browser releases as the document hides.
@swiftbrowser/react's useWakeLock(active) holds a lock while active on
either side, taking it again on a page when the document shows after the
browser let go; the Showcase's Voice Memos keeps the screen on while a
recording runs.
Where the viewer is#
navigator.geolocation in the native runtime
(packages/native/src/geolocation.ts) over CLLocationManager
(Host/GeolocationBridge.swift): getCurrentPosition asks for one fix
(current on the bridge's geolocation(id, action, json)), watchPosition
for every fix (watch) until clearWatch (clear); each fix or failure
comes to __sbGeolocation(id, json) and reaches the callbacks as the API's
GeolocationPosition and GeolocationPositionError (1 denied, 2
unavailable, 3 timed out, the timeout on the runtime's timers). The first
ask prompts the viewer for when-in-use authorization, which the asks wait
for; the app's Info.plist names NSLocationWhenInUseUsageDescription.
@swiftbrowser/react's useGeolocation(options) asks on request() (or at
once with immediate), follows with watch, and reads available,
status, position and error on either side. No Showcase app has a place
for it, so none uses it.
Speech, both ways#
The Web Speech API in the native runtime (packages/native/src/speech.ts):
speechSynthesis and SpeechSynthesisUtterance on AVSpeechSynthesizer
(Host/SpeechBridge.swift, the bridge's speak(id, json) and
speechControl(action), the utterance's events at __sbSpeechEvent(id, json)), and SpeechRecognition on SFSpeechRecognizer over the microphone
(Host/SpeechRecognitionBridge.swift, recognize(id, action, json), the
results at __sbRecognition(id, json); a continuous session starts a fresh
request after each final result). The app's Info.plist names
NSSpeechRecognitionUsageDescription and NSMicrophoneUsageDescription.
@swiftbrowser/react's useSpeechSynthesis() and useSpeechRecognition()
read and listen on either side; in the Showcase, Books reads a chapter aloud
from the paragraph at the top (Read Aloud in the reader's bar) and Notes
takes dictation into the note (Dictate in the editor's bottom bar).
Documents go where the viewer chooses#
fileExporter, the importer's other half, on every side. A host request of
kind exportFiles carries the document's files; the page shows the save
dialog where the browser has one (Chromium's File System Access API),
downloads the files elsewhere, and the native app shows the document picker
(forExporting, "Save to Files"; NSSavePanel on macOS), answering where
they went (saved, downloaded or cancelled). The Swift shim gets
.fileExporter(isPresented:document:contentType:defaultFilename:…) with
FileDocument, its configurations and the regular-file FileWrapper
(Sources/FoundationBridge/FileExporter.swift); @swiftbrowser/react gets the
fileExporter modifier with a string, bytes or a Blob as the document.
fileManager's attributes now carry created and the MIME type the
extension names on both sides (the IndexedDB rows keep a created column).
The Showcase's Pages exports a document as text and Numbers a sheet as CSV.
iCloud Drive for the app's files#
fileManager.iCloudDirectory() (@swiftbrowser/react) is the native app's
folder in iCloud Drive: the container the entitlements name, resolved off
the main thread the first time (Host/ICloudBridge.swift), its Documents
made and handed back, null on a page and in an app without the entitlement.
The files bridge takes the container as a root, wraps reads and writes
there in NSFileCoordinator, lists a .name.icloud placeholder as its
file, downloads a placeholder before a read (and before loadURL, so an
AudioPlayer plays what another device recorded), and an NSMetadataQuery
over the container's documents reports what changed to __sbFilesChanged,
which fileManager.watch(listener) delivers (the page's host reports its
own writes the same way). useFileStorage(url, default) keeps a value as a
JSON file and reads it again on a change, the file-backed useAppStorage.
swiftbrowser native init --icloud writes the entitlements (iCloud.<bundleId>,
CloudDocuments) and an Info.plist that shows the container in the Files app.
The Showcase's Voice Memos keeps its recordings and their index in the
container where there is one, else in Documents, so a memo recorded on one
device plays on the next; the Showcase project itself carries no entitlement
(it would need a team's App ID), so the Showcase as shipped records locally.
Sign in with Apple#
A host request of kind appleSignIn, on every side. The native app shows
the system sheet through ASAuthorizationController
(Host/AppleSignInBridge.swift) and answers the credential as
ASAuthorizationAppleIDCredential has it, or cancelled:; the page shows
Apple's JS in its popup once the app named its Services ID and return URL
(configureSignInWithApple), and reads the user from the identity token.
The shim gets ASAuthorizationAppleIDProvider, its request and credential
(Sources/AuthenticationServices/AppleID.swift), routes an Apple ID request
through ASAuthorizationController and the environment's
AuthorizationController to the host, and draws SwiftUI's
SignInWithAppleButton from the button, the apple.logo glyph (new in the
renderer) and the label in the .signInWithAppleButtonStyle given.
@swiftbrowser/react gets signInWithApple(), appleCredentialState(),
canSignInWithApple() and the same SignInWithAppleButton;
swiftbrowser native init --sign-in-with-apple writes the entitlement
(the entitlements file now gathers iCloud Drive and Sign in with Apple).
No Showcase app signs anyone in, so none uses it.
Native functions: the escape hatch's other half#
NativeRegistry let a Swift app put a view in the tree; NativeFunctions
(Runtime/NativeFunctions.swift) lets it put Swift the JavaScript calls
behind a name. register(name) { call in ... } is an async function
callNative(name, params) (@swiftbrowser/native) resolves with, riding the
host request path as app:<name> (so structured concurrency, errors as
messages and cancelled: as an AbortError come free); registerSync is one
callNativeSync runs inline over the bridge's callNativeSync(name, json);
nativeFunctions() lists them, hasNativeFunction(name) is the web build's
fallback check; and NativeFunctions.send(name, value) comes to
__sbNativeEvent and onNativeEvent(name, listener), for what Swift reports
unasked. Params cross as JSONValue (call.decode() for a Decodable);
NativeFunctionCancelled and NativeFunctionError are the errors to throw.
swiftbrowser native init writes an ios/NativeFunctions.swift with a
registerNativeFunctions() the App calls from its init, holding a sync
deviceName and a lowPower event as the examples to replace.
Multi-touch#
A touches element, a SwiftBrowser addition SwiftUI has no gesture for:
every finger on a view, for chords and glissandi (a piano, a drum pad). The
shim's .onTouches { touches, phase in } and @swiftbrowser/react's
onTouches wrap the view; the web renderer owns every pointer that goes
down inside it (src/touches.ts: the interaction controller never sees them,
so nothing above competes) and sends touches events with every pointer
still down, in the element's coordinates; natively SpatialEventGesture
reports the fingers on iOS 18 and macOS 15, with a DragGesture fallback
before that and in the round trip. The first of the two gaps a piano app
found (the other is sound synthesis).
The Showcase's Piano#
Two octaves under onTouches, the keys under the fingers as the notes
sounding, a sustain pedal and a choice of instruments. The sound is the
example's, not the framework's: on a page the Piano synthesizes with the
Web Audio API (four harmonics under an envelope the instrument picks, so
pianos decay and organs hold), and in the iOS app the same synthesis runs on
an AVAudioSourceNode behind functions the Showcase's Swift registers with
NativeFunctions (ios/PianoSynth.swift) and the piano calls with
callNativeSync. A general note-playing API was tried and dropped: the
framework polyfills web standards natively rather than inventing APIs, so
the general answer is a Web Audio subset over AVAudioEngine, still open;
until then the escape hatch is the route, and the Piano shows it.
Sheets in the dark, on a phone#
The web renderer's elevated dark palette for a sheet's contents (grouped background #1c1c1e, cells #2c2c2e, as UIKit raises the interface level of anything presented as a sheet) applied only to an iPad's centered form sheet, so on a phone a Form in a sheet painted the base black over the card. It now applies to every sheet card but a full-screen cover. A rounded-border text field is black in the dark everywhere, as UIKit's rounded-rect field is, instead of the elevated gray with a border. Found by holding the Showcase's New List sheet next to the native one.
Geometry that settles before the paint#
A pushed Numbers spreadsheet slid in with its content under the bar and
then stepped down over three frames. Two causes: onGeometryChange's
action ran in a passive effect, so the state it set rendered on a later
task and the page painted between each round of measure, set and lay out;
and the Showcase's table guessed a screenful for its size before the first
report, which made its frozen panes taller than the screen offered, so the
screen centered the overflowing stack under its bar until the reports
shrank it. The action now runs in the commit (a layout effect): state it
sets renders and lays out synchronously, so a layout that depends on its
own measurement converges within the frame, as a GeometryReader's does in
SwiftUI. The table starts from no size and takes what it is offered.
Dictation that does not end the app#
Notes' Dictate button ended the Showcase app on a phone: the project named
the microphone usage string (for Voice Memos) but not
NSSpeechRecognitionUsageDescription, and iOS ends an app that asks for
speech recognition without it. The Showcase's project names both now
(Native/Examples/projects.json, the generated project). The speech
recognition and audio recorder bridges check the app's Info.plist before
asking and fail the recognition or the recording with an error naming the
missing key instead, so an app that forgets the string hears about it in
error rather than from a crash log.
A worker's context dies on its thread#
The iOS Simulator test job crashed now and then a second into the native
suites with Invalid value for lock: 0, WebKit's WTF::Lock finding a
JavaScriptCore lock unlocked that nobody held, the xctest process
restarting and the job failing. Nothing in the repository prints it; the
one JavaScriptCore user off the main thread is WorkerHost, whose thread
ran its run loop's turns in no autorelease pool of their own, so every
JSValue the engine handed Swift (a call's result, a callback's arguments)
lived until the thread's end, kept the worker's context and virtual machine
alive past terminate(), and released them as the thread exited, alongside
the engine's own per-thread teardown: the likeliest source of the lock. The
thread now runs its setup, each block sent to it and each turn of its loop
in a pool, so the context goes when the worker is torn down, on the live
thread. The simulator job also keeps the crash reports and the result
bundle as an artifact when it fails, so the next crash of the kind comes
with a backtrace.
The text input hints reach the native field#
keyboardType, textContentType, textInputAutocapitalization and
autocorrectionDisabled crossed the protocol and set the page's input
attributes, but the native renderer read none of them: Amindia's sign-in
field got the default keyboard, sentence capitalization, autocorrect, and
no addresses in the QuickType bar, which .textContentType(.emailAddress)
is what asks for. TextFieldProps reads the four now and the field applies
them as SwiftUI's own modifiers (TextInputHints.swift), the keyboard and
capitalization where there is an on-screen keyboard, the content type and
the correction on macOS too; against the shim the modifiers are the shim's,
which carry the names on. A Simulator test reads them back from the UIKit
field SwiftUI draws.
AVAudioEngine for JavaScript apps#
The first phase of docs/notes/audio.md: the engine-shaped API, so a
JavaScript app makes sound the way an iOS app does. AVAudioEngine in
@swiftbrowser/react has its main mixer, output and input; players
(AVAudioPlayerNode: files, segments and buffers on a timeline, at sample
times, looping, swapped on the bar line with interruptsAtLoop); a sampler
(AVAudioUnitSampler: zones from files, placed by the note in each name or
the app's root notes, with velocity, the pedal and the bend); mixers; and
the reverb, delay, distortion, EQ and time-pitch units. Files open from the
app's files, the web or data: URLs, and a buffer can be the app's own
samples. Each call is one ordered audioEngine command
(docs/ops-protocol.md, "An audio engine").
On a page the Web Audio API answers (Web/src/audioEngine.ts): a player
keeps its own timeline of buffer sources, the sampler pitches voices from
their zone's root, the reverb convolves a generated tail per preset, the
distortion presets are waveshaper curves; time-pitch passes through, as
Web Audio cannot change pitch apart from speed. Natively AVAudioEngine
itself answers (AudioEngineBridge.swift), each command performed as it
arrives so they keep their order, with the misuse AVAudioEngine traps on
(a player unconnected or its engine stopped, a buffer in another format)
checked first and answered as a failure. The sampler's zones are rewritten
in the unit's fullState after loadAudioFiles(at:), so the instrument
keeps the sampler's default behaviour. Both sides are tested by rendering
offline and measuring what comes out (an OfflineAudioContext in
Chromium, manual rendering on macOS): a note's pitch from its zone, a
buffer's start at its sample time, a release, the pedal, an echo, a
reverb's tail, a loop swapped on its bar line.
The Showcase has GarageBand's Beat Sequencer on it: a bar of four drums synthesized and mixed in JavaScript, looped on a player and swapped at the bar line as the grid or the tempo changes, pads that play the same drums on a sampler, echo, reverb, volume and a level meter.
A native slider's value labels, and GarageBand alike on both sides#
SwiftBrowser Native drew a Slider with every child as its label, which iOS
keeps for accessibility and does not show, so minimumValueLabel and
maximumValueLabel never appeared. It reads labels now, as the page
does: the children marked min and max sit at the track's ends
(Slider(value:in:label:minimumValueLabel:maximumValueLabel:)). GarageBand's
sliders put their titles in a Text above them, since iOS shows no slider
label, and its playhead outline is the label color: a hierarchical
.primary paints the fill gray on a page (docs/ops-protocol.md, "Resolution
by role") where SwiftUI paints the label color.
.primary paints as SwiftUI paints it#
The page resolved a hierarchical style (.primary … .quaternary) by role:
the label colors for text, but the system fill grays for a background, a
shape's fill and its stroke. SwiftUI paints the foreground's levels in
every role (Rectangle().fill(.primary) is the label color, black in light
mode, white in dark), which SwiftBrowser Native drew and the page did not: a
playhead outlined with .stroke(.primary) was a faint gray on the page and
white on the phone. The page paints the foreground's levels now, the label
colors or those of a foregroundStyle set above (--sb-hierarchy-<n>);
the system fills stay what .fill (FillShapeStyle) names. FoodTruck's
.background(.quaternary.opacity(0.5)) cards are a shade darker for it, as
on iOS.
The stepper in dark mode, as iOS 26 draws it#
Measured against SwiftBrowser Native over black, the page's stepper was a
shade lighter than iOS's (its capsule the tertiary fill, (28,28,30), where
iOS 26 draws (18,18,19)) and its divider darker (the opaque separator,
(56,56,58), where iOS draws the tertiary label color, (83,83,86)). In dark
mode the capsule is now rgba(120,120,128,0.15) and the divider
rgba(235,235,245,0.3) (--sb-stepper-fill, --sb-stepper-divider);
light mode is unchanged.
A slider's label is not drawn, as on iOS#
SwiftUI on iOS draws no slider label: Slider(value:in:label:) keeps the
label for VoiceOver, and only the minimum and maximum value labels show, at
the track's ends. SwiftBrowser Native, real SwiftUI, did exactly that; the
page drew the label in a row above the track (as macOS lays a Form out),
so a slider was a row taller on the page and titled where the phone showed
nothing. The page lays a slider out as iOS does now: one 31 pt row, the
label child hidden and naming the slider (aria-labelledby), the value
labels at the ends. An app that wants a title puts a Text beside it.
StoreKit's .assigned ownership, for RevenueCat on Swift 6.4#
Ice Cubes stopped building on main once RevenueCat (resolved "up to next
major" from 5.86.0) began reading Transaction.OwnershipType.assigned, the
Swift 6.4 SDK's ownership through an organization, under
#if compiler(>=6.4); the build compiles with Swift 6.4, so the branch is
taken and the shim's StoreKit had no such member. It has it now.
The Beat Sequencer's playhead after quick changes#
On iOS the playhead went once a step or the tempo changed again before the
last change came in. The app scheduled each change at once and kept only
the bar sounding and the newest; with two waiting, the bar sounding was
forgotten, the bars left all started after the player's time, and no step
was lit. AVAudioPlayerNode, given a second interruptsAtLoop while one
waits, plays the waiting bar one pass before the newest takes over (a
native test and an e2e test hold the page to it), so changes made quickly
also came in bar after bar. The app now schedules one new bar at a time,
mixed just before the bar line (swapDue), so every change made during a
bar comes in together at its end; a tap no longer waits on the mixing, and
the level meter redraws only itself.
The Beat Sequencer's edits sound at once#
A step placed ahead of the playhead waited for the next bar line to sound,
and a step taken out still played to the end of the bar. An edit (or a new
tempo) now takes over at once: the new bar, started from the place in the
bar the playhead is about to reach (takeOver, rotated), is scheduled to
interrupts the bar playing at that sample time, a little ahead of now (as
far ahead as writing a bar takes). AVAudioPlayerNode plays the old bar on
until that sample and the new one from it (a native test); the page cut the
old bar at once and played nothing until then, and now does as
AVAudioPlayerNode does (an e2e test).
Swiping a row of the Beat Sequencer#
A row of steps reads its touches as the Piano's keys do (onTouches, the
row's width from onGeometryChange, the step under a point from
stepUnder): the first step a finger touches flips, and every step it then
crosses in that row takes the same state, so a swipe fills or clears a run
of steps, and a tap still flips one.
A note on bytes across the bridge#
docs/notes/bytes.md outlines carrying binary data between JavaScript and
Swift as typed arrays instead of base64 inside JSON: what crosses today and
what it costs (a bar of the Beat Sequencer is six copies and three
interpreted passes over 423 KB), JavaScriptCore's typed-array C API, a
HostValue beside JSONValue at the engine boundary, a hostRequestBytes
bridge call with { "$bytes": n } placeholders and a base64 fallback for
older hosts, and the order to build it in, writeBuffer first.
Bytes across the bridge#
A buffer's samples cross the native bridge as a typed array now, not base64
inside JSON (docs/notes/bytes.md, its first three steps). At the engine
boundary, JSHost carries a HostValue, JSON or bytes: on JavaScriptCore
a typed array or an ArrayBuffer passed to a function installed with
installBytes arrives as .bytes, copied out from the view's offset
through the C API, and a .bytes argument to call(_:values:) arrives as
a typed array of its kind, which the engine allocates and the bytes are copied into.
On the bridge, hostRequestBytes(id, kind, json, ...views) sends the
params' typed arrays beside the JSON, which names each as
{ "$bytes": n }, and __sbHostResponse(id, json, ...buffers) brings an
answer's back the same way; hostRequest in @swiftbrowser/native lifts the
views out itself, and gives a host without the function base64 in the JSON
as before, so nothing else changes. writeBuffer's channels are the
Float32Arrays themselves end to end: the page's host copies them into its
AudioBuffer without decoding, and the native bridge reads them from the
views, or from base64. The Beat Sequencer's bar, 423 KB, crosses as one copy
instead of six and three interpreted passes over every byte.
Every byte crossing as a typed array#
The rest of docs/notes/bytes.md's crossings now carry typed arrays beside
the JSON where the host has hostRequestBytes, and base64 as before where
it has not. fetch sends a body as a view and asks for the response's with
bytes: true; fileManager's read and write, picked and shared files,
fileExporter and the clipboard's image go through hostRequestBytes both
ways (a request through it is answered with bytes too, so an older bundle
that sends hostRequest still gets base64); a WebSocket opened with
bytes: true sends and receives binary frames as views; crypto uses
randomValues, digestBytes and hmacBytes; and TextDecoder,
TextEncoder, Response.text() and json() hand text past 64 characters
to the host's UTF-8 (decodeUTF8, encodeUTF8) instead of looping over it
in JavaScript, which on a phone runs without a JIT. installBytes natives
can now return bytes, and the native request handlers read and write byte
fields through a task-local, RequestBytes. Workers keep base64.
The page's menus as iOS 26 draws them#
A menu on the page (a Menu, a context menu, a menu-style Picker) was
iOS 18's: symbols trailing, a hairline between every item, groups split by
gray bands, a 13px corner, and a translucent panel the content read through.
iOS 26's is an inset panel (10px above and below the rows, 12px beside them)
with 26px corners, nearly opaque glass, each item's symbol leading its title
(an item without one starts at the text inset, as a checkmark that is only a
Label's image does on the phone), no lines between items, and a hairline
inset from the edges between groups and around an inline section, whose
header is a 15px caption. A toolbar button's menu grows out of the button and
covers it; a control's in the content still opens just under it.
Checkable menu rows and the check column#
The Showcase's Files menu drew its checkmark as a Label's image, so on the
phone it stood where an item's symbol goes; real Files puts it in a column of
its own, before the symbol, with every row keeping that column so titles line
up, and names the sort's direction in a subtitle under the chosen order. The
menu now says what it means the way SwiftUI does: each view and each order is
a Toggle, which iOS draws as a checkable row, its label a Label (the
symbol) or two Texts (title and subtitle); choosing the current order flips
its direction, as in Files. The page's menus draw a toggle the same way: a
checkable row that sends toggle, a leading check column every item row in
a menu with checkable rows keeps, and a second text as the subtitle in a 58px
row. A toggle in a menu had been a static text row. Around a check column
the phone indents the whole menu: section titles start with the plain
titles, a symbol's column a little past them, and the page now does too.
The on-device language model for JavaScript apps#
A JavaScript app can now talk to Apple Intelligence's on-device model.
@swiftbrowser/react has FoundationModels' shape: SystemLanguageModel
with its availability (and useSystemLanguageModel(), which watches a model
that is still downloading), LanguageModelSession with instructions and a
conversation it keeps, respond(to:), streamResponse(to:) yielding
snapshots that cancel() stops, and GenerationError by case. Each call is
a languageModel host request (docs/ops-protocol.md, "The on-device
language model"): natively Host/LanguageModelBridge.swift over
FoundationModels on iOS 26, on a page Chrome's built-in model where the
browser has one, and otherwise the model is unavailable, as on an iPhone
without Apple Intelligence. A stream is read by asking next until it says
done, each answered with the response so far once it has grown, which
needs no new event channel and lets a slow reader skip ahead. The Showcase
has a Chat example on it: suggestions to start from, the answer streaming
in under the question, Stop, New Chat, and an empty state naming why the
model is not there.
A local model where Apple Intelligence cannot answer#
Apple Intelligence needs an iPhone 15 Pro or later, so the Showcase's Chat
had nothing to talk to on an iPhone 14. A native app can now bring its own
model: SwiftBrowserNative has a LanguageModelProvider protocol and
LanguageModels.fallback, the language model bridge answers over providers
(Apple Intelligence's where it can answer, else the fallback, unless the
system model is only still downloading), and availability carries a
download's progress, which useSystemLanguageModel() follows every second
and Chat shows. SwiftBrowserLocalModel (Native/Packages) is the provider
for an open model run with llama.cpp: a package of its own, since SwiftPM
resolves every dependency a package declares, so only an app that adds it
fetches the XCFramework (llama.cpp's release b10456, the newest with an iOS
Simulator slice; about 6 MB in an iPhone app) and pays its build. It fetches
a GGUF file the first time the app asks for availability, keeps it in
Application Support out of backups, loads it once on a queue of its own, and
keeps each conversation's messages, formatted with the model's chat template
(ChatML for one without) into a context that keeps the tokens of the last
conversation and decodes only what a prompt adds. The Showcase installs
Llama 3.2 1B (808 MB); CI runs the package's tests against a 1.2 MB toy model
on the CPU.
The model downloads when asked; the keyboard follows the finger#
An 808 MB model should not start downloading because a screen opened. The
local model now waits to be asked: availability's download (its size,
whether it is here, a download's progress and failure) lets the app show
the size first, SystemLanguageModel.default.download() starts it and
deleteDownload() stops it or takes the model off the device, and
useSystemLanguageModel() asks again when either is called. Chat shows a
Download button with the size, the progress with Cancel, and a … menu with
Delete Model. scrollDismissesKeyboard takes SwiftUI's modes, and
natively the scroll view now applies them (it ignored the prop before):
interactively lets the keyboard follow the finger down as the
conversation scrolls, as in Messages; a page, which cannot drag its
keyboard, blurs the field either way.
Tools and a choice of models#
LanguageModelSession takes tools: each a name, a description, a JSON
schema for its arguments and a call the app runs. They reach Apple
Intelligence as FoundationModels Tools whose argument schemas are built at
run time with DynamicGenerationSchema, so the framework constrains the
model's arguments to them; a call waits in a per-session relay until the
app, which keeps asking toolCall while the session is open, has run it
and answered with toolResult. A local model is offered the tools in its
instructions and calls one by answering with a JSON object, which its
session runs and hands back before letting it go on. SwiftBrowserLocalModel
takes several models (Llama 3.2 1B, Qwen 2.5 1.5B, Llama 3.2 3B), each
downloaded on its own; availability lists the choices, Apple Intelligence
first where it answers, and selectModel picks one, remembered across
launches. The Showcase's Chat gives its model a clock, a unit converter and
a calculator, shows which it used for each answer, and has a Model section
in its … menu.
Synthesis in a DSP language#
docs/notes/audio.md's interpreted DSP language, built. @swiftbrowser/dsp
compiles a voice written in a subset of JavaScript (numbers, let state,
constant loops, inlined functions, Math, and stateful builtins: saw,
square, sine, triangle, phasor, noise, adsr, lowpass,
highpass, bandpass) with the TypeScript compiler's parser into a typed
register bytecode, folding constants, hoisting what depends only on
parameters and the voice's inputs to once per 128-frame block, and dropping
what nothing reads (swiftbrowser-dsp compile). Two machines run it, one
algorithm: DSPMachine in JavaScript, in an AudioWorklet whose script is
made from the machine's own source text, and DSPMachine in Swift, in
SwiftBrowserDSP (Native/Packages), an opt-in package as
SwiftBrowserLocalModel is, on an AVAudioSourceNode fed through a lock the
audio thread only tries. Sixteen lanes per register, a voice each, so one
dispatch serves every voice. Parity fixtures from the JavaScript machine hold
the Swift one to within a few millionths, and sixteen voices take 2.8% of a
256-frame block natively (36 ns per voice-sample, against 240 ns for the same
voice in JavaScriptCore without its JIT). DSPNode is the program as an
AVAudioEngine node in @swiftbrowser/react's engine, played with the
sampler's note calls; both hosts gained a hook for node kinds a package adds
(registerAudioNodeKind on a page, AudioEngineNodes natively). The
Showcase has a Synth on it, played on the Piano's keyboard.
Knobs on the Synth#
The Showcase's Synth turns its parameters with knobs (src/synth/Knob.tsx)
in place of sliders: a three-quarter arc, gapped at the bottom, filled in the
accent color up to the value, with a pointer that turns with it, drawn from
trimmed circles and a rotated capsule. A drag up or to the right turns a knob
up from where it was (180 points end to end, no jump to the finger), a
double tap puts it back at the program's default, and each shows its value
in its unit (Hz or kHz, ms or s, cents, percent). Eight of them sit four to a
row above the keyboard.
The keyboard both the Synth and the Piano play sits 2 points inside a gray rounded case, whose edge and the gaps between the keys outline its white keys on a white screen.
The Synth on its side#
The Synth's knobs sit in one row where eight fit across (a phone on its side,
an iPad) and in two rows of four where they don't, a ViewThatFits over the
two. Its screen is pinned to the top and its keyboard gives way from 200
points down to 100 (Keyboard's new minHeight), so a phone on its side
fits the knobs, the keyboard and the note without running under the title.
Clear of the notch on a phone on its side#
On a page in device mode, a phone on its side has a horizontal safe area: the notch's side and the other, 59 points in on a recent iPhone. The layout engine took it at the root of plain content, but a navigation stack fills the screen and its screens laid out their bar items, titles and content across the whole width, so a list's rows (the Showcase's) ran under the notch. A screen that reaches a side edge now keeps everything clear of that side's inset: the bar's items, the inline and large titles, the search field, the bottom toolbars and the content; the bar's background still runs edge to edge, and a screen whose content is a list keeps the grouped background behind the insets. A tab's own content (a list or other content without a navigation stack) is inset the same way, the tab taking the list's background. A split view's columns were inset already.
No large titles on a phone on its side#
UIKit shows no large titles where the vertical size class is compact, as an
iPhone on its side is; an iPad is regular either way and keeps them. The
layout engine now treats a screen under 500 points tall as compact (an
iPhone is at most 440 on its side, less under Safari's bars; an iPad at
least 744) and gives a navigation screen there no large title row, whatever
its display mode: the bar shows its inline title, centered, and the content
starts under the bar. The page takes the engine's choice for the bar's
title (data-sb-display follows the layout, not the display mode), so
turning the phone back upright brings the large title back.
Optional packages for apps outside the repository#
SwiftBrowserLocalModel and SwiftBrowserDSP lived only in this repository:
their manifests reach the core at ../... @swiftbrowser/native now ships
them beside the core it already carried (swift/Packages/<name>, copied by
sync-swift.mjs, their .product(package:) renamed to the shipped
folder's swift), and the CLI links them into an app:
swiftbrowser native init --with local-model,dsp for a new one (the
package references, the App's imports and install calls, and
@swiftbrowser/dsp in package.json), swiftbrowser native add <name> for
one that exists, editing its project.pbxproj as Xcode's Add Local would.
Only an app that links one resolves it, so llama.cpp still costs nothing to
the rest. The Showcase's project names its packages the same way
(projects.json), and CI builds an app made with --with against the
shipped copy.
Reusable workflows for building and deploying apps#
The Showcase's web and iOS workflows became two reusable ones for any app
in the organization: sb-web.yml (dependencies by lockfile, the app's
checks, build:web, Cloudflare Pages with a preview commented on each pull
request) and sb-ios-adhoc.yml (the bundle, an archive with the newest
Xcode, a fresh ad hoc profile with every registered device, the IPA and its
over-the-air install page, on the Pages project's ios alias or left in
the artifact for the caller's own upload). The profile and the page moved
from a repository script into @swiftbrowser/native as swiftbrowser-native ios-profile and ios-install-page, so a caller pinned to a release runs
the commands of the same release from its own node_modules.
swiftbrowser native init --github writes the two callers, and the
Showcase's own workflows call the same ones from this checkout.
The Synth drops its note under the keyboard; only a failure to play sound shows there now.
Memory in the DSP language: wavetables and delays#
The first step of docs/notes/audio.md's "Toward a big synth". A program may
declare export const tables = { name: frames }, each frame the amplitudes
of its sine harmonics, as plain JavaScript the compiler runs once (so a
table is generated, not typed), and play one with wavetable('name', freq, position); delay(input, seconds, longest) is a delay line per voice,
read between samples, with feedback through a voice's state. Both machines
build the tables when a program loads (an inverse FFT, 2048 samples a frame
at ten band-limited levels, read at the level whose harmonics stay under
Nyquist at the note) and size each delay's buffer then, never on the audio
thread. What sizes memory (a table's index, a delay's longest time) is a
constant register the programs are checked for, and the machines clamp at
run time as well; the Swift machine takes NaN where the JavaScript one does
without trapping. A parity case with a morphing table, a modulated feedback
comb and a high note holds the Swift machine to the JavaScript one's samples
within 2e-6. The Swift lives in the optional SwiftBrowserDSP package.
Shapes, samples, stereo and a master stage in the DSP language#
The rest of the first two steps of docs/notes/audio.md's "Toward a big
synth". export const shapes = { name: points } declares drawn curves,
read between points with shape('name', x): an LFO's cycle, an envelope,
a waveshaper. export const samples = { name: 'file.wav' } reads WAV files
beside the source when compiling (PCM or float, channels mixed to one) into
the program as base64 floats; play('name', rate, start) plays one from
each note on, backwards with a negative rate, keeping its place as a whole
sample and a fraction so a long sample does not drift, and grains('name', position, density, length, pitch) scatters up to eight grains a voice
under a parabolic window. A voice may return [left, right], and export function master(left, right) is the stage after the voices: once a frame
on their sum, in lane 0, running when no voice sounds so its delay rings
out, with its own state and builtins that a note never resets (a let is
one stage's or the other's, which the compiler holds to). The page's node
renders two channels; the native node fills the engine's two buffers.
The format stays version 1 (nothing outside the repository keeps
programs yet, so it changes without a bump). Two parity cases (a sampler with grains and drawn shapes, a
stereo voice through a master echo) hold the Swift machine to the
JavaScript one on both sides, and the new opcodes take NaN and infinity in
every operand without trapping. The Swift lives in the optional
SwiftBrowserDSP package.
Then the first of "Events and time": export const mode = 'mono' or
'legato' makes a program one voice playing the newest held note, going
back to the one before on release (mono starts its envelopes over at each
change, legato only from silence); smooth(x, seconds) is a one-pole lag
that starts where its input does, so Math.exp(smooth(Math.log(freq), 0.05)) glides; hold(x, trigger) samples and holds; and every program has
a transport, tempo (from DSPNode.tempo) and beat (advancing each
frame, moved with DSPNode.seek, carried through a new program), on both
nodes. The sum over voices skips idle ones now, which could hold a NaN (the
log of an idle voice's zero frequency) that a mask of 0 did not cancel.
The Showcase's compiled synth is checked against its source by a test, and
a third parity case (legato glide, sample and hold on the beat, a tempo
change and a seek) holds the machines together.
Notes on the beat in the DSP language#
A note, a controller or the bend sent to a program may name a beat on its
transport (node.startNote(note, velocity, channel, atBeat), and so on;
the bridge's note commands carry it as beat). The machine keeps up to
1024 such events in order, a queue sized when the program loads, and
splits its block where the next is due, so each lands on the frame nearest
its beat: an app's sequencer or arpeggiator schedules a bar ahead in
JavaScript and plays in time however late the bridge delivers. An event
whose beat has passed plays at the next block; all notes off and all sound
off, sent now, drop what waits. A parity case (notes, the pedal and the
bend on beats, a tempo change between, a late note) holds the two machines
to the same frames. The Showcase's Synth gains an Arpeggiate switch built on
it: the held keys in turn, sixteenths scheduled a quarter beat ahead from
JavaScript, the transport started over at the first key down. An e2e test
plays a note on a beat through the page's AudioWorklet.
ScopeView (@swiftbrowser/dsp) is the first view fed from the audio
thread: a node's output as a waveform that starts at a rising zero
crossing. Natively it is a SwiftUI view SwiftBrowserDSP registers with
NativeRegistry (the native element), redrawn every display frame from
the last 2048 frames the render block copies under a lock it only tries;
on a page, a canvas in a Host draws what the worklet posts about 60 times
a second, and only while a view watches (watchProgram). A node finds its
views by a token it sets as a property on attach. The Showcase's Synth
shows one beside its Arpeggiate switch.
Registered views on both platforms#
The native element only a native app drew becomes registered, drawn on
both: SwiftBrowserNative's NativeRegistry is ViewRegistry now (its
context ViewRegistry.Context), and a page has a ViewRegistry of its own
(Web/src/viewRegistry.ts) whose builders return an element, with an
update for new props and a dispose for when the element goes. The
renderer adopts the element into the box the layout engine sizes as a
GeometryReader's; a name nothing registered shows itself. <Native>
(@swiftbrowser/native) becomes RegisteredView in @swiftbrowser/react, so
one component is a SwiftUI view in the app and a package's own DOM on a
page, with no platform check. The DSP package's ScopeView is the first to
use it: a SwiftUI view natively, a canvas registered under the same name on
a page. An e2e test registers a view, updates it and lets it go.
SuperSynth, and modulation rewired while a program plays#
A new app, Native/Examples/SuperSynth, holds the big patch of docs/notes/audio.md's "Toward a big synth" instead of the Showcase: two wavetable oscillators of four unison voices spread in stereo, a sub and noise, drive and two filters a side, an LFO, a step LFO drawn as a shape in time with the transport, a second envelope and glide, a 7×7 modulation matrix, and a chorus, a ping-pong delay and a Schroeder reverb after the voices; Play, Sound, Matrix and Effects tabs, a scope, a keyboard. It has its own workflows (supersynth.yml deploys the page through sb-web.yml, supersynth-ios.yml the ad hoc iOS build through sb-ios-adhoc.yml), and CI and the Ice Cubes build ignore a change only it makes.
The language gains routes: a parameter per source and destination
(lfo.cutoff), modulate('lfo', x) and modulation('cutoff'), compiled to
one modsum instruction over the route list that skips the routes at 0, in
both machines with a parity case. Both machines run the voices only up to
the highest that sounds, and a block's statements now share one scope (a
const in a loop's body was invisible to the next statement). A frozen copy
of the patch is a parity case and a native benchmark: eight voices take 21%
of a 256-frame block in a release build.
On a page the engine's context now resumes at each user activation (a touch's end, a click, a key) while it is not running: an app that starts its engine as a finger lands, a keyboard's note, asks for audio outside an activation, and a browser that refuses left the context suspended for good.
A page's gestures also take a finger that is not the first one down: a knob
turns while another finger holds a key (a touches element owns that one),
as in SwiftUI; before, the gesture controller heard only the primary
pointer, which the keyboard had. Still one gesture's pointer at a time.
The interpreters, profiled and a third faster#
A profile of the big patch in the JavaScript machine (each instruction
timed) put a third of the time in its eight wavetable calls, a third in
dispatching instructions and a tenth in modsum. A wavetable now keeps the
frequency it last saw and the level it reads at, and looks its table up
once an instruction; route amounts must be parameters, so modsum tests
each once for all lanes; and the compiler fuses a product or a sum that
only the next instruction reads into the new madd and amul. Both
machines render every parity case exactly as before. The big patch went
from 21% to 16% of a 256-frame block natively and from 47% to about 33% of
a core in V8; docs/notes/audio.md has the profile and what is left.
Block processing in the DSP machines#
Both machines run a chunk of 16 frames at a time, each instruction over
every frame of it for every lane, instead of every instruction once a
frame. The compiler finds what feedback through state needs frame by frame
(the instructions reading or writing a state register, and those between)
and schedules it as each stream's serial part, after what it needs and
before what needs it; programs carry it as serial and masterSerial,
validation keeps state inside it, and an output held in state is copied
out. Every parity case renders the same frames as before, and a test
renders feedback in a voice and the master stage in odd pieces against all
at once. Natively the registers lay a frame's lanes side by side, so loops
over lanes stay vector loops. The big patch went from 12.6% to 11.1% of a
256-frame block natively; in V8 one voice from 10.1% to 8.8% of a core,
eight unchanged. docs/notes/audio.md has what is left: the wavetables'
reads and tanh.
Cheaper wavetable reads, and builtins#
A wavetable keeps a level's samples in order with each sample's frames side by side, so a read between two samples and two frames is one span of memory; natively, phases and positions that cannot be below 0 are truncated and wrapped without a call. The same samples come out; the big patch went from 11.1% to 10.2% of a block natively.
New builtins: onepole, dcblock, comb and allpass (delay lines of
their own, sized from a constant longest time as a delay's), softclip,
the rest of Math (log2, log10, trunc, asin, acos, atan2,
sinh, cosh, cbrt, hypot, expm1, log1p), and mtof, ftom,
dbtoa, atodb written out as arithmetic; 2 ** x compiles to exp2. A
parity case uses each. The Swift machine's instructions grow to twelve
slots, a delay line's buffer in its own. SuperSynth's reverb uses comb
and allpass and its drive softclip, so its master stage runs nearly all
over chunks: 7.8% of a block natively at eight voices, from 10.0%.
SuperSynth's panel, after Serum and Hive#
SuperSynth looks like a hardware synth now: dark plates with a title strip
and an LED (an oscillator or an effect switched in and out from it), knobs
with a lit arc and a cap, value boxes stepped by arrows or a drag, and
screens drawn as paths that show what the parameters do: each wavetable's
frames in depth with the morphed frame lit, the envelopes, the filter's
response and the LFOs. Pages (OSC, FILTER, MOD, MATRIX, FX) hold the plates
in an adaptive grid; the deck under them holds the octave, glide, the
macros and a keyboard of two octaves on a phone and up to five on a wide
screen. Every parameter has a short panel title in controls.ts, checked
against the program. All of it is drawn with Shape, gradients, shadows and
overlays the framework already had; nothing new was needed in it.
SuperSynth plays Serum presets#
SuperSynth opens Serum 1 presets (.fxp) and builds each into a program while it runs, with only what the preset uses: two wavetable oscillators with their unison, a sub, the noise, the filter, three envelopes, four LFOs and the matrix, then the effects switched on, in the preset's order. Every knob it reads and every route's amount is a parameter, so the panel (now Serum's knobs, by their parameters) turns them while it plays; a knob that shapes the program builds it again. The reader follows a format Xfer does not document (docs/notes/serum-presets.md): the knobs, the matrix, the tables and samples a preset carries, the rack's order, the macros' names. A factory table a preset only names is not ours to ship, so one of SuperSynth's own stands in, and the preset says what it does not do as Serum does. The fixed program it played before is gone.
To build programs in the app, @swiftbrowser/dsp's compiler is now two
halves: ProgramBuilder (@swiftbrowser/dsp/builder), which needs no
parser, and the parser that drives it; every program in the repository
compiles to the same bytecode as before. A table can carry its harmonics'
cosine parts (cosines), so a frame read from samples keeps its shape;
both machines build them, and a parity case has one.
The native scope draws every frame#
ScopeView in a native app sat flat while the page's moved: its canvas,
inside a TimelineView, read nothing from the timeline, so SwiftUI drew it
once and kept it. The trace is now a view of its own that takes the tick's
date, so each display frame draws what the audio thread's tap holds.
Stand-ins for Serum's own tables and noises#
A preset that names one of the tables or noises Serum comes with (Xfer's, not ours to ship) now gets a stand-in of SuperSynth's own made for that name: each of the 144 tables and 139 noises in Serum's own folders has a recipe, a generator its name suggests (a saw, a narrowing pulse, a synced saw, folding, FM, a run of vowels, sparse partials; colored noise, a hum, a kick's attack, a hit) and a few coarse traits rounded to tenths, how bright, how odd and how far it morphs. The stand-in is made when a preset asks for it, in a few milliseconds, so the app carries no audio for them. Third-party packs' tables are left to the guess by name.
Serum's LFO shapes, a multiband compressor, more unison#
SuperSynth reads the shapes drawn in a preset's LFOs (their points, values and curves, where both of Serum's layouts keep them) and plays each as a drawn shape along its cycle, so a preset's sine, ramp or pluck-like LFO moves as it does in Serum instead of as a triangle; the MOD page draws them. The compressor's multiband mode is three bands, split at 120 Hz and 2.5 kHz, each pulled down above the threshold and up below it, as Serum's does. Unison shares 12 voices between the oscillators, 9 at most for one, not 5 each.
Serum's warp modes, and noise that loops#
SuperSynth plays the warp modes a Serum preset sets: each unison voice of a warped oscillator runs from a phase of its own that the mode bends (sync, bend, PWM, asym, mirror, quantize) or pushes (FM from the other oscillator or the noise oscillator) before the table is read there; flip, AM and RM scale what it reads. Which number is which mode is inferred from Serum's menu and the sample presets. The OSC page has each oscillator's warp knob and mode. The noise oscillator loops its sample from its phase knob instead of playing it once a note, so a preset that carries a noise plays it rather than white noise.
Two builtins in both machines do it: tableread(table, phase, freq, position), wavetable's band-limited read at a phase the program keeps,
and loop(sample, rate, start), play round and round. A parity case
runs both.
Newer Serum presets: eight LFOs, synced rates, Amp#
Sixty more presets showed what the first fourteen did not: a newer preset
has eight LFOs, and routes from LFOs 5 … 8 (sources 9 … 12) were dropped,
which left some silent. SuperSynth reads all eight, with the rate each
keeps beside its shape, and plays an LFO's rate in beats when it is
synced (Serum's default), at the host's tempo: a quarter note in the
middle of the knob, an octave every fourteenth. The MOD page shows every
LFO and a synced rate as a note length. Routes to Amp turn the voice's
level, a bipolar route's flag is read as a byte, the EQ's bands are
shelves, peaks or passes as their switches say, and the compressor follows
the level with its attack and release. A route the reader cannot place is
listed in the import's report instead of left out without a word. A
route's aux source can be inverted (Serum's *(inv)) or the slot
bypassed, and a bipolar route sweeps half the knob's range each way, not
all of it: the arps, which crossfade two patterns on the semitone knobs,
had both at once at twice the depth and bent far out of tune. Their step
patterns store every grid point twice over with the same value, which read
as lines slid from note to note; a doubled point is now a step.
Serum's LFO modes, envelope curves and smoothing; a tempo#
SuperSynth plays each Serum LFO in its mode: TRIG starts over at each note, ENV plays once from each note and stays at its end, and OFF (Serum's default) runs with the song, the same for every voice, so a pump or a gate stays on the beat through chords. LFO smoothing is applied, and each envelope bends its attack, decay and release as far as the preset's curve knobs are from their defaults. The MOD page has the song's tempo (synced LFOs and delays count beats at it) and each LFO's mode.
The envelope curves are new in both machines: a program can give an
adsr instance curves (curves, exponents for its attack, decay and
release), and the builder takes them with call('adsr', args, { curves }).
An envelope without curves runs as before; a parity case runs bent ones,
retriggered and let go mid-stage.
Serum's later filter types, route outputs and unison spreads#
SuperSynth now plays all 89 of Serum's filter types. The 51 past the
multi-mode ones (combs, flanges, phasers, EQs, ring modulation, sample and
hold, formants and the rest) are named on the filter's screen, which draws
a comb's teeth. Each is played with the nearest of the machines' builtins
(combs and all-passes at the cutoff, shelves, band-passes, a hold); before,
they were all a low-pass. Each matrix slot's output knob (Mod N out) now
scales its whole route; before, it was read only for an aux route. The
unison's Warp and WT Pos spreads offset each voice's warp and table
position. The report names a unison stack, which isn't played.
SuperSynth's screens edit, as Serum's do#
SuperSynth's screens can now be edited by hand. An LFO is a shape to draw on, one LFO at a time with tabs:
- drag a point to move it (it snaps to the grid near a line); drag anywhere else to add one; double tap a point to remove it;
- drag a segment's ring to bend its curve;
- with PAINT, a stroke sets steps on the grid;
- start from a TRI, SINE, SAW, SQR or STEPS shape, and switch the mode between TRIG, ENV and OFF.
An envelope's corners drag its attack, decay, sustain and release, and its rings bend its curves (Serum's curve knobs, now rebuilt into the program). The filter's handle drags the cutoff sideways and the resonance up and down.
An oscillator's screen shows the warp's effect on the cycle as it plays. A drag scrubs the table's position, and with DRAW a stroke draws the frame the position is on.
An envelope's, an LFO's or a macro's + MOD waits for a knob, and tapping a knob adds a route to it. A knob the matrix moves shows how far in a violet ring outside its track. The MATRIX page switches a route between bipolar and unipolar, and removes it.
Native: the last element kinds and style fields#
The native renderer now draws every element kind and style field the page does (except host, which is React DOM):
canvasreplays the app's drawing commands in SwiftUI'sCanvas, with their clips, transforms, opacity, blend modes and filters.layout(a customLayoutin JavaScript) is a SwiftUILayoutrunning the protocol's measure-then-answer round trip.draggableanddropdestinationare SwiftUI's own drag and drop. The payload stays in the app, as on a page: what is dragged carries only its element's id.- Style fields:
symbolEffect,rotation3D,alignmentGuide,gridCellColumns,gridCellAnchor,hover,scrollVisibilityandpointerStyle(the Mac's).
The round trip settles two encodings that differ between the shim and the package, rotation3D's defaults and a drop destination's accepts, and every shared Fidelity screen still round-trips to the same tree.
On the page, a dragged copy whose boxes took the pointer (a background or a content shape makes a box a target) hid the destination under it; the copy now lets every pointer through.
SuperSynth uses the drag and drop: a source's + MOD can be dragged onto a knob.
SuperSynth: stand-ins go unremarked#
The import's report no longer lists the stand-ins for the tables and noises a preset names. Stand-ins are SuperSynth's approach for good, not an approximation to point out. The same goes for the later filter types, which are made from what the machines have.
A name no recipe knows is still noted: a table guessed from its words, or white noise for a noise. So is what SuperSynth leaves out or does differently from Serum: a remap's curve, routes it doesn't read, a unison it plays with fewer voices.
SuperSynth: the compressor's knobs#
A Chvrches preset's bass played at −60 dB. Its compressor, at a gentle threshold, had been read as one far below its signal at 15:1. Serum's manual has the threshold run from 0 dB at the bottom of the knob, the other way round from how SuperSynth read it. The ratio's default (0.75) is 4:1, a limiter at the top, and the make-up gain reaches 36 dB.
The threshold's range is fitted. Across 134 presets, compared with the compressor and without, −48 dB at the top keeps a preset near its own level; the manual's −120 dB took half of them down by 24 dB or more.
The multiband compressor's upward gain now follows a level that rises at once. With the attack's level, a note's onset was boosted as if it were still the silence before it, a click several times louder than the note.
SuperSynth: wheels, remaps, rise and delay#
The deck has a bend wheel and a mod wheel beside the keyboard. The bend wheel springs back to its middle and bends as far as the preset's bend range, up or down. The mod wheel stays where it is left. It is Serum's matrix source 1, which presets use as an aux to bring in vibrato, and it is dragged onto knobs from the MACROS module's + MW like a macro.
Sources 17 and 20, which put a small random detune on each note, are two values drawn as each note starts and held for the note. A voice's noise starts the same way at every note, so they are drawn from the song's position and the note.
The remap warps play their curves. After the LFOs' shapes the state keeps four more curves, the same way: oscillator A's and B's remap, then (inferred) the distortion's X-shaper A and B. Remap 1 takes the phase through the curve, remap 2 does so in each half, the second mirrored, and remap 4 in each quarter; remap 3 is a sine's S. With a remap on, the oscillator's REMAP opens its curve to draw on, as an LFO's shape is drawn.
An LFO's rise and delay are read from a newer preset (two floats after its rate). They hold the LFO at its first value for the delay, then fade the shape in over the rise. They are set on the LFO page as RISE and DELAY.
A noise sample a preset carries in stereo is stored as its left channel, then its right. It had played as one sample twice as long; it is now mixed to one channel and played at its own rate (48 kHz in the packs that carry one-shot samples, a number the state keeps).
The noise's one-shot switch was looked for and not found: the eight presets that carry one-shot samples match the rest byte for byte, apart from the sample. Nor were an LFO's dotted and triplet switches, which in Serum change which lengths a synced rate knob lands on.
CI skips a change only the docs make#
CI no longer runs for a change made only to docs/, alone or with SuperSynth: the docs build and check in their own workflow, and no CI job reads them. A SuperSynth change with its history entry and notes had run all of CI. Ice Cubes' deploy from main skips such a push too.
SuperSynth: the distortion's modes, the effects' knobs, hold and stack#
The distortion plays its sixteen modes (parameter 99, in its menu's order) where it had one soft clip for all: tube, the clips, the diodes, the folds, zero-square, downsample, asym, rectify, sine shaper, stomp box, and the two X-shapers, which read the preset's own curves (the two after the remaps) with the drive crossfading between them. Its filter plays before or after, morphing from low-pass to high-pass. Tape stop has no recipe and soft-clips, and the import says so.
The effects read the rest of their knobs, named from the panel's order and the values the presets leave at their defaults: the reverb's low and high cut, the chorus's second delay, feedback and low-pass, the flanger's and phaser's feedback and stereo phase (and the phaser's frequency), the synced rates, and the delay's bandwidth, link, offsets and tap → delay mode. The hyper effect plays its unison voices, and the dimension its size. The panel shows the modes and the knobs most presets set.
The reverb's tail is high-passed at its low cut, 20 Hz at the bottom. That removed a build-up below hearing which had made some pads several decibels louder with the reverb than without.
An envelope's hold keeps the top after the attack. The unison stack puts voices up an octave (with a fifth, in some options) or the center ones down, its options read as Serum's manual names them.
SuperSynth: envelopes on the effects, and the newest note in a master stage#
A route from an envelope to an effect's knob plays now: the FX filter's cutoff opened by an envelope at each note, a reverb's mix, an EQ's gain. Serum's effects run once, after the voices, and their envelopes follow the newest note, starting over at each one. The velocity and note do too. Four of the sample presets had played with their effects still.
For it, @swiftbrowser/dsp's master stage reads the newest note: its inputs (freq, gate, velocity and note number) are the newest note's, in four more machine registers (7 … 10, so a program's own start at 11), and its envelopes start over at every note. It is always on: nothing opts in. Both machines fill them, and a parity case renders it the same.
Source 33, control 147 and parameters 289 … 298 stay unknown. Control 147 is a template's route in seven presets from one author's packs, to a destination with no parameter, and 289 … 298 are 0 in every preset. The import still says their routes are left out.
SuperSynth: the noise's keytrack and one-shot#
The noise oscillator's keytrack and one-shot switches are read and played. With keytrack on, the noise's pitch follows the key played, C3 being the sample's own pitch, and the pitch knob moves in semitones. Before, MGMT's Kids Lead played its tune's sample at one pitch whatever the key. With one-shot on, the sample plays once from each note instead of round and round. The NOISE module has a chip for each, and the pitch knob reads in semitones while KEY is on.
The switches are two floats after the parameters (0x4c68, 0x4c6c), a float later in some newer presets. The earlier search missed them because it looked for something only the one-shot presets had, and other presets use the switches too. The keytrack switch gave itself away by the pitch knob: wherever it is on, the knob sits on a 128th. Every preset carrying a one-shot sample has both switches on, and its knob, read as semitones from C3, puts the sample's own pitch on a C.
SuperSynth: tape stop, mono and legato#
The distortion's tape stop plays now instead of soft-clipping. The drive slows the tape to 1 − drive of its speed, read by two heads that sweep back through 80 ms and crossfade. The pitch falls with the speed, the sound gets duller, and at full drive the tape stops. With no drive it is clean.
Serum's voicing is read and played. That covers mono, legato, whether a glide is always, and how many voices. They are floats in the same run of panel switches as the noise's one-shot and keytrack, at 0x4c54, 0x4c58, 0x4c5c and 0x4c70, read off the 134 sample presets:
- Mono is on in nearly every bass and lead, nearly every preset that glides, and every one-voice preset. It is on in almost no pads, keys or arps.
- Legato is only ever on alongside mono.
- The voice count is x × 31 + 1: 8 in most presets, 16 in many.
A mono preset plays one voice, the newest note, as @swiftbrowser/dsp's mono mode does; with legato on, it uses legato mode, so a note played over a held one carries on its envelopes. Without "always", a glide starts only from a note still held, and a note after silence starts at its own pitch. A preset plays its own number of voices, up to eight. With fewer voices, each note gets more unison for the same cost: 12 a note at eight notes, and all 18 at five or fewer. The OSC page has a VOICING module with the voice count and MONO, LEGATO and GLIDE ALWAYS chips.
In the sample report, which plays a three-note chord, mono presets are quieter now, since they play only the newest note.
SuperSynth: an LFO's dotted and triplet#
A synced LFO's dotted and triplet switches are read and played. A dotted LFO's cycle is half again as long, and a triplet's two thirds as long. The LFO module has TRIP and DOT chips while BPM is on, and the rate reads 1/4D or 1/4T.
Nobody here has Serum to check against, so the switches are a best reading of the sample presets. In a newer preset, LFO k's BPM flag is the first byte of a word, and the next three bytes are almost always 0. Taken in the panel's order (BPM, ANCH, TRIP, DOT), the first of them is anchor: it is on in 44 LFOs, 36 of them running free, the only mode where an anchor matters. Triplet is on in none of the newer presets, and dotted in two. An older preset keeps a byte per LFO in three runs of four, at 0x1af8, 0x1b04 and 0x1b08, read in the same order.
Anchor is read but plays the same either way. It ties a free LFO to the song's position, which SuperSynth's free LFOs already follow, and SuperSynth's song never jumps.
SuperSynth: the unison's modes and range, the glide's curve and scaling, an older preset's LFO delay#
Three gaps are closed by reading the sample presets, since nobody here has Serum to check against.
The unison's modes and range. Each oscillator's unison mode and range are floats in the panel's switch run. The mode (0x4c4c, 0x4c50) is a five-place menu: linear, super, exp, inv, random. It is set only on oscillators with four voices or more. The range (0x4c7c, 0x4c80) is x × 48 semitones: 2 in most presets, Serum's default, 3 or 4 in one author's packs, and 0 in a few. The detune knob reaches the range, so a 0 range plays unison with no detune. The modes spread the voices across it:
- super draws the inner voices in, as a supersaw's;
- exp draws most toward the middle;
- inv pushes most toward the edges;
- random gives each voice its own offset, the same every note.
The oscillator's unison row has MODE and RANGE boxes.
The glide's curve and scaling. The two floats after "always" are taken as the glide's scaled switch (0x4c60, on in three presets, two of which glide) and its curve (0x4c64, 0.5 in nearly all). The glide is now a sweep from the pitch it is at to the new note, in the portamento's time, instead of a smoothing filter:
- Curve: straight at the knob's middle, quick to start above it, slow below.
- Scaled: the time is for each octave, so a longer glide takes longer.
The VOICING module has a GLIDE CURVE box and a SCALED chip.
An older preset's LFO delay and rise. The older layout keeps them as it keeps its LFO switches, a run of four floats (an LFO each) for each, from 0x1b30. They are taken in the newer layout's order: smooth, delay, rise, one not read. Only CH_HINEV_80_CHORDS sounds different: a delay on its LFO 2 vibrato.
SuperSynth: a stereo noise sample in stereo#
A stereo noise sample a preset carries now plays in stereo, as Serum plays it, and is no longer mixed to one channel. Each side plays from its own channel, and the noise's pan knob balances the two. Warp's FM, AM and RM from the noise take the middle of the two sides.
The reader keeps one channel where the two sides are the same, so those presets cost no second read. Of the 8 stereo samples in the sample presets, the sides are the same in 5. Two sound different:
- KY - Sweet Dreams is wide (its sides correlate at 0.51), and the mixdown had narrowed it and partly cancelled it.
- MGMT - Kids Lead leans left: its right side is 30% quieter.
Notes: the matrix's unknowns, with another pack's presets#
The Monosounds pack's 269 Serum presets add to what is known about the matrix's unknowns, without settling any of them.
- Controls 147 and 148: they have no VST parameter (Serum writes 299 and 300, past the list) and sit between the hyper and dimension's knobs and the effects' ten levels. 147 is now in 23 presets and 148 in 9. Their macros' labels hint at them: KICK SIZE to 147 and PITCH DROP to 148 on ten 808s, MORPH to both on a bell, XTRA CHORUS to both on a bass layer.
- Sources 19 and 21: new. 19 goes to B's warp in three basses, 21 to B's pan in four keys and pianos. With nothing played, a pitch bend or aftertouch would move nothing, as leaving the routes out does.
All of them stay left out, and the import says so: guessing wrong would move the wrong knob audibly. docs/notes/serum-presets.md has the details.
DSP: room for longer samples; SuperSynth: long stereo noise#
A program's samples may now hold 8,000,000 values between them, up from 2,000,000: about 2¾ minutes at 48 kHz, or 83 s in stereo. Both machines enforce the new limit. The Monosounds Producer Starter Collection, 271 more presets to inspect, carries long stereo atmospheres of 24 to 58 s. Since its noise samples began playing in stereo, keeping both sides had put six of them over the old limit, and two were over it even mixed to mono. All 269 of its Serum presets now import; the other two are Sylenth1 presets, which the import refuses.
SuperSynth mixes a stereo noise sample to one channel if both sides would not fit. If even one side would not fit, it plays the start and the import says how many seconds. @swiftbrowser/dsp/builder exports SAMPLES_MAX for that.
An iPhone, an iPad or no device in the web preview#
A desktop preview's toolbar has a Device picker (Web/src/deviceFrame.ts): the
iPhone frame as before, an 11-inch iPad in landscape (1180 x 820 points, its
status bar the time and date at the leading edge, 24 points over a 20-point
home indicator), or no device, the app filling the window under the toolbar
and laying out for its size as it is resized. The layout engine gets each
device's safe area and the screen's size, so the iPad, or a wide window, is
the regular size class: sidebars, split views and form sheets. The choice
switches in place (the app keeps its state), is written to the URL as
?device=, and is remembered for the next visit; the pages' inline scripts
apply it before the first paint. The Swift apps' page, the Showcase and
SuperSynth have it, as does every app swiftbrowser native init writes; the
playground's embedded simulator stays an iPhone.
The Showcase in a split view; a flat-edged Wi-Fi glyph#
The Showcase's root is a NavigationSplitView: on an iPad (or the preview's
iPad, or a wide window) the examples are a sidebar and the one picked shows
beside it, each in a stack of its own; on a phone the list pushes it, as
before. For that, a NavigationLink(value:) in a split view sidebar's
List(selection:) now selects its value instead of pushing it, as SwiftUI's
does; outside a sidebar a value link in a selectable list still pushes. The
status bar the web previews draw has the Wi-Fi glyph as iOS draws it: three
bands cut along the radii, flat-edged, where they were round-capped strokes.
A folder for fileImporter; SuperSynth: banks#
fileImporter can choose a folder. 'public.folder' among its content types (SwiftUI's UTType.folder) makes the chooser a folder chooser:
- Web: the browser's
webkitdirectoryinput. - iOS: the document picker, opening the folder in place.
- macOS: an open panel that chooses directories.
onCompletion gets the folder's files at any depth that the other content types allow, each named by its path from the folder, the folder's name first (Bank/Leads/Saw.fxp). The pickFiles host request carries it, so the Swift shim's .fileImporter has it too: with .folder, onCompletion gets one URL, the folder's, written out with its files.
SuperSynth keeps banks with it. BANK, by the preset's name, lists them. + FOLDER chooses a folder of presets and keeps it in the app's files (fileManager, Documents/Banks/<folder>), so it is there the next time the app opens. A bank's name lists its presets, with the folders they are in, and a preset's loads it. ◀ ▶ at the ends of the name's screen step through the bank.
A preset can name a table or a noise by the path it had where it was made, without carrying it. A sound file of that name anywhere in the bank (WAV or AIFF; a wavetable's clm chunk gives its frames' size) fills it in when the preset loads. Only the presets, and the sound files they name, are kept. Files that are not Serum presets are left out, and the bank list says how many.
A close button on the preview's toolbar#
The preview's toolbar ends with a close button, an x in a circle, that hides
it for the app alone in the page and writes ?toolbar=0 to the URL, so a
reload or a shared link keeps it hidden; without the parameter it is back.
Without a device the app takes the toolbar's room too.
A compact split view pushes in the commit that selects#
In a compact width a NavigationSplitView learned of its sidebar's
selection from the list's layout effect, so a tap marked the row in one
commit and pushed the detail in the next; natively the root screen changed a
frame before the push began and lost its large title at once, where it should
slide away with the push. The list now tells the split of a tap's selection
in the same update, and a pop clears the row and the detail together: one
commit each way.
SuperSynth: stand-ins for the rest of Serum's noises#
Serum's noises in AIFF, and two folders of them, had no recipe, so presets that named them played white noise. Each of the 48 now has one, measured like the others: a kick's attack or a burst for the attacks, a bell-like strike for the inharmonic ones (partials at a bell's ratios, the higher fading sooner), and a low drone for the atmospheres (a chord of detuned partials swelling at their own slow rates, over noise as large as the original is noisy). 187 of Serum's noises have a recipe now, up from 139. The recipes hold only those traits and the names, nothing of the sounds.
SuperSynth: a denser panel, a lit tray, a shorter header#
SuperSynth's panel is denser. The plates sit closer, with less padding inside, and the title strip has an LED only on a part that switches in and out. The keyboard tray is lit along its top rim and casts a shadow up onto the panel scrolling under it.
The header is shorter. The name stands alone, without the line under it. The scope is a small screen beside it, and the main volume is a smaller knob with its title and value on its left (a Knob's labels="leading").
Controls draw from a tone's inks (INKS in theme.ts), which a Module passes to the controls inside it through ToneContext. Every plate is dark for now, but one can take tone="light" for light caps, wells and strips. A knob's cap is a whole number of points, as much smaller than the knob on each side, so it sits in the middle of its arc. Before, a fractional cap was rounded half a point off.
SuperSynth: the top scrolls away on a phone#
On a phone, SuperSynth's top (the name, the scope, the preset and its banks) scrolls away with the plates as they scroll down. The pages stay pinned at the top, and the top comes back as the plates scroll back up. Since it is the scroll itself that moves it, it follows the finger smoothly. The plates and the top are one LazyVStack pinning its section headers, and the pages are the header of a Section holding the plates. A wider screen keeps the top fixed above the plates.
Two fixes made that work on the web:
- Section rows unclipped: a
Sectionoutside a list drew its rows in a list's inset card, sized to nothing, which clipped them away. It is now a plain container there, as in SwiftUI, with no card, clip, row paint or separators. - No key warning: a
Sectionwith a header no longer warns about keys in development. - No header jitter: a pinned header was moved by script on each scroll event, which on iOS runs a frame behind the scroll, so it jittered. Where the browser has scroll-driven animations, an animation along the scroll view's timeline now moves the header, running from the offset where it starts to pin to where its section stops it, in step with the scroll. Footers, and browsers without scroll-driven animations, keep the script.
SuperSynth: wavetables drawn as Serum draws them, small knobs centred#
An oscillator's screen draws its wavetable as Serum does: in a 3D box of the cycle's phase across, its value up and the frames' depth back. The box is turned about the upright and tipped toward the viewer, then stretched to fill the screen. A cycle runs across and a little down to the right, and the frames go back up to the right, dimmer the further back they are. The frames are drawn in Serum's green, back to front, each filled as Serum fills them, green at the wave falling to dark at the bottom of its swing, and near enough opaque to hide what is behind it. The surface is drawn pixel by pixel as a smooth lit mesh (surface.ts). The whole table is sampled finely across the cycle and back through its frames, morphed between them. Each sample is shaded by how its surface faces a light from the front, above and to the left, against a flat patch: slopes toward the light catch a highlight, slopes away fall into shadow. Rows are drawn back to front, so the nearer ones hide the farther. The slope across the cycle is measured over a 48th of it, so a band-limited wave's ripple is not lit as ridges. The 8 frames' lines are drawn over the pixels as crisp paths, but only along the stretches the pixels show no nearer row hiding. The box's side at the cycle's end is drawn as a path too. The pixels become a PNG (stored, uncompressed) shown as an Image from a data: URL, drawn again only when the table or the screen's size changes. The stack sits on a dark green glass, lighter at the top. The box's faint outline frames them, its back and edges behind the frames and its front face over them. It draws 8 frames, evenly from the table's first to its last, morphed between where the table has fewer. The frame the position morphs to is drawn in its place in yellow, warped as it plays. As Serum fills it, its fill is a faint yellow from its middle (its value 0) up or down to the wave. A single-frame table, or a cycle being drawn, keeps the flat screen.
A knob's track was inset by a half point on the small knobs (the tray's and the main volume), which layout rounded off its middle, so their caps sat a pixel off their arcs. The inset is now a whole number of points at every size.
SuperSynth: wavetable lines unbroken at a crest#
A wavetable's frame lines broke at the top of a steep drop, such as a saw's, leaving a gap where the line should run over the crest. The rows just in front of a frame meet its crest at the drop's steep side, and the check of where a line is in view took them for rows hiding it. Now only a row well in front of a frame, half the gap between frames or more, hides its line.
Large titles ride the push and the pop#
A back button's pop dropped the departing screen's large title in its first frame, in every stack. SwiftUI sets the stack's path as UIKit's pop begins, and the path's setter sent the screen's tap at once, so the app removed the screen while the transition was still to run, and it was drawn from the tree's record of it, which UIKit showed without its title. An edge swipe already waited for the finger to let go. Now every pop UIKit animates waits for its transition to finish before the tap goes (PopTap, from UIKit's transition coordinator), and a cancelled swipe sends none. Meanwhile the stack's path leaves the screen out, as SwiftUI's own path has, while the tree still has it, so the screen is drawn as it is, title included.
A push from the Showcase's list dropped "Showcase" as it began. The rows were links whose buttons took the tap, so the list's row was selected only by the app's answer, under the push's transition. A split view sidebar's link now carries selects: true, and a native renderer lets the row's cell take the touch and select itself, as SwiftUI's split view does, before the app pushes.
A compact split view's selection stays in its sidebar#
In a compact width, a split view pushed its detail onto one stack rooted at the sidebar, and the sidebar's selection context reached every screen on that stack. A selectable list on a screen the detail pushed (the Files clone's folders, which select for Select) took its value links for the sidebar's, so a tap selected a row instead of opening the folder or file. Only the sidebar's own content has the context now.
SuperSynth: fuller caps and lighter shadows on the small knobs#
The small knobs (the tray's macros, the main volume) had caps lost inside their tracks, 12 points in a 30-point knob, and cast the big knobs' shadow, which round so small a cap read as a heavy dark ring, most of all natively, where SwiftUI's shadow renders darker than the page's. A knob under 40 points now has its cap a point and a half inside its track (16 points in 30) and casts a lighter, smaller shadow, nearer the cap. The big knobs are as they were.
Shaders: a language for the GPU, and SuperSynth's wavetables drawn with it#
In the iOS app, a wavetable's surface took seconds to appear. It was computed pixel by pixel in JavaScript, encoded as a PNG and sent over the bridge as an 800 KB data: URL. The app's JavaScriptCore runs without a JIT, so a loop that takes 140 ms in Node took seconds there. Now the GPU draws it from a shader, and the JavaScript only sends the table.
@swiftbrowser/shader (packages/shader) is a shader language, a small subset of JavaScript, in the way @swiftbrowser/dsp's is for sound. A module exports pixel(x, y), which returns a pixel's color, along with its uniforms and float textures. Values are numbers, comparisons and vectors written as arrays. A function has const and let, if, for and while, early returns, helpers, Math and a shader's builtins (clamp, mix, smoothstep, normalize, texel and sample for the textures, and others).
Compiling: swiftbrowser-shader compile parses a module with the TypeScript compiler, types it, and writes it out three times:
- GLSL ES 3.00 for a page's WebGL2;
- Metal for the app;
- JavaScript, which a page without WebGL2 draws with, and which the tests hold the two GPUs to.
Every backend reads the uniforms from one array of floats: the view's size, its scale and its time, then each uniform. Where the languages differ, JavaScript's meaning wins: % keeps the dividend's sign, and Math.round rounds half up.
ShaderView draws a compiled shader over its box. On a page it is a WebGL2 canvas. In the app it is SwiftBrowserShader (Native/Packages/SwiftBrowserShader), a new optional package: an MTKView that compiles the shader's Metal the first time a view draws it, keeps it for every view drawing the same source, and draws one triangle. Both draw when their props or size change, or every frame when animated. An app adds it with swiftbrowser native add shader (or native init --with shader) and calls SwiftBrowserShader.install().
Testing: the package's render fixtures are three shaders, the largest being SuperSynth's own, with their props and the pixels the JavaScript draws. The page's WebGL2 (Web/e2e/shader-view.spec.ts) and, on a Mac, Metal (SwiftBrowserShader's tests) draw the same fixtures and must match them. The Swift core, which holds the props and the uniforms packed as the page packs them, also tests on Linux.
The wavetable shader: SuperSynth's wavetable is wavetable.shader.js. Each pixel follows its view ray back through the turned box. Its column fixes where the ray crosses each frame's cycle, so the shader steps back through the frames and halves its way to the first depth where the surface rises above the ray. That point is lit as the PNG's mesh was. As Serum fills them, each of the 8 frames has a fill from its middle (its value 0) up or down to its wave: the frames' green, strongest at the wave, fading toward the middle. Nothing is opaque. The fills, the side's face at the cycle's end and the surface between the frames are each translucent, and a pixel gathers them front to back as its ray passes them (up to four times through the surface, from above lit, from under in shadow), so the frames behind show through the nearer ones. A frame's line behind a fill or a hill is fainter for each layer in front of it, not hidden; the side's face never dims the frames' ends. A frame's line is drawn across its own width in pixels, smooth-edged, where nothing hides it. A line is hidden when the ray through its own point meets a surface first, either where the ray enters or half a gap between lines or more in front of it. A line's own slope or a plateau's ripple never hides it. The table goes to the GPU as a texture of up to 64 of its frames. The box's outline and the lit frame are still paths drawn over it. surface.ts and its PNG encoder are gone.
SuperSynth: the keyboard tray's shadow, cast once#
On iOS, the knobs, keys and labels in the keyboard tray had heavy dark shadows that the page did not show. The tray cast its shadow up onto the panel from its stack, and SwiftUI's .shadow on a stack shadows each view inside it as well as the stack's background. So every knob cap, key and label in the tray cast the tray's 6-point shadow too, on top of its own. The page draws a shadow as one drop-shadow of the whole element, where the shadows of what is inside fall behind the opaque tray and do not show. The shadow is now the tray background's, as SwiftUI code would write it, so only the tray casts it, on both.
Shadows fall as SwiftUI casts them: on each view a container draws#
In SwiftUI, .shadow on a container is not one shadow around it. It falls on each view the container draws: its background, every text, shape and image inside it, and their own shadows. Only a .compositingGroup() before it makes the container cast it as a whole. The page drew shadow as one CSS drop-shadow of the whole box, so an app that shadowed a container looked lighter in the browser than on the phone. SuperSynth's keyboard tray was such a case: its knobs and keys carried heavy shadows on iOS only.
Measuring SwiftUI: a test renders the scenes with ImageRenderer on the macOS runner, so the page follows SwiftUI rather than a guess (Native/Tests/SwiftBrowserNativeTests/ShadowSemanticsTests.swift). Each scene is a hard shadow on a white box with a red square in it. The findings:
- The square casts the box's shadow onto the white.
- It still does through a clip shape,
clipped(), a mask, a blur or an opacity. - With no background, only the square casts it.
- A square's own shadow is shadowed again by the box's.
- With a compositing group, the box casts one shadow around itself and the square none.
The page now does the same (castShadows in renderer.ts, after each commit):
- Handing it down: a box with a shadow hands it to the views inside as
--sb-shadow-filter: its owndrop-shadow, then those of the boxes around it, up to a compositing group. - Drawn views: texts, shapes, images, colors, dividers, canvases, registered views, charts and controls take it as their
filter. - Backgrounds: a background painted on a box inside takes it as a
box-shadow. - Clips and masks: a box that clips or masks also takes it in its own
filter, so the shadow falls outside the clip as SwiftUI's does. - Compositing groups: a group takes it as one and hands none to what is inside.
Web/e2e/shadow-semantics.spec.ts draws the scenes the Swift test measures and holds the page to SwiftUI's results.
compositingGroup is a new style field and modifier. It is the React prop compositingGroup, and the Swift shim's .compositingGroup() and .drawingGroup(), which were no-ops, now send it. Natively it is SwiftUI's own .compositingGroup(). The Showcase's slide thumbnails, slide canvas and book covers meant one shadow around the whole view, so they now put a compositing group before their shadows. Before, every line of a cover's title cast one on the phone.
Files for uploads#
An app that uploads thousands of files, or one of two gigabytes, must never hold a file in memory it is not reading. Three things stood in the way: fileManager read and wrote whole files (a page's IndexedDB row held one Uint8Array; the native bridge Data(contentsOf:)), the native file picker read every picked file, and every file of a picked folder, into one answer, and a drop from another app arrived as base64 on a page and not at all natively.
- Ranged reads, Blob-backed files.
fileManager.contents(url, { start, end })reads a piece of a file: aBlobslice on a page,FileHandle's seek and read natively (readRange). ABloborFilewritten is kept as it is: a page's IndexedDB row stores the Blob unread (an olderUint8Arrayrow still reads), and the native app copies a picked file on disk (importItem) rather than carrying its bytes across the bridge. The wasm loader reads a Blob row on load, so a Swift app and a React app share the home. The native files bridge now reports the app's own writes, moves and removals tofileManager.watch, as the page's host did and the README promised. - Picked files stay on disk. The native pickers answer
{ name, type, size, url }and@swiftbrowser/native'sLazyFilestands for each: aFilewith its name, type and size, read by range through the files bridge whenarrayBuffer(),text()or asliceasks. A document picked is the copy in the app's tmp, a photo is copied there as the library hands it over, a folder is opened in place with its security scope kept open (PickedFiles) until the app releases it or picks again. Afetchbody, aFormDataentry, a share, an export and a download read one first (a form holding none still goes out in the same turn).URL.createObjectURLof one is itsfile:URL, which the image loader andAVPlayerread. - Drops of files and folders. A React app in a page gets a dropped file as the browser's own
File(the renderer'sfileDropsisreferenceundermount; a Swift app keeps base64data, which crosses into linear memory), and a dropped folder as its files named by their paths in it, walked throughwebkitGetAsEntry. Natively adropDestinationtakes files and folders from other apps throughTransferablefile representations, copies each into tmp while the drop runs, and answers items still on disk (url,size,path), which the runtime turns intoLazyFiles;acceptsfilters them by MIME type as the page does. - Fetch cancellation. An
AbortController's abort now cancels theURLSessiontask (fetchCancel) rather than only rejecting the promise; a late answer from an older host is ignored as before. - Request bodies streamed from disk. A native
Blobis now a list of parts, bytes in memory or ranges of files on disk, so aBlobbuilt from picked files' slices (the way a page builds an upload chunk) holds nothing in memory, and aFormDataholding picked files encodes to parts without reading them.fetchsends such a body to the host asbodyParts(typed arrays beside the request,{ url, start, end }for the files) with its totalContent-Length, and the host streams them in order through anInputStreamover aFileHandle(BodyStream.swift), a folder's security scope kept open for the read; a redirect or a challenge that needs the body again gets a fresh stream of the same parts. A host withoutfetchStreams(before 0.20) is given the files read into memory, as before.
The WebAssembly build without streamed bodies#
Streamed request bodies (BodyStream.swift) broke the WebAssembly build of SwiftBrowserNative that the native round trip runs. There, Foundation has no URLSessionTask, InputStream subclassing or httpBodyStream, and URLSession is the shim's. The stream, its session delegate and the bodyParts branch of fetch now build only where the shim's Foundation is absent, as the rest of the native host's Apple-only code does. The shim never answers fetchStreams, so it is never sent bodyParts.
SuperSynth: an iPad's pages fewer and fuller, without scrolling#
On an iPad the synth kept the phone's five pages, each a grid of a few panels with room to spare, and the page scrolled when a panel was tall. A wide screen now has three pages, SYNTH (the oscillators, sub, noise, voicing and filter), MOD (the envelopes, LFO, macros, tempo and matrix) and FX, and every panel of a page fits on the screen. The phone keeps its five pages.
- Columns placed tallest first. A page's panels go into as many columns of at least 320 points as fit, up to three. Each panel, tallest first by an estimate of its height, goes into the shortest column, and each column keeps the panels in the page's order, so the columns end near the same height rather than one row's tallest panel setting the height of the row.
- The header holds the tabs. The pages' buttons sit in the header's row, an LED and a name each, rather than in a row of their own. On a screen at least 1100 points wide the preset bar joins them there too.
- Shorter keys on a short screen. On a wide screen less than 900 points tall the keyboard is 84 points rather than 120.
Gated regions: SuperSynth's effect switches without a build#
Switching one of SuperSynth's effects on or off built the patch's program again and loaded it, so an effect could not be heard coming in while a note played. The program left out the effects that were off, because the DSP machines run every instruction they are given: an effect present but mixed to nothing still cost its full price. A comparison measured locally put a program with everything built in at 1.3 to 4 times the cost of SuperSynth's own for the same preset.
Gated regions in @swiftbrowser/dsp let a program hold a part that runs only sometimes. ProgramBuilder.gate(condition, fallback, body) marks body's instructions as a region that runs while condition is above 0.5. The condition is a parameter, or arithmetic on parameters: block-rate, and the same for every voice. The region's results are chosen against fallback. In the program, groups lists each region's condition register and the region around it, and sampleGates and masterGates give each instruction its region. Both machines read the conditions at each block's start. When one changes, a machine makes its streams again without the regions that are off, and does three more things:
- The choice costs nothing. The machine drops each region's
selectand the test that feeds it, and whatever read theselectreads the operand it chose (sampleExits,masterExits). - Scheduling follows what runs. The machine schedules what is left again, as the builder does. Otherwise an off effect with feedback, such as a chorus after the effects that are on, would keep the code between them running frame by frame.
- A region comes back clean. A region coming on again starts over: its builtins, and the state its
movs write, are as when a voice starts. A delay switched back on does not replay what it held.
The builder takes back out of a region any value made inside it that something outside reads, so shared values stay computed. validateProgram and the Swift program's parser check the regions, and a select a machine would rename may not write an output, state, route or condition register. Allocation stays off the audio thread: the Swift machine compacts and schedules into buffers it makes when the program loads. A parity case (gates) switches nested voice regions and two master-stage regions, one of them a delay fed back through state, on and off while it plays, and the Swift machine renders it as the JavaScript one does.
SuperSynth builds all ten effects in the rack's order, each behind its own Serum switch parameter (FX_ENABLED). A switch is now a knob like any other: the panel sets the parameter, and the effect comes in or drops out from the next block. The switches are no longer in STRUCTURAL. The patch keeps every effect in rack, with whether it is on. Measured on the init patch and a lead preset with five effects on, the program with every effect built costs the same as the one with only those on, within the measurement's noise, in both machines.
Gated regions, simpler: a table of results, and the machines schedule#
Gated regions came in carrying what a program would need to run on a machine that knew nothing of them: a real select and a test at each region's end, marked for a machine to remove, and serial ranges worked out by the builder, which each machine worked out again whenever a region turned. Nothing outside this repository runs these programs, so that is gone, and the format stays at version 1:
- A region's results are a table. Each region lists its results as
[register, on, off]. The register is one no instruction writes, and an instruction that reads it readsonwhile the region runs andoffwhile it does not. A machine renames those reads when a region turns, in every stream, block-rate code included. Noselect, test or exit marker is left, so neither is the check that a removed instruction wrote nothing a machine could not rename. Where a result would be an output or a modulation source, which are read by register past any renaming, the builder copies it through amov. - The machines schedule. Programs no longer carry
serialormasterSerial. Each machine schedules its streams when it loads a program (which instructions feed back through state frame by frame) and again when a region turns, by one rule written once in each. The builder emits each stream in program order and fuses products and sums there; the validators no longer check where state is touched. The compiler's tests read the schedule from a loaded machine. - A region's condition is a parameter.
gate(parameter, fallback, body)takes a parameter, so the condition is the same for every voice by construction. A machine reads the value the app set rather than its 20 ms glide, so a switch acts at the next block. - The patch has one list of effects. SuperSynth's
Patchkeepsrack, every effect with whether it is on;effectsis gone.
Measured as before, the programs cost what they did, in both machines. The parity fixtures carry the new format, and the Swift machine, scheduling for itself, renders them as the JavaScript one does.
Choices: SuperSynth's effects reordered while they play#
Serum lets a patch put its effects in any order. SuperSynth read the order from the preset and built the effects in it, so changing it would have meant building and loading the program again, which starts every effect over: a reverb's tail would stop dead.
Choices in @swiftbrowser/dsp let a parameter decide what a register reads. ProgramBuilder.choice(parameter) returns a register and an options call that gives it what it may read as, one of which the parameter's set value names (rounded, clamped to the last). The options may be made after what reads the choice, so an effect's input can be another effect's output built later. In the program, choices lists each choice's parameter, register and options (at most 256). A choice's register is one no instruction writes, like a region's result, and a machine renames reads of it as it renames those, following a choice of a region's result to what that reads as.
- The machines order the streams again. When a choice changes, a machine compacts its streams as for a region, then sorts the sample and master streams so each instruction comes after what writes what it reads, and before what writes the state it reads (it reads the frame before's). Where nothing decides, program order holds, so a program built in an order runs as built. The sort is stable, a heap over the ready instructions; the Swift machine sorts into tables it makes when the program loads, so a turn allocates nothing on the audio thread.
- A cycle is refused. Choices that would make something read a value made from itself are not run: the machine keeps the last choices that made no cycle, and remembers the refused ones so as not to try them again every block. A program loaded with a cycle runs in its own order.
- What an effect holds carries over. Nothing is built or reset when the order turns, so a delay's line, a reverb's tail and a filter's state go on from where they were.
- The builder finds options made late. Its liveness pass runs again until nothing more is live, since a choice can read as a value made after it.
validateProgram and the Swift parser check the choices: a parameter, a register nothing else writes or names, 1 to 256 options, none of them state. A parity case (choices) turns an oscillator choice in the voice and three master-stage effects' inputs while it plays, the echo behind a gate and one turn to a cycle, and the Swift machine renders it as the JavaScript one does.
SuperSynth builds the ten effects in Serum's first order, each one's input a choice of the voices or any effect's output (fx.in.<name>, 0 to 10), and what they give out another (fx.out). fxRouting(order) gives the parameters' values for an order, and the preset's order sets their defaults. Each FX plate has arrows that move the effect up or down the rack: the patch's order changes in place, so a patch built again keeps it, and the node is sent the routing, with no build. Measured on the init patch, the program costs what it did in both machines; a turn costs about 0.3 ms once, in the JavaScript machine, in the block where it happens.
SuperSynth's menus and switches without a build, and faster builds#
After effect switches and effect order, most of SuperSynth's other menus still built the program again, which starts every voice and effect over: the filter's type, the oscillators', sub's and noise's switches, the warp modes, the sub's shape and octave, the distortion's mode and filter, the delay's mode, sync and link, the EQ bands' types, the filter effect's type and the chorus, flanger and phaser sync switches. They now turn while the patch plays.
@swiftbrowser/dsp
- A choice is scaled.
choice(parameter, scale)reads as the optionround(value × scale)names (the program'schoices[].scale), so a 0 … 1 knob is a menu as Serum reads it (×88 for a filter type, ×23 for a warp mode). - The machines run only what is needed. When a region or a choice turns (and on load), each machine finds what the outputs need, back through the renamed operands, state included, and leaves the rest out of its streams. An option not chosen costs nothing, like an effect switched off. Something that comes to run again starts over: its builtin as when a voice starts, the state it writes at its first value. That rule covers a gated region coming on too, so the machines no longer keep a list of each region's builtins and state.
- A turn makes nothing on the audio thread. The JavaScript machine now does a turn the way the Swift one does: a writers index made at load, a work list instead of repeated sweeps, operands read into one buffer, and ordering only where the stream reads something made after it (an effect order). That cut a turn on a busy preset from about 1.2 ms to under 0.2 ms; a lookup table built anew for every operand read was most of it. In Swift a turn costs about 0.1 ms.
- The builder makes an instruction once. The same instruction over the same registers, in the same stage and region, is the one already made: a builtin too, except a noise's and grains' (each has its own seed) and an envelope's (its curves are its own). Options that are alike cost one, and a program runs a little less than before: 123 instructions rather than 127 on the init patch, 405 rather than 438 on a lead preset.
- Builds are quicker. Liveness is a work list rather than repeated sweeps, sample data is copied whole and base64-encoded into a byte buffer, and counts are typed arrays.
SuperSynth builds every option of those menus, and pick puts a choice on the knob. A filter's 89 types share their cutoff, drive and the later types' periods, and the multi-mode types alike in kind and poles are one recipe. A unison voice's 24 warp modes share their phase, amount and reads. Wavetables and noise stand-ins are made once per source rather than every build, now that oscillators switched off are built as well. unisonVoices builds an oscillator switched off with its own unison where both oscillators fit the budget, so switching it on needs no build; where they do not fit, the switch builds again. STRUCTURAL keeps only the unison counts and stacks, the Hyper unison and the envelope curves. MENUS lists what the matrix cannot route to, since a choice reads its knob as it is.
Measured locally against main, a build of the init patch takes about 8 ms rather than 2.5 ms, and a lead preset about 17 ms rather than 10 ms. A program is about four times the size (the options it carries), while what runs is the same or less.
SuperSynth's unison, stack, Hyper, polyphony, legato and glide without a build#
Group 2 of what still built SuperSynth's program again: how many copies of something play. These now turn while the patch plays, except where turning them would cost more than a build.
@swiftbrowser/dsp
- Voicing parameters. A program can name parameters for its voicing (
voicing: { voices, mode }, built withProgramBuilder.voicing): how many voices play, from 1 up to the program's, and the mode (0 as many, 1 mono, 2 legato). Both machines read them at each note. At a block's start where they turned, the voices past those that now play let go, and a mode's held notes start again from the one voice sounding. A parity case (voicing) turns polyphony and mode while chords play. pick(parameter, scale, options)makes a choice with its options at once, at the rate of the fastest of them, so a choice of constants is block-rate and costs nothing as it runs. The same parameter, scale and options are one choice, and options all alike are that option.- Parameters at rest are left alone. A parameter's glide comes to rest on its target and is then not written again. Before, every parameter register was filled across every voice every block, which with SuperSynth's hundreds of knob parameters was real work in a wide program.
- Turns are checked only after a parameter is set. A machine looks at its regions, choices and voicing at a block's start only when
setParameterwas called since the last block. - A Swift fix. The Swift machine compacted its block stream but still ran it to its full length, the stale tail included. It now runs only what it compacted, as the JavaScript machine did. Unrenamed instructions in that tail could read a choice register as zero; the
choicesparity case now has a block-rate choice.
SuperSynth
- Unison voices. Each oscillator is built with as many unison voices as fit the budget beside the other oscillator's (
unisonPlan), and its unison knob picks how many play. Each voice's spread, detune, stack offset and blend are constants chosen by the knob (the stack's through a choice on its own knob), and what is heard is a choice of the voices' running sums, so the voices past the count do not run. The stack and the Hyper's unison (1 … 7 delays, their averages chosen) are choices too. - Voicing. Polyphony, legato and the glide's settings (always, scaled, curve) are program parameters, so the panel sets them on the node. A patch builds again only where
needsBuildsays so:- mono turns on or off (a mono patch is built with one voice: one voice in an eight-voice program cost about 40% more natively, its registers strided);
- the glide turns on or off (the portamento knob to or from zero; before, turning it up from zero did nothing until something else built the program);
- an oscillator's switch or unison leaves the two no longer fitting the budget.
- Only the curves rebuild.
STRUCTURALkeeps only the envelope curves.
Measured locally against main, the machines run the init patch and a mono lead preset as fast as before (the programs run the same instructions). A build of the init patch, which now carries nine unison voices an oscillator with every warp mode, takes about 14 ms (8 ms before this, 2.5 ms on main before the menus); the lead preset about 17 ms, as before.
Text editors: the caret stays put when the text changes from outside#
A texteditor showed another person's edit (or the app's own change to its text) by replacing the whole text, which on the web left the caret at the end, and a selection the app sent back with the same numbers was taken for the echo of the viewer's own and skipped. Now a text that is not what the editor last reported is a change from outside: the app's bound selection is applied even when unchanged, and without one the caret is moved past the change (shiftOffset in the web renderer, caretAfterChange in SwiftBrowserProtocol, the same on the iOS 18 plain editor). What a collaborative editor needs: apply the remote edit to the text, shift the caret the same way, set both in one render. docs/ops-protocol.md, "Rich text editors".
Data replaced as it plays: tables, shapes, samples, curves and unison tuning#
The first part of group 3: the data a program is built with (arrays and curve shapes), not its code.
@swiftbrowser/dsp
- Data replaced by name.
DSPNode.setTable,setShapeandsetSamplereplace one of the program's tables, shapes or samples from the next block, with nothing built again; what plays it goes on reading the new one. Each machine now keeps every table, shape and sample in a buffer of its own, so a replacement is a swap.- A table's samples (an FFT a level,
DSPMachine.tableLevels) are made off the audio thread: on the page's main thread, then transferred to the worklet; natively on the calling thread, handed to the audio thread through the renderer's queue. - The buffer the audio thread swaps out goes back to the main actor to be freed, as a retired machine does.
- The machines refuse a replacement past what they hold (256 frames of tables, 65,536 shape points, 8,000,000 samples).
- A parity case (
data) replaces a table with one of more frames, a shape and a sample while notes play, in both machines.
- A table's samples (an FFT a level,
- Envelope curves are registers. A program's
curvesnames the registers an envelope's attack, decay and release exponents are read from, rather than constants, so a parameter turns them.- They are read at each chunk's first frame for each voice and held to 1/16 … 16.
- An exponent of 1 works out no power, and a voice whose three are all 1 skips the bending entirely.
- A worklet test runs the generated worklet script in a stand-in scope and checks a table, shape and sample sent as the page sends them.
- No exclusivity checks as it renders (Swift). The tables', shapes' and samples' storage is fixed slots changed in place (
Slots), not array properties, and the instruction being run is a constant for its kernels' closures. Swift checked both for exclusive access at every read, about 4% of a lead preset's time; it now runs 3% under main's.
SuperSynth
- Tables and shapes. A table drawn on, a drawn LFO shape (its points and ends) and a remap curve are replaced on the node, not built.
- Envelope curves. The curve exponents are parameters (
curveName) the curve knobs set (curveValues), so the envelopes do no arithmetic for them. That kept the runtime as it was: deriving the exponents in the program cost about 6% natively.- Each envelope's three parameters are made once, so an envelope the voices and the effects both have (envelope 1 routed to an effect) builds.
- Unison tuning. Each oscillator's unison mode is a choice of each voice's detune and its range a parameter (
tuningName). - Nothing rebuilds on a knob.
STRUCTURALis empty. The curve knobs joinMENUS, since a route cannot move what is read as set.
Measured locally against main, the machines run the init patch and a lead preset as fast as before, in both. The matrix (adding, removing or flipping a route without a build) is the next part.
SuperSynth's matrix without a build#
Group 3, part 2, of what still built SuperSynth's program again: adding, removing or flipping a route.
@swiftbrowser/dsp
- Route lists replaced as a program plays.
DSPMachine.replaceRoutes(index, list)(both machines) replaces one of a program's route lists: source and amount registers, pair after pair, up to 128 pairs (ROUTES_MAX). The machines check it as a program's own (registers in range, amounts parameters, nothing a choice or region renames) and make their streams again at the next block.DSPNode.setRoutes(index, list)sends one (the page's worklet and the native node).loaddrops what was set for the program before.- A parity case (
rerouted) gives an empty list a block-rate source, then an LFO, then both, then none, while notes play.
- Folding as the streams are made. Before it finds what runs, a machine passes over an instruction that comes to one of its operands or to 0: x + 0, x × 1, x × 0, a mix at 0 or 1, a select of a constant, a mov, a parameter clamped to a range its own is inside, and an empty route list (the zero register). Outputs, state, curves and route members are never folded.
- Re-rating. A sample-stream instruction that is not a builtin and reads only what is set once a block (no state, nothing worked out frame by frame, not the beat) moves to the block stream. A knob with an empty list then costs what the knob alone did, and one a macro moves costs its arithmetic once a block.
- Builder.
routeList(pairs)makes a list,fillRoutes(index, pairs)fills it again before the build (its sources may come after what reads it), andkeep(value)keeps a value nothing reads yet and gives its register, for a list to name later.
SuperSynth
- Every knob read has a route list, one a stage, and every source is built in each stage, kept as it is and moving both ways (
s - 0.5). What no list reads does not run.- The 16 route amounts (
r0…r15) are parameters from the start. routeLists(built, patch)gives each list's registers for a patch's routes; the app sends the lists that changed and every route's amount (one removed moves those after it down a slot).- A route that would go round (from a source into one of its own lists, or through others) is left out, at the build and after it alike.
- The 16 route amounts (
- What still builds: a route scaled by an aux source or its slot's output knob, more than 16 routes, and a route to a part built only where something moves it: an envelope's hold at 0, the unison's warp or position spread at its center, the Amp destination. Turning such a knob from where it does nothing builds too; before this, turning a hold up from 0 did nothing until something else built the program.
- Knob reads are shared within a stage, so the effects' repeated reads of a knob are one list and one value.
Measured locally against main, the machines run the init patch and a lead preset as fast as before: the same in V8, and natively 1% under main on the lead preset (by instruction count). A build of the init patch takes about 21 ms (about 17 ms on main) and making its machine about 13 ms (10 ms); the lead preset builds in about the same time as before.
A tree drawn by another root#
RemoteTree (@swiftbrowser/react): the ops of another SwiftUI root, wherever it runs (a sandbox, a worker, another runtime), drawn as elements of a host tree, with the renderer's events for them forwarded back under the child's ids, the child's title, toolbar and search field joining the host's screen, its sheets and alerts presented over the host's root, and its animated passes animating the host's. For NoyaOS's apps: sandboxed scripts whose UI is SwiftUI inside the host app's own screen. docs/ops-protocol.md, "A tree drawn by another root".
SuperSynth builds once a preset, but for mono#
Part 1 of building SuperSynth's program only once: the edits within a preset that still built it again.
patchValues(patch)gives every parameter the program reads besides the knobs. These are the voicing, the envelopes' curves, the unison's tuning and voices, the glide's switch, the LFOs' settings, the noise's switches, which parts run, the routes' amounts and slots, and the effects' order. A program is built with them as defaults. The app'ssync()sends whichever an edit moved, and the route lists that changed, in place of the separate rebuild paths.- Unison. Each oscillator is built with nine voices. A parameter (
unisonName) says how many play, as the budget shares them, so past the budget nothing builds. - The glide is a gated region on
glide.on. - LFOs. Mode (TRIG, ENV, OFF) and sync are choices. Length, rise, delay, smooth and LFOs 5 to 8's rates are parameters. The fade and the smoothing are gated regions.
- The noise. One-shot and keytrack are choices.
- Parts that run only where they do something: the envelopes' holds, the unison's warp and position spreads, the Amp destination and the noise's random phase. Each is a gated region whose switch (
partName) followswants. - Route slots. A route scaled by an aux source or its output knob plays through slot i: a choice of source (either way) times a choice of aux source (or none, upside down or not) times the output knob.
- The compressor's bands (one or three) are a choice.
- What still builds: mono on or off, since a mono patch is built with one voice. In a program of eight, one voice of a mono lead cost natively about two fifths more, as the machines run a chunk's frames of one lane apart. More routes than the 16 slots also builds.
- A preset loaded after another sets back every parameter the last program had set. Before, a knob turned in one preset kept its value in the next.
Measured locally against main, the init patch runs the same instructions, and a mono lead preset runs within 0.2% natively (by instruction count) and about the same in V8. A build of the init patch takes about 26 ms (21 ms on main), and making its machine about 15 ms (12 ms).
A screen recording of the Showcase on CI#
The Showcase screen recording workflow records the iOS Simulator while a Debug Showcase walks a script of taps and pops (scripts/showcase-recording.sh, Native/Examples/Showcase/ios/ScreenScript.swift), for what the package's tests cannot see: how a push or a pop looks, frame by frame. It was built to chase large titles vanishing at the start of a push or a pop on iOS 27, which the iOS 26 simulator does not show; docs/notes/large-titles.md has what is known and how to probe it once an iOS 27 simulator or Xcode 27 is on GitHub's images.
SuperSynth loads a preset as data#
Part 2 of building SuperSynth's program only once. A preset opened is loaded into the program as it runs, instead of building one for it.
@swiftbrowser/dsp
- All sound off snaps parameters. After all sound off (controller 120), what is set before the next block jumps there rather than gliding, in both machines. A preset loaded as data starts as the program built from it would. A parity case (
halted) checks it in both machines. - Cheaper
replaceRoutes. It checks a list against masks made once (the JavaScript machine rebuilt a set of every parameter at each call) and passes over a list that is the same as the one there. Loading a preset's 137 lists went from about 6 ms to under 0.1 ms on the audio thread.
SuperSynth
applyPatch(target, built, patch)loads a preset into a program built before. It sends all sound off, every knob,patchValues, every route list, and the data. The app uses it for every preset whose mono matches the program's; only mono on or off builds.- What a preset's data is (
patchData): the oscillators' tables, the twelve shapes (eight LFOs, two remap curves, two X-shaper curves) and the noise's two samples (noiseOf). A program is built from the same data, so a preset applied to it plays as the program built from it would. - No longer fixed at the build:
- Each source's filter routing: both buses, a choice on its knob. The filter is a gated region on
filter.used. - The bend's range (
bend.up,bend.down). - The noise's kind: a sample, a sample a side, white noise, or white noise darkened by a parameter's color.
- The compressor's resting level: its followers start at -1 and read as it.
- Each source's filter routing: both buses, a choice on its knob. The filter is a gated region on
- The report's notes come from the patch (
patchNotes), not the build. - Measured locally:
- A preset loaded as data costs the audio thread about 4 ms in V8, against about 26 ms for a new machine and its first block. The main thread spends about 2 ms making the preset's data.
- The program runs as main's does: the same instructions, within 0.1% natively.
The Swift machine runs only the lanes that sound, and SuperSynth builds once#
The Swift machine laid a register's frames out at the program's full voice count. With fewer voices sounding, and always in the master stage (one lane), every stateless instruction ran a strided loop over frames and lanes that does not vectorize. A register now holds a frame's running lanes side by side: the sounding voices' (up to the highest), or the master stage's one. Every instruction runs over one span of memory however many voices sound. Registers are made again each chunk, and what lasts between blocks (parameters, constants, the tempo) fills its register uniformly, so the layout follows each block's voices. The beat is written for the voices, then for the master stage.
Measured natively (per 256-frame block, eight-voice programs, against main):
- Init patch: 1, 3, 5 and 8 notes run 20%, 33%, 25% and 13% faster.
- A lead preset played poly: 22%, 18%, 20% and 4% faster.
- A mono lead in an eight-voice program: 0.459 ms down to 0.344 ms, under the 0.40 ms of its own one-voice program.
- The package's big patch: 10.2% to 9.5% of a block.
The JavaScript machine already keeps a lane's frames together; it is unchanged, and the parity tests hold.
SuperSynth builds once. With one voice of eight costing no more than a program of one voice, a mono patch is built in the program of eight, mono or legato its voicing's mode. Mono on or off, and a preset whose mono differs, now play with no build, a mono preset loaded as data like any other. Only more routes than the matrix's 16 slots, which Serum cannot make, would build it again. In V8 the mono lead runs at 1.30 ms a block in the program of eight, against 1.39 ms in one of its own.
A DSP language of its own#
@swiftbrowser/dsp compiled a subset of JavaScript, parsed by the TypeScript compiler. SuperSynth outgrew it, and built its program with 1,560 lines of TypeScript calling ProgramBuilder. The package now has a language of its own, written in .dsp files (docs/notes/dsp-language.md). Every program moved to it, SuperSynth's included, and the JavaScript-subset compiler and the package's typescript dependency are gone.
The language (src/lang: lexer, parser and lowering) is plain TypeScript with no dependency, so it can run in an app as well as at build time. It lowers through ProgramBuilder; the machines and the program format are unchanged.
- Declarations.
param name: type = default, typednumber(min...max),int(min...max),boolor an enum.@name("s{i}")names a parameter for the app, andparam knob[i in 0..<299]: …declares one for each index.table,shapeandsampledeclare data,voicing(voices:count:mode:)the voices, andconst,enum,fnandimport/exportthe rest.
- What is known while compiling, apart from what plays.
- Numbers (with units:
5ms,2khz,12st,-6db), strings with{…}in them, arrays, records, ranges, enum cases and closures are worked out while compiling. ifandfortake only these. Calls are inlined and loops unrolled.- Arithmetic and the builtins go side by side over arrays, so a stereo pair is
[l, r].
- Numbers (with units:
- Swift's syntax where it fits:
0..<9and1...9,.casevalues, labeled arguments, and trailing closures (map(0..<9) { u in … }). A statement ends at its line's end; a line starting+ xcarries on the one before, and-xstarts a value. - Choices while it plays.
choose(p) { n in … }builds an option for each value of an int, enum or bool parameter, or each ofsteps:along a 0 … 1 knob, and runs only the one picked.when s { … } else { … }is a gated region on a switch.chain(input, name: "fx") { effect a(on: s) { x in … } … }is an effect rack whose order is parameters.c ? a : bon a signal is aselect.
- The matrix.
matrix(slots: 16, sources: Source)declares it, its sources an enum's cases.- A
@modulatableparameter read in a stage reads with its route list added.source lfo1 = …makes a source;raw(p)reads a parameter without its routes. routeListsandrouteValues(@swiftbrowser/dsp) turn an app's routes into the lists and parameters to send, leaving out one that would go round.
- What the app is told.
swiftbrowser-dsp compile x.dsp --tswritesx.program.tsbeside the program: its settings typed, each parameter's register and range,values(), the matrix and chains, and its exported constants and enums. - Editors.
syntaxes/dsp.tmLanguage.jsonis a TextMate grammar for.dspfiles.
SuperSynth is src/program/supersynth.dsp, with Serum's layout in serum.dsp; npm run dsp compiles it.
- The app imports the program, its matrix and Serum's constants (
P,RACK, the menus) from what the compiler writes, so they are kept in one place. - A preset loads into the one program as data.
buildPatchis now the compiled program with a patch's values, route lists and data, and nothing is built. - Checked against the builder it replaces: 40 random patches (knobs, routes with aux sources and output knobs, rack orders, LFO settings, voicing and glide) play the same within 3.5e-6 of their peak.
- The program (478 kB of JSON, its LFO and curve shapes left to the preset) is in the app's bundle, 740 kB minified.
Ported:
- The example and Showcase synths compile to the programs their JavaScript versions did; the Showcase ships
synth.dsp. - The parity cases are
.dsp(test/sources.ts), and render sample for sample as they did. - The exception is the big patch, whose matrix is now the language's. A source no route reads does not run, and starts from its beginning once one does, so its LFO's phase differs after a route is added.
ProgramBuilder's oldroutes,modulateandmodulationare gone with the compiler that used them.
The Swift machine's filter and oscillators vectorize#
The interpreter's stateless instructions already ran across the voices in loops the compiler vectorizes. Its oscillators and its state-variable filter did not: a branch in every iteration, the math library's tan and sin, and Swift's overflow checks on the index arithmetic each kept the loop scalar. Those were most of the time left in a voice made of oscillators and filters. (Compiling a program to C one voice at a time ran no faster than the interpreter; across the voices it ran 1.6 to 1.8 times faster, which is what showed where the time went.)
- The filter works out its coefficients with a polynomial
tan(Cephes'tanfto π/4, and 1 / tan(π/2 − x) past it, within 1.5e-6 oftan: a cutoff 0.0002% off at the top of the range), in a loop with no branch:- every frame where its cutoff or resonance moves (an envelope's cutoff);
- once a chunk where both are set once a block. The machine now keeps which registers change from frame to frame as it makes its streams (
framewise).
- The oscillators run in a loop each, their PolyBLEP corrections chosen with no branch, and the sine works out a polynomial (folded to a quarter cycle, Taylor's to x¹¹: within 2e-7 of
sin). - Index arithmetic in these loops wraps (
&*,&+): an overflow check was enough to keep a loop from vectorizing. - The JavaScript machine is unchanged. A polynomial in emulated 32-bit floats (
Math.froundeach step) runs slower in V8 than its ownMath.sinandMath.tan. - The parity test still holds every frame within 1e-5 of the JavaScript machine, but for one in a hundred at most, within 1e-3. Those are where a step reads a sine: 2e-7 of difference can put a sample on the step's other side, so the step's edge moves by a sample. In the
builtinscase,trunc(sine * 3)does that twice in 2,048 frames, and the master's comb and allpass echo each one (11 frames on a side). A step a sample earlier or later can't be heard.
Measured on a 2.1 GHz Xeon (Linux, Swift 6.4, release; best of three alternating runs, nanoseconds a voice-sample):
| Before | After | |
|---|---|---|
| The example synth (16 voices) | 31–34 | 20–23 |
| Eight sines (16 voices) | 72–78 | 51–54 |
| Eight unison voices of two oscillators, a filter a side (16 voices) | 160–168 | 134–136 |
| The big patch (8 voices, wavetables) | 198–204 | 203–210 |
| SuperSynth's init patch (8 voices) | 102–116 | 106–110 |
The big patch and SuperSynth spend their time in wavetable reads, delays and the effects, which this leaves as they were.
SuperSynth's keyboard is laid out whole, and slender on an iPad#
The keyboard placed its black keys from its measured size, so they came only once that size had gone to JavaScript and back: at launch, a moment after the white keys. They are now laid out as the white keys are, a row of the same slots, each black key filling the slot it sits after, scaled to 0.6 of it toward a point past the slot's far edge (so it ends centered on the gap) and moved on half the gap. Its corners and shadow are drawn larger by as much, so they scale back to what they were.
On an iPad the keys were stubby: the octaves were as many 40-point keys as fit, up to five, so a board 84 or 120 points tall had keys one and a half to two and a half times as tall as wide. Now the octaves are those whose keys come nearest four and a half times as tall as wide, no narrower than 22 points, up to six: six on an iPad on its side, four upright, five on a phone on its side, two upright still.
- From the layout. A
ViewThatFitsof boards of six octaves down to two, each as wide at least as that many rounds from, so the board has its octaves from its first frame rather than after it is measured. Touches find their key by the same count. - Around the octave picker's. The octaves past two go either side of the two it picks (one more above), so the picker's C3 stays in the middle and both of its ends stay within MIDI's notes.
SuperSynth's keys have even gaps, and stand as tall as the wheels#
- Even gaps. The white keys were 1.5 points apart. The page's layout floors each frame to a whole pixel and SwiftUI rounds to the screen's, so a gap of half a pixel's worth came out a pixel narrower or wider from key to key (1 or 2 on the page, 4 or 5 on a 3× phone). The gap is 2 points now, a whole number of pixels at any scale, and the keys take the difference instead, one a pixel wider than another. What a touch lands on counts the gaps too.
- As tall as the wheels. The bend and mod wheels were 120 points tall and the keyboard 84 or 120 plus its case, so they never lined up. Both are 120 points tall now, the keyboard with its case, on every screen: the keyboard no longer gives way to a shorter height (the wheels never did), and a short wide screen (an iPad on its side) no longer plays on keys 84 points tall.
SuperSynth's lit wavetable frame is drawn by the shader#
The wavetable's surface and its frames' green lines were the shader's (wavetable.shader.js), but the frame the position morphs to, lit in yellow, was three paths over it: its fill, its line and the line's glow. So it was drawn by other code than the frames around it, came a frame late (its paths waited on the screen's size), and was sent again as paths each time the position moved.
The shader draws it now, over everything else, as before:
- Where it is. A uniform,
litDepth, from the position: the table's own frame at that depth, so a position moving changes one number. - Warped, the whole stack. The warp bends every frame the oscillator can play, so the stack shows them all bent, not only the lit one: where the oscillator has a warp, the shader's table is its frames warped (worked out in JavaScript, as the warp is), 256 points across for the edges a warp makes, and sent again only when the warp or its amount change.
- Drawn. Filled from its middle to its wave, then glowing and its line 1.8 points wide, from each pixel's distance to the nearest piece of the line across as far as the glow reaches, so its corners and ends are round and a steep drop is as thick as a flat stretch.
SuperSynth's own changes are tested#
CI (ci.yml) skips a change only SuperSynth makes, and SuperSynth's workflow (supersynth.yml) built and deployed its page and nothing more, so a change to SuperSynth alone ran none of its tests. One of those changes (its lit wavetable frame drawn in the shader) left @swiftbrowser/shader's render fixtures stale, since they draw SuperSynth's wavetable shader, and nothing ran them until the next change CI did run. supersynth.yml now has a job that type-checks and unit-tests SuperSynth and the shader package, and the render fixture is written again.
A custom shape drawn from its first frame#
A custom Shape (a path drawn for its rectangle) was drawn only after its laid-out size had reached JavaScript and its path had come back for it. In the native app that is a trip across the bridge each way, so at launch SuperSynth's lit wavetable frame, its fill and the box around it came a frame or more after the rest.
Most paths are drawn from their rectangle in straight lines: a point a fraction of the way across, a margin in from an edge. So @swiftbrowser/react's Shape now works its path out at three sizes (1000 by 1000, and a thousand wider and taller) and checks it at three more, among them a tiny one where a clamp shows (a rounded corner's radius held to half the side). A path whose commands stay the same and whose every number is a constant plus a multiple of the width and of the height is sent once, as those parts (affinePath). The page and the native renderer draw it at whatever size they lay the shape out at, from its first layout. Any other path is sent as before, for the size the shape reports.
- React (
components/shapes.tsx):affinePath(path); aShapewith one reports no size and is not rendered again for one. - The page (
pathShape.ts,renderer.ts): an affine path is drawn at the element's laid-out size after each layout, and again when its props change. - Native (
AffinePathin SVGPath.swift,AffinePathShape): SwiftUI'spath(in:)works it out for its rectangle.
Every shape SuperSynth draws at launch is affine, and its page draws as it did.
A platform in the environment: the first step toward macOS apps#
The plan for macOS apps is docs/notes/macos.md: a Swift project compiled for macOS, a page that looks like a Mac window, a React app that takes the Mac look on a desktop. This step is the vocabulary every layer shares: platform, ios or macos, in the environment event, the layout environment, the document (html[data-sb-platform]), React's environment (usePlatform(), and mount's platform option, which by default is macOS in a desktop browser at the regular width) and the native root view (the OS it runs on). The CLI's --platform macos (or platform in swiftbrowser.json) makes #if os(macOS) hold in the app's sources instead of os(iOS), defines SWIFTBROWSER_MACOS, and starts the page in a Mac window: the preview's device picker gained a Mac, a 1024 × 700 point window whose 28-point title bar with its traffic lights the page draws over the app's top, as it draws the iPhone's status bar. Nothing the renderer draws differs by platform yet; the Mac idiom is the next step.
The Mac idiom: text, the title bar, the tab bar, the chrome#
With the platform macos (docs/notes/macos.md, stage 2's first slice) the page draws a Mac window's chrome in place of iOS's:
- Text. The macOS text styles (body 13, headline 13 semibold, large title 26;
MAC_TEXT_STYLE_SIZESin typography.ts) at every Dynamic Type size, with no scaling: a Mac has no Dynamic Type. - The title bar. A navigation screen's bar is the window's title bar: 52 points, unified, when the back button, bar items, the sidebar toggle or a split view's columns are in it, the title leading-aligned after the leading items at 15 semibold; the plain 28-point one, the title centered, when nothing else is. No large titles. The items are 28-point bordered buttons in slots 8 apart, no glass; on the window's own bar (the top of the screen, under the drawn title bar) the window buttons keep the first 80 points. The bar is opaque, the window's chrome color with a hairline under it, and the drawn title bar of the Mac window shows only its three lights over it.
- The tab bar. A segmented control centered in a 44-point row at the top of the content, each tab a 96-point segment with its title alone; the selected tab fills the rest.
- Colors. The window's chrome, controls and separators as
--sb-mac-*tokens underhtml[data-sb-platform="macos"], the grouped background the window color, the dark content area a Mac's.
The engine keys on LayoutEnvironment.platform (engine.ts, MAC_*), the page on html[data-sb-platform] (styles.css, the block at its end) and two flags the engine's chrome sets (data-sb-unified on a screen, data-sb-tabs-top on a tab view). Every number is a first pass, to be measured against the real app by the Mac fidelity harness (stage 3). Still to come in stage 2: the controls that change kind (checkbox, bordered button, pop-up picker), lists and the sidebar, the search field in the toolbar, sheets and alerts.
The Mac idiom: push buttons, checkboxes, pop-up buttons, lists#
The second slice of the Mac idiom (docs/notes/macos.md, stage 2), the controls that change kind and the lists:
- Buttons. A bordered button is the Mac's push button, 22 points tall with 10 either side of its label, the control color with a hairline; and every
automaticbutton outside a list row and a bar is bordered too (the engine marks it,data-sb-bordered), as SwiftUI on macOS draws one. A prominent one is the accent with white text. The control sizes scale down to 16 (mini). - Toggles. A toggle is a 14-point checkbox before its label (the engine's
checkboxrect; the page draws the accent and a check mark while on); in a list row, a grouped form's, it is the small 26 × 15 switch at the trailing edge. - Pickers. A menu picker is a pop-up button: its value and the chevrons in a 22-point bordered button (
popup), the chevrons on an accent square; 24 tall in a list row, as the row's value. - Lists. Rows are at least 24 tall (28 in a sidebar) with 4 (6) above and below their text and 10 beside it; a sidebar's rows are inset 10, a grouped form's cards 20 with a 10 radius; sections 12 apart, headers 11-point bold in the secondary color 4 above their rows; no chevrons on any row; a selected row is the accent with white text. The split view's sidebar column is 220 wide.
As before, every number is a first pass for the Mac fidelity harness to measure (stage 3). Still to come in stage 2: the search field in the toolbar, text fields, steppers and date pickers, sheets and alerts, the sidebar material.
The Mac idiom: the search field in the toolbar, the sheet as a panel#
The third slice of the Mac idiom (docs/notes/macos.md, stage 2):
- Search. A searchable screen's field is in the unified title bar, at its trailing end: 22 points tall and 180 wide (less in a narrow bar), 16 from the edge, before the trailing items; the content starts under the bar, with no field row below the title and no capsule at the bottom (the engine's
searchBarrect,data-sb-search-bar). A search field anywhere else is 22 tall too, and every one is a bordered field with the magnifier, no glass. - Sheets. A sheet is a window-modal panel hanging from the title bar: the form sheet's card at 480 × 400 (less in a small window), centered, square at the top and rounded below, with no grabber; it drops in from above.
Still to come in stage 2: text fields, steppers, date pickers, menus, alerts, the sidebar material.
One Xcode target for iOS and macOS, and a notarized Mac build#
The project swiftbrowser native init writes builds for both platforms from one target (Xcode's multiplatform app: SUPPORTED_PLATFORMS lists the iPhone, the simulator and the Mac, and the SDK follows the destination), so the same App file, asset catalog and bundle run on a simulator, an iPhone or the Mac itself, and there is no flag to choose. The target's folder is apple/ now, one folder for both, and the examples' projects were regenerated over it (ios/ moved). The Mac build has its own entitlements, apple/<Name>-macOS.entitlements: the App Sandbox with the network client, the files the viewer picks and the JIT JavaScriptCore wants under the hardened runtime, which the project enables because notarization requires it; the iOS capabilities (--icloud, --sign-in-with-apple) reach the Mac file too. The App file keeps @UIApplicationDelegateAdaptor under #if os(iOS), and the app icon set has the Mac's slots.
sb-macos.yml is the third reusable workflow (docs/native.md, "Building and deploying from GitHub Actions"): it bundles the JavaScript, archives the project for macOS signed with the team's Developer ID Application certificate and a secure timestamp, exports the app, submits it to Apple's notary service through the App Store Connect API and waits, staples the ticket, zips the app and writes a download page, deployed to the mac alias of the Pages project (https://mac.<project>.pages.dev) beside the web build and the iOS install page. Without the Developer ID secrets the app is still built and signed ad hoc, as the run's artifact (not notarized or deployed), and CI's native job builds the examples and a new app for macOS unsigned, so the Mac target is tried without any certificate. swiftbrowser native init --github writes a macos.yml caller beside web.yml and ios.yml; showcase-macos.yml calls it for the Showcase, by hand and on main when the app or the renderer changes. Secrets: APPLE_DEVID_P12_BASE64 and APPLE_DEVID_P12_PASSWORD, with the team id, the App Store Connect key and the Cloudflare token the iOS build already uses.
The Mac fidelity harness#
What the Mac idiom's numbers are measured against (docs/notes/macos.md, "Measuring"): Examples/Fidelity built for macOS 14 with swiftc, launched once per screen and appearance with -screen and -shot (scripts/mac-screenshots.sh), writes its own window's image, the title bar included, and exits (WindowShot in its App file; the app's own window needs no screen recording permission, and no simulator is involved). The page, with the site built --platform macos (scripts/build-wasm.sh's SB_PLATFORM), is shot in the Mac window by fidelity-screens.mjs --platform mac, and the two sets are put side by side with the differing pixels by .github/workflows/mac-fidelity.yml, run by hand like the iOS one. For the app to build on a Mac its iOS-only calls go through Sources/Compat.swift (.barTrailing, .barLeading, .barBottom, .inlineTitle()): the Mac's placements on macOS, the very same calls on iOS and in the browser built for iOS, so the ops the app sends there are unchanged; its iOS 26 checks say macOS 26 too.
The Mac idiom: text fields, steppers, alerts#
The fourth slice of the Mac idiom (docs/notes/macos.md, stage 2): a text field is 22 points tall in every style, bordered in every style but plain (the control color, a 5 radius, a focus ring in the accent); a stepper's control is the Mac's 13 × 22 pair of arrows, up over down, 4 after its label (the engine's arrows rect, the increment above the decrement); an alert is a 260-point panel (the engine's panel rect) in the window color with a 10 radius and a shadow, its title and message centered at 13 bold and 11, its buttons 22-tall push buttons 16 in, two side by side 12 apart with Cancel leading and the default one in the accent, more stacked 8 apart. The alert's metrics are a table per platform now (ALERT_METRICS, MAC_ALERT_METRICS). Left in stage 2: sliders, date pickers, menus, the sidebar material; every number waits for the Mac fidelity run.
The Mac idiom: sliders, date pickers, pull-down menus#
The fifth slice of the Mac idiom (docs/notes/macos.md, stage 2): a slider is a 20-point row with a 4-point track and the Mac's 20-point round knob (the engine's knob rect); a compact date picker's date and time are 22-point bordered fields 6 apart with 6 beside their text (fields); a menu outside a bar and a list row is a pull-down button, 22 tall with 10 beside its label and the chevrons on an accent square after it (pulldown), while in a bar item or a list row it stays the label it was. Stage 2's controls are all drawn now; what is left is the sidebar material and, once the Mac fidelity run has screenshots, every number against them.
AppKit in the shim, for apps built for macOS#
Stage 3's first piece (docs/notes/macos.md): import AppKit compiles in a build for macOS. Sources/AppKit is the UIKit shim's types under their Mac names, so a color, an image, a font and a pasteboard are the same objects whichever framework the app names them through: NSColor is UIColor with the Mac's semantic colors (windowBackgroundColor, labelColor, controlAccentColor…) mapped onto the page's, NSImage(systemSymbolName:accessibilityDescription:) is UIImage(systemName:), NSFont is UIFont with the Mac's sizes, NSPasteboard.general reads and writes UIPasteboard.general, NSWorkspace.shared.open opens links as the application does, NSApplication and @NSApplicationDelegateAdaptor make and launch the delegate once, NSAppearance.current is the page's color scheme, and an NSViewRepresentable (or view controller representable) is drawn as a UIViewRepresentable is, its view a UIView. The open and save panels cancel (the file importer and exporter are the way). Color(nsColor:) and Image(nsImage:) bridge as the UIKit ones do. The CLI links the module only in a build for macOS (macOnlyFrameworks), so an iOS build keeps canImport(AppKit) false and its #if canImport(UIKit) branches as they were.
The sidebar material: a sidebar list on a Mac sits on the sidebar's lighter gray (--sb-mac-sidebar), not the grouped background.
SwiftUI's Mac-only API in the shim#
The rest of stage 3's surface (docs/notes/macos.md): Settings, Window and MenuBarExtra scenes (a Window shows as a WindowGroup does when it is the first scene; the settings window and the menu bar item are declared and never shown, as a page has neither), the window's .windowStyle, .windowToolbarStyle, .windowLevel, .defaultPosition and .commandsRemoved (accepted; the page draws the Mac idiom's title bar), HSplitView and VSplitView (stacks, not draggable), .navigationSubtitle (kept; not drawn yet) and .onContinuousHover with HoverPhase (nothing reported, as onHover). The names compile in an iOS build too, as SwiftUI's do.
The Mac idiom measured against the Mac app#
The Mac fidelity harness ran (docs/notes/macos.md, "Measured"): the Fidelity example as a Mac app on CI's runner against the page in its Mac window, 31 screens in both appearances. The page's Mac numbers were a first pass; they are the Mac's now. The window's title bar is white with a rule under it over a #f6f6f6 window; the unified bar's first slot starts 90 in, its trailing items end 13 from the edge 10 apart, the back button is a bare secondary chevron, a text item a bordered 28 button; a tab view at the top of the window puts its picker in the window's 38 toolbar and the tab's stack draws that row as its bar. Lists lost their cards: full-width rows on white, 16 in, separators under every row, an 11-bold header with a rule across the list, a Label with its symbol at the point size and no icon column, a checkbox before its label in a row, a push button at the row's leading edge. The segmented control is 22 with 13 regular labels and shows its label; a plain button's label is secondary; a sheet is a 470 panel centered in the window at its content's height with a 40 title bar and its cancel and confirm actions in a 60 bar at the bottom; an alert's buttons are 28 and gray under the app's icon. The comparison's differing pixels went from 3–47 % per screen to 1–6 %.
The harness itself needed four fixes first (the Fidelity example's iOS-only API behind Compat.swift, the window at 1024 × 700 with sheets and alerts in the shot, 1× comparisons) and the runs found two CLI bugs: --platform never reached the app loader, so every macOS build had been an iOS one, and "platform" in swiftbrowser.json was refused. fidelity-screens.mjs --only a,b takes a few screens, for iterating locally against a downloaded mac-screens artifact.
The Mac's Form, and the subtitle#
A Form on a Mac is the columns style (docs/notes/macos.md, "The Mac's Form"), measured in the Mac app: labels right-aligned in a column before their controls, no cards or insets, on the window background, centered in the window when shorter than it. The shim's and React's Form mark their list form: true; the engine's macFormPlan lays the rows out (a text field's title, a picker's, a stepper's, a date picker's and a slider's label in the column, the control alone at the controls column; a stack with such a control shifted to it), the page draws the column's texts as formLabel spans. .navigationSubtitle is drawn: the shim and React carry it to the screen (subtitle), a unified title bar stacks it under the title at 11 regular, a plain bar joins it to the title after an en dash. The native renderer draws a form: true list as the system's Form (which the round trip's shim re-emits with the flag) and a screen's subtitle with .navigationSubtitle on a Mac.
The Mac idiom on macOS 26#
The user compared the Mac look with System Settings on macOS 26 and found it a design generation behind. The page had been measured on CI's macOS 15 runner, and only on iPhone-shaped screens. The Mac fidelity harness now runs on macos-26 (docs/notes/macos.md, "Measuring") and takes three Mac-shaped Fidelity screens: a sidebar beside a grouped form, a grouped form of controls, and folders beside a list. It also compares the Showcase's native Mac app, walked to each screen by its screen script, with its web page in the Mac window.
The page now draws macOS 26 (docs/notes/macos.md, "Measured"):
- A white window with no title-bar background, and 26 corners with a 52 toolbar (16 with the compact 32 bar).
- Toolbar items in 36 glass capsules, with the back button the first slot of the leading one, and a 325 glass search field.
- The tab picker as a glass capsule in the toolbar.
- A floating 140 sidebar panel with gray-pill selection and 32 rows.
.formStyle(.grouped)as System Settings' cards, which neededformStylecarried from the shim and React to the page.- Capsule push buttons (24, 28 large), content-sized segmented controls, and pop-ups the widest option plus 43.
- Sheets with a 48 title bar and a 26 radius.
- Alerts without the app icon, their text leading and 13 on glass, centered in the window.
Most screens now differ from the app by 1–4 % of pixels; the rest is mostly fonts.
The native renderer on the Mac, after the Showcase comparison#
Comparing the Showcase's native Mac app with its web page found two things in the native renderer. A navlink row in a list drew iOS's chevron, which a Mac's link row has no room for; it now has none on macOS. UIKit's system colors were fixed light values on macOS, so secondarySystemGroupedBackground cards (Reminders) and a secondarySystemBackground bar (Voice Memos) stayed white in dark mode; each is now its light and dark value, as the web renderer's Mac idiom draws it.
No bottom bar on the Mac#
A Mac has no bottom toolbar: SwiftUI's .bottomBar is iOS's, and the native renderer places those items as .automatic, at the toolbar's trailing end. The web Mac idiom drew them as iOS's floating bottom capsules; now the engine's barPlacement puts them with the trailing items, in order, a spacer splitting their capsules, and the content runs to the window's bottom. Toolbar items also keep the toolbar's colors whatever their .tint, as SwiftUI on macOS 26 draws them (Reminders' tinted "New Reminder" is gray there). The web should always match the native renderer.
A Mac app's list rows, by defaultMinListRowHeight#
The Showcase's folder list looked denser than Apple's Mac apps: the default list (inset grouped, which the Mac has no style for) is SwiftUI's inset one with its own 24-point rows, and Apple's apps space a content list's rows like a sidebar's, 32. The renderers keep SwiftUI's default; an app asks for more the SwiftUI way, .environment(\.defaultMinListRowHeight, 32), which now reaches both renderers: the shim sent it already (the list's minRowHeight, which the web engine honored), React's List takes minRowHeight, and the native renderer sets the environment on its list. The Showcase gives its content lists 32 on a Mac (usePlatform), so its folders, notes, reminders and files are spaced as a Mac app's. That turned up a runtime bug: the native runtime (run.ts) dropped the platform the native root view sends with its environment, so usePlatform said ios in a native app on a Mac; it is forwarded now.
The Mac list's inset, header rule and last row#
Measured against the native Showcase on macOS 26, the page's Mac lists were off in three places: a row with listRowInsets of zero ran to the list's edges, while SwiftUI's inset style keeps its own 16 (the Notes search field); a section's header had no rule under it, since the page's rule hung off a hidden header element and never drew; and the last row of the list had a separator under it, which SwiftUI leaves out. Now the Mac list's rows are inset 16 as the list's own inset, with no cell padding of their own, a rule crosses a section's rows at its first row's top under a text or view header, and the list's last row has no separator unless a footer or another section follows. The first row starts 10 under the top, a header at the top 4 higher (Fidelity's lists, real SwiftUI).
The sidebar's width, and dragging it on a Mac#
The Showcase's Mac sidebar looked narrow: 140 is what SwiftUI gives a split view's sidebar by default, and Apple's apps ask for about 200 with .navigationSplitViewColumnWidth, which the shim ignored, React had no prop for, and neither renderer honored. Now the modifier is a splitColumnWidth hint on the column content's styled wrapper ({ min?, ideal, max? }; the fixed form sends all three): the shim sends it, React's NavigationSplitView takes sidebarWidth (a number or { min, ideal, max }), the web engine sizes the sidebar at the ideal within the bounds and the 40% cap, and the native renderer applies SwiftUI's modifier. A Mac lets the user drag the sidebar's edge, so the page does too: an invisible strip astride the panel's trailing edge drags the width between the column's min and max, re-laying the split out each frame, and keeps it. The Showcase asks for 200 on a Mac.
The native Mac screenshots then showed the sidebar still 140: SwiftUI does not read .navigationSplitViewColumnWidth from inside the column's NavigationStack, where the styled wrapper puts it. The native split view now finds the hint on the sidebar's content and applies the modifier to the column's root, as SwiftUI documents it, so the native and web sidebars agree at 200.
The sidebar's top band is SwiftUI's own#
Asked how both apps would turn off the window-white strip at the top of a Mac sidebar, the answer measured on the macos-26 runner is that they can't: six Fidelity variants (the window toolbar's background hidden on the list and on the split, no navigation title, the title removed from the toolbar, the list ignoring the top safe area, and the window toolbar hidden outright) all keep the strip, and the list that ignores the safe area scrolls under it. SwiftUI's sidebar column draws it on its own; Apple's full-height sidebars are AppKit's. Both renderers keep matching real SwiftUI. The shim now accepts .toolbarBackgroundVisibility(_:for:), .toolbar(removing:) and the windowToolbar placement, so apps that use them compile (they change nothing, as on a Mac they changed nothing).
Control values: what follows from a knob, worked out by the program#
SuperSynth's JavaScript used to work out a dozen values from the knobs and send them as parameters: the glide's switch, the bend's reach, the envelopes' curve exponents, each oscillator's unison voices, whether anything goes through the filter, the compressor's resting level, and which parts run. Every knob that fed one had to call back into the app (VALUE_KNOBS), and an AU or VST host, which only sets parameters, would have left them stale. A first try made them derived parameters, but a parameter is something the app sets, so they are control values instead.
- Language. A top-level
letis a control value: arithmetic on the parameters' set values (not their glides or routes) and constants, or an array of them, typed ifchooseneeds its options (let voices: int(1...4) = …). A condition written in place inwhen,choose,voicingor an effect'son:is one too. Control values are not parameters, and the TypeScript leaves them out;meta.controlsnames their registers andnamedControlsworks them out as the machines do. - Format. A program carries
controlCode(pure opcodes only) andcontrols(the registers the rest of it reads). Regions, choices and voicing name a control: a parameter's index, or the parameter count plus a control's index. - Machines. Both run the control code at a block's start, but only when a parameter it reads was set to a new value, and fill a control's registers only when it changed. A knob the controls don't read, such as the cutoff, costs nothing extra; one they do read costs about 2 µs in JavaScript. A
controlsparity case checks that the machines agree. - SuperSynth. supersynth.dsp works these values out from the knobs. The app sends only data: which Serum saved the curves (
curves.newer) and which parts a route moves (part.routed.s<i>).unisonPlan,curveValues,wantsandVALUE_KNOBSare gone. The import report reads the unison from the program (patchControls). A test compares the program's values with the old JavaScript over 300 random patches. The bend knobs now take effect as they turn; before, the app read them only when a preset loaded. - Perf. For the same patch, both machines schedule the same instructions as before (JavaScript: 816 sample and 1136 block words for a busy patch). Release Swift timings with eight voices are within noise of main: best still blocks 148 µs against 142 µs, and with two knobs automated every block, 164 µs against 164 µs.
Where the mouse is: onContinuousHover#
onHover said that a mouse was over a view, not where, so an app drawing collaborators' pointers could show them only while a finger or button was down. onContinuousHover(coordinateSpace:perform:) now reports as SwiftUI's does: a styled box with continuousHover: "local" | "global" sends continuoushover events, active with the location (in the box's own coordinates, or the root's, scrolling included, the same a reportsFrame geometry reader reports) once per animation frame as the mouse moves, then ended once as it leaves; touch never hovers. The web renderer's HoverTracker follows the marked boxes under pointermove; the native package's ContinuousHoverReport wraps SwiftUI's own modifier. @swiftbrowser/react takes a function, or { coordinateSpace, action } with a named space resolved as a drag's is. RemoteTree forwards the events like any other, so an app in a sandbox hears them too. The Swift shim's onContinuousHover stays a name that compiles and reports nothing, as the page it draws has no pointer.
The DSP language, reviewed before production#
With no .dsp program in production yet, the language was reviewed end to end (docs/notes/dsp-language.md, "Reviewed before production") and changed where it could compile a program the author did not write, or where a word carried two meanings. Nothing changes what a program compiles to: every shipped program, the parity sources and the Showcase's synth compile to the bytecode they did, and SuperSynth, whose source moved, renders the same samples for the same patches.
control. A top-levelletwas a control value and a stage'sleta binding of any rate. Control values are now declared withcontrol name = …; aletat the top level says so, andconst x = knob * 2points tocontrol.- A voice's inputs bind by name, any of them in any order.
voice(freq, gate, note)used to bindnoteto the velocity. - Refused, with a line: a fold to infinity or NaN (which reached the JSON as
nulland failed at load); a range gone over with fractional bounds (0..<2.5iterated 0 and 1);a < b < c; a builtin's name as a value's at any level (SuperSynth hadlet delay,let signand a parameternoise); assigning a parameter, now named as one. - Imports by path (
import "../lib/reverb" { … }, found from the importing file), and a standard library built into the compiler,import std { pan, glide, reverb }, written in the language. - Units.
stis gone (it made a ratio, whichnote + 12stread as nonsense);ms,s,hz,khzanddbstay, spellings of a number, not dimensions. - For an app's knobs:
@label,@unitand a///comment above a parameter go into the metadata and the TypeScript, as the setting's doc comment. - Labels in any order. An argument to a function, a closure or a builtin is given by position or by its parameter's label; the labeled ones go where they say, and the unlabeled ones fill the parameters no label named, in order. Closures took no labels before, and a positional argument after a labeled one could fail as "given twice".
- Docs: the default is 16 voices, not 8; the declarations' words are contextual, not keywords; the builtins' first argument is
input, as its label is; awhen'selseis built always but runs only while the region is off.
canImport(AppKit) holds in a build for macOS alone#
Stage 3 of the Mac work put an AppKit module in the shim, linked only in a build for macOS so that canImport(AppKit) would stay false on iOS. The compiler answers canImport from the module search path, though, not from what is linked, and the kit kept every module in one directory passed with -I: every build had canImport(AppKit) true beside canImport(UIKit), which no Apple platform has. A package with a declaration under each compiled both, and main's CI went red from #422 on: RevenueCat's StoreKit2ConfirmInOptions (a stored property under each, so the memberwise initializer wanted both) in the CLI's RevenueCat fixture, and SFSafeSymbols (an initializer under each, redeclared) in Ice Cubes.
The kit now keeps the Mac-only modules (MAC_ONLY_FRAMEWORKS, AppKit) under Modules/macOS, which a build for macOS alone searches (kitSwiftFlags takes the platform; appFrontendFlags adds the directory for the WebAssembly compiler; the probes that import every module search it too), and its format is 2. An iOS build answers canImport(AppKit) false again, as an iPhone does. The RevenueCat patch keeps an eighth edit giving the options an initializer for each, which a build for macOS, where both hold, still needs.
That alone left Ice Cubes red on CI, where the kit is built in the same job: a binary module records the search paths it was compiled with, and the compiler searches them too when it loads the module, so every kit module led back to the builder's products directory, where AppKit sits beside the rest, and RevenueCat (importing SwiftUI) found canImport(AppKit) true and imported it, which the app's own compile then could not find. The kit is built with -no-serialize-debugging-options, so its modules carry no paths (format 3).
The master stage's block stream#
The builder put every master-stage instruction in the master stream whatever its rate, and the machines' schedule-time hoisting (rerate) ran only on the voice stream, so a knob's curve in an effect (hertz(knob), an EQ gain's 2 ** (…)) ran on every frame. Both machines now hoist the master stream too: what reads only what is set once a block (the parameters and the newest note's inputs; the voices' sum changes every frame) runs once a block in the master stage's one lane, before the chunks. Nothing a program computes changes, so the parity fixtures stand.
Measured with Swift 6.4 on the same shared 4-core Xeon VM as before, release build, best of several runs: SuperSynth with eight voices, two unison oscillators and all ten effects on went from about 0.68 to 0.65 ms a 256-frame block, a gain of about 4%, within the machine's noise; the big patch and the example synth did not change. Of SuperSynth's 295 master instructions a chunk, 122 moved (17 exp2 among them), fewer than the estimate had hoped would matter: the arithmetic is cheap next to the builtins.
What the measurements found instead is where the effects' time goes. SuperSynth's cost splits into about 0.39 ms for the voices and 0.27 ms for the effects, and a micro-benchmark puts an instruction's dispatch at about 13 ns in either machine path: the chunked path spreads it over 16 frames (0.9 ns a frame for a madd), while the serial part, the instructions feedback through state needs, pays it on every frame. SuperSynth's effects keep 62 instructions a frame in that part (the flanger's, phaser's, chorus's and delay's state cell loops), about 0.2 ms of the 0.27. A dedicated serial path with its operands resolved once a chunk, or writing such loops with comb and allpass (whose feedback is inside the builtin), is the next step; the voices' time is in the wavetable reads themselves.
The wavetable kernels, a lane at a time#
Measuring where SuperSynth's voices spend their time (a scratch benchmark of twelve of each builtin a voice at eight lanes, Swift 6.4 release on the shared Xeon VM) put wavetable at about 12 ns an element against 1.3 for a phasor and 1.9 for a saw, and its twelve reads a voice at about three quarters of the voices' cost. The read cannot vectorize across lanes (its table loads are gathers), so it is scalar work, and the kernel did a frame's worth of it for every element: the phase read from and written back to state, the level checked, the position clamped and split into its two frames. The Swift machine's wavetable and tableread now go a lane at a time, the phase kept in a register over the chunk's frames, and where the frequency or the position is set once a block (the usual, as the framewise marks say) the level and step, or the two frames, are worked out once a lane. The arithmetic is the same either way, so the samples are: the parity fixtures stand. Per element, a read of a 1- or 16-frame table went from about 13 to 10.4 ns and of a 256-frame table from 18 to 13; SuperSynth's voices from 0.41 to 0.35 ms a block. The JavaScript machine keeps its kernel: its values are the same, and its cost matters less.
Two things the measuring turned up besides. The Linux build targets baseline x86-64, which has no rounding instruction, so the oscillators' loops did not vectorize there: built for a CPU with SSE4.2 (-Xswiftc -target-cpu -Xswiftc nehalem, 128-bit like NEON), a phasor goes from 3.1 to 1.3 ns an element and the example synth from 0.127 to 0.076 ms a block. A phone's arm64 has the instruction, so the Linux numbers in these notes overstate the oscillators' share. And the serial part's cost is dispatch, not arithmetic: 60 feedback steps that do not depend on each other cost about 9.5 ns an instruction-frame, a chain of dependent ones 12.4, against 1 for the same madd over a chunk. Running the serial part's frames in one call rather than one a frame changed nothing there and slowed the chunked path, so the per-frame dispatch itself is what a faster serial part would have to shed; SuperSynth's effects keep 62 instructions a frame in it, about 0.2 of their 0.26 ms.
SuperSynth's flanger is a comb#
The flanger was written as a delay fed back through a state cell, the one effect of the rack that a builtin says outright: comb(y, seconds, feedback, 0, 0.01) a side, its feedback inside, so it runs over the chunk rather than frame by frame in the serial part. A state read is last frame's value, so the loop it fed back through was a sample longer than the delay; the comb's is the delay exactly. The notches move by well under a percent, inaudible, and the program is six registers smaller. The phaser's loop (four all-passes), the chorus's (two taps through a one-pole) and the delay's (a band in each line) are no builtin's shape, and stay as they are.
SuperSynth's program, tidied#
Read again after the language review, the program had a few things the language now says for it. wet, a closure mixing each side, was mix, which goes side by side on its own, so hyper no longer takes it as a parameter; the four oscillator switches (choose(knob[P.oscOn + k], steps: 2) { on in on == 1 ? x : [0, 0] }) are one switched(index, x); panned takes a pair as well as a mono value (x * [1 - pan, 1 + pan]), so the noise's balance is a panned too; the EQ's, filter's and compressor's decibel knobs read dbtoa(…) rather than 2 ** (x * (log2(10) / 20)); the distortion's cutoff is hertz(knob) like the others'; the glide's 0.6931471805599453 is log(2); and a 0 + and an arguments array went. Over sixteen random patches with the effects on, the samples are the committed program's to within 3e-8 (the compressor's threshold constant folds in another order), and the program is two registers smaller.
SuperSynth's phaser is a phaser, and its reverb Freeverb's#
The effects were written to Serum's panels, not its processing, and two of them were not the effect their name says. The phaser was four allpass builtins, which are Schroeder's delay-line all-passes, a reverb's diffusers: white noise through it at a fixed sweep showed twelve notches spread from 180 Hz to 13 kHz, a comb, where a phaser has a few that move. It is now four first-order all-pass stages (allpass1: twice a one-pole low-pass less the input, written as one mix at −1), swept two octaves by the depth knob and fed back as before, and the same measurement shows two notches, at about 350 Hz and 2.3 kHz for the knobs' middle. The reverb was Schroeder's 1962 design, four combs and an all-pass a side, which rings metallic for want of echo density. It is Freeverb's now: eight damped combs and four all-passes a side at Freeverb's times, the right side's lines 23 samples longer for width, with SuperSynth's size (stretching the lines and feeding the combs back more), damp, pre-delay, low and high cut and width knobs as they were. A short note with the reverb alone decays as it did, within a few percent, and at the same level. With every effect on the master stream grows from 169 to 201 instructions a chunk and its serial part from 54 to 62 a frame (the phaser's stages feed back), about 60 µs more a block on the Xeon VM.
A text system shaped after TextKit 2#
The start of a code editor (docs/notes/textkit.md): line numbers and long files were the requirements, with no third-party editor in the page and one JavaScript surface to drive both renderers, so the editor's logic is written once. The surface mirrors TextKit 2's objects with offsets for locations: TextContentStorage (the text by paragraph, one replace edit), TextLayoutManager (paragraphs laid out into line fragments as they are asked for, carets and hit tests, rendering attributes over ranges for a highlighter, a navigation by grapheme, word, line, paragraph and document that keeps its column going up and down) and TextViewportLayoutController (the viewport's paragraphs and an overscan, no others, the rest at estimated heights). The web engine under Web/src/textkit keeps paragraph lengths and heights in Fenwick trees, so a hundred thousand lines index in milliseconds and a keystroke costs the engine's copy of the text. This milestone is the engine and its tests; the view with its gutter and contenteditable input, the shiki worker in an optional package, and the native engine over NSTextLayoutManager follow in that order.
The code editor's view on the page#
@swiftbrowser/code, an optional package like shader and dsp: CodeEditor, a registered view with line numbers for long files, on the text system. The editor's logic is EditorController, written once for both platforms with no DOM (a selection whose head keeps its column going up and down; typing, Return keeping the indentation, deleting by character, word and line; Tab and Shift-Tab; undo joining keystrokes, redo; the Mac's keys and the others'). The page's view draws the viewport's fragments as placed lines in a contenteditable the browser gives its caret, selection, keyboard and IME, the gutter stuck to the left, and sends each edit as a delta; the app-side wrapper applies the deltas to its mirror and hands the app the text. Writing it found that the engine kept a paragraph's line ranges as absolute offsets, stale after an edit before it; they are offsets from the paragraph now. The Showcase's Code screen opens a three-thousand-line Swift file in it on the page (the native view is next).
The code editor colors its text#
@swiftbrowser/code highlights: shiki's TextMate tokenizer in a worker (the page's Worker over the package's entry; natively the host's over the bundle an app names highlighter, run in a WKWebView for its JIT and WebAssembly), each line's rule stack kept so an edit re-tokenizes only until the lines after it are as they were, in slices between messages so a long file never blocks an edit. Grammars and themes load on the page lazily and cross once; the text crosses once and each edit after, as paragraphs replaced; the viewport's lines come back as tokens the view applies as rendering attributes after each layout. CodeEditor takes language (forty of shiki's grammars by name and alias, registerLanguage for the rest) and theme (shiki's, GitHub's light and dark following the page's scheme by default, coloring the chrome too; colors overrides). Two engines: shiki's JavaScript regex engine by default, Oniguruma's WebAssembly as a second worker entry (configureHighlighter({ engine: 'oniguruma' }) on a page; the entry a native app bundles). Without a worker the engine runs inline, and a worker that fails before answering hands over to it.
The code editor's native view#
SwiftBrowserCode, an optional package like the shader's: CodeEditor natively, a text view on TextKit 2 (UITextView on iOS, NSTextView on the Mac) with a gutter of line numbers drawn beside the layout fragments on screen. The view edits its text itself and reports each edit as a delta in UTF-16 offsets, heard from the storage as its delegate, a LineIndex of line starts kept in step; Return keeps the indentation and Tab inserts the indent unit. The highlighter stays in JavaScript: the view says which lines are on screen, the app-side CodeEditor follows the edits by paragraph, asks for those lines and hands the tokens down as a prop, laid over the lines as the storage's colors; its worker is the host's, run in a WKWebView, bundled by the app as highlighter (swiftbrowser-native build --worker highlighter=@swiftbrowser/code/highlighter.worker; a bare specifier is a worker entry now). The core (props, line index, deltas, colors) tests on Linux; swiftbrowser native init --with code links it; the Showcase's Code screen is the editor on every platform.
SuperSynth: a knob event re-renders the knob#
The plugin plan (docs/notes/plugins.md, "Measured: a knob dragged") found that every knob event in SuperSynth ended in redraw(), which re-rendered the whole panel (2,905 nodes) before anything was laid out or drawn, about 20 ms under V8 and 140 in QuickJS, where the in-memory renderer wants a frame in 16 ms. The knob's position was in the patch's raw array, a plain array the root re-rendered to show; so were the matrix's amounts and the voicing.
They move through a PatchStore now (Native/Examples/SuperSynth/src/patchStore.ts): the same array, the same route objects and the same voicing, kept where the patch keeps them (so applyPatch, patchFrom, sync and the tests read what they did), with a version and a subscription per key: a knob (k<index>), a route's amount (r<index>), the routes aimed at a knob (d<index>, its modulation ring) and the voicing. A knob, a value box, an oscillator's screen (its position and warp), an envelope's screen (its times and curves), the filter's screen (cutoff and resonance), a matrix row and the voicing plate are small components that read the store through useSyncExternalStore and re-render when their keys move; the root subscribes only to the knobs that shape the panel (SHAPE_KNOBS: a part's switch, an oscillator's unison, a warp mode, the filter's type, the effects' switches). set() sets the store and the program's parameter, and redraws the panel only for NOTED_KNOBS, whose report the root shows; setRoute() and setVoicing() set the store and send the program what moved (the voicing's five parameters diffed against what was sent, as sync did for everything). What re-renders the panel on purpose (a preset loaded, a route added or flipped, the rack reordered, an LFO's settings, a table drawn) still does. The pixels after a drag are what they were: the CLI's screenshots before and after the change are byte for byte the same, at rest and after six drags, as are the Node session's.
Measured on the shared Xeon VM, SuperSynth's Native bundle at 1194 × 834 points, 2× (a plugin window), the OSC A level knob dragged 96 points up or down in ten steps (nine drag events) six times. swiftbrowser-shot --verbose now prints how long each script command took (the only change to packages/raster; the session's hit test also needed the fix the plan notes, content over a box's background, applied locally for the measurement and not in this change). Under V8 the app is mounted in Node through @swiftbrowser/native's run, so it gets the environment a native host gives it and lays out as the CLI does (scripts/knob-bench.mjs, React's production build), the session's time split from the app's:
| Per knob event | Before | After |
|---|---|---|
| QuickJS, the CLI: handler, render, layout and commit | 340–430 ms (3.1–3.9 s a drag) | 240–310 ms (2.2–2.8 s a drag) |
| V8: the app (handler and React render) | 33–47 ms | 4–7 ms |
| V8: the session (layout and its commit steps) | 20–33 ms | 20–32 ms |
Passes (applyOps batches) |
0.9 | 0.9 |
| Ops | 4 | 4 |
The passes and ops are the same because the committed tree was already right: the whole panel re-rendered and diffed to the knob's four ops. What went is the render, about 35 ms of the app's 40 under V8 and about 120 ms under QuickJS; of the app's 5 ms left under V8, the profile shows the host tree's flush walking the tree for changes and the knob's own render, with the layout engine (plan, measure, layoutStack) and the garbage collector taking the rest of a frame. The first drag of a run shows fewer passes (0.4) because the knob reaches 1 after four events and the rest change nothing. The next things, per the plan, are the session's: a layout that revisits only what changed, and a paint of only the damaged region.
Slots, state, macros and snapshots: the plugin's foundations in the language#
The first stream of the plugin plan (docs/notes/plugins.md, foundations 2 and 3). Three additions to the .dsp language, each carried into the metadata and the TypeScript: @slot(n) pins a parameter to one of a host's 512 parameter slots (two on one slot, or one in the macros' eight, is an error; [i in …] declarations interpolate the index); @state marks preset state rather than a performance control, saved and restored but never given a slot (a chain's order and a route's source, aux and output are state without saying so); and macro N -> p maps one of eight host macros to a parameter of the program's own, or macro N -> [p: 0.5, q: -0.25] to modulatable destinations by amount, the macro then a parameter the destinations' reads add, as a route adds. matrix(…, amountSlots: 310..<326) pins the routes' amounts. slotMap(meta, previous) (@swiftbrowser/dsp/slots) then gives every performance parameter its slot: pinned first, then sticky by name from the program loaded before, then free slots in declaration order.
A snapshot (@swiftbrowser/dsp/snapshot, format version 1) is a program and its state without JavaScript: the compiled program's JSON, everything a patch sets by name (parameters, table frames rather than levels, shapes, route lists, samples), the metadata and the slot map. SnapshotRecorder is the target applyPatch writes through; loadSnapshot builds a JavaScript machine from one, and DSPSnapshot (SwiftBrowserDSPCore, Snapshot.swift, its own file beside the Foundation-free work) a Swift machine. Snapshot fixtures beside the parity ones, and SuperSynth's Init preset's, check that the Swift machine plays a snapshot as the JavaScript machine plays the patch. SuperSynth's program pins its knobs to their Serum indices (0 to 298), the wheels to 300 and 301 and the route amounts to 310 to 325, marks the rest of what a preset sets as state, maps Serum's four macro knobs, and writes its factory presets (the init patch and three stand-ins made from it) as snapshots at build time (npm run snapshots). Its compiled program is byte for byte what it was: nothing changes what a program computes, and every parity fixture stands.
The in-memory renderer lays out what changed#
Measured on 2 November 2026 toward a live plugin editor (docs/notes/plugins.md, "Measured: a knob dragged"): SuperSynth's bundle in swiftbrowser-shot at the plugin window's 1194 × 834 points at 2×, a knob dragged ten steps, each step a commit of four ops. The session laid the whole tree out at every commit, 2,905 nodes in about 360 ms under QuickJS, where a frame wants 16. The web renderer has had incremental layout since Phase 9 (LayoutPass, kept across commits and told what the ops touched); the session now keeps one pass too, told by its tree as the ops arrive (OpsTree.observer: an update invalidates the node, its ancestors and its descendants, an insert the parents on both sides and the moved subtree, a remove drops the subtree), and lays out again only what a commit changed, exactly as the engine's protocol requires (a changed child and every ancestor up to the root are measured again; a sibling whose proposal and origin are the same is kept). An environment change starts a fresh pass. The steps after a layout (focus, scroll commands, the geometry reports) walked the tree four times to find a few nodes; the session indexes those nodes as the ops arrive, and collects the images of the nodes a commit touched rather than every node's.
The harness is in the code so the numbers repeat: swiftbrowser-shot --verbose times each command and prints each commit's cost (ops applied, layout with the nodes placed and kept, the steps after), --full-layout lays the whole tree out at every commit to measure against, and packages/raster/bench/knob.mjs runs the knob script and prints the medians. On the shared Xeon VM, a knob commit went from 362 ms (ops 1.0, layout 359 with 2,119 nodes placed, steps 5.1 before the index) to 9.0 ms (ops 1.0, layout 5.9 with 47 placed and 26 subtrees kept, steps 1.9), and a ten-step drag from about 4.2 s to 1.4 s; the rest of the drag is the app's own JavaScript re-rendering its whole tree on every knob event, and the paint of the whole frame, each a stream of its own. The layout tests, the renderer's tests (two new ones drive a slider by drag and structural changes and check the live result against a fresh full layout, map by map and pixel by pixel) and the pixel comparisons with Chromium (at rest, scrolled, tapped into a detail, the long screens scrolled to their charts) are unchanged, to the hundredth of a percent, except the more screen's Canvas clock, which varies between two runs of the same code.
Found on the way: the session's hit test walked a .background { } box's children content-first in paint order but reversed, so the background was tested before the content and every point in SuperSynth hit the root ZStack's full-window Color; paintOrder now puts a decorated box's background decoration under its content, as the painter draws it, with a test.
The code editor colors what is about to appear, and scrolls sideways on iOS#
Seen on an iPhone: the text wrapped though the switch said not, and never scrolled sideways; lines came up plain until colored. A UITextView scrolls only up and down and wraps at its width, so on iOS it sits in a scroll view that moves it sideways, the view as wide as its longest line (LineIndex.longestLine times a character's width, the font being monospaced), wrapping only when asked. The highlighter's engine goes on through the whole text between messages, so a request finds its lines known and an answer is a round trip away; the views ask further ahead in the direction they scroll than behind (the native one while scrolling, throttled, its tokens applied at once since they edit nothing now); preloadHighlighter loads grammars and themes as the app starts, and the app-side wrapper asks for the first screen before the native view has said what it shows. The Showcase preloads Swift's.
The in-memory renderer paints only what changed#
Toward a live plugin editor (docs/notes/plugins.md measured a SuperSynth knob frame at 234 ms of painting in wasm, 350 natively, for a few thousand changed pixels), the rasterizer keeps a frame between renders and repaints only the damage (docs/raster.md, "Painting only what changed"): the new display list is diffed with the last op by op as bytes, each op's token carrying the hash of the transforms, clips and layers open around it (and of its whole effects layer); the damage is the union of the changed ops' estimated bounds, with shadows' and blurs' reach, grown to any glass surface that reads pixels under it; and the new list's ops that meet the damage are drawn into a scratch with every pixel write held to it, the rectangles copied into the kept frame. Shapes and clip masks are rasterized over a fixed grid of 256-pixel tiles in whole paints and repaints alike, so a repaint can skip the tiles it does not need and still produce the same bits; layer pixmaps and masks are pooled across frames. A test draws the Fidelity screens both ways through a slider drag, a scroll, a tap and the effects screens and requires identical PNGs; the crate's tests do the same for shadows, transforms, clips, layers and glass. session.render({ mode: 'frame' }) and Raster.renderFrame give a host the damaged rectangles and the frame's pixels to blit; render() and the CLI's PNGs are unchanged, and swiftbrowser-shot now says per shot what the display list, the paint and the PNG took and how much it repainted (--full-paint for whole paints, scripts/knob-bench.sh for the measurement).
Measured with that harness on the shared Xeon VM (SuperSynth at 1194 × 834 points, 2×, the OSC A level knob dragged; the native CLI, five runs): a whole paint of the screen 136–171 ms, of the knob frame 134–250 ms; the knob frame with damage 8.2–9.3 ms for one rectangle of 24,552 pixels, 0.62% of the frame; the knob dragged back, nothing changed, 0.4–0.6 ms. The display list (the painter in QuickJS, 29–36 ms) and the PNG (17–24 ms, which a window does not need) are now what stands between a knob and 16 ms. Found on the way: the session's hit test tried a .background { } decoration before the content over it, so every point of SuperSynth hit its full-window background Color and a drag moved nothing; paintOrder now orders them as the painter draws them.
The DSP core builds anywhere Swift does#
SuperSynth as a plugin (docs/notes/plugins.md) keeps DSPMachine as the one engine, behind a C API where the host is not Swift, which means the core has to build on Windows; it had not been tried. Foundation 1 of that plan, done first because Swift on Windows is the plan's least proven piece:
- No Foundation in the core. The machine's 54 transcendentals (
Foundation.sin,exp,pow,tanh…) go throughCMath, a shim over the C library the platform has (Darwin, Glibc, Musl, ucrt), imported internally; Foundation re-exported the same functions, so no value changes. The program's JSON, read byJSONSerialization, is read byDSPJSON, a decoder of the core's own (RFC 8259, numbers through the standard library's correctly roundedDoubleparser, nesting held to 64: the first run's macOS tests crashed with a bus error, the parser's recursion at 512 deep overflowing the 512 KB stack of a secondary thread in a debug build, which Linux's 8 MB stacks had hidden), with a base64 decoder for a sample's audio;FoundationEssentials'JSONDecoderwould have done on Linux and Windows but is not a module of its own on Apple platforms and is a far larger thing to link than 300 lines.DSPProgram(object:)takes aDSPJSON. Every parity case renders bit for bit what it did (checked with a hash of the samples in both versions), the core's objects have no Foundation symbol, and the tests read the fixtures with the C library and decode them withDSPJSON, so the test target imports no Foundation either. - The renderer's handoff in the core.
RendererandScopeTapmoved from the Apple-only module into the core asDSPRendererandDSPScopeTap, unchanged in their rules (the audio thread only tries the lock, never blocks, frees nothing; a retired machine and swapped-out buffers wait forcollect). The lock isDSPLock, the standard library'sMutex(Synchronization, Swift 6) on Linux and Windows; on Apple platformsMutexneeds macOS 15 and iOS 18 and the package ships for macOS 14 and iOS 17, so there it stays theOSAllocatedUnfairLockthe renderer had, until the deployment targets rise. - A C API.
@_cdeclfunctions over the machine (CAPI.swift,include/swiftbrowser_dsp.h; packages/dsp/README.md documents them): create from a program's JSON at a sample rate, parameters by index and name, notes, bend, controllers, tempo, seek, render, reset, destroy. TheSwiftBrowserDSPEngineproduct is the core as a dynamic library to link them from, andSWIFTBROWSER_DSP_CORE_ONLYmakes the package the core alone, with no dependency on the renderer at../... - A Windows job (native.yml
dsp-windows): the swift.org 6.4.0 toolchain throughcompnerd/gha-setup-swift, the core built and tested in debug and release, then the engine linked as a DLL with the runtime beside it and with--static-swift-stdlib, each one's imports and size written to the job's summary.
Measured on Linux (Swift 6.4.0, Ubuntu 24.04, x86_64, release): the engine as a shared library is 1.9 MB with the Swift runtime beside it (libswiftCore, libswiftSynchronization and libswiftGlibc, plus libswift_Concurrency, libswift_StringProcessing, libswift_RegexParser and libdispatch, which the driver links by default though the core uses none of them, about 14.5 MB of libraries between them, 10 MB of it libswiftCore), and 10.8 MB with --static-swift-stdlib (6.5 MB stripped), when it needs only the system's libc, libm, libstdc++ and libgcc_s and exports the 17 sbdsp_ functions: the whole engine in one file, which is what a plugin wants.
What the Windows job found (2 November, swift.org 6.4.0, windows-latest, x64): the core builds and all 30 tests pass in debug and in release, the 22 parity cases included, so the Universal C Runtime's transcendentals land within the fixtures' tolerance of glibc's and Darwin's, and the Mutex handoff and the C API run there as on Linux. The engine as a DLL is 2.1 MB (with the snapshot loader; 1.9 before it) and imports swiftCore.dll and swiftSynchronization.dll from the Swift runtime, plus the Visual C++ runtime (vcruntime140.dll and the UCRT api sets for math, heap and runtime), which a plugin on a machine without Visual Studio needs installed or shipped. swift build --static-swift-stdlib is accepted on Windows and changes nothing: the DLL comes out the same size with the same imports, although the SDK does carry a static runtime (usr/lib/swift_static), so SwiftPM is not applying it to a dynamic library product there; linking the runtime in on Windows is left for the shell's own build (the plan links the engine as a static library into a Cargo cdylib, where the static runtime libraries can go in with it), untested here. As it stands the runtime ships beside the plugin as DLLs, swiftCore.dll at 5.9 MB and swiftSynchronization.dll at 74 KB (the job's summary lists every DLL the toolchain redistributes), plus vcruntime140.dll (118 KB) where the Visual C++ runtime is not installed, where Linux and macOS take the runtime inside. Not a blocker for the plan, but a packaging fact: a CLAP on Windows is a folder, or an installer that puts the Swift runtime beside it, and two Swift plugins on one machine want the same runtime version or their own copies.
The in-memory renderer's knob frame, end to end#
The renderer stream of the plugin plan (docs/notes/plugins.md, "After the first streams"): the three sessions before it each measured a knob frame's part alone, before the others merged, so the first thing here is the frame on main, whole, split the way a live editor would pay for it, and then the two parts they named as remaining: the painter's display list, built whole each frame, and the app's JavaScript under an interpreter. The harness is the one they left (swiftbrowser-shot --verbose, bench/knob.mjs, SuperSynth's bundle at 1194 × 834 points at 2×, the OSC A level knob at 100,296 dragged ten steps), with the split made finer: --verbose now tells a command's time inside the app (its handlers, React's render, the host's flush, the ops' encoding) from the session's (the ops parsed and applied, the layout, the commit's steps), and a shot's display list into the painter's walk and the encoding; bench/knob-v8.mjs takes the same knob, page changes and scroll under V8 with the wasm rasterizer, the engine taken out. Two more scenes beside the knob, since they change more than it: a page change (the OSC page to FX, back, to MOD, back: tap "FX", a new subtree of 1,872 nodes) and the panel scrolled 120 points in a 1194 × 640 window, where it overflows (at 834 points it fits and does not scroll).
The baseline (main at 6ed1499, the shared Xeon VM, three runs; a frame is the event through the pixels, with no PNG, which a window does not write):
| QuickJS, per knob event | ms |
|---|---|
| The app: handler, React render, host flush, ops encoded | 29–49 |
| The session: ops applied 0.8, layout 6–10 (47 placed, 26 kept), steps 1.9–3.8 | 4–14 |
| The display list: the painter's walk of 2,905 nodes for 890 ops 22–34, encoding 6–11 | 28–45 |
| The paint of what changed (1 rectangle, 24,552 px, 0.62%) | 7.6–14.7 |
| A knob frame | about 80–115 |
Under V8 the same frame was app 4.4–9.2, session 1.1–1.8, painter 3.2–8.1, encoding 1.0–4.4 and paint 11.7–16.8 (wasm) per event. A page change cost the app 170–400 ms and the session 500–860 (the layout of a new page), its display list 33–52 ms and its whole-frame paint 130–250; back to the OSC page the display list was 243–308 ms, because the two wavetable shaders ran again (110 ms each in bytecode) for a remounted view. A scroll walked and encoded the list in 30–46 ms and painted the whole frame (132–224 ms).
What changed, each measured alone with the same harness, SuperSynth's screenshots byte for byte the same through every scene, the React host's tests, the renderer's and the pixel comparisons with Chromium (at rest, scrolled 200 points, tapped into a detail) unchanged:
- The display list is incremental (docs/raster.md, "An incremental display list"). The painter keeps each node's ops across frames and reuses a subtree's when nothing under it changed and it is drawn under the same context, scroll shift and offset; the session marks nodes stale as ops change them, as a layout places or hides them, and as scroll offsets, focus or a swipe move (an image loading or an environment change clears everything). The encoder keeps each op's bytes with the op. A drawn shader is kept by content as well as by its props object, so a page shown again reuses its wavetable pictures. A new test holds the incremental list to a fresh walk op for op and byte for byte through a slider drag, scrolls, tab changes, a push and a pop, focus and typing, a swipe, sheets and dark mode. A knob frame's display list went from 28–45 ms to 2.2–3.2 (45 nodes walked, 26 subtrees reused); back to the OSC page from 243–308 to 32–50.
- The React host flushes only what changed. Profiled with probes in an instrumented bundle (the
globalThis.__sbProfilehook--verboseprints), the app's 30–45 ms per knob event in QuickJS were almost allHostTree.flushin @swiftbrowser/react: at every commit it walked every element, copied each one's props to resolve preferences and hoists, built the live set, and deep-compared every element's props with the committed ones, about 45 ms a commit for 2,905 elements (React's own render was a few milliseconds, the ops' JSON a fraction of one). The reconciler's mutations now mark the instance and its ancestors stale, and a flush resolves and diffs only the stale subtrees; a clean subtree keeps its entry from the last flush, and what it sent up (a preference's props, a hoisted element) is kept with it and replayed into the ancestors resolved again; what left the tree is found in the old children of the elements resolved now. The ops are the same (the React host's 235 tests, the renderer's 108 and the screenshots agree). The app's share of a knob event is 2–3 ms in QuickJS now and 1.6–3.3 under V8. This is the one change outside packages/raster, where the plan put the host's flush. - The session's commit steps walked the whole tree twice a commit whenever the tree had a text input or a scroll view (focus sync, scroll commands), 3–4 ms in QuickJS; the indexes the session keeps say when nothing asks for focus and no command is new, which is every commit of a drag. The steps are 0.2 ms.
After (the same harness, three runs):
| QuickJS, per knob event | Before | After |
|---|---|---|
| The app | 29–49 ms | 2.1–3.4 ms |
| The session (layout 9.4–10.5 of it, 47 placed, 26 kept; ops applied 0.8; steps 0.2) | 4–14 ms | 7–11 ms per pass |
| The display list (walk 1.4–2.0, encoding 0.8–1.3) | 28–45 ms | 2.2–3.2 ms |
| The paint of what changed | 7.6–14.7 ms | 7.5–12.3 ms |
| A knob frame | about 80–115 ms | about 21–29 ms |
A ten-step drag, bench/knob.mjs median (its commits, no shot) |
380 ms | 184 ms |
Under V8 a knob event is app 1.6–3.3, session 1.0–1.4, painter 0.4–1.1, encoding 0.3–0.7, paint 11–19 ms (wasm). A page change is app 150–320 ms (React rendering a page of plates) and session 380–860 (a new subtree laid out whole), its display list 28–55 ms and its paint of most of the frame 90–200 ms; the scroll's display list 34–47 ms (the shift under the scroll view changes, so all of it is walked again) and its paint the whole frame, 113–224 ms.
What stands between a knob and 16 ms now is in the two parts this stream was told to leave as they are: the layout, 9.4–10.5 ms for 47 nodes placed and 26 subtrees kept (1.0–1.4 ms under V8, so the interpreter's ratio, with plan, measure and layoutStack on top of the profile), and the paint, 7.5–12.3 ms, of which the rasterizer's trace (SB_PAINT_TRACE=1) shows 61 of 890 ops drawn: the OSC panel's rounded background fill and inside stroke on the tiles the knob touches (about 1.8 ms) and the six knobs around the dragged one, each a rect with a shadow under a masked layer (0.3–0.6 ms each). The app's JavaScript (2–3 ms) and the display list (2–3 ms) are a quarter of the frame now. Of SuperSynth's own: a knob event costs its handler, the store and the knob's render, nothing a renderer can take; a page change re-renders a page of plates (150–320 ms in QuickJS) and lays it out afresh (400–860 ms), which keeping the pages mounted would trade for memory, for its owner to weigh; and each wavetable display's shader takes 110 ms on the CPU at start, where a GPU backend would take a few.
Hermes against QuickJS. Hermes (facebook/hermes main at 26fbb82, 30 October 2026, built here from source in release with no Intl and no debugger; the npm hermes-engine-cli binaries are 0.12 of 2022) compiles the bundle ahead of time to bytecode. The same harness ran in both engines: one classic script of a host bridge in JavaScript (__sbNative with timers on a virtual clock, ops kept), SuperSynth's bundle unchanged, and a driver that replays the nine events of a knob drag the session recorded (bench/engines), twenty drags over, since the Hermes CLI's clock is Date.now; and a second script that adds the session itself over a stub rasterizer (real font metrics, text measured at the role's average advance, shaders drawn blank), so the layout, the commit's steps, the painter and the encoder run in the engine too, the knob dragged through the session's own drag command. QuickJS ran them through a small rquickjs runner, the CLI's engine and version. Hermes needs -Xes6-block-scoping, a hidden flag, for esbuild's output: without it a let in a loop head is one binding per call, and every getter of esbuild's module helper read the last property, so React's createContext was its version string.
| Per knob event, the same script | QuickJS | Hermes (bytecode, -O) |
|---|---|---|
| The app alone (handler, React, the host's flush, the ops encoded) | 2.2–2.8 ms | 0.63–0.81 ms |
| With the session: the ops applied, the layout, the commit's steps | 15.9–17.1 ms | 3.2–3.7 ms |
| The display list after a drag (the painter's walk and the encoding) | 2.6–2.9 ms | 0.9–1.1 ms |
| Start-up to the first full layout (from the wall time less the drags) | about 1.3 s (the CLI's 1.3–1.5) | about 0.3 s |
| The engine's binary | QuickJS-NG about 1 MB (the runner 1.6 MB stripped) | the hermes CLI 7.1 MB stripped, its compiler in it; libhermesvm 18.6 MB as an unstripped static archive |
| The build | none | hermesc -O 3.1 s for the 0.8 MB bundle, 1.3 MB of bytecode |
Hermes is three times faster on the app and four to five times on the layout and the painter, and starts in a quarter of the time. In the frame that counts, the JavaScript of a knob (the app, the session's commit, the display list) is about 19 ms in QuickJS and would be about 4.5 in Hermes, which with the native paint of 8 to 12 ms puts the frame at 13 to 17 ms: on the budget, where QuickJS's 21 to 29 is not, before the layout's and the paint's own work. The swap is not small: a host over Hermes's C API (hermes.h, JSI or NAPI) in place of rquickjs, with the bridge's ten functions, typed arrays and promise draining written again; hermesc with the block-scoping flag in the bundle's build; no Intl (the CLI's prelude already supplies one for QuickJS); five to seven megabytes more in the binary; a C++ toolchain at build time; and a measurement of memory, which this did not take. The numbers say the layout engine under an interpreter is the case for it, and the decision belongs to the plan: if the layout stream brings a knob's 10 ms down by other means, QuickJS stays within reach of the frame; if not, Hermes is the engine that gets there with the renderer as it is, and the bridge is the smallest part of the renderer to write twice.
A SwiftBrowser Native bundle runs in a desktop window#
The next stream of the plugin plan (docs/notes/plugins.md, "The editors": the live editor window a CLAP or VST3 plugin draws). swiftbrowser-window (packages/raster/window) runs a SwiftBrowser Native bundle, the same app.js the iOS host runs in JavaScriptCore, in a native desktop window drawn by the in-memory renderer with no browser: the QuickJS host and session of swiftbrowser-shot (now a library the two binaries share) on the wall clock, the session's frame blitted to a winit window through softbuffer repainting only its damaged rectangles (the frame mode of "Painting only what changed"), and the mouse and keyboard fed to the session as its own gestures. It opens standalone (Window::standalone) or as a child of a window a plugin host hands over through CLAP's gui extension (Window::embedded, an HWND, NSView or X11 window); examples/embed.rs embeds it in a plain parent window made with the platform's own API (x11rb, Win32, AppKit) on Linux, Windows and macOS.
The input is the session's, one OS event at a time rather than a script's whole gesture (packages/raster/src/pointer.ts): a press that lifts within the slop is a tap at the pressed point, one that moves past it is the drag the session's drag would make of the same two points by the same priorities (a grip reorders, a drag gesture gets began, changed per move and ended with a measured velocity, a slider or a knob follows the pointer, a swipeable row follows and settles, a sheet or the back edge settles at the release, else the scroll view under the press pans); a move with nothing pressed hovers where the app asks (.onHover, .onContinuousHover) and sets the window's cursor (.pointerStyle, the I-beam over a text field); the wheel and trackpad scroll what is under the pointer; keys and typed text, Escape, Return, Backspace, select-all and the clipboard reach the focused field; resizing the window relays out the tree. A ScopeView draws a flat trace as the CLI does, with the hook where a plugin host hands it the engine's frames. The engine runs on its own thread (QuickJS values stay on one thread, and React and the layout engine want a deep stack); the window thread translates events and blits, asking for a frame only when the session's revision moved, and coalescing pointer moves that arrive faster than it paints, as a browser does. The session (its new input API, a revision counter and a per-frame profile) and the CLI crate's split into a library and its binary are the only changes to packages/raster; the painter, the layout engine and SuperSynth are untouched.
Measured with a synthesized knob drag (swiftbrowser-window --drag, which plays pointer events in as the OS would, and --stats, a line a frame): SuperSynth's bundle in a 1194 × 834-point window at 2×, the OSC A level knob held and wiggled so every move turns it, on the shared Xeon VM (Linux, software rendering under Xvfb), with the renderer-speed stream (the incremental display list, the host's partial flush) merged. A frame repaints only the knob (one rectangle, 24,552 pixels):
| Per frame (median / p90) | Damage repaint | Whole frame (--full-paint) |
|---|---|---|
| The app's JavaScript (a knob event, React's render and commit) | 2.9 / 4.0 ms | 3.6 / 4.9 ms |
| Layout (what the commit changed) | 5.9 / 8.8 ms | 6.1 / 8.4 ms |
| The display list (the painter, incremental) | 2.1 / 3.3 ms | 2.3 / 3.2 ms |
| Paint (the rasterizer) | 6.9 / 9.9 ms | 141 / 163 ms |
| Copy and blit | under 0.1 ms | 7 ms |
| From the pointer move to the blit | 20.5 / 35.2 ms | 318 / 386 ms |
| Frames a second | 41 | 6.1 |
A knob frame is at the budget: a pointer move reaches the screen in about 20 ms, at 41 frames a second against the 60 the events arrive at; on the CI runner (ubuntu-latest, a faster machine) the same drag runs at the input's own rate, 67 frames a second with a 12 ms median from the move to the blit (engine turn 11 ms: app 2, layout 3.5, display list 1.4, paint 4). The Windows and macOS jobs open the window on SuperSynth, standalone and embedded, and upload its first frame. Painting only the damage is what makes it possible (7 ms against 141 for the whole frame); with the display list and the app's own work down to a few ms each, the largest pieces left are the rasterizer's repaint of the knob and the layout of what changed, now the window's own to shorten. Before the merge, with the display list at 25 ms and the app's JavaScript at 23, the same drag ran at 15 frames a second with a 130 ms input-to-blit median, several inputs queueing and coalescing behind each 60 ms frame. A new CI workflow (raster-window.yml) builds the window on ubuntu, windows and macos, opens SuperSynth in it both standalone and embedded in a parent window, screenshots the first frame on each, and runs the knob-drag measurement on Linux into the job summary. The pixels the window blits are the frame mode's, so they are the screenshot's to the bit.
SuperSynth as a CLAP plugin: the shell over the Swift engine#
The plugin plan's next stream (docs/notes/plugins.md, "CLAP and VST3"): SuperSynth, and any .dsp program, as a CLAP instrument with no editor yet, over the Swift engine, with a VST3 made from it. Native/Plugins/clap is a Rust crate (clap-sys, the raw CLAP C API: the shell is thin C-ABI code around a C engine, and clack's safe layer is pre-1.0 with an audio-thread model of its own to reconcile with the engine's single-owner rule) building a cdylib; it sits under Native/ beside the engine's package and the SuperSynth example whose snapshots it bundles, since packages/ is the npm workspace.
- The engine linked in. build.rs copies the engine's core into Cargo's
OUT_DIR, builds it there in release withswift buildas a static library (the repository's package is never touched), and links it with the Swift runtime: on Linux statically (the toolchain'susr/lib/swift_static:swiftrt.oand the eight archives the core's autolink entries name, grouped, their symbols kept out of the export table), on macOS against the system's runtime in/usr/lib/swift, and on Windows as the SDK's import libraries, with the runtime's DLLs beside the plugin (below).SBDSP_CORE_LIB_DIRtakes a prebuilt engine,SBDSP_SWIFT_RUNTIMEpicks static or dynamic, and the build writes what it linked into a CMake fragment for the wrapper. The C API gainedsbdsp_snapshot_machine_create(a machine from a snapshot, loaded) andsbdsp_machine_position, each tested against the Swift machine; nothing else in the engine or the snapshot format changed. - The slot pool as parameters. 512 parameters, ids 0 … 511, forever; the loaded snapshot names them from its metadata and slot map (
@labelelse the name, a dotted name's prefix as the module). Every slot is 0 … 1 to the host, the real value (its unit, an enum's case, On/Off) in its text, so a program change changes no slot's range and hosts getRESCAN_VALUES,TEXTandINFO; the full rescan, which CLAP allows only deactivated, is asked for (throughrequest_restart) only when the pool's shape changes, a slot gaining or losing its parameter or a default moving. Blank slots are hidden and read-only; the eight macros at 500 … 507 are always shown, read-only where the program maps none, and a knob and the macro mapped to it read alike. The value a host sets is kept as the fixed point of its trip through the parameter's units and back, and the state's floats parse back to the bit, so a state saved, loaded and saved again is identical, which clap-validator checks. SuperSynth's knobs carry no@label, so a host showss45: a program-side follow-up. - State, presets, events, transport. State is the snapshot itself with the current values written in,
formatandversionfirst: a project is a preset and a preset file a state. The factory snapshots (npm run snapshotsin SuperSynth) are bundled and offered throughpreset-discoveryandpreset-load(which also takes a snapshot file by path); a bare build without them bundles Init from the committed fixture. Note, MIDI, parameter and transport events apply at their sample offsets by segmented rendering; MIDI CC 1 and pitch bend go to a program'smodwheelandpitchwheelparameters where it has them (SuperSynth applies its own bend range), else the machine's bend. The transport sets the tempo when it changes and seeks when playback starts or the position is a millibeat from the machine's count. A snapshot loaded while active builds its machine on the main thread and hands it to the audio thread through an atomic, the old one retired for the main thread to free; nothing locks, allocates or frees on the audio thread. - Checks.
cargo testruns a host (tests/host.rs) that dlopens the built library as a DAW does, checks every one of SuperSynth's 317 slots against the snapshot's metadata, plays the Init preset from the fixture's events inside 512-frame blocks and holds both channels to the JavaScript machine's render, then round-trips state exactly, loads a factory preset and follows a transport. ThePluginworkflow does the same on Linux, macOS and Windows, runs clap-validator on the.clap, builds the VST3 (and the AUv2 on a Mac) with clap-wrapper's clap-first build from the crate's static library and runs pluginval on it. A second workflow,Plugin Windows debug, runs by hand: the Windows build with its link summarized, a probe that loads the.clapand the VST3 module as a DAW'sLoadLibrarydoes and calls each entry, and pluginval both ways, again undercdbwhen one fails.
Measured (2 November, release builds): the plugin's output is within 3.2 × 10⁻⁷ of the JavaScript machine's on every frame of the Init fixture, on all three platforms (the parity tests allow 10⁻⁵). clap-validator passes everywhere (Windows: 20 of 21 tests, one skipped) and pluginval at strictness 5 passes the VST3 on Linux, macOS and Windows. On Linux the .clap is 9.2 MB stripped with the engine, the Swift runtime and the four factory snapshots (2.1 MB of JSON) inside, exports four symbols and needs only libc, libm, libstdc++ and libgcc_s. On macOS it is a bundle linking the system's /usr/lib/swift. On Windows the plugin is one file too: SuperSynth.clap is 9.9 MB with the Swift runtime inside and imports only the Visual C++ runtime (VCRUNTIME140.dll, MSVCP140.dll and the UCRT api sets; installed on most machines, a redistributable otherwise) and system DLLs; the VST3 module is 7.9 MB. That took two findings, both from the debug workflow's first run. The static link had stopped at three unresolved symbols, the Synchronization module's metadata the core's objects imported (__imp_) because they were compiled against the runtime's dynamic module variants: SwiftPM's --static-swift-stdlib reaches only its link step, while -Xswiftc -static-stdlib reaches the compile, where the driver resolves the runtime's modules from usr/lib/swift_static, and with it the link is clean (no symbol still imported, where the first attempts had some two hundred) against the SDK's libswiftCore.lib and friends (the lib prefix telling them from the import libraries) with the import libraries' /DEFAULTLIB turned off. The build does this by default now; SBDSP_SWIFT_RUNTIME=dynamic is the way back to the shipped-DLL layout (SuperSynth.clap 4.5 MB with swiftCore.dll 5.9 MB and swiftSynchronization.dll 75 KB beside it, copied by scripts/package.mjs from the import table), which a DAW's LoadLibrary does not look beside the plugin for in any case, so it would have needed delay-loading as well. And pluginval's trouble on Windows was never the runtime: the probe showed the VST3 module loading in every configuration and GetPluginFactory returning null, and clap-wrapper's source says why: on Windows it finds its CLAP entry in its own module with GetProcAddress(self, "clap_entry"), where Linux and macOS use dlsym and CFBundleGetDataPointerForName on the archive's global, so the module has to export the symbol, which Rust's #[no_mangle] pub static does from a cdylib but not from a staticlib linked into someone else's module (the wrapper's own CLAP module on Windows had exported nothing at all). A linker directive in the wrapper's entry source (/EXPORT:clap_entry,DATA) exports it, pluginval passes the bundle in both of its modes, and the Windows step gates the workflow like the others. clap-wrapper's modules must link the dynamic C runtime (/MD) to match the Swift runtime and Rust; the wrapper defaults to the static one.
The editor in the plugin: SuperSynth's screen in the host's window#
The plan's editor stream for the CLAP and VST3 (docs/notes/plugins.md, "The editors"), on the window stream ("A SwiftBrowser Native bundle runs in a desktop window") and the shell ("SuperSynth as a CLAP plugin"). The plugin now has CLAP's gui extension: SuperSynth's own screen, the React app the iPad and the page run, drawn by the in-memory renderer in a child of the window the host hands over, with no browser in the plugin. swiftbrowser-window is linked into the shell; set_parent opens Window::embedded on the host's X11 window, HWND or NSView, and the host's timer (timer-support, 16 ms) pumps it from the main thread, as a plugin host's loop allows. The window is 1194 × 834 points, the layout the app was measured at, not resizable yet. clap-wrapper carries the extension into the VST3 (and the AUv2) as the formats' own views.
The app talks to its AVAudioEngine through host requests, one audioEngine command each; in the plugin they go to the plugin instead of an engine of the app's own. The shot host (packages/raster/cli) gained an optional request handler, installed as __sbNative.hostRequest and answered at once through the runtime's __sbHostResponse, and the window crate carries it in its options, with the bundle's and the session script's text in place of files (the plugin embeds both; build.rs copies packages/raster/dist/session.js and SuperSynth's apple/app.js into OUT_DIR, or builds without an editor and says so). A DSPNode parameter set by name becomes a change to the slot the loaded snapshot maps that parameter to, normalized, handed to the audio thread through a single-producer, single-consumer ring (no lock, no allocation) that process drains at the start of each block, applying each and telling the host with a CLAP_EVENT_PARAM_VALUE on its output events (a params.flush drains it too, for a change while the plugin is inactive, which the handler asks the host for with request_flush); the keyboard's notes, the wheels and the controllers go the same way; and a ScopeView draws the plugin's own output, the left channel of each block kept in a ring of 4,096 frames the timer reads 512 of into the window's scope_frames when new sound arrived. The app's other requests (files, the clipboard) read as unsupported, as in the CLI.
Two things the window crate needed for a plugin. winit allows one event loop per process and refuses a second (EventLoopError::RecreationAttempt), which an editor closed and opened again, or two instances with editors open, would have hit: the crate now keeps the process's one loop in a thread-local and a Hub of every window on it, each event handed to the app whose window it is for (replies from the engine threads carry their window's key), so pump serves every editor and a standalone window still runs the loop to its end. And an embedded window that closes leaves the hub without ending the loop. The CLI binary and the embed example are unchanged in use; the raster-window workflow's screenshots are the same bytes.
Measured here (Linux, Xvfb, the shared Xeon VM): the plugin's first frame in the host's window, 1194 × 834 at 1×, SuperSynth's screen with the header's scope drawn from the plugin's output and no "cannot play sound" banner (the engine started through the bridge), 335 KB as a PNG, about 30 s after set_parent on this VM under cargo test (the app's start in QuickJS and the first full layout and paint; the window stream measured 1.1 s for the start alone on a quiet machine). The Linux .clap is 29.5 MB now, from 9.2: the renderer's fonts (11 MB, to be subset to what the editor draws), QuickJS and the window stack; it still needs only libc, libm, libstdc++ and libgcc_s, the X11 libraries being loaded at run time. tests/host.rs has a test that makes an X11 window as a host would, opens the editor in it through the extension, fires the host's timer while processing blocks, and waits for the first frame's PNG; the Plugin workflow runs the tests under Xvfb on Linux and uploads the frame. The wrapper's VST3 builds with the window linked in on Linux (the Windows and macOS system libraries the window needs are listed in the wrapper's CMake, to be proven by their jobs).
Not yet, in the order they matter: the editor opens on its own Init patch rather than on the plugin's state, since the app has no way to read a snapshot back into a patch (the reverse of snapshotOf), so a project reopened shows Init while the plugin plays what was saved; host automation does not move the editor's knobs (the app would need a parameter-changed hook on DSPNode); a preset opened in the editor sends its parameters but not its tables and route lists (the C API has no setTable, setShape, setSample or setRoutes), so the plugin should load the editor's snapshot whole instead; the window is a fixed size; the fonts are not subset; and the editor's parameter changes carry no gesture events, so a host records them as values without a touch.
Faster CI for the plugin and the window#
From the editor PR's runs: the Plugin workflow's Windows job took 23 minutes, of which 6.4 were the test step compiling every dependency a second time, because the release profile's panic = "abort" cannot apply to tests and Cargo rebuilt the whole tree with unwinding for them; without it the tests reuse the build (one crate compiled for the tests, measured locally), and a panic still cannot cross into a host, since unwinding out of an extern "C" function aborts. The factory snapshots and the editor's two scripts are the same text on every platform, so the plan job builds them once on Linux and the three platform jobs download them, where each ran npm itself (3.5 minutes on Windows). Plugin Windows debug runs only by hand now (it ran a 24-minute Windows job on any pull request that touched it), the raster-window workflow no longer runs for SuperSynth's own changes (the Plugin workflow's editor test opens the same bundle in the same window), and the Plugin workflow now runs for changes to packages/raster, whose window and renderer the plugin links.
The plugin's editor edits the plugin's patch#
The four gaps the editor's first cut left ("The editor in the plugin"), closed. The patch lives in the plugin and SuperSynth's app is its editor (Native/Examples/SuperSynth/src/plugin.ts, PluginLink), through @swiftbrowser/native's escape hatch: the plugin offers three native functions and sends two events, which the shot host now carries (__sbNative.nativeFunctions, app:<name> requests to the plugin's handler, and __sbNativeEvent from the window's new NativeEvent command).
- The editor opens on the plugin's state. A snapshot gains an optional
editorfield ({ app, version, data }, packages/dsp'sSnapshotEditor), what the app that made it keeps to edit it again, which no engine reads (the Swift and Rust readers ignore it, the Rust one keeps it when it saves). SuperSynth's snapshots carry their preset data there (src/serum/editorState.ts:PresetDataas JSON, itsFloat32Arrays base64, each encoded once while unchanged), the factory snapshots and the fixture included (3 KB more each, their tables being named). At start the editor callsplugin.stateand opens the patch in it with the knobs and route amounts the snapshot's parameters hold laid over it (the plugin saves those as the host left them), muting its node meanwhile so opening sends nothing back; a snapshot it did not make opens as Init with its knobs. When the host loads another state (a project, a preset), the plugin tells itplugin.loadedand it asks again. - Host automation moves the knobs. Each timer turn the plugin compares the slots with what the editor was last told and sends what moved as
plugin.parametersby name in their units; the app turns those knobs and route amounts in its store, sending nothing back. The editor's own changes are no news to it: the handler records each slot's value as the plugin will hold it (snapped) and when, and a slot the editor set in the last 300 ms, or holds at the value it set, is skipped, so a knob being dragged does not jump back to a value the audio thread applied a block ago. A macro's own slot is not sent; the knob it drives moves in its own. - A preset opened in the editor is loaded whole. The editor sends
plugin.loadwith the preset's snapshot (its preset data in it); the handler reads it at once, so a refusal reaches the editor, and the main thread loads it at the next timer throughPlugin::load, the same path as a host's preset: the machine built again with the tables, shapes, samples and route lists the C API cannot change one by one. Edits to those (a table drawn, the matrix's lists, an LFO's shape) go the same way, 400 ms after the last; edits to parameters reach the sound as they are set (a slot's through the queue, one with no slot by the machine's index, which is the program's parameter order) and the editor's state follows them asplugin.update, which the plugin keeps in the snapshot it saves without touching the machine (Plugin::update_state, any thread, under the snapshot's mutex), so a project saves the editor's state and the values of parameters with no slot. - Resizing and smaller fonts. The editor is resizable from 800 × 560 to 2560 × 1600 points (
can_resize,get_resize_hints,adjust_size; the window relays out on the size, as it did standalone), and draws with the renderer's faces cut by fontTools to what the screen draws: Inter's upright weights from regular to black, DejaVu Sans Mono and DejaVu Sans, each to Latin, Latin-1 and Latin Extended-A, punctuation, arrows, mathematical operators, geometric shapes and the music signs (scripts/subset-fonts.sh, committed in Native/Plugins/clap/fonts, 1.4 MB). The window crate's packaged fonts moved behind adefault-fontsfeature, on by default, which the plugin turns off, so they are not linked in. The Linux.clapis 21.4 MB, from 29.5.
Checked: the editor test (tests/host.rs, under Xvfb) now also waits for the editor to ask for the state, automates a knob and waits for plugin.parameters naming it, loads a preset from the host and waits for plugin.loaded and the editor asking again, finds SuperSynth's editor state in the plugin's saved state, and checks the size limits; unit tests hold the echo rule, the size limits and update_state (the editor's state and a parameter with no slot kept, a slot's value left the plugin's), and SuperSynth's snapshot tests round-trip each factory preset through its editor state as a plugin saves it. By hand, with a preset loaded by the host before the editor opened: the editor's screen showed that preset (name, levels, unison, detune), drawn with the subset faces. Not covered by a test: the editor's own plugin.load and plugin.update, which a test would have to drive the app's screen for.
The plugin without Wayland or image decoders#
Two of the size cuts measured for the 21.4 MB Linux plugin (an unstripped build's symbols by crate: Wayland's client and protocols with winit's backend for them about 0.4 MB, the JPEG, GIF and WebP decoders about 0.4 MB). The window crate (packages/raster/window) builds winit and softbuffer with X11 alone on Linux and the BSDs (default-features = false, winit's rwh_06 and x11, softbuffer's x11 and x11-dlopen, so no Wayland and no KMS either): a plugin host hands over an X11 window anyway, Wayland having no parenting for a foreign window, and a window of its own runs on XWayland where the desktop is Wayland's. And the decoders past PNG are an image-decoders feature, on by default, of the CLI (swiftbrowser-shot) and the window, which pass it to the raster crate's jpeg, gif and webp; the plugin turns it off with the window's other defaults, since SuperSynth's screen draws no image (one it met would fail to decode, as an SVG does). PNG stays: the frame is written as one. The Linux .clap is 19.6 MB, from 21.4, more than the two estimates together (the KMS backend and the crates only Wayland pulled in went with them). The window opens standalone and embedded under Xvfb with the same first frame to the byte, and the plugin's tests pass, the editor's included.
The plugin's engine as Embedded Swift#
The Swift runtime was about 5 MB of the plugin and the engine itself 0.3 MB, so the plugin now ships the engine compiled as Embedded Swift on Linux and Windows, which needs no Swift runtime: only the C library and Swift's Unicode tables (String's normalization). The core (Native/Packages/SwiftBrowserDSP/Sources/SwiftBrowserDSPCore) builds both ways from the same sources. Its key paths became closures, which Embedded Swift lacks and nothing else notices. Under #if hasFeature(Embedded) its C math comes through a module map over math.h (Native/Packages/SwiftBrowserDSP/Embedded/LibM, as Embedded Swift has no Glibc or ucrt module), and its lock is an atomic flag, since Embedded Swift has no Mutex: the audio thread only tries it, as before, and the main thread spins on it, yielding. The package's own build and its 37 tests are unchanged.
scripts/embedded-core.sh compiles the core whole-module with -O, and build.rs runs it itself on Linux, where Embedded is now the default (SBDSP_SWIFT_RUNTIME=embedded; static and dynamic still build with the runtime). Swift's Windows toolchain cannot compile Embedded Swift: it ships no Embedded standard library (module 'Swift' cannot be imported in embedded Swift mode on the runner), and Swift's build skips Windows for Embedded's Unicode tables. So the Windows engine is compiled on Linux, embedded-core.sh <dir> windows: the core to LLVM IR against the Linux x86-64 Embedded library (textual IR, as the bitcode writer crashes on it), which clang compiles for x86_64-pc-windows-msvc, and Swift's Unicode normalization tables compiled from Swift's source the same way and archived with it. That holds because the core's C functions take and return only scalars and pointers, so no struct is lowered by the Linux C ABI, and its IR has no thread-locals or constructors. The plugin supplies the four C functions the Windows C runtime lacks (src/embedded.rs: posix_memalign over malloc, arc4random_buf over BCryptGenRandom, sched_yield over SwitchToThread, and hypotf, which the C runtime has only inline in its header). The Plugin workflow gains a Linux job that compiles the Windows engine, and the Windows job links it without installing Swift (1 minute 45 seconds it no longer spends). macOS is unchanged: the system has the runtime, so there is nothing to save.
Measured on GitHub's runners with the same chords on both builds (an eight-note chord on a preset, 512-frame blocks at 48 kHz, bench/, which prints a checksum of the output): on Windows the .clap is 13.0 MB against 19.8 MB, imports no Swift runtime and no C++ runtime (MSVCP140.dll, which the Swift runtime had needed), renders the same output, and is about 2% slower (Warm Pad 16.7 times real time against 17.0, Init 25.0 against 25.4). On Linux, measured on the shared Xeon VM, it is 13.6 MB against 19.6 MB at the same speed. The plugin's tests pass on both with the same parity against the JavaScript machine (worst 3.13 × 10⁻⁷). -Osize saves 0.1 MB more and is 40% slower, so the core stays -O.
The DSP compiler in Rust, and packs#
The .dsp compiler (lexer, parser, lowering and ProgramBuilder) ported to Rust in packages/dsp/rust, held to the TypeScript compiler's output byte for byte: the examples, the Showcase synth and SuperSynth (220 KB of JSON) are the same text, and so are the 152 programs and 77 of the 79 error messages the TypeScript test suite compiles (recorded and replayed by replay; the other two compile without a readFile, which the replay always passes). JavaScript's numbers are kept exactly: Math through libm (fdlibm's family, as V8's), **'s and Math.min's special cases, Math.fround, and Number.prototype.toString for every number written. Compile times, medians on the shared Xeon VM: SuperSynth 32 ms (fastest 22 ms), bigpatch 1.3 ms, synth 0.07 ms, where Node takes 86, 9.8 and 0.6 ms warm, 320, 32 and 12.5 ms for a process's first compile, and QuickJS (what an app or a plugin embeds) about 2,064, 81 and 4.8 ms. A quarter of the Rust compiler's time is allocation and a sixth writing the JSON, neither optimized yet.
Packs (notes/packs.md): what a plugin bundles, a program's source files and its compiled program, each entry deflated, a packed program's big integer arrays and samples raw beside the JSON of the rest. dspc --pack writes one (several programs if given several) and --unpack reads one back to the compiler's JSON byte for byte; the Swift core reads them (DSPPack, DSPProgram(packed:)) with a deflate decoder of its own (DSPInflate), so it imports no Foundation still. SuperSynth's pack, both sources included, is 68.6 KB and loads in Swift in 4.1 ms to its checked program, where its JSON is 220 KB and takes 5.1. Measuring that found the Swift program check spending 25 ms of SuperSynth's load on messages for checks that passed, built eagerly for each of 25,000 operands; they are built on failure now, and the check takes 2.2 ms.
The Rust compiler then gained the program's metadata (compileDspModule's meta: parameters, controls, data names, chains, macros and the matrix), the TypeScript output byte for byte for the 152 programs and the examples, which dspc --pack writes as each program's meta entry and Swift reads (DSPPack.meta(named:)). And TypeScript reads and writes packs (@swiftbrowser/dsp/pack: packPrograms, unpackPrograms, packProgram, unpackProgram, deflating through CompressionStream), with swiftbrowser-dsp pack beside compile: a program it packs is the Rust compiler's bytes, and a pack it writes reads back in Rust and loads in Swift.
The plugin bundles one pack, and names SuperSynth's program by its hash#
What the CLAP and VST3 embed, packed (docs/notes/packs.md, "The plugin's bundle"): build.rs compiles SuperSynth's program from its source with the Rust compiler and writes one pack of it and its metadata (both named by the program's SHA-256), its source files, the four factory presets, the editor's faces and its two scripts, each entry deflated; src/assets.rs inflates each the first time it is needed (the faces and scripts when the editor opens). Each preset carried the whole program and its metadata (542 KB a preset); a preset whose program and metadata are the bundled ones now names the program instead ("program":{"sha256":…}, no meta), so the four are 65 KB packed where they were 2.17 MB, and one with another program keeps its own, the way presets with a user's program will. The bundle is 1.13 MB where its contents were 5.2 MB embedded raw (deflating the presets together would not have helped: deflate's 32 KB window cannot see one repeat another), and the Linux plugin is 9.7 MB, from 13.6, built from the same presets and scripts.
The state the plugin saves is a pack too, its snapshot naming the program by hash: about 16 KB a SuperSynth instance where it was 540 KB of JSON; a state saved as JSON still loads. References stay inside the plugin: it puts the program back before the engine or the editor reads a snapshot. The pack format gained a file kind (the faces and scripts) in its three readers, the Rust one an index that inflates entries one at a time, and the Rust compiler a test, run by the Plugin workflow, that compiles each parity source to the TypeScript compiler's program.
A graph editor for DSP programs#
SuperSynth gains a DSP page (docs/notes/graph-editor.md): a new program of one's own, edited as a graph beside its text, in the manner of Enso's graph editor. The text is the program and the graph a view of it: each node a statement, each port an argument of its call bound to the callee's parameters as the compiler binds them, each wire a name a statement reads. Every edit made in the graph (a wire pulled to a port, an argument typed, a node added from the search, renamed, extracted or deleted) is a splice of the text, so comments and layout survive and undo is the text's. The parser now gives every node its span and keeps comments (parseSource), tested by slicing every node of every program back to the node it parsed from; lang/graph.ts and lang/edit.ts are the graph and its edits. The program compiles as the text rests and plays on its own node, the keyboard and scope following it while the page shows, its parameters as knobs and a compile error on its node. The in-memory renderer, which the plugin's editor draws with, kept a text editor's spaces collapsed and its runs uncolored; it now draws them as UITextView and a textarea do.
The headless renderer (swiftbrowser-shot, swiftbrowser-window and the plugin's editor) started every app compact, since run starts it so and only a resize told it otherwise: the plugin's 1194-point editor showed SuperSynth's compact layout, and the DSP page its graph and text one at a time. The session now tells the app its whole environment once it runs (start(): the appearance, the text size, and the size class the screen's width gives), as a native root view does on appearing, and a resize still tells it a new size class as the width crosses 700 points.
The DSP page's programs are files (graph-editor.md, phase 5): NEW, OPEN and SAVE, a program saved as a pack of its source, the editor's layout (<name>.dsp.layout.json) and, when it compiles, its program and metadata, so it loads in an engine with no compiler; a bare .dsp opens too, with the automatic layout. @swiftbrowser/dsp's packs now read where the platform has no CompressionStream (the native apps' JavaScriptCore, the plugin editor's QuickJS) with an inflate of their own, the Swift core's ported, and write stored entries there.
In the plugin the DSP page's program is what plays while the page shows: each compile loads a snapshot of it into the plugin (its program inline, its slots from its metadata, its knobs' values), with the program's name, source and layout as the snapshot's editor state, so a project saved on the page reopens the editor there with the program playing; leaving the page loads SuperSynth's patch again.
The DSP page's node search is a command palette: a card centered over the dimmed editor, opened by + NODE or ⌘K (Ctrl-K), its field focused, the best match highlighted, the arrows moving it, Return adding it (wired from the selected node) and Escape or a tap outside closing it.
The in-memory renderer handed a .shadow to each view inside its box, even where the page casts it under the box whole: around a box that clips (clipShape, cornerRadius, clipped), masks or composites (compositingGroup), as renderer.ts castShadows does. The palette's card, its rows' backgrounds each casting a 24-point shadow on the rows around them, came out dark. Layers now take CSS drop-shadow()s (the display list's layer flag 32, drawn by the crate from the layer's alpha after its other effects, each shadow under the result so far, the frame's damage grown by their reach), and the painter gives such a box one layer with the shadows reaching it, its own and its ancestor's, and its views none.
TextEditor gains marks: ranges drawn with a color behind their characters that are the view's alone (no caret moves, nothing takes the focus, the text and its runs carry none of them). The DSP page selected a node's statement by setting the editor's selection, which on an iPad brought up the keyboard; a node now marks its statement, and a statement that does not compile is marked in the warm color. The web's rich editor draws marks with the CSS Custom Highlight API, the in-memory renderer behind the runs' backgrounds (which its text editor now draws too), and the native iOS 26 rich editor as backgroundColor on its string.
SuperSynth's keyboard tray folds: its ▾ leaves a strip with SHOW to bring it back (the notes held let go first), the choice kept across launches (useAppStorage), so the DSP page and the panels above have its room.
The DSP page's cards and wire handles took taps where they lay before they were moved: each card's offset came before its contentShape, tap and drag, and an offset moves what is drawn, not the layout frame the modifiers before it take taps in (SwiftUI's rule, which the renderers keep), so a tap on the empty canvas near its origin selected a card drawn elsewhere, often the output. The offset now comes last; a test holds every card's and handle's gesture inside its offset.
The DSP page's node inspector is gone: the selected node is edited where it is drawn, its title a field that renames it, each port's value a field (committed on Return, as it loses the focus, or as the card is deselected), ⤴ beside an expression argument to make it a node of its own and ✕ in the header to delete the node. An unselected card stays text, so a tap selects it without bringing up a keyboard; the code pane has the column to itself.
The DSP page's knobs are a UI panel of their own: on a wide screen over the code beside the graph (which gains the height the strip above it took), on a phone a third pane beside GRAPH and CODE.
A DSP-page card's menu comes up on a long press or a right click: Open for a node with a body, Delete for a statement. The selected card's ✕ is gone; the menu is on the card before its offset, so it is hit where the card is drawn.
Selecting a DSP-page card no longer moves its text: the fields that replace its title and values stand in the text's font and frame (the values had a font of their own, and the title's field filled the row where the text did not), and making an argument a node of its own moved from a ⤴ beside it, which pushed the value aside, to the card's menu.
A tap on the DSP page's graph, on a node or on nothing, takes the focus from the code editor (its keyboard with it on an iPad): the editor's focus is bound, and selecting or deselecting releases it.
The DSP page's programs are made of several files: modules the program imports and files its samples read, shown in a row over the graph (a module chosen shows in the program's place, graphs and code; + FILE adds one), compiled through readFile, saved in the pack and carried in the plugin's snapshot. A message from a module's function now names the module, in the TypeScript and Rust compilers alike, so the failure is marked in the module's text.
The DSP page's UI panel edits the program's data under its knobs: tables (a frame drawn, or started from a common wave), shapes (points painted, resampled) and samples (a WAV imported into the program's files) on SuperSynth's own screens, each change playing at once and written into the text as the declaration's value when the finger lifts; + TABLE, + SHAPE and + SAMPLE declare one. The edit API gains dataDeclarations, setDataValue and insertDeclaration.
The DSP page makes declarations and statements without typing them: a PROGRAM tab lists the file's declarations (each one-line declaration a field that writes it whole, functions and stages opening their graphs, a menu to delete one that nothing reads) with chips to add a parameter, control, const, enum, function, voice or master stage, and to import the program's modules; the palette adds var, state, when, if, for, an array and set. The edit API gains declarations, replaceDeclaration and deleteDeclaration, insertDeclaration takes every kind, and insertStatement indents a statement of several lines as a whole. A node whose value is a name or a literal alone no longer shows its syntax's kind as its head.
The DSP page edits modulation: a stage's node becomes a source from its menu (the matrix and its sources enum declared where the program has none), a parameter's row makes it @modulatable or maps it to a host macro, and where the program has a matrix the UI panel lists its routes (source, destination, amount, both ways), played at once, sent again each time the program compiles, saved beside the layout as <name>.dsp.routes.json and carried in the plugin's snapshot. The edit API gains makeSource, setModulatable, isModulatable and addMacro.
The DSP page's routes take an aux source (upside down with INV) and an output knob, as Serum's do; its macros move one parameter over its range or several by their amounts (macro 2 -> [cutoff: 2000, q: -0.25]), edited in the UI panel. Arrays and closures show as Enso shows them: an array written out is a node of its items, each a port, with a row to add one; a closure of one expression is written in place as a lambda; a node that makes several values says how many (×4) and draws its wires wider. The edit API gains appendItem, macros and setMacro; a graph node gains array and count, and a closure argument its inline text.
The DSP page previews each statement's value under its card as the program plays, as Enso shows a node's: the compiler keeps each stage statement's value in a register of its own when asked (LanguageOptions.probes, the program playing the same), the TypeScript and Swift machines copy the registers the editor names each chunk (setProbes, DSPProbeTap), and ProbeView, a registered view on the page and in SwiftUI, draws them without their values reaching the app's JavaScript. The program's UI is laid out as the program says: @group("Filter") puts a parameter or a data screen in a section, @style shows a number as a knob or a slider and a choice as a menu or steps, in both compilers alike; the PROGRAM tab's menus set them (setAttribute).
The DSP page's code is highlighted where the graph shows it: a card's expressions and arguments, and each PROGRAM row, colored as the code pane colors them (Code, the same grammar), and its fields too while they are not being typed in. A program's preview goes flat, not frozen on its last values, when the sound stops.
SuperSynth's own program opens on the DSP page and is worked on there at speed. The canvas builds only the cards near what its scroll view shows (the visible rectangle from onScrollGeometryChange, grown and snapped to tiles), so a voice of hundreds of statements is a screenful of cards; LazyVGrid and LazyHGrid build a ForEach's cells 48 at a time behind a lazyspacer the page puts at the grid's end, and the UI panel's knobs and the PROGRAM rows are lazy; a menu of every parameter is a Menu holding one inline Picker, and the page builds no rows for a picker that is a menu's item; a rich text editor whose runs differ only in color keeps one text node and paints each color as a highlight (the Custom Highlight API), so the code pane is a handful of elements, not a span per token; a preview's canvas draws again only when its values change. A macOS-only rule, .sb-section:has(> .sb-section-footer:not([hidden])), made Chromium recompute styles across the whole page at each change (300 ms switching to the PROGRAM tab, on any platform): a section now carries data-sb-header and data-sb-footer. The compiler reports each parameter's name in the source (knob[290] for s290, CompiledModule.parameterSources), so a macro's menus write names the program declares, and the PROGRAM rows show a declaration's keyword line, not its attributes.
SuperSynth's program titles and sections its knobs as SuperSynth's panel does: serum.dsp's KNOB_LABELS and KNOB_GROUPS give each of the 299 knobs its title and section (@label("{KNOB_LABELS[i]}") @group("{KNOB_GROUPS[i]}") on the family), so the DSP page's UI panel shows MAIN, OSC A, FILTER and the rest, each closed until opened, rather than 299 knobs called S0 … S298; a knob no preset is known to set keeps its name and goes in OTHER. The CLAP plugin gives a parameter its @group as its module where its name has no dotted prefix, so a host lists OSC A's LEVEL apart from OSC B's.
The DSP page opens SuperSynth's own program playing the patch loaded now (PATCH): its text (supersynth.dsp and the serum.dsp it imports, carried in the app as program/sources.ts, which npm run dsp writes), the patch's knobs and the rest of what the program reads as its knobs' values, its routes as the page's, and its tables, shapes and noise samples played in place of what the text declares, given again after each compile until that declaration is edited (LiveData). The TypeScript the compiler writes types a parameter's group and style.
The data PATCH plays in place of the text's (a patch's wavetables, shapes and noise) is the document's now, kept by the app as its files and routes are, so it outlives the page and undo brings back what an edit let go. It is merged into each compiled program, so the data screens show it, SAVE packs it (the pack's program carries it and <name>.dsp.live.json names it; opened, it is read back from the program) and a plugin plays it (its snapshot's program carries it and its editor state names it).
A React app's lazy stacks on the page unbuild the rows far from the visible area, as SwiftUI's do: a leading lazyspacer stands for the rows dropped before the built ones, as long as they were, with no gap after it, and the page asks to drop whole batches more than two screens away (before, with what each took; or after) and for the last one back when the spacer comes within a screen, so a long scroll keeps a few screens of rows built and nothing on screen moves. Lists, grids, the native renderers and the in-memory one keep the rows they build.
The DSP page compiles its program in a worker of its own on a page (compiler.ts, compile.worker.ts; an answer for text changed since is let go, and a worker that fails is let go for a compile on the page's thread), so a program the size of SuperSynth's no longer stalls typing: opening it went from about 1.7 s of the page's work to 1.5. The native app and the plugin's editor, which have no page Worker, compile on their own thread as before.
SuperSynth is one program shown two ways: SYNTH, its panel, and EDITOR, its graphs and code, both views of one session (program-editor/session.ts: one document, one compile, one node, one history), so they are always in step and either's UNDO takes back either's edits. The panel is the program's panel.ui (docs/notes/program-ui.md): plates of knobs, faders, switches, menus and stepped boxes bound to its parameters, screens bound to its data (an oscillator's table, an envelope, a filter's response, a painted shape, a sample), the matrix, its macros and modulation sources, in one scroll view on every screen; SuperSynth's own reproduces the pages it replaces (OSC, FILTER, MOD, MATRIX, FX), the effects in the program's chain order. EDIT rearranges it (a control selected, made another kind, rebound, retitled, moved, removed; rows and plates added, moved, removed), each change written to panel.ui; a program without one shows the panel its metadata implies. The editor's UI panel and PATCH are gone; Serum's presets load into whatever program plays (patchOnto), and the plugin always plays the program, a project saved with SuperSynth's patch opening as SuperSynth's program playing it.
How a control shows is the panel's alone: @style is gone from the language (both compilers), and @group is a parameter's only, its module in a host (the CLAP plugin's) and its section on a panel the program does not write; the metadata's groups list went with data's @group. A host's load in the CLAP plugin drops a snapshot the editor asked for just before it, which had undone the host's load and kept the editor from hearing of it.
FlowStack, a layout primitive of SwiftBrowser's own (SwiftUI has none built in): its children at their ideal sizes in lines, a new line where the next would pass the width it is given. The web's layout engine (and so the rasterizer, the plugin's editor among its users) places it, the DOM renderer shows it as it shows the other stacks, and the native renderer lays it out with a SwiftUI Layout doing the same. SuperSynth's plates lay their rows of controls out with it, so a row wraps where a plate is narrower than it: the plugin's editor (the rasterizer's text a little wider than Chromium's) had pushed its first plates past each other and the window's edge.
SuperSynth's program declares its knobs in their units: filter.cutoff: number(8...22050) hz with @taper(log), env1.attack: number(0...32) s with @taper(power(5)), oscA.unison: int(1...16), fxFilter.type: FilterType (an enum of Serum's 89), the rest number(0...1) where Serum shows a percentage, each @slot keeping its Serum index. Its body reads the names, and its curve functions (hertz, seconds, lfoHertz) are gone with the knob tables. For that the language has tapers (@taper(log), @taper(power(n)); the unit after a type's range, number(8...22050) hz): a tapered parameter's register holds its position, the machines (TS, Swift, the CLAP plugin's slots) turn a value set into it once, and every read goes through the taper, so a modulated read costs what it did (the TS machine's bench: the same 1.5 s and the same checksum, before and after); routes and macros add along the knob, so a route of half to the cutoff sweeps half its octaves whatever the unit; travel(p) reads where a parameter is along its knob; an enum's case counts as its index where the compiler needs a number. The panel reads any program's value in its declared unit (hertz, seconds, decibels, an enum's case as words); its Serum format, knobs.ts and preset.ts's copies of the curves are gone, and the preset reader binds a preset by name through the program's metadata (SERUM_KNOBS, knobValue), so the only Serum-specific code left is the .fxp reader and that binding (docs/notes/panel-plan.md). panel.ui names the parameters (knob(filter.cutoff)) and is written in the language's own syntax: a plate a const whose value is a plate(…) call, a page an exported const listing its plates, read with the parser as it is, an edit rewriting only the plate it changes.
The panel's first frame, its readouts and its tray#
The page opens on the panel as it will stay: the session starts with the program as shipped compiled (shippedCompiled: the checked-in program and its metadata, where the document is that program), so the first frame has every parameter's label, unit and range, and the compile that lands a moment later (the probed program the node plays) changes nothing on screen. Before, the first frame drew the panel with raw names and unformatted values and reflowed when the compile landed, a layout shift of 0.12 on a phone; it is 0 now.
The panel's readouts as they were before the parameters went into their units, which had changed them (the screenshot comparison that said otherwise compared alpha channels, so it saw no difference between any two opaque images; it compares colour now): a number with no unit on 0 … 1 reads as a percentage (LEVEL 75%, not 0.75) and on -1 … 1 a signed one; the oscillators' pan knobs say format: pan (C, L50); the octave and semitone readouts are whole and signed (int: SEMI +7, as the program rounds them), so the OSC titles fit again; whole reads a whole number in its unit, ratio a compressor's 4.0:1; the FILTER screen takes its type as the enum's case rather than a knob's position times 88, which had drawn the wrong response; and the tray's TUNE and glide TIME knobs are back, named by their parameters. A plate's title strip now shows as much above its contents as below (2 px each): the plate's 1 px border is drawn over the strip's top row, so the strip is a lip taller and its contents sit a lip down.
The keyboard tray's groups are the panel file's: export const tray = tray(group(…), …, phone: […]), each group a caption, a knob and its strips width wide, phone the rows that stand in for them on a phone (derived where it names none). SuperSynth's VOICE and GLIDE groups moved from the app's code into its panel.ui, so a program's tray is its own, and the app's code binds no parameter by name but the wheels' (pitchwheel, modwheel, bend.up, bend.down), which are every program's. The screens are unchanged pixel for pixel.
A library of tables, noises and filters; the effects in the standard library#
The stand-ins for Serum's tables and noises are a library of SuperSynth's own, any program's (src/library): 144 tables and 187 noises, the same recipes under generic names that say what they are (Saw dark 3, Pulse bright closing, Vowel warm 2, Kick short dark 12, Drone long dark 4), in families (Analog, Digital, Spectral, Vowel; Analog, Organic, Kicks, Hits, Inharmonic, Drones), each keeping the seed its random choices had, so every one sounds as it did (checked sample for sample). Which library table or noise plays for each of Serum's is serum.dsp's to say, by the path a preset writes (TABLE_STANDINS, NOISE_STANDINS, read from the compiled TypeScript as the layout is); serum/standins.ts only looks a path up. The import's report says "no stand-in here" where it said "no recipe".
OSC A and B pick their tables from the library: the row over the screen names the table as its live data titles it (the preset's name for a table it carries, the library table standing in for one of Serum's, Default for Serum's own saw), ‹ › step through the library's tables, and the name tapped opens their menu by family, the one playing checked. A table picked goes live under the oscillator's declaration, titled with its name (LiveRef.title, saved in the pack's live file and a plugin snapshot's editor state), so it survives a save and a reopen, and the title is what the row shows.
The library's menus are a submenu a family (SwiftUI's nested menus, the web renderer's submenu panels), then Import WAV…, which reads a WAV or AIFF the way a bank does (a Serum wavetable's clm frames, any other sound cut into cycles of 2048; a noise as it is, its left channel) and plays it live, titled with the file's name. The NOISE plate picks the same way: its item names the sample it plays (noise(noise.kind, …, sample: noise)), a row over its screen names what plays (the sample's title, else the kind), ‹ › step through the noise library, and a noise picked goes live as the sample (a colored-noise recipe rendered two seconds long) with the kind set to its first choice, which plays it. A patch's noise is titled too (the preset's sample's name, or the library noise standing in where that is a sample). Live data is written by the program's name for it: a data declaration now reports its @name (DataDeclaration.alias, noise for noiseLeft), and the synth view finds the declaration by either.
The envelope and filter screens read the program plainly, as the pickers do. An envelope's curves are three parameters of the program's, −1 … 1 each, 0 a straight stage, turned up the stage bends sooner, by one rule the screen and the program share (curveExponents in the editor, exponent in supersynth.dsp: two octaves of exponent a quarter turn, 1/16 … 16). Which Serum saved a preset is the reader's business alone: its curve knobs read as their distance from that Serum's defaults (knobValue and knobRaw take the era), so curves.newer is gone from the program, and the screens no longer build a Serum knob array to call the reader. The filter screen classifies the type by its enum case's name (low24, cmbMinus, phs12Plus, lowEq6, formant1 …) rather than by Serum's index, so any program naming its types that way draws right. The dead 'serum' format strings are gone.
The filters are the standard library's: import std { filtered, Filter, FILTERS }, fifty kinds any program can play (SuperSynth's filter code moved there, by kind rather than by Serum's menu: low-passes of three slopes, driven or not, high- and band-passes, a peak, a notch, a morph, combs and flangers fed back either way and darkened or not, phasers of one to four stages, shelves and a peaking EQ, ring modulators, sample and hold, combs, all-passes, a reverb, two more low-passes, Add Bass, three formant pairs, a band reject, two distorted combs), every kind built and the one picked run. SuperSynth's filter type parameters are the library's Filter, and serum.dsp maps each of Serum's 89 types to the library filter that plays it (FILTER_STANDINS, as the tables and noises are mapped): the reader turns a preset's type knob into that case and back. Every Serum type renders sample for sample as before (checked against the program before the change, at two variants each). The filter screen draws a library filter by its case (src/library/filters.ts), nothing of Serum's. The Rust compiler carries the same library (rust/src/std_source.rs) and compiles the program identically.
The effect screens read the program for what is off their plates: a chorus's taps are its delay parameters (<effect>.delay1, .delay2) and an EQ's corners its frequency parameters (<effect>.low.freq, .high.freq), by the effect's name, so the screens follow a patch's own values rather than a constant copied from the program (the old constants stand in only for a program that has no such parameters); the effect screen redraws as those parameters move. The flanger's and reverb's sketches keep their own model of the program's formulas (a 2.5 ms delay swept 2 ms, combs 31 ms long), which no parameter carries. The LFO shape helpers (lfo.ts) and the harmonics (harmonics.ts, the FFT a carried table's frames go through) moved from serum/ to program-editor/, being any program's; serum/wavetables.ts keeps what reads a preset's table.
The effects are the standard library's: hyped, distorted (with Distortion and FilterPlace), flanged, phaseShifted, chorused, echoed (with DelayMode), compressed, reverb and equalized (with EqBand), each stereo in and out, rates in hertz and times in seconds, any program's. SuperSynth's rack calls them with its knobs, working out its tempo-synced rates and delay times first; its own copies of the effects, and serum.dsp's copies of their enums, are gone. The library's reverb is now the Freeverb (eight damped combs and four all-passes a side, pre-delayed, cut low and high, widened), stereo in, in place of the small Schroeder one. The effect screens draw the library's effects: their numbers (a flanger's 2.5 ms delay swept 2 ms, a phaser's four stages over two octaves, a chorus's 4 ms sweep, the reverb's comb lengths, stretch and feedback, feedback knobs × 0.9, mix knobs to a half) are in src/library/effects.ts, the library's description for the app, as the filter shapes are. Every effect renders sample for sample as before, checked against the program before the change across the distortion's modes and places, the delay's modes, the EQ's kinds and the multiband compressor.
Sylenth1, a second bundled program#
Sylenth1 as a second bundled program, to prove the app a host: sylenth.dsp (its layout: each parameter's index from the preset format, its menus, its ranges) and sylenth1.dsp (four oscillators with unison of eight from the language's builtins, two filters from the library's kinds with their routing and control section, four envelopes, two LFOs with Sylenth1's eleven waves, a thirty-two-slot matrix for its sixteen routes, the voicing and glide, and the rack from the library in its fixed order), with its panel (sylenth1.ui, the document's panel.ui). src/sylenth reads its presets and banks: v2 programs as they are, v3 programs (one parameter more, the table deflated) through the reader's inflate, each knob's position turned into the program's value by name along the program's ranges and tapers, the routes into matrix routes, the polyphony and legato into the voicing. The app bundles both programs (BUNDLED_PROGRAMS), a Program menu in the preset well switches between them, and a .fxp opened loads into the program its plugin id names, switching the program where it is the other; the session's shipped compile covers both. Checked in headless Chromium: the switch from the menu draws Sylenth1's plates, and a v3 preset opened while SuperSynth plays switches to Sylenth1 under the preset's name. Not played yet: the arpeggiator (read and kept as state), aftertouch; the knob laws are assumed from the panel's ranges until measured against the plugin (docs/notes/sylenth1.md).
Serum 2: its format read, its presets opened, the program widened#
Serum 2's demo installer, opened for research: its 626 factory presets decode (versions 3 … 6; 237 set the arpeggiator, 97 with a drawn pattern), and its binary keeps its enums as text and its menus as pointer tables, so the Serum 2 note now has the mod source list (1 the wheel, 2 … 5 the envelopes, 6 … 15 the LFOs, 16 velocity, 17 note, 18 aftertouch, 21 … 24 the note-on randoms and alternates, 25 … 32 the macros, 38 fixed, 39 … 48 the LFOs' Y, and on to 59), the sixteen effect types, every menu's cases in order, the arp's parameters and its pattern format (a clip of notes indexed into the held chord, each with eight attribute lanes). Serum 2's enums are Serum 1's with cases appended, which corrected the Serum 1 reader where it had inferred: the filter types (96, the knob stepping by 1/95, which every sample preset's value falls on: LH 6 among the multi-modes, a flange-phaser pair after the phasers, four distorted combs and two Scream 3s after the band reject), the distortion's sixteenth mode (tape sat, a soft press with the highs lifted going in and taken back coming out, in the standard library's Distortion as tapeSat where a tape stop was), the unison stacks (12 and 12+7, one to three times each), and an LFO's rise and delay (in that order after the smooth: the knob the sample presets set on their vibratos is the delay). The effects' parameter orders and the 144 table and 187 noise paths the stand-ins map were as read. The warp modes' order stays inferred, Serum 2 listing its own.
A Serum 2 preset opens: src/serum2 has a Zstandard decoder and a CBOR decoder of its own (beside the Serum 1 reader's inflate), reads the .SerumPreset container, and maps the modules onto the Serum 1 reader's patch by name, each display unit turned into the program's knob position along its own ranges, each menu's case by Serum 2's name, the matrix by source number and destination module, the rack in Serum 2's order; what Serum 2 has that the program has not (oscillator C, filter 2, envelope 4, LFOs 9 and 10, macros 5 … 8, the bus racks, its own effects and oscillator kinds) is said in the import's notes. Every one of the 631 presets at hand decodes to what Python's decoders give, maps and builds; the app tells the file by its magic and opens it under OPENED .SERUMPRESET (checked in headless Chromium with a synthetic preset, a factory arp preset and a Serum 1 .fxp after it).
The program widened toward Serum 2: oscillator C, filter 2 with each source's balance between the two filters and filter 1 chained into filter 2, envelope 4, LFOs 9 and 10, macros 5 … 8 and 64 route slots, each at a host slot of its own past Serum 1's knobs (serum.dsp's S2), each a plate (OSC B and C one tabbed plate, the two filters another, so the top row keeps its columns) and a source or destination of the matrix. The patch pipeline carries what Serum 1 has no shape for by name (PresetData.extra, a third table), sets every parameter past Serum 1's knobs to its default first so a Serum 1 preset leaves the new parts as the program starts, and lets a route reach any slot. The Serum 2 reader fills them: over the factory presets the notes left are the bus racks and Serum 2's own effects, kinds and sources. 607 parameters and 10 586 registers, the same in Rust; checked in headless Chromium with a factory arp preset (five notes where there were eleven).
docs/notes/serum2-gaps.md: every Serum 2 feature the presets use that is still missing, each marked with what it needs (program only, a language feature, an interpreter opcode or voicing change, or app work) and how it would be built, with an order: the bus racks first (one language feature, a voice giving several stereos), then the program-only pieces (utility and Bode, the richer effect parameters, the warps, the LFO kinds, the unison extras), the arpeggiator, voice inputs (aftertouch, MPE, the voice index), the sample oscillator on a sample-read opcode, nested racks and a filter list a program chooses, the matrix's per-slot curves, an FFT for convolution and the spectral oscillator, and multisamples last.
The machines toward Serum 2: sampleread, program format 2, buses and convolve#
sampleread(sample, position), opcode 80 in both compilers and both machines: a sample at a position 0 … 1 of the program's own, between samples and clamped, stateless as shape is, so a sample oscillator's loop points, crossfades, reverse and ping-pong are arithmetic on a phasor in the program (Serum 2's sample kind, docs/notes/serum2-gaps.md). The samples parity case scans with it; the machine's loader table, the Rust word table and the Swift opcode enum carry it. The damaged-pack test now flips a byte inside a packed program's own bytes, where the regenerated parity pack put a source's text under the old offset.
Program format 2: the machines give a voice its note's pressure (aftertouch, polyphonic or the channel's), slide (MPE's Y), bend (its own pitch wheel, -1 … 1, left out of freq so a program sets the range), release (the note-off velocity), index (its lane), order (which note since the start) and sounding (how many voices sound) as registers 11 … 17, and the master stage the newest note's four as 18 … 21; voicing takes priority: (a VoicePriority parameter: last, first, high, low, velocity, deciding which voice a full machine steals and which held note a mono program plays) and latch: (a bool parameter: notes stay after their keys lift until a key goes down with none held). Both compilers lower the names and both machines fill the registers once a block, so the sample loop is untouched and the benchmarks hold (Swift supersynth 0.129 ms a block against 0.132 before). The web node sends stopNote's release velocity and sendPressure, sendSlide and sendNoteBend; the native bridge, the renderer, the C API and the CLAP plugin (note expressions, MIDI aftertouch and CC 74) carry the same. Two parity cases, inputs and monopriority, play every one of them on both machines.
Buses: a voice gives several stereos, [main, bus1, bus2] (each one value or [left, right], up to 8 past the main one), and master(main, bus1, bus2) takes each bus's sum over the sounding voices as a stereo of its own, the program's busOutputs and busInputs pairs; both machines sum the buses in the loop that sums the main pair (nothing more when a program has none), both compilers lower them, and the buses parity case sends two to an echo and a wash. Serum 2's two bus racks (docs/notes/serum2-gaps.md) are now program work.
convolve(sample, input, longest), opcode 81, in both compilers and both machines: the input through a sample as an impulse response (at the sample's own rate, scaled so its gain stays, up to the constant longest seconds, at most 4), in the master stage only. Its first 256 taps run sample by sample and the rest as a uniformly partitioned overlap-save convolution of 512-point transforms, the next block's tail worked out a block ahead, so it adds no delay; replacing the sample remakes the impulse and this block's tail at once. Both machines work it in double precision, the same operations in the same order (the TypeScript machine's convolver lives inside the class, which the worklet stringifies; the Swift one is DSPConvolver, which the plugin's Embedded Swift build compiles too). The standard library's convolved is a stereo convolution reverb on it, the convolution parity case plays both with an impulse at half the machine's rate replaced as it plays, and a machine test checks it against a direct sum. A stereo two-second impulse costs about 0.8 ms a 128-frame block in the JavaScript machine and 0.45 ms in Swift; programs without it are unchanged.
convolve takes impulses up to 24 s (Serum 2's longest factory one is 20.4 s), in partitions of two sizes: the first 256 taps sample by sample, taps up to 8192 in partitions of 256, the rest in partitions of 4096 whose 8192-point transforms and sums are spread a slice at a time over the sixteen small blocks of each large one, the next large block's sum made a block ahead so nothing waits. The large partitions' spectra are kept in single precision and sized from the impulse loaded (grown, never shrunk), so a program's longest costs no memory until an impulse that long arrives; the impulse is made when the machine is (off the audio thread in Swift). A stereo two-second reverb fell from 0.63 to 0.28 ms a 128-frame block in the JavaScript machine and from 0.43 to 0.19 ms in Swift; twenty seconds costs 1.0 and 0.4 ms. The parity case's impulse now reaches into the large partitions, and a machine test checks a sparse 33 000-tap impulse against a direct sum, rendered in uneven blocks and replaced as it plays.
Convolution in SuperSynth, and the plugin's state by hash#
SuperSynth plays Serum 2's Convolve. Serum's factory impulses are Xfer's and referenced by path, so SuperSynth has a library of its own: 35 impulse responses made from recipes (src/library/impulses.ts), reverbs as noise split at 1.5 kHz under decays that reach −60 dB at the recipe's length with the highs dying sooner, built up after a pre-delay with early reflections and two sides apart; speakers and cabinets as a band-pass with a presence peak; small bodies as a dozen resonances; Neutral, a plain medium space, and Dry; each side at an energy of one. serum.dsp maps every one of the 75 impulse paths the factory presets name onto them (IMPULSE_STANDINS; one not listed by its folder, the sound-design ones Neutral, the vinyl click Dry). The program's rack gains a CONVOLVE effect (mix, pre-delay, damping, tone and input trim, through the standard library's convolved, which now takes an impulse a side) with its impulse as the impulse samples; the Serum 2 reader maps the module's switch, wet, pre-delay, damping, tone and trim (the factory median trim of −15 dB at 0, as the library's impulses are quieter than Xfer's), its routes, its embedded impulse where it has one and its size, and says what it leaves out (the impulse's attack and decay, minimum phase, a pre-delay in beats). The rack's screen for it names the impulse and draws its level along its length, steps through the library, opens its menu by family, and imports a WAV, AIFF or FLAC: serum/audiofile.ts reads FLAC now (every subframe kind, both Rice codings, the three ways two channels are coded together, 8 to 24 bits; a 20 s stereo impulse in about 0.1 s), checked against the reference encoder's files. A patch carries an impulse only while its convolution is on, so builds and plugin snapshots stay small, and every patch's rack order takes the convolution after the effects it lists. All 626 factory presets read and build; the 152 with Convolve on play it, 151 on stand-ins. SuperSynth's per-block cost is unchanged.
The plugin's state names a library impulse by its hash. The impulse generator works in plain arithmetic now (its own exp, log, sin and cos, halves rounded up), so a port makes the same bits; its recipes and each side's SHA-256 moved to impulses.json (npm run impulses writes the hashes, a test checks them), and the plugin's Rust port (src/impulses.rs) reads the same file and makes all 35 bit for bit (tested against the hashes). Saving, the plugin names a sample whose bits are a library side {"rate":…,"sha256":"…"} (a dry two-float one stays, as a hash would be longer), a quick look at its length first so only a library-length sample is hashed; reading, it makes the side again before the engine or the editor sees the snapshot, in the writer's spelling by splicing and in any other through a parse, and refuses a hash that is no library side. A twenty-second hall in a project is two hashes where it was 9 MB of base64.
CI holds the library impulses to a second, hand-kept list of their hashes (SuperSynth's test/fixtures/impulse-hashes.json, which npm run impulses never writes): a recipe or generator change that alters an impulse a saved project may name fails even after impulses.json is rewritten, as do a removed one; the TypeScript test and the plugin's Rust test (on each platform it builds on) already compared what they make with impulses.json, and now say which impulse differs.
The plugin's state names library noises and tables by their hash too. Their generators work in plain arithmetic, the impulses' (now src/library/dmath.ts, with a power): the drones' and bell-like strikes' partials turn a sample at a time by a rotation instead of a sine a sample, the hum works out one 60 Hz period and plays it through, and decays multiply a sample at a time, so the noises are made 4.7 times as fast as before (all 187 in 0.9 s, the longest drone 40 ms). A table in a snapshot is its harmonics, so the analysis (harmonics.ts) works its FFT's twiddles in plain arithmetic too, and Math.hypot became a square root; the tables Serum names and no stand-in covers are seven guesses, now enumerable (guessedTable). Recipes and hashes moved to noises.json and tables.json beside impulses.json (npm run library writes all three), and the plugin's Rust ports (src/dmath.rs, noises.rs, tables.rs) make every noise sample and every table's harmonics bit for bit. Saving, the plugin names a library noise's sample as it does an impulse's side and a library or guessed table {"sha256":"…"}; reading, it splices each back, a table's numbers as JavaScript writes them. Over 105 of Serum 2's factory presets the saved state fell from a median of 367 KB to 27 KB (the largest from 4.4 MB to 124 KB), each read back to the snapshot it was; hand-kept noise-hashes.json and table-hashes.json hold the new hashes as impulse-hashes.json does the impulses'.
The plugin's state carries the LFOs' shapes, and the remap and shaper curves, as their points. A snapshot holds each as the 1024 numbers drawn from them, about 20 KB of JSON an LFO and ten LFOs a patch; the points were already in SuperSynth's editor state. Saving, the plugin draws each shape from those points (or from the triangle or straight line it starts as) with its Rust port of the app's drawing (src/shapes.rs after renderLfo), and where that gives the very numbers carried, writes {"drawn":[[x,y,curve],…],"ends":…,"steps":…} in their place; reading, it draws them again. The curve's power (eased) is in plain arithmetic now, a straight segment exactly as before, and test/fixtures/drawn-shapes.json holds the app's and the port's drawings to the same bits. Over the same 105 Serum 2 presets every one of their 1,470 shapes is points and each state reads back exactly; the median state fell from 27 KB to 7.1 KB (the largest is 98 KB).
SuperSynth models Serum 2's Convolve shaping its impulse and syncing its pre-delay, which the import had said it left out. From the manual (ϕ MIN "converts the IR to a minimum-phase representation, keeping the frequency response unchanged"; ATTACK fades the impulse in; DECAY shortens it) and the factory presets' values, not a measurement of Serum: library/shaping.ts makes the impulse minimum phase by the real cepstrum folded (its magnitude spectrum kept; at four times its length, twice past a million points, with a transform of its own that looks its twiddles up), then fades it in over the attack (half a cosine) and lets it fall 60 dB by the decay, cut where it has fallen 120 dB; the decay knob's top, 40 s, leaves it whole. The presets set decay from 10 µs to 40 s, often far past their impulses' lengths, so it is read as a decay time rather than a length. The patch's impulse data carries the shaping (attack, decay, minPhase), and impulseOf applies it as the impulse plays, after its size. The pre-delay's sync is a parameter (convolve.sync, slot 466, the CONVOLVE plate's BPM switch): synced, its seconds are read as beats at 120 BPM, snapped to a power of two and played at the host's tempo. Of the 152 factory presets with Convolve on, 61 now shape their impulse and 2 sync their pre-delay, every one built with finite taps; the one with a minimum-phase 20 s impulse takes about 3 s to make it, once. A shaped impulse is no library side, so the plugin's state carries it: over the 105-preset sample the median state is still 7.1 KB, six carry their impulse, and the largest is 2.4 MB.
The CONVOLVE screen shapes its impulse, and every effect has Serum 2's LEVEL. The shaping is the program's now (convolve.attack, convolve.decay, convolve.minPhase: saved with the patch, not host slots; the program does not read them), which the Serum 2 reader sets in place of fields on the impulse data and impulseOf reads. Under the impulse on the CONVOLVE screen are ATTACK, DECAY and ϕ MIN; a change shapes the impulse again a moment after the control rests, from what it was before its shaping: shapeImpulse remembers that for each impulse it makes (and its minimum phase, so another attack or decay redoes only the envelope), a library impulse is found again by its name after a project is reopened, and an impulse from a file or a preset is reshaped while the app runs, else plays as saved (the screen says to open its file again). A picked or imported impulse comes in shaped as the settings say. The panel's value cells now step along a parameter's taper (a decay from microseconds to 40 s). Each effect's output level is <effect>.level (slots 470 … 480, in the rack's order): a gain on a squared taper, 0 dB at the knob's middle, silent at 0, +12 dB at the top, modulatable, scaling the effect's output while it is on; a value cell in each plate's title strip, read in decibels (a gain format). The Serum 2 reader takes each effect's kParamLevelOut (a knob position) and the routes to it: 209 of the 626 factory presets set an effect off 0 dB, and 83 routes to an effect's level play. Turning it on showed an older bug: picking an impulse from the CONVOLVE screen's library never stuck, as its two sides were set one after the other on the document as the last render had it, the right side's edit undoing the left's; Session.edit now takes a function of the document as it is, and the panel's data edits use it.
The session tested headless, and two iOS layout fixes#
SuperSynth's tests now run the app's program session headless (test/session.test.ts, with createSwiftUIRoot as packages/react's tests do) and the panel's data edits as plain functions (setsLive and withLiveValue in program-editor/live.ts, taken out of SynthView's setData): an impulse's two sides set one after the other each stay, and edits and undos made in a row before a render each build on the last. Writing them turned up a second bug beside the one the CONVOLVE screen showed: the session kept each undo step with a deferred state update, which React may run after the document has moved on, so an undo could restore what it should have undone. The steps are taken when the edit is made now and kept in a ref (depth re-renders). Put back, each bug fails its test.
Two iOS layout fixes from a screen recording. The phone's jump bar (the chips along the top of MAIN and FX) waited for the page to be measured, which a native host reports after the first pass, so it appeared a moment later and pushed the page down; before a measurement the size class now says whether the screen is a phone, and on one the bar is there from the first frame. A strip cell's label no longer refuses to shrink: where a row has no room for it (a program's raw parameter names, as before its metadata lands) it is cut short, where it used to push its plate past the screen, and on iOS widen the whole app until something rebuilt it. Reproduced with swiftbrowser-shot (the native bundle headless) on a bundle made to start without its metadata; the app as shipped draws the same pixels as before.
The arpeggiator#
An arpeggiator for both bundled programs (docs/notes/arp.md). It is the machine's, between the keys and the voices, so the app, the web node and the plugin all play it: a program's arp(on: …, order: …, …) declares it (both compilers; the program format's arp, each setting a control), and while it is on the keys go to it and it plays the voices a step at a time on the transport. It holds Sylenth1's arp and Serum 2's: fourteen orders (up, down, the up/down and down/up pairs, random, random once a round, as played, converge, diverge, step, chord) over the held notes and their octaves; each round transposed by a multiple of a shift in one of twelve shapes; a step's length, gate and chance; a grid of up to 32 steps, each a transpose, a velocity (0 a rest) and a tie (the next step legato, the same pitch held); velocity by key, first key or step, eased toward a target; latch (and the pedal), retrigger. The TypeScript and Swift machines play the same notes at the same beats (plain arithmetic in one order, a generator of the arp's own for its draws; a block ends at the arp's next event, so the block size changes nothing), held to it by the arp parity case and eleven machine tests. Sylenth1's program plays its arp settings and sixteen steps as they were read (its time knob's law a guess); SuperSynth's has arp.* parameters, and the Serum 2 reader fills them from the arp slot's active clip, a pattern's notes as the grid (33 factory presets turn the arp on, 12 with a pattern). Both panels have an ARP page: the settings and STEPS, a new steps panel item that draws the grid's velocity, transpose and tie lanes, checked with headless shots on a phone and a wide screen.
The arp's patterns hold what Serum 2's do. The step grid could not hold chords within a step, notes off the grid, playback modes, repeats or more than 32 steps, so a pattern is now a list of notes kept as program data (a shape): each a start and length in steps, a row of the held chord, a velocity, a chance and a velocity spread, up to 512 of them on a timeline as long as it likes. The factory patterns settled how rows read: row r is held note r mod n, a wrap transpose up each time round, folded by a range, so Acid101's pitch of 1 and range of 12 make its rows over one key semitones; row −26 is read as the whole chord, and Serum's Chord step action as each note's chord voiced from its row. The arp walks a pattern's cells forward, back, both ways, at random, every cell once a round, from or to a random cell, once, or on one cell; besides, both machines now have repeats (the run stops after so many rounds with every transposition), an offset, thru, a retrigger on the beat and chance before or after the order moves on (arpPattern parity case, ten more machine tests; the lowering's check of the step lists had matched stepChord too). SuperSynth keeps its pattern as arp.pattern in place of its 96 step parameters; the Serum 2 reader writes each pattern's notes as they are (all 12 factory patterns whole, up to 35 notes), leaving only a rate in hertz and the Phantom wrap said; the ARP page's PATTERN plate draws and edits the notes on rows of the chord (checked with headless shots, phone and wide).
Serum 2's gaps, worked through in order#
What Serum 2 still lacks, measured: every factory preset read through the import and what it says it leaves out tallied (docs/notes/serum2-gaps.md, now with a table of it and the order to take it in). The first, cheapest step is done. SuperSynth's program has Serum 2's further modulation sources, which the machines already gave a voice: aftertouch (channel and polyphonic), pitch bend, MPE's X, Y and Z, release velocity, a fixed value, the note-on alternates, the voice index, the count sounding and a discrete per-note random; and each filter's output level (filter.level, filter2.level, slots 481 and 482, an OUT cell in each filter's strip), which 27 presets set to silence, read and routed, with routes to the voices' amp. Presets that import with nothing said went from 13 to 20, and a preset's median from 7 notes to 6; tests play the new sources (aftertouch turning an oscillator down, a filter at no level silent).
The second step of Serum 2's gaps: the LFO kinds, Utility and Bode. Each of SuperSynth's ten LFOs has a kind (curve, path, Lorenz, Rössler, random), a ×10 rate and a direction (forward, reverse, pendulum), all state. Lorenz and Rössler are three state cells stepped by their equations at the LFO's rate, random a new held value each cycle, a path its X shape at the phase and its Y shape (lfo1.y, a shape an LFO, which the reader renders from the path's points) at the same phase; each kind runs in a when region, so the per-block cost did not move (0.0625 ms against 0.0627). The Y is a source, lfo1y … lfo10y, appended to the matrix's sources so a saved route keeps its index. Each LFO plate has a third row: KIND, DIR, ×10 and the Y source. The standard library gains utilized (each side's polarity, one-pole low- and high-pass, the lows made mono under a crossover, width and balance) and frequencyShifted (a Hilbert pair of second-order allpass chains times a quadrature sine, the sidebands mixed by the direction and spread by the width, a delay and feedback after it, a mono input), checked with a 440 Hz tone shifted 100 Hz each way; SuperSynth's rack ends with UTILITY (slots 483 … 493) and BODE (slots 380 … 391), each with its switch and LEVEL, and the Serum 2 reader fills them and their routes (the Bode's blur said). The rack's collapsed strips are 4 points shorter and its gaps a point narrower for the thirteen effects (on an 11-inch iPad with two effects open the rack still runs about one strip past the page and scrolls, as the eleven did by 25 points); each LFO row's KIND and DIRECTION menus show only their choice. On a phone a selected effect's title strip ran past the screen, ▲ ▼ beside ROUTES, and shifted the page (the delay's did already), so a phone's title shows the route count without the word; the UTILITY and BODE title strips keep to what fits a phone (MONO and LEVEL; BPM, DELAY and LEVEL), the polarity switches, the crossover and the Bode's width and mono input being parameters the presets set without a cell on the panel. Of the 626 factory presets, those that import with nothing said went from 20 to 45, and a preset's median from 6 notes to 5.
The third step of Serum 2's gaps: the mix and the bus racks. Each of SuperSynth's sources goes into the filters or past them to the main rack, out direct (past every effect, at the direct output's volume) or nowhere, and each filter's output the same three ways (*.out; the factory presets route 76 sources and 42 filters to None, which played before); each source and filter sends its own signal to each bus by a knob (oscA.bus1 …, host slots 392 … 399 and 494 … 499, modulatable). A voice gives [main, bus1, bus2, direct]; each bus is a rack of the main rack's thirteen effects again on its own parameters (bus1.chorus.mix …, 224 of them, preset state with no host slot), built by the one rack(x, r) the main rack is, whose lets pick each rack's parameters; scripts/bus-racks.mjs writes both the parameters and the lets from the main rack's declarations, and the panel's bus plates from its main ones (npm run dsp runs it; a test checks the files are as it writes them). A bus's rack runs only while one of its effects is on, a voice works out its sends only while a bus runs or a send is up, and each bus has a volume and goes into the main rack, out direct or into the other (bus 2 into bus 1 a sample late through a cell, so no rack is built twice). Building it showed a compiler bug: a choose whose option was a state cell made a program the machines refuse; both compilers now copy the cell out (the buses parity case feeds one back). The bus racks made a block cost more even with nothing on them, which a profile put on two loops of the machines that walked the whole program each block: flushing denormals from every filter, and gliding every parameter toward its target. Both machines now flush only the filters in the streams that run and glide only the parameters set since they came to rest; with them the four factory patches cost 3 … 8 % more a block than the program before the buses on the same TypeScript machine (Mono Bass 0.159 ms against 0.149), and sound the same to the bit. A route's destination may now name a parameter of no slot (a bus's effect's), and the Serum 2 reader reads the routing slots' outs and sends, the global bus volumes, destinations (0 the main rack, 1 direct, 2 the other bus, read off the presets: the 7 that send a bus into the other have effects there) and the direct volume, both bus racks as it reads the main one (each effect from Serum's defaults, a second said), and routes into a bus's effects, onto the sends and the volumes. A bus's convolution plays the program's own impulse for now and the reader leaves it off (64 presets). The FX page shows one rack at a time, picked in its head (MAIN, BUS 1, BUS 2, a dot on one with an effect on); the MIX page has the outs and each bus's sends, volume and out (checked with headless shots, phone and iPad). Of the 626 factory presets, those that import with nothing said went from 45 to 53, a preset's median from 5 notes to 4; the 193 that said their bus effects were left out play them.
A bus's convolution plays an impulse of its own. The patch data carries each bus's (busImpulses, as impulse is the main rack's), which the Serum 2 reader reads from the bus's Convolve as it reads the main one's; impulseOf(patch, bus) stands a library impulse in for one of Xfer's and shapes it by the bus's own attack, decay and minimum phase (bus1.convolve.attack …), and a build, a loaded patch, the DSP page's data and a plugin's snapshot carry bus1.impulse … (a library one by its hash, as the main rack's). The machines' samples hold 8 million floats: the noise's room is what it was less the buses' dry impulses (eight floats), and a bus's impulse takes what the noise and the main rack's leave, cut there and said. Each bus's CONVOLVE plate's screen picks and shows its own. All 71 bus convolutions on in the factory presets play (2 cut for room, the longest 20 s); presets that import with nothing said went from 53 to 56.
The fourth step: Serum 2's warps. WarpMode keeps Serum 1's 24 in their place and takes Serum 2's after them, 76 in one menu: FM, AM and RM from the second other oscillator, the sub and each filter (a sample late, through a cell); phase distortion, FMX and FMP from each source; phase distortion by the oscillator itself; even/odd; a low- and a high-pass at the note; the distortion's curves. Controls work out a mode's kind and source, so each unison voice chooses among 46 kinds; each warp is a phase map and a change to the read, which is what lets a second warp (osc*.warp2Mode, .warp2) follow the first in series with one table read. Comparing the program before and after on Serum 1's modes, every one sounds the same to the bit, and a block costs what it did; the registers grew from 18 781 to 26 665. A Serum 1 preset's warp knob is still read over its 24 places; a mode past them, which the knob has no place for, is kept in the patch by name, and so through a plugin's save. The Serum 2 reader maps every warp name the factory presets use, warp 2's mode and amount, and routes to warp 2; the oscillator screen draws self phase distortion, even/odd and the curves. Each oscillator's unison strip has WARP 2 ▾ (a value item may now carry a menu, as a knob does), its amount beside it once a mode is chosen; on an iPad's oscillator plate SPREAD and STACK are cut short in that strip. Of the 626 factory presets, those that import with nothing said went from 56 to 103, and a preset's median from 4 notes to 3.
The fifth step: the mod slots' curves and smoothing. matrix(…, curves: true, smoothing: true) gives each slot two shapes, route{i}.curve and route{i}.auxCurve, that its source and aux are read through (the diagonal at first; a route both ways is read through its curve, then moved to its middle; an upside-down aux is turned over after its curve), and a smoothing time, route{i}.smooth, a smooth over the slot's value where it is above 0. A route with either goes through its slot; routeShapes(matrix, routes) gives the shapes to send as routeValues gives the parameters. Both compilers make the same program byte for byte (smoothing a word of the Rust one's), and the routeCurves parity case plays curves, an aux's curve upside down and smoothing, then changes them, in both machines. SuperSynth's 64 slots have both, and a block costs what it did. A route carries its curves (128 points) and its smoothing in seconds: in the patch, the DSP page's routes and routes file, and a plugin's snapshot (every slot's two shapes; the plugin's compaction carries them as their numbers). The Serum 2 reader draws a slot's own curves (flex) where it has them, else bends the diagonal by its curve-in (the main curve) and curve-out (the aux's), on a scale guessed from one preset family; smoothing is the mean of the rise and fall times, said where they differ, and a slot's delay is said and left out. The MATRIX page's route detail draws the response through the curve and has CURVE (a bend, dragged; DRAWN for a slot's own) and SMOOTH under OUTPUT, whose partial fill now starts at the bar's left. Of the 626 factory presets, 102 import with nothing said (one fewer, for the three delays and three rise-and-fall pairs now said), a preset's median still 3 notes.
The sixth step: an effect more than once, and the splitters. Two additions to the language, in both compilers byte for byte and a parity case (splitRack) for both machines: an effect family, effect eq[i in 1..<3](on: …) { x in … }, one effect for each index named by it (eq for 0, then eq2, eq3), so the first of each can stand apart and keep its place in the rack and its saved input numbers; and an effect of several inputs, effect join(on: s) { low, mid, high in … }, an input for each parameter (fx.in.join.low …), giving its first while off, the metadata listing such an effect's inputs. A chain was already a graph, each effect's input any other's output, so with these a rack splits: band effects that read one input, the effects of each band after it, a join. SuperSynth's racks each have as many of each effect as serum.dsp's RACK_COUNTS says (the main rack three EQs, compressors, distortions and filters, two of most others; a bus fewer), whose parameters the rack generator (scripts/bus-racks.mjs) writes from the first's, the rack function reading every instance as a record (eqs[i].freq), and a splitter: three bands, low and high, low, mid and high, or mid and side (split.kind), complementary so they sum to the input within a float's rounding, and their join. The registers grew from 28 498 to 33 064; the factory patches sound the same to the bit at the same cost a block. The Serum 2 reader puts a second or third effect on the program's (more are said), reads a splitter's bands from the module counts after it and the effects that follow, and routes onto instances and the crossovers; a rack it cannot write as an order of the firsts goes in the patch as its routing (rackRouting). The FX page shows a family's later members and the splitter only while on (+ ADD at the rack's foot turns one on at the end of the line), each band's name on the line and as a tag on its effects, the arrows moving an effect across a band's mark (never into a band its kind hides) or the splitter with all it holds; switched off, the splitter leaves the line and its bands' effects stay in it in order. Of the 626 factory presets, those that import with nothing said went from 102 to 177, and a preset's median from 3 notes to 2.
The seventh step: the sample and granular oscillators. The machines gain granular(sample, window, position, density, length, pitch), opcode 82, in both compilers and both machines with a parity case: up to sixteen grains a voice, each under a window shape read across it, spawned at the density's rate, each taking its position, length (1 ms … 10 s) and pitch (a negative one backward) when it starts. An instruction holds five operands, so the window's shape index is packed with the sample's, and the per-grain randomness is the program's own: noise drawn into those operands is sampled once a grain. Each of SuperSynth's oscillators has a kind (osc*.kind: wavetable, sample, granular), a stereo sample of its own (osc*.sample, .sampleRight) and a grain window (osc*.window); a sample plays at the note against its root from its start, looping or once, and a cloud plays grains around the oscillator's position, each grain's place, length, pitch and direction drawn from noise both sides share, with random pan as a second, decorrelated cloud in the sides. The registers grew from 33 064 to 33 473; the factory patches sound the same to the bit at the same cost a block. Serum 2's factory samples are Xfer's, so the library's noises gain a Tonal family of 18 pitched stand-ins made at middle C (plucks, keys and tones: partials with their own decays and stretch, a strike or a breath), ported to the plugin bit for bit and held by hash; serum.dsp maps the 130 sample paths the factory presets name onto them, a folder's sound for one it does not list. A patch carries an oscillator's sample only while its kind plays one (up to six seconds a side, room the noise leaves for them), as do builds, the DSP page's data and plugin snapshots, where a stand-in is its hash; the window is drawn from Serum's kind, parameter and skew (library/windows.ts: Hann, triangle, Tukey, Gaussian, Blackman-Harris, exponential decay). The Serum 2 reader reads a sample oscillator's path, start and loop, and a granular one's density, grain length, scatter, pitch, length and direction spreads, width and window, saying what it leaves out (a loop region and its modes, a scan, a warp or unison on a sample, random gain; what Serum's default density mode means is not known, and its values are read as grains a second). On the panel, any item may now say only: <param>, is: <values> and shows only while the parameter is one of them; each oscillator's kind is a menu at the left of its screen's row, and a sample or a cloud shows a new sampler screen (the sample's level along it, marked where it plays from and dragged, the library's sounds stepped or imported, its root by note name) over the kind's own knobs, so the plate keeps its size (checked with headless shots, wide and on a phone). Of the 626 factory presets, those that import with nothing said went from 177 to 179, a preset's median still 2 notes; the 110 sample and 66 granular oscillators play (but one granular one with no sample of its own), and the 158 presets with a multisample and 43 with a spectral oscillator still play those as wavetables.
The eighth step: the spectral oscillator. The machines gain spectral(sample, start, speed, ratio, loop), opcode 83, in both compilers (byte for byte) and both machines with a parity case and a machine test: the sample resynthesized by a phase vocoder, so its pitch (times ratio) and its time are apart. Each 512 output frames it takes the sample's 2048-point Hann-windowed frames where it reads and a hop before, as two real transforms in one complex one on the convolution's FFT; finds each bin's frequency from how its phase moved; moves it by the ratio to the nearest output bin (several summing at the strongest one's frequency); carries each output bin's phase on by a hop; and overlap-adds the inverse transform under the window. It reads from start at each note on and moves at speed (its own pace at 1, held at 0, backward below), round again while loop is on, else silent past either end. Its memory is its own, a lane each in double precision (the Swift machine's DSPSpectral, which the plugin's Embedded Swift build compiles too; CMath gains a double atan2), and the two machines agree within the parity bounds. SuperSynth's oscillators gain a fourth kind, spectral: the oscillator's sample at the note against its root, from START at SCAN's pace, once or looping, in mono (the sample's left side, half the cost: about 35 ms of the JavaScript machine's time a second of audio, a voice), through Serum 2's spectral filter as a time-domain band from LOW to HIGH (a notch where LOW is above HIGH) mixed by FILTER, run only while that is up. The registers grew from 33 473 to 33 593; the factory patches sound the same to the bit at the same cost a block. The Serum 2 reader reads a spectral oscillator's sample, start, loop, scan rate (a position set by hand held there) and its filter's band and wet, and says what it leaves out: the filter's shift (20 presets; what it moves is not known), phase lock, transients kept apart, a frequency offset and the spectral warps. The kind menu has SPECTRAL, with START, LEVEL, SCAN (×1.00, its pace), LOW, HIGH and PAN over LOOP and FILTER (checked with a headless shot). The 53 spectral oscillators in 43 factory presets play; 179 presets import with nothing said, a preset's median still 2 notes, and only multisamples (158 presets) still play as wavetables.
The ninth step, and the last of the order: multisamples. No new opcode: each of SuperSynth's oscillators gains a fifth kind, multisample, holding up to eight zones, a mono sample each (oscA.zone1 …), with each zone's lowest and highest key, root and tune in a zone map (a shape, oscA.zones, four numbers a zone). Each zone plays its sample at its own pitch at its root, gated by whether the key is in its range, from START, once or looping; its level follows the velocity as VEL says, under an envelope of its own where ENV is on. Writing it turned up that SuperSynth's voice redefines note as the matrix's source (the key over 127) early on, so the oscillators now take the key itself, with the gate and velocity. The factory patches sound the same to the bit at the same cost; the registers grew from 33 593 to 34 186. serum2/sfz.ts reads SFZ: regions under global, master and group headers, keys by number or name, a value running to the next opcode. The Serum 2 reader turns a multisample oscillator's embedded SFZ into zones at velocity 100 (the 79 oscillators with other velocity layers say so), its loop from the oscillator or the SFZ, its envelope from Serum 2's override or else the SFZ's amp envelope, and its velocity tracking the same way, and says the rest (timbre shift, scan, key zones, warps, unison). Xfer's samples play stand-ins (serum/zones.ts): a zone's sample as the list has it; a kit's drums by their words (kick, snare, tom, hat …) at their own keys; else the instrument by the SFZ's name, then its folder (piano, electric piano, strings, choir, brass, winds, plucks, mallets, pads). Neighbouring zones with the same stand-in become one zone, so a piano is one zone of the library's piano at middle C. An oscillator keeps at most eight zones (the narrowest neighbours joined, which is said), and its zones share the room its sample would take, cut and said. A factory drum sample's stand-in now goes by its folder's words too. On the panel, MULTI has the sampler screen on its first zone with a strip of its zones by key, START, LEVEL, VEL, ATTACK, RELEASE and PAN over LOOP, ENV, DECAY and SUSTAIN. A library sound or a WAV makes one zone, and Import SFZ… takes an SFZ with the sounds it names (picked together, each matched by its file name) as the player's own multisample, played as it is. Of the 626 factory presets, those that import with nothing said went from 179 to 195, and a preset's median is still 2 notes. Every oscillator kind of Serum 2's now plays: of the 246 multisample oscillators, only one, which has no SFZ, still plays as a wavetable.
Routes to any knob, and the gaps left#
With the order's nine steps done, a tally of what each note alone keeps from importing clean put routes first, and the tenth step was the routes to knobs the program has or could have. A route now reaches any of the program's modulatable parameters by name, not only one with a host slot: a cloud's density, grain length and spreads, a spectral oscillator's filter, a multisample's velocity tracking and envelope (now modulatable), an oscillator's start, position and scan pace where its kind reads them (said where Serum's oscillator would read one and ours does not; a route to the wavetable's part of an oscillator of another kind is dropped silently, as Serum ignores it), and an LFO's smooth, rise and delay (now modulatable). There are three new knobs: each LFO's start phase (Serum 2's phase in degrees, read; the cycling modes start there, an envelope-mode LFO as before), the sub's coarse pitch past its octave (read), and the compressor's MIX against the dry signal (Serum 2's wet, read; the rack generator gives it to every compressor instance and bus). The panel shows them as PHASE on each LFO's third row, CRS in the sub's strip and MIX in the compressor's strip. The factory patches sound the same to the bit at the same cost; the registers grew from 34 186 to 34 620. Of the 626 factory presets, those that import with nothing said went from 195 to 239, and a preset's median from 2 notes to 1. docs/notes/serum2-gaps.md has the new tally and an order from here.
After the tenth step, a list of the gaps left that can reasonably close, worked through in order. The Bode's blur first: each Bode (every instance and bus) gains BLUR (bode.blur, preset state, modulatable, on its strip), the shifted sound run through four allpasses (4.7 … 17.3 ms, gain 0.6) and mixed in by it, a guess at Serum 2's diffusion; the reader reads Serum's percent and routes to it. The factory patches are bit for bit as before at the same cost. Of the 626 factory presets, 258 import with nothing said (239 before). Then the LFOs' points: Serum 2 lets a route move an LFO's points through a mod bus (a point's value, place or curve, on a drawn LFO or a path), which 63 factory presets do. SuperSynth gains four point knobs (point1 … point4, the bus's value, −1 … 1, modulatable, preset state), each on one LFO (point1.lfo), and for each the LFO's shape (and a path's Y) with the bus's points moved as far as they go up and down (point1.high, .low, .highY, .lowY, rendered by the reader with how far that is, .up, .down); the LFO crossfades toward them by the knob over that distance, in a when region per knob that runs only on its LFO. That is exact for a point's value (a drawn shape is linear in it) and a crossfade for its place or curve. The factory patches play bit for bit as before at the same cost; 277 of the 626 import clean. Then filter 2 routed into the filters (23 presets): it is filter 2 chained into filter 1, the filters the other way about, so SuperSynth gains filter.chained (preset state; the filter strip had no room for a second switch beside 1 → 2) and plays the two filters in a when region of their own while it is set, filter 2 first and its output into filter 1 with what leans there, filter 1's out the pair's; the reader sets it unless filter 1 is routed into filter 2 too (said). 285 import clean. Then the noise's colour, which 46 presets route to and none sets: what Serum 2's does is not known, so COLOR (noise.tone, modulatable, the middle flat) is a stated guess, a tilt about 1 kHz to ±12 dB at either end, run in a region only where a route moves it or it is off the middle (noise.tilted). 305 import clean. Then the oscillators' pitch modes and frequency offset, which the import neither read nor said: each oscillator gains RATIO and HZ (oscA.ratio, oscA.hz, preset state, modulatable), its frequency times the ratio and the hertz added after, with the reader's guess at Serum 2's numbers (a ratio's 2, 3 … a multiple and 0 and below halvings; a harmonic's 0 the note, 1 the second), and routes to both. So that a route sweeps either along its whole range, the language's @taper(power(n)) now takes n 1, a linear taper (both compilers, byte for byte; the machines already read any whole exponent). 314 import clean, and a preset's median is now nothing said. Then the sound as a source: each oscillator's, the noise's, the sub's and each filter's output are the matrix's sources audioA … audioFilter2 (OSC A … FILTER 2), appended so saved routes keep their indices, made after what they read so a route back into their own part reads them a sample late; routes from them into the effects are said. 319 import clean. Then the routes to the envelopes' curves and to the octaves: the curve knobs are modulatable, each a part that works its exponent out a voice only where a route moves it (once a block otherwise, as before); each oscillator and the sub gain OCT MOD (oscA.octaves, stepped, with the linear taper), which Serum's routes to the octave knob reach. 333 import clean. Velocity layers stay out: a factory multisample has twenty to thirty regions a layer, and the program's eight zones split among layers would cost the keys more than one layer at velocity 100 does. Then unison on a sample or a multisample oscillator: up to three voices, the outer pair detuned the detune's width apart and spread across the stereo width, the middle one too at three or more, in a region that runs only where unison asks for more than one; past three voices, and on a cloud or a spectral oscillator, it is said. 338 import clean. Then a sample's loop region and modes: a sample oscillator loops round its own region forward, there and back, backward or tailed, crossfaded over the loop's end, stepping along the sample with sampleread from each note's start in a region that runs only where one is set; the app sets each sample's length (oscA.seconds) as it loads one, and the oscillator's kinds became when regions (a choose cannot hold the loop's state), the factory patches bit for bit as before at the same cost. 348 import clean. Then the FX filter's stereo, which 21 presets set and the import neither read nor said: STEREO spreads the two sides' cutoffs apart, an octave each way at either end (a guess), on every instance and bus, routes reaching it. 353 import clean. The racks' counts stay as they are: a third Utility or a second Convolve on a bus would make one preset each import clean, for a convolution's memory or a rack's registers more in every patch.
Continuing down what was left: the LFOs' mono switch where it can be honoured without the language: running with the song, a drawn LFO is the same in every voice already, and a mono random one now draws its value from its cycle's number (lfo1.mono), so every voice holds the same (a test plays two notes together as the sum of each alone, which a per-voice random does not); mono retriggered or an attractor is still said. And unison on a sample or a multisample up to seven voices, spread as a wavetable's are, the voices past the count not run. 358 import clean. Then a cloud's scan: a granular oscillator whose scan is set or routed moves along its sample from each note at its pace, round the end, in a region that runs only where it scans (the reader turns it on). 362 import clean. Then the warps on the sample kinds: those that work on the sound itself (AM and RM by their source, the low- and high-pass, the distortion's curves) play on a sample, cloud, spectral or multisample oscillator's output as they do on a wavetable's, read from the kind's own module (the import had read the wavetable's instead) with routes to their amounts; the phase warps are said. 382 import clean. FM, FMX, FMP and PD by a source on a sample kind move its playback frequency by the modulator, an octave either way at the top (FMX's model; a guess for the others). 384 import clean. And the multisamples' velocity layers, said in 79 presets: a preset carries no multisample's audio, so every zone plays the library's stand-in for its sample's name, and in all but 2 of the 108 layered factory multisamples every layer would play the same stand-ins as the one at velocity 100; the layers are now said only where another would bring a stand-in in (both kits). 419 import clean. Self-PD on a sample kind plays as its playback frequency moved by its own sound a sample before (a feedback FM, a guess). 427 import clean. A multisample's timbre shift picks the zone a key that far off would play (read as semitones, a guess), at the note's own pitch, routes reaching it. 437 import clean. A cloud's scan turns round its region (Serum 2's end), and a sample's or a spectral one's random start starts each note up to that share of the sample later, drawn from where the song is (a voice's noise starts each note the same). 442 import clean.
Then a cloud's random grain gain, which needed the interpreter: granular takes a gain (granular(…, pitch, gain = 1)), each grain taking it as it starts as it takes its pitch. An instruction holds at most five operands and the granular opcode had all five, and both machines lay their decoded instructions out around that (the TypeScript one at a stride of eight, the Swift one at twelve with every slot after the operands spoken for), so rather than widening every instruction, a gain other than the constant 1 makes the new opcode granulargain (84), whose last operand carries the pitch, held to ±16 as the machines hold it anyway, plus 32 × the gain's step (0 … 31), on the pitch's side; the machines take the step and the pitch apart again exactly (both whole steps of 32 apart), at a cost of about a tenth of a cent in the pitch. A gain of the constant 1 still makes opcode 82, so every program compiled before compiles byte for byte the same and old packs load. Both compilers make it byte for byte alike, and the parity case's third cloud plays it in both machines within the tolerance. SuperSynth's clouds take 1 − |noise| × oscA.spreadGain, which the Serum 2 reader fills from the random gain and routes to. 449 of the 626 import clean. Then a batch of small ones: the voice filters' stereo (set in 45 filters and never read before, routed in 14 presets), the voice panel's envelope and LFO time scaling, routes to the global transpose, a sample's fixed pitch, and unison on a cloud (each grain one of the unison's voices). 460 import clean.
Then the LFOs' mono switch for retriggered LFOs and attractors. A voice can now read newest (the newest note's freq, gate, velocity, note …, any voice's), which only the master stage could: the machines already kept those registers for it, in its one lane, and now set them across every lane and before the voices' block code (the values are the same everywhere, so both machines' layouts read them alike), and both compilers resolve newest in either stage, functions included (byte for byte; the inputs parity case's voices read it). SuperSynth's mono LFO, retriggered or once from each note, keeps a clock in each voice that starts over whenever the newest note does (it changes, or its key goes down again): every voice's phase, random draw and attractor state start over together and so run alike. A free-running attractor stays said. 464 of 626 import clean. Then the multiband compressor's crossovers and band gains, which 80 to 134 presets set and the import had never read: the standard library's compressed takes where its bands split and each band's gain after (its defaults what it did, so programs that called it before compile the same; both compilers' copies of the library alike), and SuperSynth's compressors have them as knobs on every instance and bus, routes reaching them. 468 import clean. Routes to a convolution's size (an impulse stretched by up to two decades as it plays) and to a vintage reverb's scale (its meaning unknown) stay said. Then the rest of the multiband compressor and the reverb's types. The standard library's compressed takes each band's threshold, pull above, lift below and deadband (all 1 unless given, so what called it before plays the same), and its reverb takes a design (ReverbKind: plate, hall, vintage, space, abyss), the plate Freeverb as it was, a constant design building only its own; SuperSynth's compressors and reverbs have the new knobs on every instance and bus. Reading which reverb fields the presets keep by type showed the import had taken a reverb's DELAY (a hall's decay) for its pre-delay; it now reads the pre-delay from PRE DELAY. The bands' fields and the designs' knobs have no units said anywhere, so their laws are guesses, listed with the others to measure. 470 import clean; the factory patches play as they did. A reverb's pre-delay past PRE's 0.2 s goes on a LONG PRE knob added to it (the library's reverb taking how long its pre-delay may be), up to the 2 s a delay may be: 473 import clean. Then routes to a convolution's size, which stretch its impulse as it plays: the reader sums how far the routes reach along the size knob, the app renders the impulse at its size and at both reaches, and the program crossfades three convolutions by where the routes put it (one convolution, as before, where nothing routes to the size). 482 import clean. Then PRE and LONG PRE as one knob: PRE in seconds up to 2, Serum 1's knob (0 … 0.2 s along it) read by its own law where a preset's place for it is read, and a Serum 2 pre-delay past that kept by value, as a value a knob's place cannot hold is; the factory patches play within 1e-7 of before (the conversion's rounding now the app's, not the machine's). Then the sample oscillators' details: each oscillator's key and velocity zone, the spectral filter's CUT as a knob routes reach, and a spectral oscillator's loop region and ping-pong, which spectral's loop operand now carries packed in a whole number (0 and 1 as before; both machines, the parity cases, no compiler change). 498 import clean; the factory patches play as they did. Then, without touching either machine: eight LFO point knobs instead of four, a fourth compressor, filter and EQ and a third Bode in the main rack and a third compressor and Utility and a second filter on each bus, and a sample oscillator's end. 510 import clean; the factory patches play as they did, at the same cost. Then a fifth compressor in the main rack, a second distortion on each bus, and a second Convolve in every rack, playing its own impulse (with its own stretched copies where routes move its size) that the reader takes from the preset and the app renders after the others. 520 import clean; the factory patches play as they did, at the same cost.
The branch reviewed before its merge#
Ninety commits on, the branch was read end to end for what would get in the way of the next engine change, every suite run on it (none had run in CI, the branch having no pull request), and the cheap fixes made before the merge; the structural ones wait for the engine iteration, which they lead.
- The generated program files leave git.
supersynth.dsp.json(4.2 MB),supersynth.program.ts,sylenth1.*andsources.ts, re-committed on most of the ninety commits, were 25 of the 29 MB the branch added to the repository, andtest/fixtures/snapshot.jsoncarried the compiled program a second time, byte for byte.npm run dspwrites them now (from the compiler's source through Vite's module runner, so no build of packages/dsp comes first), every script that needs them runs it, and they are ignored. The snapshot fixture stays, as the test output it is, naming its program by hash; the program is committed once, as a pack (test/fixtures/supersynth.dspk, 416 KB), which the Swift tests read withDSPPackand the plugin's build and host test check against their own compile.git ls-files src/programwent from 6.0 MB to 413 KB. - The Rust compiler spells a tie's digits as JavaScript does. Naming the program by its hash showed two of SuperSynth's 337,104 numbers spelled differently by the two compilers: f32 values widened to f64 that sit exactly between two 17-digit strings, which JavaScript rounds to even and Rust's formatting up.
write_numberworks the exact digits out and takes the even candidate where it reads back;test/fixtures/numbers.json(8,267 values, 409 of them ties, written bynpm run fixtures) is checked by both sides, and SuperSynth's program hashes the same from both compilers, which the plugin now asserts. validateProgramrefuses what the Swift parser refuses: asamplereadnaming no sample, a negativearp.pattern, an empty step list, an unknownarporvoicingkey, and the bus registers counted among the named ones.test/fixtures/invalid.jsonholds ten programs both validators must reject, checked on both sides.- The Rust compiler's copy of the standard library (
std_source.rs, a byte copy ofstd.ts) is pinned by a test. - SuperSynth's tests get 30 s each (five rendered 4–5 s against vitest's 5), three dead exports go, the README says what
npm run dsp,npm run snapshots,npm run libraryand the hand-kept hash lists are for, and the ninety commits' history is under headings of its own.
What waits for the engine iteration, in the order to take it: the five-operand instruction ceiling (six opcodes at it, granulargain existing only for it, a grain's gain packed into its pitch's sign at 1/31 steps, granular's sample and window packed into one constant, spectral's loop region into one operand); scripts/bus-racks.mjs, a macro expander writing 2,300 lines into supersynth.dsp and panel.ui because the language cannot say "a host slot for the main rack, state for the buses'"; the arpeggiator as a module of its own with a pattern field rather than a tagged shape; and the patch model, Serum 1's reader type with Serum 2's fields and a by-name bag beside it, where the by-name path is the one an engine change can keep.
The eight-operand instruction#
The first of what waited for the engine iteration. An instruction held at most five operands because both machines decoded their streams at a fixed stride built around five (the JavaScript machine eight words: op, destination, five operands, instance; the Swift machine twelve, every slot after the operands spoken for), and six opcodes sat at that ceiling. Three packings worked around it: granular's sample and window shape were one constant, sample + 65536 × window; a cloud's gain made a second opcode, granulargain (84), whose last operand carried the pitch plus 32 × the gain's step, so the gain came in 31 steps and the pitch lost precision to the sum; and spectral's loop region was one operand, 2 + 2 × (start × 2048 + end) + swing, its ends in 2047ths of the sample, which SuperSynth built from its knobs and both machines took apart again. Each was a format inside the format, written by both compilers and read by both machines, and the next builtin with six inputs would have needed another.
The wire format was never the limit: each instruction is its opcode, its destination and as many operands as its arity, so only the decoded stride moves. It is twelve words now in JavaScript (op, destination, eight operands, instance, one spare) and sixteen in Swift (the same, then the state offset, the state-register bits, a delay line's buffer and an envelope's curve); DSPMachine.STRIDE is what the tests that read the streams count by. Then the packings go: granular(sample, window, position, density, length, pitch, gain) takes all seven as its own operands, each grain taking the gain (held to 0 … 1) as it starts, unquantized, and granulargain and its state are gone (84 is left a hole, which both machines' tables agree on); spectral(sample, start, speed, ratio, loop, loopStart, loopEnd, swing) takes its region whole, its ends no longer quantized, and SuperSynth passes its loop knobs straight in. Alongside: a constant voice mode, which a program could give twice (a top-level mode beside voicing.mode, the voicing's winning), is the voicing's only, a control value as the arp's constants are; the Rust builder's key for an instruction it has made already held five operands and would have panicked on more; one table (LONGEST in TypeScript, DSPOpcode.longest in Swift) gives each opcode whose memory a longest time sizes, delay, comb, all-pass and convolve, its operand and most seconds, where the validators had a constant for the delay lines and a branch for the convolution; and a test holds the AudioWorklet script's own copies of the opcode tables (it has no value imports) to OPCODES and BUILTIN_STATE.
Programs change, so the format is version 3, and each machine refuses a 2: nothing outside this repository keeps programs, and what inside it does (the parity and snapshot fixtures, the parity and SuperSynth packs, the Showcase's synth, the macOS node test's inline program) is compiled again. A program without a cloud or a spectral oscillator compiles to the same instructions as before, its version aside. SuperSynth's program loses the packings' arithmetic: 56,699 registers to 56,608, its sample stream 98,767 numbers to 98,614. Of the parity cases only granular and spectral sound different: the granular case, whose third cloud has a gain, by up to 0.0012 against a peak of 0.46 (the gain's steps and the pitch's lost precision gone), the spectral one by up to 0.00004 on 501 of its 6,144 samples (its region's ends exact). SuperSynth's snapshot fixture, the Init patch, plays bit for bit as before (only its program's hash and a route's register numbers change); what sounds different is a cloud whose grains' gain is spread (Serum 2's random gain, which 14 of its factory presets set), now at the gain it was given rather than the nearest 31st.
The wider stride costs nothing measurable. The big patch (packages/dsp/examples/bigpatch.dsp), eight voices sounding, a 256-frame block, the PR branch against this one on the same 4-core VM: in the JavaScript machine (V8, Node, seven runs of 400 blocks after 100 to warm, six alternations), 1.70 ms best and 1.81 ms median before, 1.67 and 1.81 after, about a third of the 5.33 ms a block lasts; in the Swift machine (release build, theBigPatchsCostPerBlock, 30 runs each, alternating, both orders), 0.424 ms best and 0.458 ms median before, 0.416 and 0.464 after, 8 to 9% of the block. Both differences are inside the spread of either side's runs, so the decoded stream's third more memory is not where the time goes; the instructions' own work is.
The convolver tidied#
convolve's impulse is now an object of its own (ConvolverImpulse, DSPImpulse): its head and its small and large spectra, made from a sample at a version to a number of taps (the sample's length or the longest, the shorter), and shared by every instance reading that sample to that length; each instance keeps its own input spectra and sums. The small spectra are sized from the impulse rather than from the longest, and the Swift machine's transform tables are one set a machine rather than one an instance. Both machines make the impulse when the machine is made (the JavaScript one did at the instruction's first run, inside the worklet's process) and when the sample is replaced, the instance taking it at its next run as before. A large ring that grows for a longer impulse keeps the input's spectra so far, newest last, where it started empty, so the longer impulse plays every tap the kept input reaches from the next frame (a machine test checks it against a direct sum; no fixture grew a ring with input in it, so every one renders the same).
The page's node makes a replaced sample's impulses for its program's convolutions (DSPMachine.impulses) and transfers them with the audio, as it makes a table's levels, so the worklet only swaps them in. Left on the audio thread, in both machines: each instance's two sums by the new impulse and its ring's growth (about 24 and 30 ms for a stereo 20 s reverb at 48 kHz in the JavaScript machine, where the impulse itself took 113 ms more); the Swift machine still makes the impulse on its audio thread when a sample is replaced, as the plugin's renderer hands it the sample there.
Measured: SuperSynth's Init snapshot (36 convolves, each its own sample, so nothing to share) holds 5.3 MB of convolver memory in the JavaScript machine where it held 9.8, and its Swift machine takes 137.3 MB to build where it took 145.5. A stereo reverb on one 20 s impulse at 48 kHz holds 23.9 MB where it held 31.7 (JavaScript) and 27.7 where it took 35.2 (Swift, with the sample's 3.8 MB copy). At worst, 24 s at 192 kHz, an impulse's large spectra and an instance's ring are about 37 MB each, so 74 MB for one convolve and 110 MB for two on one impulse; the README's row says so.
The new parity case convolutionLong plays two sides through one impulse and the left through it cut at a second, to 24 s at 24 kHz, a 2 s impulse (10 large parts) replaced while it plays by a sparse 4 s one (22, more than a large block's 14 slices), so both machines grow the ring with input in it and sum by the new impulse; it adds 329 KB to parity.json (3.49 to 3.82 MB), the right side silent and the new impulse in steps of 1/64 to keep it so. parity.dspk is not remade (test/parity-pack.mts; it still holds 21 of the cases).
The arpeggiator as a module of its own#
The first of the engine iteration's structural changes the review named: the arpeggiator, 560 lines duplicated line for line inside the two 3,800-line machines, so a change to one order meant editing both machine files around everything else.
- A class beside each machine.
Arpeggiatorinpackages/dsp/src/arp.tsand inSwiftBrowserDSPCore/Arpeggiator.swift, each the other's mirror, method for method in the same order, each saying so in its header. A machine makes one when its program has anarp, hands it the keys, the pedal, all notes off and the transport, ends its blocks at the arp's next event, and gets the voices back as note ons and offs (ArpVoices; in Swift a generic parameter of each call, so the plugin's Embedded build stores and allocates nothing for it).arp.tshas no value imports and the machine reaches it only asDSPMachine.Arpeggiator, set below the class, so the worklet's script embeds the two classes' text side by side; a worklet test plays an arp through it. Nothing played changed: the parity fixtures regenerated byte for byte, and the 22 arp tests and both arp parity cases passed unchanged. The Embedded build picks the new file up with the core's others. - Parity where the review found gaps.
arpOrdersturns the order through all fourteen and the transposition through all twelve as it plays, over two keys and then three, the range narrowed and a key let go; theinputscase goes on to fill the machine with held keys and steal bypriority: .velocity(the quietest) and then.first(the newest). The parity pack carries 22 programs. - The pattern as a field of its own is planned, not done: a validated
patternslist (notes with named fields, the chord row a named value) in place of a tagged shape, withreplacePatternin both machines and a pattern's way through the web node, the native node, snapshots, the plugin and SuperSynth's PATTERN plate. The plan and its file list are in arp.md; it waits for the instruction format, the parameter-slot feature and the patch model, whose files it edits.
The racks written once#
The first of the engine iteration's structural fixes: scripts/bus-racks.mjs, the 207-line regex expander that wrote 1,740 lines of parameters and 71 of lets into supersynth.dsp and 536 lines of plates into panel.ui. What it produced that the language could not was one thing: a parameter family whose first item has a host slot and whose others are preset state. Every bus parameter and every further instance's was the main rack's first again, renamed (eq2., bus1.eq.), regrouped (EQ 2, BUS 1 EQ), its @slot dropped and @state added; the lets in rack(x, r) then picked each rack's by name, and two controls (the further compressors' resting levels, each bus's "an effect is on") were written out from the same lists. A family could already range over a list of records and interpolate them in its attributes; it could not say "slotted here, state there", because @slot took one expression and @state was a flag.
The addition is @state(c): a bool known while compiling, @state where it holds and nothing where it does not, and where it holds the parameter's @slot is not read (so one slot expression names the slotted items' slots, @slot(P.eq + d.b) @state(!d.slotted)). It lowers in the attributes alone in both compilers, no new value, word or opcode, and a parity case (stateWhere) carries it through both compilers, byte for byte with its metadata, and both machines. SuperSynth's effect parameters are now each one family over instances("eq") (serum.dsp: every rack's instances of the effect from RACK_COUNTS, each with its rack, its number, its name and group prefixes and whether it is the slotted one; bands: 2 for the EQ's two), the rack reads its own through inRack(prefix, r), the eleven effects' LEVEL family became a family each like Utility's and Bode's, and the controls are a map and a function. supersynth.dsp went from 3,924 lines to 2,212. Its 2,019 parameters are the same in everything the metadata says (names, slots, state, ranges, defaults, tapers, labels, groups), the chains are the same, both compilers make the same program of it, and the Init snapshot renders sample for sample as before; the parameters' order changed (each family's items together, every rack's, where the main rack's came first and the buses' after), and with it the registers and the route lists' registers, which nothing in the app or the plugin reads by position.
The panel's plates could not follow: panel.ui is read by the panel's own reader, which takes each plate as written and writes it back a plate at a time, with no families or functions, and plates as a family would need that reader to evaluate them and its writer to leave them alone, or the panel to take the instance counts from the program's chains. That is larger than this fix, so the plates for the further instances and the buses, and the FX page's list, are written by scripts/panel-racks.mjs, the old script's panel half (95 lines), which npm run dsp runs and a test checks; panel.ui is the same 1,068 lines.
The patch model, by name#
The first of the engine iteration's structural changes: SuperSynth's patch, which was Serum 1's reader type with Serum 2 bolted on. PresetData held Serum 1's knob positions at their VST indices (raw, read as raw[P.x] and through knobValue wherever the program, the editor state or the import report wanted a value), what Serum 2 set past them by name (extra), and a field or a tuple slot for each other thing a patch carries, three of them differently named for "the impulse of convolution n in rack r"; Patch added fields derived from raw (oscillators, filter, envelopes …) that drifted from it when a knob changed. A harness came first (test/harness): the whole suite run with every patch it makes recorded as its snapshot, its import notes and its snapshot reopened through the editor state, compared before and after each step.
- One model by name.
PresetData.valuesis the program's parameters by name, each in its units. The Serum 1 reader fills it fromrawonce, through the metadata (src/serum/knobs.ts: the parameter at each VST index's host slot, its taper, the few knobs no taper writes); the Serum 2 reader puts each value by name;patchValues,applyPatch,patchOnto,patchNotesand the editor state read onlyvalues.rawstays inside the Serum 1 reader (Serum1Data) and Init's own state; noraw[…]read is left in the program, the app, the panel or Serum 2's reader (which still sets Serum 1's knobs by their index,set(P.x, …), as the reader of those knobs). The editor state is version 2; version 1's knobs are read as the Serum 1 reader reads them. - One shape for what a patch carries. Tables, impulses, oscillators' samples, grain windows, multisamples' zones and LFO points' buses are each keyed by the program's name for them (
tables.oscC,impulses['bus1.convolve2.impulse'],samples['oscA.sample'],windows,zones,points.point1), soimpulseOftakes a convolution's name andpatchDatagives every impulse by name; an editor state with the old fields is read by these names. - Serum 2's reader per module.
serum2PresetData(760 lines) reads each module with a reader of its own (oscillators.ts,voice.ts,lfos.ts,racks.ts,matrix.ts) into oneReading(reading.ts), in the order it did;serum2/patch.tsis 100 lines. - The panel off the readers. A sound file's reading and its making into a table or a noise (
library/audiofile.ts), a multisample's zones and the SFZ parser (library/zones.ts,library/sfz.ts, the stand-in for a zone's sample the caller's) and an arp pattern's shape (program-editor/arp.ts) leftserum/andserum2/; nothing underpanel/,library/orprogram-editor/imports them.
Every patch the suite makes plays the same snapshot before and after (1,900 compared). What the harness shows otherwise: 38 patches now reopen from their editor state as they play, where before tests that set a Patch field by hand (a table, the noise) reopened without it; one import note, "osc A's unison is 2 voices here (the preset has 3)", is gone from a test patch whose unison is set by name, the old note having read the knob's position under it; a new test reads a version 1 editor state; and two tests make one patch more or fewer, by the way they are written now. preset.ts went from 802 lines to 440, program.ts from 998 to 908. What is left: the noise keeps a sample shape of its own (sample, not left), the remaps, shapers and arp pattern stay fields of their own, and a route's destination is still a host slot where the parameter has one.
clap-validator's hang, a subnormal sample out#
The branch's first CI run hung in the CLAP job on all three platforms: clap-validator 0.3.2 logged a panic on its audio thread (Activated != Processing, src/plugin/instance/audio_thread.rs:154) three seconds in and then nothing until the job was cancelled. The test was param-fuzz-basic (50 sets of random values for every automatable parameter, each played for five blocks of 512 frames with random notes and MIDI), and the panic hid its real failure: a block with a subnormal sample in it, which the validator counts against a plugin (check_out_of_place_output_consistency). A failed block returns from the processing loop with the plugin still processing; PluginAudioThread's Drop then marks it activated before calling stop_processing, whose assertion panics, the audio thread never sends the main thread its Stop, and the main thread waits for it forever. That part is the validator's bug, and only a failing test reaches it.
The subnormals came from an envelope bent hard: a curved stage puts out its level raised to the curve's exponent (up to 16), and an attack's level starts at a frame's step, about 1e-4 for 0.38 s, so its first frames come out below a float's least normal and Osc A through it plays them. One failing set of values from the host test's fuzzing (the validator's, modelled), cut down, needs five parameters: the master, Osc A on and its level, Env 1's attack and its attack curve. The envelope is as it was on main, which passed: the validator's random values are fixed by its seed and drawn one per automatable parameter, and the branch has 357 of those where main had 202, so every set it tries changed.
Both machines now flush a sample out below a float's least normal to 0 at the end of each block, as they already flush the filters' integrators; nothing above 1.2e-38 changes. Two host tests hold it: the validator's fuzzing modelled (50 sets, five blocks each, every sample finite and normal) and the cut-down attack, which put out eight subnormal samples before. clap-validator passes all 21 tests in 16 s locally.
Routes into the arpeggiator#
The gap the tally put first: an arp setting was a control, arithmetic on parameters worked out before the block, and a route reaches only a @modulatable parameter where a stage reads it, so nothing could move the arp's gate, rate or range (Serum 2's factory presets route into the gate 21 times and the rate twice, which the import said and left out).
- A setting as the master stage reads it. A setting (not
on, nor a step list) whose own expression reads a@modulatableparameter is lowered a second time at the master stage's end, with its route list, macros, clamp and taper, and kept; the program's arp names that register by field (arp.signals,ARP_SIGNALS' order). Both compilers do it byte for byte; a program whose arp reads no such parameter compiles as before. One without a master stage is refused, and a bare tapered parameter as a setting now reads as its value (its taper), not its knob's position, in both. - The arp reads it a block late. At each block's end the machine hands the arp the master stage's lane (
heard), and each signal keeps its last frame's value where it is a number; a setting with one reads it from then on, its control only before the first block. A block ends at the arp's next event, so a step reads the master stage as it was the frame before. Both machines pin the registers (never folded) and count them as read. Weighed and left: the arp summing the routes itself (a second matrix in each arp), the newest voice's lane (silent before the first note), the same block (the master stage runs after the voices), an opcode writing into the arp (arp.md, "Routes"). - Checked alike.
validateProgramandDSPProgramrefuse a signal for a setting the arp has not, or naming a register the master stage does not write (invalid.jsongains both). ThearpRoutesparity case routes an LFO into the gate and a swept knob into the rate along its knob and into the range, then changes the routes and the knobs under them; the Swift machine plays it as the JavaScript one does, and the Rust compiler makes the same bytes (the parity pack carries 25 programs). Two machine tests inarp.test.ts. - SuperSynth.
arp.gate,arp.beatsandarp.range(now a number the arp rounds) are modulatable, the rate written into thearp(...)rather than a control of its own, and the Serum 2 reader maps routes intoArp0's gate, rate and range: the rate's amount −7/3 as far along the program's knob (Serum's halves a step every fourteenth of its way, the program's doubles it every sixth; past six octaves, said), the gate and range in their units (guesses). A route into the arp from a source only the voices have is said. The program grew 21 registers (56,608 to 56,629) and three empty route lists; the Init snapshot renders as before. The factory presets are not in the repository, so the clean-import tally is not measured again: at most 543 of 626 if those 23 now import clean.
The mod slots' rise, fall and delay#
What the fifth step of Serum 2's gaps left: a slot's smoothing rose and fell at one speed (the mean of Serum 2's two times, said where they differed, 3 factory presets), and its delay offset was said and left out (3 presets). The machines gain slew(input, rise, fall), opcode 84 (the hole granulargain left), in both compilers byte for byte and both machines: smooth's one-pole with a coefficient of its own each way, the rise's while the input is above where it is and the fall's while below, a time of a frame or less going straight to the input. matrix(…, smoothing: true) now gives each slot route{i}.rise and route{i}.fall in place of route{i}.smooth, and delay: true gives it route{i}.delay, all state, in seconds.
What Serum 2's delay does, the notes do not say (a delay of the modulation signal, or a hold from the note), and no factory preset is at hand to read its values from, so the delay is the cheap reading: an onset delay, the slot's value held at 0 until that long after its stage's gate rose (a voice's note; in the master stage the newest note's, which a note played legato over another does not raise again), then playing, smoothed after where it is. The time since the gate rose is one clock a stage, two state cells, in a region that runs only while some slot's delay is above 0; each slot's delay is a region on its own delay (read as set, not glided: a parameter's register glides toward a new value over a block or two, which a hold should not), and its smoothing a region on its rise and fall, so a slot with neither runs nothing more than before (the old smoothing's gt and select a frame are gone too). A delay set while a note plays counts from then, as a region coming on starts over. A true delay line on each slot's signal would need a buffer a slot and voice and is not done.
routeValues sets each slot's rise, fall and delay (0 where no route scales it), and a route with any of them goes through its slot. SuperSynth's 64 slots have all three (2,019 parameters to 2,147, 56,610 registers to 57,458); a route carries rise, fall and delay in the patch, the routes file and a plugin's snapshot (by parameter name: the plugin is unchanged). The Serum 2 reader sets rise and fall apart (milliseconds, as before) and the delay offset as milliseconds too, a guess; a slot whose parameters carry a key naming the delay's sync (kParamDelay…Sync, also a guess) has its offset read as beats at 120 a minute, which is said. The MATRIX page's route detail has RISE, FALL and DELAY (each a bar and its time, OFF at none) where it had SMOOTH, two rows more in its settings column; not checked with a headless shot. Of the factory presets nothing is measured here: only the synthetic fixtures run, and the 3 and 3 presets should import without those notes.
Tests: the routeCurves parity case plays a square LFO rising fast and falling slowly into the pitch and a delayed route into the cutoff, then a fall alone and a longer, smoothed delay (held again), then neither, over two notes; a new source-backed case, routeTimes, in the pack (25 programs), plays rise, fall and delays in both stages, the master's from the newest note, set as a note plays and changed, and the Rust compiler makes it byte for byte (SuperSynth's program too). A language test holds a delayed route at 0 for exactly its frames from each note and checks a rise or a fall alone follows the other way at once.
Measured on the JavaScript machine (a 256-frame block, seven and nine rounds of 400 blocks after 100, before and after alternating in one process, each program as its own compiler made it; the VM was shared with another stream's work, so every number is about a third above an idle run and the spread is several per cent). With no slot timed, both are within the noise: SuperSynth's Init 1.20 against 1.18 ms best (median 1.31 against 1.44, and 1.38 against 1.25 in the other run), Warm Pad 1.67 against 1.69, Pluck 1.07 against 0.94, Mono Bass 0.47 against 0.44; the big patch 2.21 against 2.27, and with its matrix declared with smoothing and delays but its routes plain 2.23 against 2.16. With the big patch's eight routes through slots, smoothed: rising and falling apart costs what one smoothing time did (2.57 against 2.64 ms best, 2.79 against 2.79 median); delaying four of them as well costs 0.2 to 0.3 ms a block more (2.85 best, 2.97 median), the clock's few instructions a frame and two more a delayed slot. SuperSynth's Warm Pad with eight routes through slots, four of them delayed, 2.07 … 2.12 against 2.22 … 2.47 ms best. So a delay costs where it is set, as a route does, and nothing where it is not.
A value every voice reads: the mono attractor running free#
The last of the LFOs' mono switch. A free-running attractor in Serum 2 is one orbit for the instrument, which a note joins where it is; SuperSynth's voices each stepped their own from their note, since a voice's state is its own and no voice reads another's (said by the import, 8 presets, 1 alone). The language gains shared name = … (a signal, : stereo, or a family [i in …]): a top-level declaration lowered at the master stage's end, from the top level, whose value goes to a register no instruction writes; at each block's end both machines take the master stage's value at the block's last frame, and at the next block's start set it across every lane, so any stage reads it as a block-rate value one block late (0 before the first block and after all sound off). The program carries it as shared, [from, to] pairs; from is pinned, reading to makes what writes from live in the compiler's and both machines' liveness (a voice's region on it off, the master stage's work for it stops), and both validators check from a register the master stage writes (not state) and to one nothing writes or names, two new refusals in invalid.json. Both compilers make it byte for byte; the shared parity case (an orbit and two phases, voices a block apart, the orbit's region off and on, all sound off) plays alike in both machines, and a machine test holds two voices a block apart to the same value a block late. It is the arp routes' mechanism (the master stage's register at its last frame, pinned, validated as the master stage's), with the voices reading it. docs/notes/dsp-language.md, "A value every voice reads", has the design and what was rejected: a voice reading another's lane, each voice catching its own orbit up, the master's frames copied at sample rate, the same block, and an expression in the voice lowered elsewhere.
SuperSynth's lfoOrbit[k] is LFO k's Lorenz or Rössler orbit, stepped in the master stage at the LFO's rate as the master stage reads it, each kind in a region that runs only while the LFO is a mono attractor running with the song (lfoOrbited); the voices read it in place of their own, whose regions are off meanwhile. The import sets the switch and says nothing: 521 of 626 by the tally, not run here (the factory presets are not in this checkout). The program has 57,570 registers (56,610), its master stream 90,998 words (88,318), its sample stream as it was; the Init snapshot renders bit for bit as before.
Measured in the JavaScript machine (V8 under vitest, best and median of seven runs of 400 blocks after 100 to warm, three rounds a run, two runs each alternating with the base, eight notes sounding, a 4-core VM under other agents' load): the Init snapshot at 128 frames, 0.608 and 0.655 ms best (0.84 … 0.89 median) before, 0.626 and 0.633 (0.87 … 0.89) after; the Init patch with LFO 1 a mono Lorenz attractor with the song on oscillator A, 0.634 … 0.641 ms best (0.86 … 0.87) before, eight orbits, 0.587 … 0.594 (0.79) after, one; the big patch at 256 frames, 1.559 … 1.587 ms best (1.61 … 1.70) before, 1.585 … 1.598 (1.70 … 1.73) after. Where nothing is shared the cost is inside the runs' spread; a mono attractor is about 8% cheaper. The Swift machine was not timed in a release build.
The arp's signals and the shared values, one mechanism#
The routes into the arp and the shared values were built in parallel and came to the same thing twice: a register of the master stage's, read at a block's last frame and used the next block. Merged, they are one. Each compiler gives the register by one rule (sampledRegister: the value's own where an instruction of the master stage writes it, else a mov), the arp's signals kept and the shared values live only while read; one validator check in each language (sampled: written by the master stage, not state, which now refuses an arp signal naming state too); one pin; and in each machine one step at each block's end samples them all into one array, which the arp reads its signals from (a view of it, its heard gone) and from which the shared values are set across the lanes at the next block's start. arp.signals and shared keep their formats. Every parity case renders and compiles as before (the arpRoutes and shared cases byte for byte as their own branches made them); the pack carries 27 programs, and SuperSynth's program (58,437 registers) is the same from both compilers.
The spectral oscillator's phase lock, its transients and its end#
What the import said spectral left out of Serum 2's spectral oscillator: phase lock, transients kept apart, and its END. Both machines do the first two inside the opcode, sample for sample alike (the same arithmetic in the same order, in double precision as the vocoder was), and the third needs no machine change of its own.
- The operands.
spectralalready held the eight an instruction could, and the owner's rule is no two quantities in one operand, so an instruction holds ten now: the JavaScript machine's decoded stride is 14 words (op, destination, ten operands, instance, one spare), and the Swift machine's stays 16, its operands in slots 2 … 11, then the state offset, the state-register bits, a delay line's buffer (a convolution's or a spectral resynthesis's instance) and one slot that is a delay line's length or an envelope's curve, which no instruction has both of. The Rust builder's instruction key holds ten.spectral(sample, start, speed, ratio, loop, loopStart, loopEnd, swing, lock, transients), both new ones defaulting to 0, is opcode 83 still, and the format is version 4 (each machine refuses a 3). END is the region's end in both modes, as a sample oscillator's is (its loop no further), so it is no operand: once through, the read is silent pastloopEnd(1 by default, so nothing written before sounds different), and SuperSynth passes its loop's start and end each no further than END while it loops, and END while it does not. - Phase lock is identity phase locking after Laroche and Dolson. A frame's peaks are its bins above the two on either side (the first and last bins free on their outer side, so a spectrum falling or rising from its edge has one); each peak's region runs out to the lowest bin between it and the next peak. A peak's frequency, from its phase's advance over the hop as before, gives the output bin it moves to, and its whole region moves with it by as many bins; only the peak's phase is carried on (from what its output bin had, a hop on at its frequency), and each other bin in the region takes the peak's phase plus the difference the sample's frame has between them, so a partial's bins stay as coherent as the sample had them, where before each output bin's phase ran on alone and a peak's neighbours collapsed into it. The bins come back at two thirds of their amplitude (the frame is the sample's again, windowed twice, and four overlap), and a locked note's first frame is the sample's own. At its own pace and pitch, locked, it gives the sample back within 0.005; unlocked, the bins summed into one put it off by more than 0.05; locked, a stretched or an octave-up sine keeps its level within 2%.
- Transients kept apart. Each frame measures its high-frequency content, Σ k |X_k|², and the one a hop before it (the second transform it already makes, so the measure costs a multiply-add a bin); where the newer, in the direction it reads, is more than four times the older (and not near silence), and the last frame was not so, a transient starts. That frame takes the sample's own phases and its bins' own frequencies (the frame a hop before has not what the measure would need), and the four hops after, a frame's length, read the sample at its own pace where it reads slower, so the attack passes through the frames as the sample has it rather than being smeared across all the frames that see it; what that reading took it past where its pace would have is paid back after at half the pace, so a stretched loop keeps its tempo (clicks every 6,000 frames stretched fourfold come every 24,048 output frames, as without). A phase reset alone was not enough: a click stretched fourfold, reset but read at the stretch, still spread nine tenths of its energy over ±1,173 frames. Kept apart, it is within ±17 (locked or not; ±19 locked a fifth up, ±687 unlocked, where the bins collapse), against ±2,055 without.
- Cost. In the JavaScript machine, a second of a 48 kHz sample at half its pace in one voice: about 30 ms before (29.6 to 30.8 best of seven), 29.0 to 30.8 after with neither on, 30.2 with transients and 26.6 to 28.0 locked (a locked frame works out the phase advance only at its peaks, one
atan2a bin fewer). The wider stride, the big patch as the eight-operand section measured it, alternating against the iteration's base on the same VM: in JavaScript (ten alternations of seven runs of 400 blocks) 1.99 ms best and 2.20 median before, 2.02 and 2.24 after; in Swift (release, 15 runs each, both orders) 0.429 ms best and 0.453 median before, 0.422 and 0.446 after. Both inside the spread of either side's runs. - Tests. A parity case,
spectralLock, plays four resyntheses of a sample with clicks in a tone, stretched, backward, round a region and once to a region's end, with lock and transients turned on and off as they play and the sample replaced by a shorter one with its clicks closer together; the parity pack carries 25 programs. Machine tests: the one-shot end, the lock giving the sample back, and a click stretched fourfold keeping its attack with transients and smearing without. Every other parity case renders as before, bit for bit. - SuperSynth. Each oscillator has
oscA.phaseLockandoscA.transients(preset state, LOCK and TRANS on the spectral kind's third row) and a spectral one plays to its END (oscA.scanEnd); the Serum 2 reader fills the three where it said them. 2,025 parameters and 56,628 registers (from 2,019 and 56,608); the Init snapshot renders bit for bit as before. A test plays a spectral oscillator to its end, once and round a loop, and a click through it kept apart, locked and not. The factory presets are not in this checkout, so the tally in serum2-gaps.md is as it was measured; three notes are gone.
Left alone: an unlocked frame still sums the bins falling into one output bin, so pitched and kept apart its click spreads (±687 frames at a fifth up); the transient threshold (fourfold over a hop) and the pace at which a transient's lead is paid back (half) are choices, not measurements of Serum's; the spectral warps and the oscillator's unison are still said.
A sample's slices#
Serum 2 slices a sample oscillator's sample (off, auto at a threshold the player drags, or manual: auto, then slices moved, added or removed by hand) and plays its slices a key each from a root note (any C), each to the next slice or, with Play Slice to End, to the sample's end; with Play Single Slice, one slice on every key, its rate the key's, a route choosing which. The import said slicing whenever a preset set it. Program and app, no engine change.
- The program. Each oscillator has a slicing mode (
oscA.slicing, serum.dsp'sSliceMode: off, keyed, single), its slice points as a shape ofSLICES(64) knots (oscA.slices, each slice's start along the sample, 0 … 1 in order, read each at its own knot, the unused tail 1) and their count (oscA.sliceCount), the root (oscA.sliceRoot, a note, 36 at first: Serum's C1, a guess), TO END (oscA.sliceToEnd) and SLICE (oscA.slice, 0 … 1 along the slices, modulatable and unslotted, as the other new oscillator knobs are). Keyed, a note plays slicekey − root(silence for a key past either end) at the sample's own pace whatever the key, its pitch fixed asoscA.fixedfixes it; single, SLICE's slice at the note against the sample's root. Either is chosen as the note begins, and plays once from its point to the next (or to END), throughlooped, the loop region's reader, which now takes an end as it took a start, a slice never looping. Where a sample plays from and to is worked out once an oscillator (sliceOf, else its start and END) and handed to every unison voice, so the random start and the slice are drawn once a note, not a voice: the program was 50 instructions under the builder's 50,000 before (49,950), and is 188 under now (49,812; the builder's count, its instruction list at the end of the build), 2,171 parameters (2,153) and 58,323 registers (58,455). A sample not sliced plays as it did. - The app.
library/slices.tsslices a sample by its transients: its level over 5 ms windows (their RMS, a share of the loudest's), a slice at a window rising over the louder of the two before it by the threshold or more (oscA.sliceThreshold, 0.3 at first, the app's alone: the voice does not read it), placed at the rise's first sample past a fifth of the way from the quiet before to its peak, slices 30 ms apart at least (the larger rise kept), the first at the sample's start.oscSlicesOfgives a sample oscillator's points: a preset's own (PresetData.slices, shares of the sample), else the sample it plays sliced at its threshold, whether its slicing is on or not, so turning it on slices at once;patchValuessets the count andpatchDatathe shape, whichpatchOnto,applyPatchand a plugin's snapshot carry. The factory presets' samples are Xfer's, so their stand-ins are sliced by their own transients. On the panel the sample kind has its own sampler: SLICE (the mode), ROOT and TO END under it, a SLICE knob in single mode, the slices drawn on the sample, and THRESH in its band, dragging which slices the sample again, as picking or importing one does. - The Serum 2 reader. The synthetic fixtures carry no slice fields but
kParamSlicingEnabled, so that is all it reads: a sample oscillator with it set is sliced keyed at SuperSynth's threshold and root, and the import says that the preset's threshold, root note, options and moved slices are not read; on a granular or spectral oscillator, slicing is said. - Tests. The slicer finds clicks in hiss at their samples (within 2 ms), the quiet one only at a low threshold, one slice for a tone or silence and one for clicks closer than 30 ms; a preset's points are kept in order and in the sample; a stand-in's points become the program's shape and count. Played: key root + 2 gives the sample's third slice, frame for frame, at its own pace two octaves from the sample's root, then silence; keys outside the slices are silent; TO END plays to the sample's end; single mode at the sample's root is the keyed slice, an octave up half as long; unison spreads a slice. The reader keeps a sliced preset sliced. The snapshot fixtures are regenerated.
Left out: sending slices to a clip (the clip player is not built), auto-syncing them to one, slicing a cloud or a spectral oscillator (Serum's manual position mode, where slicing is not offered, is a spectral one's), the preset's own threshold, root, options and moved slices (their fields' names are not known here), and Serum 2's "single slice" destination as the reader maps routes (a route to oscA.slice plays). The threshold's scale and the 30 ms gap are choices, not measurements of Serum's.
A multisample's zones each loop their own way#
What Serum 2's gaps said of a multisample: each zone played play or loop from START over its whole sample, so an SFZ's loop points were ignored, and the oscillator's loop mode past forward was said. Program and app, no engine change.
- The zone map. Eight numbers a zone (
ZONE_SIZE, serum.dsp;ZONESstays 8, the shape 64 points): its lowest and highest key, root and tune as before, then its loop's start and end (0 … 1 along its own sample), its sample's length in seconds (for the loop's steps), and how it loops (ZONE_LOOPS: 1 as the oscillator loops, 0 once through, 2 round its loop while held then on to its end).oneZoneMap,zonesOfand the panel's zone strip read and write it;zoneMapLoopssays whether a map needs the loop reader, which the app sets asoscA.zoneLoopswith the map (patch values and the panel's SFZ import alike). - The SFZ. A region's
offsetandend(its sample cut to them),loop_start,loop_endandloop_mode(loopstart,loopend,loopmodetoo, so a region's own spelling overrides its header's).importedMultisamplecarries them on each zone, its loop along what it plays; a stand-in for a sample a preset only names keeps looping its whole sample, as before. - One reader. The sample and multisample kinds are one region now (
played): one unison, level and pan, one envelope and velocity for a multisample after the unison, not in each of its voices, and one loop reader,looping, the sample'sloopedmade general: a region's bounds, the step's denominator, the crossfade's start and the mode's choices are worked out once a note (loopRegion) and handed to each unison voice, which keeps only its position and direction. Where a multisample's zones loop otherwise than round their whole samples forward, or LOOP IN and OUT are narrower, or the mode is past forward (loopReading), the first zone holding the note is read through it, round its own region at its own length's steps in the oscillator's mode and crossfade; elseplayandloopas before. One reader a voice rather than one a zone: eight would have been about 15,000 instructions over the cap, and a note reads one zone (zones that overlap sum only on theplayandlooppath). - Cost. The program's emit count, which the builder caps at 50,000, went from 49,950 to 49,905; its sample stream holds 24,483 instructions (23,727), its registers 58,543 (58,455), its parameters 2,156 (three
oscA.zoneLoops). Scheduled in a voice: the Init patch 69 sample instructions before and after, a sample looping 82 → 74, round a region 163 → 158, a plain multisample 146 → 139, one in ping-pong (its zones through the reader) 340. Timed in the JavaScript machine (eight notes, 375 blocks of 128 frames, a 4-core VM shared with two other agents), each within its runs' spread: the Init patch 261 … 307 ms before and 273 … 349 after, a multisample 923 … 1,116 before and 883 … 1,076 after. - The reader. Serum 2's loop mode on a multisample oscillator plays (ping-pong, reverse, tailed), no longer said; one it does not know is. The module's loop start, end and crossfade are not read on a multisample: neither the guide nor a test preset shows them there.
Tests: the zone map's numbers for a stand-in and an imported multisample, an SFZ with loop points, offset and end imported and played (each zone round its own region, ping-pong, once through and while held), and the reader's loop mode and its said-list. 402 tests in SuperSynth's suite.
A sample oscillator's scan and its position by hand#
What the import still said of Serum 2's sample oscillator: routes to its scan (14 presets) and its position. Its guide's SCAN sets "the speed and direction of the sample playback" (±200 % by default, a Reverse switch beside it), so in SuperSynth a sample's scan (oscA.scan, read until now only by the spectral kind and the cloud) is its playback's speed, its pitch moving with it as a tape's: 2 an octave up, 0 stopped, below 0 backward. Program and app only; no engine change.
- The program. A sample kind's playback frequency is multiplied by its scan once an oscillator, before its unison's voices, and only where
sampleScanned(the knob off 1, oroscA.scanRouted, which the app sets from the routes as it doespart.routed.*);playandloopalready step either way, silent past the start or round again. Backward from START it runs toward the sample's start, and from its END where START is at the very start (backward from there it would be silent at once: a guess at what Serum's reverse does). The loop region (looped) works either way with no second copy of itself: it wraps at the end it moves past, there and back turns at whichever end it meets, the backward mode runs to the loop's far end and then round the other way, the crossfade holds at the wrap whichever way it is crossed, and before the sample's start it is silent (a backward run out stays at −1, below which it has not started). Held by hand (oscA.manual, MANUAL, Serum 2's manual mode), the sample is read where its position says (WT POS,oscA.position, smoothed over 5 ms so a moving route scrubs) and not played. - The budget. The program was 50 instructions short of the builder's 50,000 (49,950, its instruction list at the end of the build). A loop region scanned both ways written as a second
loopedtook 3,036 more (each sample oscillator's read is built eight times, once for each unison voice and once alone). So the start (and its random start's draw, the same for every voice) is worked out once an oscillator now, outside the unison, which gives back 231; the direction-aware loop is the onelooped, about three operations more a voice than before; and the held read is outside the unison too. The program is 49,956 instructions (from 49,950), 2,159 parameters and 58,450 registers (from 2,153 and 58,455); the big patch, whose oscillators are wavetables, runs as it did. - The reader.
kParamScanRate(percent, 100 its own pace where a preset leaves it out) is the scan, held at the knob's ±200 % and said past it;kParamReverseits sign (no longer said);kParamManualPositionModeandkParamPositionthe held mode and its position. The guide lists manual mode only in the granular and spectral loop menus, so a sample's is read as theirs, a guess. The matrix keeps routes to a sample's scan and position; a position route on a sample not held moves nothing, as the guide's sample mode has no position knob, and is kept for when it is held. Lock Scan Rate to Tempo, Sample Length to BPM and the ±400/±800 % ranges are not read: their fields are not known here. - The panel. The sample kind shows SCAN (×, as the spectral kind's) and POS beside START, and MANUAL beside LOOP.
- Tests. A sample at scan 2 plays an octave up and at 0.5 an octave down, a route to its scan moves it, and its own pace renders as before to the bit; a ramp played backward runs down from START and is silent past the start, from its end where START is 0, round the whole sample where it loops, inside its region in the forward, there-and-back and backward modes, and down from its END once; held, it reads its position whatever the note. The reader's tests read a sample's scan, reverse and manual position, and keep the routes to them. The factory presets are not in this checkout, so the tally in serum2-gaps.md is as it was measured.
Left alone: the multisample kind, which the guide gives no SCAN, still says a scan and a reverse; a held sample is a level while nothing moves it (a scrub, not a granular or spectral hold), and its unison plays one voice.
One sample reader for the slices, the zones' loops and the scan#
The three streams above, merged: each rebuilt the sample kind's reader (the slices as looped taking an end, the zones as loopRegion, looping and loopRead in one played region for the sample and multisample kinds, the scan as looped stepping either way). The zones' structure is kept, and the slices and the scan plug into it. Program only, no engine change.
- Once a note, an oscillator.
playedworks out, before the unison's voices: the start and its random draw (onestartOf, which the slices' and the scan's streams had each moved there); for a scanned sample (sampleScanned, the sample kind's alone) the backward start from END and the pace, the frequency times the scan; a sample's start, end, loop ends and beginning, a slice's (sliceOf) where it is sliced, else its start, END, LOOP IN and OUT and the sample's very start; andloopRegionfrom those, which now carries the beginning too. A multisample's zone numbers are as before; it is never scanned, so it plays as the zones' stream had it. - A voice.
loopingkeeps a voice's position and direction and steps either way, as the scan'sloopeddid: wrapped at the end it moves past, there and back turned at whichever end it meets, the backward mode to the loop's far end and round the other way, silent past the end and before the beginning; a zone's own way (once through, round while held) as the zones' stream had it.sampleLooping(LOOP, but not a sliced sample's) chooses the modes and the crossfade, so a slice plays once. - Slices played backward. A sliced sample scanned below 0 plays its slice from its end down to its start, silent before it, where the scan's rule alone would run on into the slices before it. Neither stream nor Serum 2's guide says which; a slice is "from its point to the next", so it stays inside it.
- Held. MANUAL (
sampleHeld, the sample kind's) reads the sample at its position (heldAt) in place ofplayed. - Cost, and the cap. The builder's instruction list at the end of the build (the count its cap guards): the base 49,950, the slices alone 49,812, the zones' loops 49,905, the scan 49,956; the slices and the zones merged 49,998, with the scan 50,241. Nothing was worked out twice (the start's draw is one); what is new is the scan's both-ways stepping in each of the 24 loop readers a voice builds (three oscillators, eight times each), about ten operations each. The program is past 50,000, so
MAX_INSTRUCTIONSis 65,536 now, inbuilder.tsandbuilder.rsalike: a guard against a runaway build, which nothing else reads. 2,180 parameters and 58,985 registers. - Docs. serum2-gaps.md's multisample entry had swallowed the octave routes' heading; it is back. Routes to a convolution's DECAY (4 presets) are noted as not reachable from the program: the app shapes the impulse before it plays. The slices' section above quoted 49,157 instructions, and the scan's 49,946 and 49,952, by another measure; they are the builder's now.
A route to a sample's scan adds its amount to the scan, as the language's untapered destinations do (fixed at 0.25 renders as the knob at 1.25, frame for frame): its test's 560 Hz for 550 is the zero-crossing count's resolution over a tenth of a second.
Tests: all three streams' (the slices played frame for frame, the SFZ regions with loop points, ping-pong, once through and while held, a ramp played backward in each mode, the held position), 412 in SuperSynth's suite. The snapshot fixtures are regenerated.
The arp's pattern as a field of its own#
An arp's pattern was a shape ([1, length, count], six numbers a note, row −1000 the chord), which both machines read
by its 1 tag and both validators checked only as 2 … 4096 points. It is the program's own data now (arp.md, "The
pattern as a field of its own"), the engine's half: the format, both compilers, both machines, the node, the worklet
and snapshots. SuperSynth, the Showcase's app and the plugin are the second half.
- The format is version 5.
Program.patterns, each{ name, length, notes }, a note{ start, length, row, velocity, chance, spread }withrowa whole number −128 … 127 or"chord";arp.patternan index in it.validateProgram(patternFault) andDSPProgram(DSPProgram.Pattern) refuse the same things in the same words, eleven of them ininvalid.json.ProgramMeta.patternsnames them.ARP_PATTERNandARP_ROW_CHORDare gone, with nothing kept for format 4. - The language.
pattern groove = { length: 8, notes: [{ start: 0, length: 1, row: 0, velocity: 0.9 }, …] }, a declaration of its own besideshape, its notes records with velocity and chance 1 and spread 0 where left out and.chordfor the whole chord; no value is 16 empty steps;@nameand a family as a shape's. The Rust compiler writes the same bytes and the same refusals (its word table gains six names at its end, so no other word moves). A pattern declared by a shape is refused, as the plan's smaller option (a shape lowered as a pattern) would have kept SuperSynth's source as it is but left the editor nothing to show a pattern as. - The machines. Each arp copies its pattern's notes into arrays sized for 512 when it is made, its start,
length, row, velocity, chance, spread and a chord flag a note, and reads them where it read the shape; the
semantics are unchanged, and the
arpPatterncase, its pattern now declared, renders bit for bit as before.replacePatterncopies a new pattern in from the next step, the walk going on and a waiting note keeping its index (one past a shorter pattern's plays nothing): on the JavaScript machine by name, checked by the arp'sfits; on the Swift one packed off the audio thread (Pattern.packed, seven floats a note), handed over byDSPRenderer's.patternevent and copied in without allocating, the buffer freed back as a shape's is. The Embedded build of the core still needs the same C symbols. - The ripple.
DSPNode.setPatternsendspattern.<name>, which the worklet andProgramNodetake (the native bridge passes it through); a snapshot carriespatternsbesideshapesand applies them withreplacePattern(SnapshotRecorder.setPattern,DSPSnapshot.patterns), which is format 2. The Showcase's synth is the same program at version 5. - Tests.
arpPatternReplaced(a parity case onarpPattern's source, so the parity pack still holds 28 programs) replaces the pattern by a shorter one with notes waiting, then by a longer one off the grid on new keys, and both machines play it alike; a snapshot case carries a pattern; the language's and the builder's refusals, the renderer's handoff, and a pattern replaced against one built in. Every other parity case and snapshot renders as before, bit for bit. 260 tests in the package, 7 in the Rust compiler, 45 in the Swift core's (three skipped: SuperSynth's snapshot fixtures are format 4 until its half).
Left for the second half: SuperSynth's source, Serum 2 reader, patch, PATTERN plate and program editor, its fixtures
and the three Swift tests that read them; the plugin's snapshot version, its tests' snapshots and its compaction of
arp.pattern as a shape.
The second half: SuperSynth's arpPattern is a pattern declaration (sixteen empty steps), and a patch's
arpPattern the program's pattern but its name, { length, notes }, which Serum 2's reader gives (row −26 as
'chord', the notes inside its length, the first 512), applyPatch sets with its target's setPattern, buildPatch
puts in the program's patterns and patchOnto makes live data; an editor state saved with the old shape keeps no
pattern (the shape is not read). The PATTERN plate reads the program's pattern and writes it as live data or as the declaration's text
(patternText), playing it at once through the node's setPattern; the program editor's data, live data, data
screens (a PATTERN card), declarations and highlighter take the kind. The fixtures are snapshot format 2 (the Init
preset renders sample for sample as before) and the three Swift tests run again; the plugin reads format 2 and carries
patterns through its compaction and state untouched. 414 tests in SuperSynth's suite, 227 in the Showcase's, 45 in
the Swift core's (none skipped), and the plugin's 30 unit and 8 host tests, the editor's window among them.
What no program used, taken out#
A survey of every program in the repository (the package's examples and tests' sources, the Showcase's synth, SuperSynth and Sylenth1) found parts of the language, the format and the package's exports that nothing used. They go, and the program format is version 6, with nothing kept for 5.
grains(opcode 54), the first cloud: eight grains a call under a parabola, whichgranularreplaced (sixteen, under a window shape, each grain's own place, length, pitch and gain). No program called it; the parity casesamplesplayed one besideplayandsampleread, and plays without it now, the one fixture regenerated. Both machines lose its code, its 34 words of state a lane and the 20 ms spray only it read; a Swift test that read a shape,playandgrainsreadsloopin its place.smooth(opcode 55) wasslewwith one time. The language keeps it, and both compilers lowersmooth(x, t)toslew(x, t, t). The two kept the same state (where it is, then each time last seen and its coefficient), worked the same coefficient from the same time (1 − e^(−1 / (t × sampleRate)), 1 at a frame or less) and started where their input was; they differed only at a time of a frame or less, where slew went straight to its input and smooth stepped y + (x − y). Slew steps so at every time now, so a smooth renders bit for bit as it did: SuperSynth's and Sylenth1's programs are their format 5 programs with each smooth the equal slew, instruction for instruction; the Init snapshot and the parity cases with a smooth (time,bigpatch) render as before; and 716,800 frames of wild input (noise scaled up to 10^±38, times from 0 to half a second) are what the old smooth gave, sample for sample. What moves is a slew of a frame or less whose input crosses more than about 2^29 in magnitude from one frame to the next, where y + (x − y) in double precision lands a rounding away from x: no program makes such a signal, and the parity cases with slews (routeCurves,routeTimes) render as before.- The codes stay where they are. 54 and 55 are left empty, as 36 to 39 are, so every other instruction of every program is the bytes it was and the format's rule (never renumber) holds; the Rust compiler's lookup by code skips both gaps. Both validators refuse 54 and 55 as any unknown opcode (an invalid case for 55).
@unit("hz"): the unit after the type (number(20...20000) hz) said the same, and every program wrote that. The metadata'sunitcomes from the type alone.ramp(n)as a data default, andsawTable(n), which only these notes named:mapwrites either.file()stays.- Both compilers still write the same bytes. The Rust compiler interns its words in a fixed order, each a fixed
number;
grains,rampandunitkeep their places, no longer a builtin, a function or an attribute, so no word after them moves. SuperSynth, Sylenth1 and the Showcase's synth compile in Rust to the TypeScript compiler's programs and metadata, byte for byte. - One pack path.
defaultCodec,portableCodec,streamCodec,PackCodec,packProgramandunpackProgramhad no user outside the package. The hand-written inflate stays inside it: JavaScriptCore (the native apps' own JavaScript, aJSContext, not a web view) and QuickJS (the plugin's editor) have noCompressionStream, and both run SuperSynth's program editor, which saves and opens.dspkfiles (the AudioWorklet reads no pack).readPack,writePack,packProgramsandunpackProgramslook at the platform as they run, its streams where it has them, else the inflate to read and entries stored to write; a test takes the streams away and reads the Rust compiler's pack and writes one stored. - Exports nothing read.
PROGRAM_KIND,STRAIGHT,slotNames,SNAPSHOT_FORMAT,SNAPSHOT_VERSION,watchProbes,inflateandInflateErrorleave the package's index (the package still uses each), andBLOCK_FRAMES, which nothing read, is gone. No Swift or Rust file named any of them.
Tests: 261 in the package (smooth as a slew, an invalid program with opcode 55; the grains machine test gone, its
other uses loop and granular now), 7 in the Rust compiler, 45 in the Swift core's, 414 in SuperSynth's suite and
227 in the Showcase's. The parity pack holds 28 programs, as it did. The Showcase's synth and SuperSynth's fixtures
are version 6; SuperSynth's Init snapshot renders as before, its program's hash new.
A section: what declarations share, said once#
SuperSynth's program declared its parameters one by one, and its 400 attribute lines said again what the lines beside
them said: 397 @names, most a prefix such as osc{"ABC"[k]}. and a member, 296 @groups, 280
@states, and on every declaration of an effect its family ([d in instances("compressor")]). The language gains
section name[i in a..<b] { … }, attributes before it (dsp-language.md, "Sections"). Each declaration inside is
written by the name the program reads (param oscLevel, read as oscLevel[k] as before) and named for the app by the
section's @name (the section's own name where it has none), a dot and its name past the section's, its capital
lowered: oscLevel in @name("osc{"ABC"[k]}") section osc[k in 0..<3] is oscA.level, oscB.level, oscC.level.
The section's index is its declarations', and its other attributes are each one's that gives none of that name
(@group, @state, @state(!d.slotted) …), a declaration's own replacing the section's; an @name of a declaration's
own is kept whole. A section holds param, table, shape, pattern and sample, the kinds that take @name, and
does not nest; it declares nothing itself. Both compilers keep each declaration with its section and read the section's
attributes after the declaration's own, where they read those, so no program, metadata or format changes; the Rust
compiler's word table gains section at its end. They refuse in the same words a declaration whose name is not the
section's and a capital and that gives no @name, a kind that takes no @name, a section in a section, a family of
its own in a family's section, and the section's attributes where a declaration does not take one (@group on a
shape) or where it gives one twice.
- SuperSynth in 30 sections: the oscillators (three, split where one parameter of their run has no group), the
noise, the sub, the envelopes, both filters, each effect over its instances (
@name("{d.name}") @state(!d.slotted) @group(d.group), its Serum 2 knobs giving their own@state), the EQ's bands, the splitter, the voicing, the glide, the LFOs' settings and points, the noise's settings, the arp, the points' shapes, and the oscillators' samples and shapes. 8 of the 318 declarations in them keep an@nameof their own (oscVelTrack's.velocity, the utility'slpfandhpf,filterIntoFirst'sfilter.chainedin filter 2's section …).@name397 → 109,@group296 → 65,@state280 → 95; 150,025 bytes → 132,766, and 2,390 lines → 2,425: each section's head and brace take lines, and what attributes are left (@slot,@label) keep their line above each declaration, as the file writes them. Sylenth1 in 15 sections: 24,011 bytes → 20,816, 414 lines → 450. Both programs compile to the.dsp.jsonand.program.tsthey did, byte for byte, in either compiler; SuperSynth's fixtures (snapshot.json,supersynth.dspk) are as they were. - The editor.
declarations()gives each declaration its section's name and span, and the PROGRAM tab heads a section's declarations with a row of its own, its head as written, and reads the group the section gives them;insertDeclarationputs a new declaration after the section its kind's last one is in, so it takes nothing from it;isModulatableanddataDeclarations(a member'salias, and a family's section making it a family) read the section's;setModulatableandsetAttributerefuse to take from a declaration what its section gives. The grammar and the code pane's highlighter take the word. - Tests. A program in sections against the same written out (program, metadata and parameters' sources alike, in
both compilers), the refusals, the builder building a section's parameters as written out, and the editor's view;
the
arpRoutesparity case declares its arp settings in a section (@modulatable section arp { … }) and compiles to the program it did, so the Rust compiler's parity test compiles a section from the pack, written again. 264 tests in the package, 8 in the Rust compiler, 414 in SuperSynth's suite.
Unison as a region#
Unison was unrolled while compiling: a map(0..<9) built every copy of an oscillator, a ladder of partial sums and a
choose over the count picked how many played. SuperSynth's voice stream was 24,783 instructions, 58,985 registers
and 4,302 instances, and the builder's cap had been raised for it once already. unison(count, most: N) { u in … }
builds the body once (dsp-language.md, "Unison as a region").
The format is version 7.
Program.unisons, each{ control, most, master?, from, to, parent, index, state, instances, groups, choices, results }: the count's control and its most (1 … 16), the body a run ofsampleormaster, the region around it, its index register, copy 0's state entries and instances with the other copies' after them a copy at a time ([first, count]), the regions and choices made in it, and its results ([register, value], the register read as the copies' sum). Both validators check it in the same words: ranges, kinds, stages, every body instruction in its region or one of its own, and nothing outside a body reading what it makes, nor a copy's state or instances named by any instruction; eight new cases ininvalid.json.The machines write the copies out when they load a program (machine.ts
expand, Machine.swiftexpandingUnisons, register for register): copy k after copy k − 1, its index a constant k, its state and instances the k-th, its other registers its own, inside a region on while the count is above k − ½ (a control value,ge), each result a chain of the copies' sums read past the copies that do not play. A pure instruction of a copy whose operands are constants is worked out then, amovthe streams pass over. Nothing else in either machine changed: block processing, liveness, folds, regions and choices see ordinary streams. A copy turned back on starts over.The compilers.
unisonis a builtin where nothing of the program's is called so (std'shypednames its count so);{ u, n in … }gives the copies playing. The builder tags the body's instructions, moves what reads nothing of a copy's out before it (a modulatable read's route list made first inside one, say), keeps the same instruction twice from being one across its edge, writes the body's state back inside it, fuses nothing across it, lays the copies' state and instances out after copy 0's and groups the body's choices. The Rust compiler writes the same bytes and the same refusals; its word table gainsunisonandmostat its end. A unison in a unison, asourcein one and state from outside written in one are refused.The big patch (packages/dsp/examples/bigpatch.dsp) is the proof: its four detuned copies a
unison(UNISON). Before, 36 block, 131 sample and 57 master instructions, 405 registers, 35 instances, 21,908 bytes of JSON; after, 16, 110 and 57 (17 of the sample stream the body), 357 registers, 35 instances, 21,387 bytes. As the machines run it, its streams are the unrolled program's lengths (39, 80 and 54) with 438 registers to 405, and it renders sample for sample as before: the copies are summed in the ordersumsummed them, and each copy's spread, worked out in 32 bits as it loads, came out where the compiler's 64-bit fold rounded it. Natively 8.4% of a 256-frame block at eight voices before and after (the least of ten release runs each, on a 4-core box shared with other builds, single runs up to 14%); in V8 1.72 and 1.71 ms a block (32%). The Showcase's synth has no unison.SuperSynth plays its unisons as regions: the wavetable oscillators' (
wavetabled, up to nine voices each), the sample kinds' (unisoned, up to seven) and Hyper's in the standard library (hyped, its 1 … 7 taps, three racks). serum.dsp's compile-timespreadAt,detuneSpreadandstackedbecamespreadOf,detuneOfandstackOfonuandn: a voice's place is(2u − (n − 1)) / (n − 1), its numerator whole so it rounds once (it is the compiler's 64-bit fold of2u / (n − 1) − 1in 32 bits for every u < n ≤ 16), taken as a choice of the count's so that a lone voice's blend and pan multiply by constants and fold as they did; the super, exp and inv detune modes are arithmetic, and what is a table per voice (the random mode's hash, a stack's cycle, Hyper's delay times and rates) is a list read bybyIndex(hyperEachin std): selects onu, which the machines fold to each copy's constant. The per-note work the sample kinds share (the start and its draw, the slice, the scan's pace, the loop region) stays outside the region, once. Every parameter, slot and piece of metadata is as before but for the registers past the voice stage (100 parameters' and the matrix's kept sources', and the arp's signals), which follow the shorter program.before after block / sample / master instructions 684 / 24,783 / 20,870 570 / 12,003 / 20,858 control code 1,305 1,311 registers 58,985 44,407 instances 4,302 4,302 JSON (compact; the .dsp.jsonfile)2,041,449 (4,374,712) 1,631,986 (3,520,149) the pack ( supersynth.dspk)430,856 335,456 As the machines run it, the Init patch's voice stream is 69 instructions either way and its block stream 151 then 159 (the detune and stack arithmetic on
n, once a block a copy); with osc A and B at nine and seven voices, 117 and 230 against 117 and 224. Init, that patch and one with Hyper at five taps and a stack render bit for bit as before (eight notes, three let go, 400 blocks, both sides), and so does the Init fixture: only its program's hash changes, andsupersynth.dspkwith it. At eight voices, the least of eight interleaved runs, release builds on a loaded 4-core box: natively Init 0.288 → 0.278 ms a 256-frame block (5.4% → 5.2%), the unison patch 0.438 → 0.423 (8.2% → 7.9%), with Hyper 0.463 → 0.457; in V8, the least of ten, 1.71 → 1.56, 2.24 → 2.22 and 2.28 → 2.31 ms (single runs moved 5% either way). The builder gained a fix the real program found: a state written back inside a body takes the body's region when its value's region is outside the body (or none). The program editor's graph showsunisonas a node of its count, its body a graph of its own (programEditor.test.ts). Sylenth1's unison is still written out.Tests. Two parity cases,
unison(a body with its own phase in state, an envelope with curves that followuand a filter, its count turned from 3 to 5 to 1 to 4 to 2 while notes play, a route moving a parameter it reads, and a mono unison of one copy) andunisonGates(a unison inside a region turned off and on, a choice inside it, its count turned; a master-stage unison of delays fed back through each copy's state); both render bit for bit as the same programs written out by hand, and the Swift machine within the harness's tolerance. The parity pack holds 30 programs. The language's tests compare a unison against its copies written out, before and after its count turns, and refuse what it refuses.
Merged onto the trim (format 6, no grains nor smooth, and section blocks): the format is 7, the Rust word table's
unison and most after section, and every case but the two new renders as on main, bit for bit. 280 tests in the
package, 8 in the Rust compiler, 45 in the Swift core's, 414 in SuperSynth's suite (415 with SuperSynth converted)
and 227 in the Showcase's.
Stereo in the master stage's lanes#
Every effect in the standard library did its work twice, let [l, r] = x and then two of everything, and the master
stage ran in lane 0 alone, so 15 of the 16 lanes of each of its instructions did nothing: SuperSynth's master stream,
three racks of effects, was 20,858 instructions (dsp-language.md, "Stereo in the master stage's lanes").
- The language broadcasts the rest of what an effect needs:
state x: stereo = 0keeps a stereo (two cells in a voice, named as two states of its name; one in the master stage), and a stereo test picks side by side. Arithmetic and the builtins already went side by side. In a voice, an effect written once on its stereo and the same written with each line twice, a side each, are the same program, byte for byte (the language'sstereotests; a state's two cells are named apart). - The library reads once:
echoed,reverb(its two sides one tail at[0, REVERB_SPREAD]),compressed,chorused,flanged,phaseShifted,distorted,equalized,convolved,utilized,frequencyShifted(its Hilbert sections on a stereo) andfiltered(a stereo in, and a cutoff a side) lose theirL/Rcopies, andhyped's end its crossed pair; its unison of taps,hyperVoicesfrom the unison work, stays a voice a side by turns. The effects are 273 lines where they were 321, std.ts 525 where it was 572. SuperSynth's rack reads its filter's two cutoffs (filterStage(x, …, [freq / spread, freq * spread], …)), its compressor's mix and its bus feedback (state fromBus2: stereo) the same way. Every program the library plays renders as it did, bit for bit. - The format is version 8: the master stage runs in lanes 0 and 1, its stereo's left and right.
masterInput,masterOutputand each ofbusInputsare one register;left,right,pairandswap(85 … 88) move values between the lanes, and both validators refuse them outside the master stage (two new cases ininvalid.json). The machines keep the master stage's delay lines a side, its builtins' lanes reset alike (a noise's seed the same in both), a convolution in lane 0 with its value in both, the input's and the buses' sides written to their lanes, the output read from them, and a shared value or an arp signal sampled from lane 0. As a program loads, each machine works out where an instruction's lanes are the same or only lane 0 is read (markLanes,laneMarks), and runs it in lane 0 alone, so a mono value, and a left side read alone, cost what they did. - The compilers hold a master stage's stereo as one register: a side is a value in its lane (
Signal.lane), an instruction on values in one lane works there (one in the other lane read into both first),x[0] + x[1]isx + swap(x), and two sides become one register where they meet a stereo or a region's edge (an effect's output, a region's value and its else, a choice's options, a unison's sums, stereo state, the output). A mono state, a route's source, a region's result, a shared value, an arp signal and a probe take a value in one lane read into both. The Rust compiler writes the same bytes: SuperSynth's, Sylenth1's and the 31 parity sources. - Measured. SuperSynth's master stream went from 20,858 instructions to 16,824 (its voice and block streams as
they were), its builtin instances from 4,302 to 3,074, its state from 971 to 781 and its registers from 44,407 to
39,607. With its ten effects on, what its master stage runs a chunk went from 254 instructions to 162 and its serial
part from 70 to 41 a frame. What did not halve is mono: each modulatable parameter's read (889 route lists with their
clamps and tapers), the LFOs and envelopes, the regions' glue, and 204
pairs (75 of two constants, once a block). Sylenth1's master stream went from 880 to 745 (what runs a chunk with its seven effects on from 168 to 100, its serial part from 123 to 71), and it renders as it did, sample for sample, its effects off, on, and on in other modes. A rack of every library effect (the new parity casestereoEffects) went from 1,290 to 880. Natively, release builds on a 4-core box other agents' builds shared (the least of nine interleaved runs, single runs up to 30% above it), SuperSynth with eight voices and its ten effects on went from 0.40 to 0.36 ms a 256-frame block (7.6% to 6.8%) and with no note from 0.28 to 0.24; in V8 from 1.60 to 1.52. - The big patch wrote its master stage a side at a time, and so paid the lanes' moves and gained nothing: 57 master
instructions to 64, 0.44 to 0.47 ms a block natively and 1.50 to 1.56 in V8. Its chorus, ping-pong, reverb and
allpasses are now written once on their stereo (
state echoes: stereo,delay(x, [0.011, 0.013] + …), the ping-pong's feedback[echoes[1], echoes[0]]), the comb filters on the middle still mono: 47 instructions, 41 as it runs, its serial part 26 a frame where it was 31, rendering sample for sample as before (its parity case and snapshot). That alone left its master stage about 10% slower natively than it was in one lane; measuring it (callgrind, the instructions a block takes) found where, and both machines changed. A lane loop that started at a lane read at run time (for lane 1 alone, a mark six of SuperSynth's instructions had) made the Swift compiler check a serial filter's pointers for overlap before every frame, a sixth of the stage: that mark is gone, lane 1 alone runs both lanes, and every lane loop starts at 0. A mono instruction read its operands in both lanes where its value was read in both, so the reverb's four comb filters, summed into a mono value the allpasses read in both lanes, each copied itself to lane 1; now a mono instruction reads its operands' lane 0 and what the fold could pass over it to (an operand where another may come to a constant, as x × 1) in its own value's lanes, so the sum copies once, andx op swap(x)(the middle,(dry[0] + dry[1]) * 0.5) is known to be mono. The builder also puts a lane instruction that reads nothing the one before it wrote ahead of it, so `[0.011, 0.013]- 0.003 * sine(…)
is onemadd`. With them, the big patch's master stage alone takes 0.094 ms a block natively where it took 0.097 in one lane (callgrind: 308.0 million instructions for 220 blocks where it was 309.0 million), 0.184 in V8 where it took 0.189; the patch with eight voices 0.422 natively where it took 0.430, and 1.43 in V8 where it took 1.46 (callgrind counts 1.6% more instructions there, in the voices: the two tests of its marks every instruction makes).
- 0.003 * sine(…)
- A bug in the Swift machine's fold, found and fixed. Where the fold passes over a
movand its reader then reads the register themovread, the reader's state bit, which says an operand holds one value rather than a frame's, was the old register's: an instruction reading state through a copy the fold removed read the frame's slot instead, which is never written (machine.ts reads the bit from the register it runs on). The hand-written program of the master stage's two-lane test had been changed to avoid the copy; it is back as it was, relying on the fold, and passes, with the state bit following the renamed register. machine.test.ts plays the same program on the JavaScript machine. - Tests. The parity case
stereoEffects: every library effect in a rack after the voices, its modes, designs and curves turned and effects switched while it plays, a mono bus echoed into both sides and the bus's sides swapped into the mix; it renders bit for bit as the unison branch's compiler and machine render the same source written a side at a time. Every other parity case, the snapshot fixtures and SuperSynth's snapshot render as before, bit for bit, on both machines (their programs regenerated, the parity pack 31 programs). A program playing effects in a voice and the same in the master stage give the same samples. The Showcase's program changed only its version (it has no master stage). 288 tests pass in the dsp package, 8 in the Rust compiler, 45 in the Swift core's, 415 in SuperSynth's suite and 227 in the Showcase's.
Modules: reserved names, qualified imports, declarations exported#
A module exported constants, enums and functions only, so a program's parameters, controls, shared values, data and
sections all lived in its one file (SuperSynth's 2,422 lines); a builtin's name could still be a function's parameter,
so the standard library's hyped, whose count was called unison, could not reach the unison region and kept a
helper to play it. Three changes to both compilers, no change to the format or the machines (dsp-language.md,
"Modules", and Decisions, "Every builtin's name reserved" and "Modules declare what a program does").
- Every builtin's name reserved. A function's parameters are checked where the function is declared (called or
not), a closure's where it is made, an import's name where it is bound, as
let,var,state, a loop's name and a declaration's were;unisonjoins the names reserved. The message names the builtin and suggests a rename (unison is a builtin: name the program's own value otherwise (unisonValue, say)).hypedtakesvoicesand plays its unison itself;hyperVoicesis gone, and SuperSynth's racks give the count asvoices:. SuperSynth's program is the same, byte for byte. - Qualified imports.
import stdbrings a module in under its name (std.reverb(…),std.Filter, a type too),import serum as sunder another,import "lib/fx" as fxa module by its path;import std { reverb }stays. A qualified name resolves as the name imported would; an annotation names a module's own enums (a module's function typed by its enum used to fail, the annotation read in the program's names).asis a word only after an import's module (the Rust word table gains it at its end); the grammar and the code pane's highlighter take it. - Module declarations.
exportgoes before aparam,control,shared,table,shape,sample,patternorsection(a section's declarations exported as one), before or after its attributes. A module's declarations are the program's whether exported or not, made where the module is first imported, its own imports first, each module once: an import line stands for the declarations written out there, so a split at declaration lines is the same program. A parameter's or data's app name is one namespace for every file (two files declaring one is refused, naming both); identifiers are each file's. The stages,voicing,matrix,macroandarpstay the program's. A module's controls and shared values read its own names; a shared value's messages name its module, and a sample's file is found beside the module that declares it.CompiledModule.parameterFilessays which module declared each parameter. - The big patch in three files (examples/modules/: the oscillators' tables, shape and parameters in one module,
the effects' parameters and the master stage's function in another, imported as
fx) compiles to the one-file program and metadata byte for byte, in both compilers; examples/bigpatch.dsp stays, the parity case and the benchmark. - The editor.
graphsOf(source, file, modules)reads the modules' sources: imported parameters and constants are inputs as the program's are, a module imported whole is one (fx), and a qualified call (fx.effects(x)) takes its function's ports.declarations()lists a module's parameters, controls, shared values and data after the import that brings them in, each with its file; SuperSynth's PROGRAM tab shows each on a line with its module (a tap opens it), IMPORT chips name a module's exported parameters too, and a module takes + PARAM and + CONTROL. - Parity. The parity sources hold one file a case and the pack tooling writes each source alone, so modules are
tested in the package's suites (a program in modules against the same written out, the order, the refusals) and the
Rust compiler's; every compile of the TypeScript suite (586, recorded and replayed by
replay) gives the same program, metadata or message in the Rust compiler. SuperSynth's and Sylenth1's programs and fixtures are unchanged. 297 tests pass in the dsp package, 11 in the Rust compiler, 415 in SuperSynth's suite and 227 in the Showcase's.
Stereo for functions and samples, and the sections finished#
A pass over what the programs still wrote by hand (dsp-language.md, "Stereo for functions and samples, the sections
finished"). Every program compiles to the bytes and metadata it did, in both compilers: SuperSynth's (supersynth.dsp,
whose supersynth.dsp.json and supersynth.program.ts are the same files, and whose committed snapshot.json and
supersynth.dspk did not change), Sylenth1's, the big patch, the examples and the Showcase's.
- A list at a run-time index.
values[u]withua signal is a chain of selects, written asc ? a : bwrites it, which the machines fold to each unison copy's item; a list of more than 16 numbers in a stage is a step shape (each item twice, read at the middle of the index's pair). serum.dsp'sbyIndexand std'shyperEachare gone:random[u],map(…) { … }[u],HYPER_DELAYS[i]. - Stereo in functions. A
fnof asignalgiven a stereo runs once a side (in the master stage once, on the register of its lanes), its state each side's; a function may be declared again with onesignalparameter astereo, the call picking by its argument;swapped,middleandsideare a stereo's parts, written as the idioms they replace (middleisx + swap(x)halved in the master stage), and std'smidSideandfromMidSidewriteutilized's width. The big patch's drive and filters are one function on its stereo, Sylenth1's filtersfilterStage(inA, 0, note), the library's swaps and middles named. - Stereo samples.
sample x: stereoisxandxRight, the app's names, read a side at a time by the builtins and by a function of asample: SuperSynth's oscillator samples, its noise and its 36 impulse samples are 20 declarations where they were 40, and its sample readers (loopRead, the newplayedFrom,heldAt, the cloud) take the stereo whole. The app's live data names each side under its one declaration (noiseSample,bus1Impulse), and the editor's data list gives a stereo sample's right side's name (right), which the panel finds it by. - Sections, the rest.
nonetakes a section's attribute away (Sylenth1's effects are modulatable sections, their switches@modulatable(none));@slot(from: n)numbers a section's slots (SuperSynth's oscillators, envelopes, filter 2 and eleven effects, the runs that skip a slot left as they were);@group("MIX") section { … }groups without a name (SuperSynth's MIX and two VOICE runs, Sylenth1's MIX); data sits among a section's parameters (pattern arpPatterninsection arp); a///above a section is refused. - The arp's settings from its section.
arp(settings: arp, beats: …, stepChord: arpChord): SuperSynth's 26 labels are three. - Messages. A stateful builtin in a side of a stereo test says to compute it outside and select; a builtin's name
taken says so and suggests one (
sideValue); a declaration misnamed in a section says what to call it (name it osc and a capital (oscLevel)); an attribute data does not take names the declaration. - The count. supersynth.dsp from 2,422 lines to 2,390, serum.dsp from 1,000 to 991, std.ts from 525 to 527 (the
two mid/side functions in,
hyperEachout). No machine, format or fixture changed. 304 tests pass in the dsp package, 14 in the Rust compiler, 416 in SuperSynth's suite (one, which plays all 24 warp modes, near its minute on a loaded box) and 227 in the Showcase's.
The engine pass: stereo constants, the machines' fold, moves kept, a body's state chosen, 32-bit folding, explain#
What the unison and stereo work found the engine lacking, in six parts (dsp-language.md, "Folding as the machines run"; "What the compiler writes"; "What a program costs").
- Stereo constants (format 9). A stereo of two constants in the master stage (
[0.011, 0.013],[x, 0]'s zero) cost apaira block; it is now a register ofstereoConstants([register, left, right]), filled as the program loads, its left in lane 0 and its right in lane 1. Both builders make one (and copy one where a route list, a curve or the master output would name it); both validators check its register is written and named nowhere else, that the program has a master stage, and that nothing of a voice reads it, directly or through a region's result, a choice or a unison's sum (four cases in invalid.json); both machines fill it, mark its lanes apart and never fold it. SuperSynth's master stream went from 16,824 instructions to 16,749 and itspairs from 180 to 105 (its 75 of two constants are 13 stereo constants); Sylenth1's from 745 to 733; the big patch's from 47 to 44 (fourpairs to one). Everything rendered as it did, bit for bit. - The machines' fold goes on until nothing more folds, follows every renaming to its end (what reads a choice or a
region's result reads where a chain of folds comes to), and works out a pure instruction whose operands are all
constants with the arithmetic its stream runs (machine.ts
pure, Machine.swiftevaluate), its register holding the value and its writer left out; a pass marks what it reads, so it goes again only where it folded something already read. The unison copies' own fold, as the machines wrote them out, went. As SuperSynth runs, Init's streams went from 143 block, 58 sample and 50 master instructions to 126, 52 and 48 (ten effects on: the same block and sample, 162 master to 160), and a patch with osc A and B at nine and seven voices from 214 and 106 to 192 and 100. Every parity case renders on the JavaScript machine as it did; on the Swift machine too butstereoEffects, by at most 4.5e-8, where a choice now reads through a region's mix at 1 to its second operand, which the Swift machine computes in floats as a + (b − a) (the JavaScript machine, in doubles, gets b). The lane marks count a pure instruction of what may be constants as what may be one. Making the streams again takes the JavaScript machine about a millisecond more for SuperSynth (some 4 ms where it took 3, on a loaded box), its streams now holding the copies' index arithmetic. - Moves kept (builder.ts
movesKept, builder.rsmoves_kept): each stream asfuseleft it is checked against program order; an instruction put ahead of one it came after, and the two a superinstruction is made of, must share their region, unison body and choice option (eachchooseoption is now tagged,option) and not read what the other writes; else the build fails naming both. The lane move and the fusions now ask for the same option too, so no program trips it (SuperSynth's program keeps one lane instruction behind another option's: the same samples). A test puts the lane move's first version back and thegatescase fails to build. - A unison body's own state written in an option: each option of a
choosein the body starts from the cells as the choose found them, and each cell an option wrote is then a choice of what the options left (the cell as it was for one that did not), so a copy keeps what its own choice gives. Other state is refused as before. The validators already accepted the program it makes. The parity caseunisonStatewrites a body's phase in an option and its level in a region, and after the voices a stereo state under a choice, the mode, count, region and feedback turned; the parity pack holds 32 programs. - 32-bit folding. Both compilers round what they know to a 32-bit float at every operand and result, so a formula
folds to what the machines compute; data (tables, shapes, samples, patterns) stays in 64 bits, rounded once where it
is stored. The standard library's
unisonSpread(u, n)takes constants or signals: SuperSynth'sspreadOf(written so its numerator rounded once) and Sylenth1'sspreadAtboth use it, and Hyper's delays and rates are arithmetic on the copy's index again where a table (hyperEach, thenHYPER_DELAYS) gave them. SuperSynth's random detune keeps its 64-bit values, written out (RANDOM_DETUNE): the hash in 32 bits would put every voice elsewhere. SuperSynth's sample stream went from 12,003 to 11,988 and its master stream from 16,749 to 16,701. The renders against main's, largest difference and RMS: of the parity casesstereoEffectsalone, 3.2e-6 and 1.0e-6, and every other case and the snapshot fixtures bit for bit; SuperSynth's Init snapshot 7.5e-9 and 4.1e-10. SuperSynth played (eight notes, three let go, 400 blocks, both sides) against main: Init 3.5e-7 (RMS 6.4e-8, its peak 0.23), ten effects on 1.5e-6 (3.0e-7), nine and seven unison voices 3.4e-7 (6.1e-8), those with Hyper and a stack 2.5e-7 (4.7e-8), with the random detune 5.1e-7 (7.7e-8); Sylenth1 at its defaults and with unison bit for bit. The split big patch (examples/modules) and the single one still compile to one program. swiftbrowser-dsp explainprints, from the compiler alone, each stage's streams and control code, the unison bodies (a copy's instructions, the copies, what moved out and from where), the choices achoosemade with their options' instructions, the regions, the master stage's lane moves and stereo constants, and the ten source lines that make the most instructions; the builder keeps each instruction's file and line (origin) and gives what it made asexplanationwith{ explain: true }. The Rust compiler has none. For SuperSynth its busiest line is the LFOs' (1,600 instructions at supersynth.dsp:1323), its largest regions the two buses' (3,327 each), its largest choices the reverbs' kinds (329 instructions an option).- Measured, release builds, the least of eight interleaved runs natively and six in V8, main's program and machine
against the branch's, on the 4-core box other agents shared: the big patch with eight voices 0.422 ms a 256-frame
block natively before and 0.427 after (medians 0.438 and 0.442), 1.60 and 1.61 in V8; SuperSynth's Init with its ten
effects on and eight voices 0.360 and 0.359 natively, with no note 0.234 and 0.231, 1.70 and 1.67 in V8. What the
pass takes away runs once a block (a
pairof constants, a choice's arithmetic), so it is within the box's noise; what it gives is a program that says what it costs and code written once. - Tests. Merged onto the modules and language branch (
claude/dsp-modules): its programs and mine compose with no change to either's, the fixtures regenerated by their generators as they were, and the split big patch and the single one still one program. 328 tests pass in the dsp package, 19 in the Rust compiler, 46 in the Swift core's, 416 in SuperSynth's suite (the one that plays all 24 warp modes takes about 55 s of its minute alone, and ran past it once while the suite shared the box) and 227 in the Showcase's.
SuperSynth's program in modules, its names by one rule, its parameters documented#
A pass over SuperSynth's and Sylenth1's programs with what the language and engine passes added (modules, sections,
/// docs): the program split by its parts, its names made one rule, every parameter it declares documented.
Modules. supersynth.dsp is the top: its imports, the MAIN knobs (a
@group("MAIN")section) and the macros, the voicing, the matrix, the arp and its settings' section (arp(settings:)reads the top file's sections), and the two stages. Each part is a module beside it, its knobs, data, controls and functions together, imported in this order: voice.dsp (the voicing, the glide, the tune, the bend, the wheels, the time scaling, and the laws the others share), matrix.dsp (which parts a route moves, the Amp destination,part, the per-note randoms), oscillators.dsp, envelopes.dsp, filters.dsp, lfos.dsp, effects.dsp and mix.dsp. LfoMode, LfoKind and LfoDirection are serum.dsp's, with Serum's other kinds. The file had its knobs, then its state, its data, its controls and its functions, so a part lay in five places: put together by part, the parameters, controls and data go in another order (their registers with them).partOn, one control over the envelopes' and the oscillators' knobs which their own functions read, is each part's switches in its own module (envHolding,envCurving,uniWarping,uniPositioning,noiseRandomized,ampRouted;patchControlsgivespartOninPARTS' order still). The app finds a program's data in its modules: live data plays over a module's declaration while its file has it as it was, and a panel's edit of a module's data goes into that file (Session.editFile). Sylenth1 stays one file.Names. A section's member is named by its app name's last word (dsp-language.md, "Sections"), and SuperSynth's names put a family's index right after its word, a value of one source under that source's name (program-ui.md, "SuperSynth's names"). Filter 1 and filter 2 are one
section filter[k in 0..<2], each run of slots from where the index says (@slot(from: [P.filterType, S2.filter2][k])), its defaults and its chained switch's state byk(@state(k == 0)). The effects' levels, outside their sections with the sections' attributes written again, are their members, and an oscillator's scan routing its kind section's (@group(none)). Through the readers, the panels, the plugin's and the Swift machine's tests and the docs; a saved state with an old name loses that value:Before After Identifier oscA.velocityoscA.velTrackoscVelTrack, its@namegoneoscA.envoscA.envOnoscEnvOn, its@namegoneutility.lpf,utility.hpfthe same utilityLowCut,utilityHighCut→utilityLpf,utilityHpflfo1.phasethe same lfoStart→lfoPhase(the functionlfoPhase→lfoPlace)point1the same lfoPointinsection point→ the familypointfilter.type…filter.on,.level,.stereo,.out,.bus1,.bus2filter1.*filterType…filterType[0],filter2Type…filterType[1]filter.chained(2 → 1, grouped FILTER 2),filter2.chainedfilter1.chained(grouped FILTER),filter2.chainedfilterIntoFirst,filter2Chained→filterChained[0],[1]; the controlfilterChained→filtersChainedtuning.mode.A,tuning.range.AoscA.detuneMode,oscA.detuneRangetuningMode,tuningRange→oscDetuneMode,oscDetuneRange;tuningName→detuneNamefilterBalance.A….N,.SoscA.filterBalance…noise.filterBalance,sub.filterBalancefilterBalancepart.routed.s36part36.routedpartRouted, insection partSylenth1's mix.a,mix.bmixA,mixBthe same Sylenth1's filterA.resonance,filterCtl.resonance,syncthe same filterReso,filterCtlReso,synced→filterResonance,filterCtlResonance,syncDocs. Every parameter either program declares has a
///comment: SuperSynth's 309 declarations (1,632 of its 2,180 parameters, the rest the matrix's route slots and the chains' order) and Sylenth1's 108 (216 of 352). A comment that was about one knob is its doc as it was; one about a run or a section's members gave each its share; a knob kept for a preset and not played says so. The docs are the metadata's and the TypeScript's (Settings' doc comments,parameters[name].doc); the panel and the plugin show labels, not docs.Lines.
File Before After supersynth.dsp 2,390 415 voice.dsp 75 matrix.dsp 37 oscillators.dsp 936 envelopes.dsp 77 filters.dsp 81 lfos.dsp 240 effects.dsp 826 mix.dsp 55 serum.dsp 989 995 sylenth1.dsp 454 565 At the split, before the docs, the modules and the top were 2,469 lines (406 the top), the 79 more each module's header, imports and exports.
The same program. The split and the filter family reorder the parameters, so the .dsp.json is another file; the sound is not: sixteen renders of random settings by name (every effect, route, kind and switch among them, four notes, both sides, four thousand frames) hash alike against main's with the names mapped, the Init fixture's frames are as they were, and
swiftbrowser-dsp explaingives the same counts (39,456 registers, 2,180 parameters, 3,074 builtin instances, 781 state, 496 control values, every stream's instructions and every region's and choice's), its lines aside. The split compiles byte for byte (.dsp.json and .program.ts) to the one file its modules make written out where they are imported; the names, the MAIN and oscillator sections, the filters'@slot(from:)and the docs leave the program byte for byte as it was (with the names mapped; the docs change only the .program.ts's doc comments anddocfields), the levels' move only their registers; Sylenth1 is byte for byte its program withmix.aandmix.bmapped. The Rust compiler compiles both to the TypeScript's bytes (SuperSynth's SHA-256d54bd656…, the fixture's).What the language could not say, for a pass to come: a module's declarations are made where it is first imported, so a part whose knobs, state, data and controls lay apart in the program's order is one module only by moving them (and its registers); a module reads nothing of the file that imports it, so a control over two parts' knobs read by both parts' functions (
partOn) had to become a control in each;arp(settings:)names a section of the top file only, so the arp's settings cannot be a module's; an import names every value it takes (the top's imports of its modules are 81 names) and cannot take a module's section whole; a doc comment above a section is refused where its members share one, and a data declaration's///reaches no metadata; and a family numbered from 1 needs an@nameto say so (point{k + 1}).Tests. On main (the engine pass merged): 417 pass in SuperSynth's suite (the one that plays all 24 warp modes, 51 s of its minute alone, ran past it once while the suite shared the box), its typecheck, 227 in the Showcase's, 338 in the dsp package, 19 in the Rust compiler, 38 in the plugin's (built without its editor: no bundle here) and 46 in the Swift core's.
The language's third pass: sections imported whole, the arp's from a module, a section's docs, families from 1#
The previous pass's "what the language could not say", taken in turn (dsp-language.md, "Modules", "Sections", the arp's paragraph, and Decisions, "Sections imported whole, families numbered from 1"). Both compilers, no change to the format or the machines; SuperSynth's and Sylenth1's programs are the same, byte for byte, after each part.
- A section imported whole.
import oscillators { osc }brings a module's exported section in as one name, its members read past it as the app names them (osc[k].levelforoscLevel[k], the index on the section, so it reads as oscillator k's level;noise.oneShot);osc.level[k]is refused, saying to writeosc[k].level, andimport oscillatorsreachesoscillators.osc[k].level. The runs of one name a module exports are one section. Sections are a namespace of their own, read only byname.member, so a name may be a value and a section both (glide, the portamento, andglide.always;part, the function, andpart[i].routed) and a section namednoisehides no builtin; a local of its name hides it. A member is read by its name or through its section, not both. SuperSynth's top file importsvoicing,glide,osc,noise,suband (below)arpwhole: its imports of its modules are 52 names where they were 81 (with serum.dsp's, 56 where they were 89); its localsubbecamesubSound, filters.dsp readsosc[0].toFilter,noise.toFilterandsub.toFilter, oscillators.dspvoicing.mode, and envelopes.dsp's and oscillators.dsp'spartbringspart[i].routedwith it. The editor wires a section imported whole from one input (@section:osc, rolesection), counts a module's member read through it as a use, and SuperSynth's IMPORT chip names a module's exported section once instead of each member. - The arp's section from a module.
arp(settings:)takes a section imported whole, by its name or qualified (arp(settings: a.arp)), its members passed as the settings they name. SuperSynth's arp knobs and pattern are arp.dsp's (with the arp's four enums from serum.dsp), imported where the section stood, and the top keeps the call:arp(settings: arp, beats: arp.beats * (arp.dotted ? 1.5 : 1) * (arp.triplets ? 2 / 3 : 1), stepChord: arp.chord). The app's bundled files and the plugin's editor carry arp.dsp. - A section's
///and the data's. A///above a named section opens each member's doc, the member's own after it on a line of its own (as if written above each), the section's alone where a member has none; one above a section with no name is refused. Atable's,shape's,pattern's orsample's///is now its documentation: the metadata'sdocs(each kind's by name, a stereo sample's under both sides, a family's under each item; absent where no data has one) and aDatainterface in the TypeScript, each entry's doc comment its doc. SuperSynth documents all 137 of its data names (3 tables, 65 shapes, 1 pattern, 68 samples), its oscillators' data section and its point knobs' shapes with a shared opening; its program is the same, its metadata and .program.ts gain the docs, and the pack (test/fixtures/supersynth.dspk) gains them in its metadata entry, its program entry andsnapshot.jsonas they were. - Families numbered from 1.
@name(from: n)on a family names its items fromnwhile its index counts from 0: on a section with an index its section's name and the number (lfo1.mode), on a member family of a section with no index after the member (arp.step1), else after its name (macro1). Where@name("lfo{k + 1}")spelled it: SuperSynth's macros, envelopes, filters, LFOs, point knobs and point shapes, and Sylenth1's LFOs and arp steps. - Messages. A member imported by its name and with its section ("oscLevel is imported twice: by its name and with
section osc (osc.level): import the section or its member"), a member a section lacks ("section osc has no member foo
(oscFoo)"), a section read as a value ("osc is a section: read a member of it, osc.level[k]"), a section imported
twice,
arp(settings:)given a parameter ("arpRate is the parameter arpRate, not a section: …") or a family's section, a///above a section with no name, and@name(from: n)where nothing is a family or on a member of a section that is one; a member of a section that is one for each read without its index (osc.level[k], "section osc is one for each k: read its member as osc[k].level"), or one of a section with none given one. - What the language still cannot say (the previous section's list): taking a section whole, the arp's section in a
module, a section's doc, the data's docs and families from 1 are done. Two rules stay, as rules: a module's
declarations land where it is first imported (a part whose declarations lay apart is one module only by moving
them), and a module reads nothing of the file that imports it (
partOnstays a control in each part). And new edges this pass leaves: a section imported whole from two modules by one name is refused, not merged (so mix.dsp'sosc{…}.out,noise.outandbus{b + 1}.*stay bare names in the top, 12 of its 52), and a module reads its own sections' members by their names, not past the section's. - Tests. Every compile of the TypeScript suite (708, recorded and replayed by
replay) gives the same program, metadata or message in the Rust compiler; SuperSynth's and Sylenth1's programs and metadata are the TypeScript's in Rust. 347 tests pass in the dsp package, 24 in the Rust compiler, 417 in SuperSynth's suite (and its typecheck) and 227 in the Showcase's.
Serum's laws read from the Serum 2 demo, and the import run over its presets#
- What was read. The parameter layer of Serum 2's demo plugin (2.1.5, from its Windows installer, outside the
repository): each parameter's record (range, exponent or log scale, steps, default), how its value is shown, and the
table by which Serum 2 reads a Serum 1 preset's 343 VST parameters into its own. A preset keeps each parameter as
min + (max − min) · v^eof its knob's position v, and a Serum 1 raw value is that v: so every stored value comes back to its knob, and the records are the laws. Notes:serum2.md("The parameters' records"),serum2-gaps.mdsection 16,serum-presets.md("Serum 1's list, as Serum 2 imports it"). Nothing from the plugin is in the repository; the notes state the laws. - The laws section 16 assumed. The rate knobs pick from one list of 43 note lengths in threes (straight, dotted, triplet), an LFO's at round(42 v), a clip's at round(42 v), the arp's at 15 + round(26 v); an LFO's rate is kept in hertz (100 Hz × v⁴). The chorus's depth is 0 … 26 ms on a squared knob; the compressor's threshold 20 log10((1 − t)³) dB, its bands' thresholds 4t² × (48 u − 24 + c) dB with their deadbands, ratios and the lift below (0 by default) as stated; the reverb's knobs are named by its type (a plate's DELAY its pre-delay in ms, a hall's its decay in seconds, an abyss's and a space's their feedback); the filter balance starts at −100; and the noise's "colour" is the noise's pitch, ±64 semitones where it tracks.
- Serum 1's list. It confirms every slot the reader names and adds: the noise's fine pitch (29), the filter's pan (50), LFO 5 … 8's rates (260 … 263), the two chaos sources (67 … 70), mod slots 17 … 32 (228 … 259), the LFOs' rise and delay (273 … 288, 0 … 4 s linear), each effect's level (289 … 298); the older layout's fourth run of LFO floats is the rise, the run before it the delay. Laws the program has otherwise, to change where its files are rewritten: the glide (8 s, not 32), the coarse pitch (±64), the LFO and effect LFO rates, the chorus's delays and filter, the phaser's, delay's and EQ's frequencies, the delay's times, the compressor's threshold, attack and release, the reverb's pre-delay, the hyper's unison count.
- The import, run. All 626 factory presets read through the Serum 2 import (none throws): 549 import with nothing said, the median 0 (the tally had said 521). One stored value falls outside its parameter (a coarse pitch of −64); one note is a slot with no destination, which Serum ignores.
The language's fourth pass: a section's members by their paths, sections in sections#
A section's member had two spellings, its identifier in its own module (lfoMode[k], the section's name and a capital)
and its path in an importer (lfo[k].mode), and the groups inside a part (an oscillator's unison, its warps, an LFO's
fade) only their identifiers to say them. Both compilers, no change to the format or the machines (dsp-language.md,
"Sections", "Modules", and Decisions, "One spelling for a section's members, nested sections").
One spelling. A member is declared by its name alone and read by its path everywhere: in its module, in its section's body and in an importer.
// Before // After @name(from: 1) @state @name(from: 1) @state section lfo[k in 0..<10] { section lfo[k in 0..<10] { param lfoMode: LfoMode = .trig param mode: LfoMode = .trig param lfoFade: int(0...2) = 0 section fade { @modulatable param mode: int(0...2) = 0 param lfoRise: number(0...8) = 0 @modulatable … param rise: number(0...8) = 0 } … … choose(lfoMode[k]) { mode in … } } } … choose(lfo[k].mode) { mode in … }The app's name is the path with each family's number folded in (
lfo1.mode,lfo1.fade.rise); a member takes no@nameof its own but@name(from: n)on a family. A member written with its section's name first is refused with what to write, and an import of a member by its name with the section to import instead; the bare-member import and its "imported twice" message are gone. The editor names a member by its path (osc.uni.count, its uses read through its section's input, its own file's too), as do the live data's declarations (osc.window,point.high,arp.pattern,osc.zone), the IMPORT chip andparameterSources(osc[0].warp[1].amount). Rewritten mechanically, SuperSynth's and Sylenth1's programs compile to the bytes they did (program, metadata and .program.ts, both compilers); the effects' list of switches became closures ({ i in hyper[i].on }, an indexed section's member being no list), Sylenth1's oscillator's localpartbecamep(it hid the section).Sections in sections. A section may hold named sections, indexed or not, and member families; the index on each level (
osc[k].warp[w].mode,osc[k].zone[z]), attributes inward with the nearest winning,@slot(from:)counting the items depth-first, a///above each level opening its members' docs, a nested section's@nameits own part of the path. An oscillator's unison:// Before // After @label("UNISON") section uni { param oscUnison: int(1...16) = 1 @label("UNISON") @modulatable @label("DETUNE") param count: int(1...16) = 1 param oscDetune: number(0...1) @modulatable @label("DETUNE") … param detune: number(0...1) @slot(STACK_AT[k]) @label("STACK") … param oscStack: Stack = .off } @slot(STEREO_AT[k]) @label("STEREO") … param oscStereo: number(0...1) section uni { … @slot(STACK_AT[k]) @label("STACK") param stack: Stack = .off @slot(STEREO_AT[k]) @label("STEREO") param width: number(0...1) … }(two runs of
uniwhere the declarations lay apart, so nothing moves).@slot(from:)now counts each item where it takes a slot (an item that is state there,@state(c)holding, takes none), so the second warp, Serum 2's and state, leaves the first warp's slot followed by COARSE's.Renamed. The names under a newly nested group, through the panels, the Serum 1, Serum 2 and Sylenth1 readers, the plugin's test, the app's tests and the docs; a saved state with an old name loses that value:
Before After oscA.unison,.detune,.blend,.stack,.stereo,.uniWarp,.uniPosition,.detuneMode,.detuneRange(and B, C)oscA.uni.count,.uni.detune,.uni.blend,.uni.stack,.uni.width,.uni.warp,.uni.position,.uni.detuneMode,.uni.detuneRangeoscA.warp,.warpMode,.warp2,.warp2ModeoscA.warp1.amount,.warp1.mode,.warp2.amount,.warp2.modeoscA.keyLow,.keyHigh,.velocityLow,.velocityHighoscA.key.low,.key.high,.velocity.low,.velocity.highoscA.loop,.loopStart,.loopEnd,.loopMode,.loopFadeoscA.loop.on,.loop.start,.loop.end,.loop.mode,.loop.fadeoscA.slicing,.sliceCount,.sliceRoot,.sliceToEnd,.slice,.sliceThresholdoscA.slice.mode,.slice.count,.slice.root,.slice.toEnd,.slice.which,.slice.thresholdoscA.spreadPlace,.spreadPitch,.spreadLength,.backward,.spreadPan,.spreadGainoscA.spread.place,.spread.pitch,.spread.length,.spread.backward,.spread.pan,.spread.gainoscA.filterLow,.filterHigh,.filterMix,.filterShiftoscA.filter.low,.filter.high,.filter.mix,.filter.shiftoscA.envOn,.attack,.decay,.sustain,.releaseoscA.env.on,.env.attack,.env.decay,.env.sustain,.env.releaseenv1.curveAttack,.curveDecay,.curveRelease(toenv4)env1.curve.attack,.curve.decay,.curve.releaselfo1.fade,.rise,.delay,.smoothed,.smooth(tolfo10)lfo1.fade.mode,.fade.rise,.fade.delay,.smooth.on,.smooth.timedelay.timeL,.timeR,.offsetL,.offsetR(anddelay2,bus1.delay…)delay.time.left,.time.right,.offset.left,.offset.rightutility.invertL,.invertR(andutility2,bus1.utility3…)utility.invert.left,.invert.rightconvolve.reachDown,.reachUp(andconvolve2,bus1.convolve…)convolve.reach.down,.reach.upSylenth1's delay.timeL,delay.timeR,eq.bass,eq.bassFreq,eq.treble,eq.trebleFreqdelay.time.left,delay.time.right,eq.bass.gain,eq.bass.freq,eq.treble.gain,eq.treble.freq243 of SuperSynth's 2,180 names and 6 of Sylenth1's 352. Unchanged though moved: the zones (
sample zone[z]in the oscillator's section,oscA.zone1…, andshape zones,oscA.zones, wherefloor(k / ZONES)named a flat family of 27) and the LFO's rate (a run ofsection lfo,lfo1.rate).The same program. Sylenth1 is its program byte for byte with its six names mapped. SuperSynth is too but for the warps, whose four declarations lay apart and are now two members of a family made a member at a time (their twelve parameters in another order, their registers with them): sixteen renders of random settings by name, old names mapped to new (every effect, route, kind and switch among them, four notes, both sides, 4,096 frames) hash alike against the program before this pass, the Init fixture's frames are as they were, and
swiftbrowser-dsp explaingives the same counts for both programs (39,456 registers, 2,180 parameters, 3,074 builtin instances, 781 state, 496 control values, every stream's instructions, every region's and choice's), its lines aside. The pack fixture (test/fixtures/supersynth.dspk,snapshot.json) is remade for the names; its program's SHA-256 isb895f64c…. The Rust compiler compiles both programs to the TypeScript's bytes.Left as they were. The compressor's bands (its
gainandthresholdare knobs of their own besidegainLow…, sogain.lowwould be a member and a section of one name), the arp's knobs (their names are the arp's settings'), Sylenth1's oscillator unison (its identifiers name no group), the point knobs' shapes (point1.high,.highY, as they were), and single knobs.Lines. oscillators.dsp 950 → 985 (a group's
sectionline, its brace and its opening///), lfos.dsp 246 → 254, envelopes.dsp 77 → 81, effects.dsp 844 → 863, sylenth1.dsp 565 → 575.Tests. Every compile of the TypeScript suite (727, recorded and replayed by
replay) gives the same program, metadata or message in the Rust compiler; SuperSynth's and Sylenth1's programs and metadata are the TypeScript's in Rust. 351 tests pass in the dsp package (four new: sections in sections), 25 in the Rust compiler (one new), 417 in SuperSynth's suite (and its typecheck), 227 in the Showcase's, 38 in the plugin's (built without its editor) and 46 in the Swift core's (which read the remade pack fixtures).
Serum 2's engine laws, read from the demo (November 2026)#
A notes-only pass: the demo plugin's voice engine read past its parameter records (the previous pass's), for the laws
the notes had kept as guesses. Each law was read in the code, and where it is a function of numbers alone, run on
chosen inputs to tabulate it; nothing from the plugin is in the repository. The laws are in docs/notes/serum2.md
("The engine's laws"), serum-presets.md (the unison and glide rows, the knobs' curves, Warp) and
serum2-gaps.md (§16, with what each asks of the program and the reader).
- Read, high confidence. The unison's five modes as formulas of a voice's place (super tan, exp u|u|, inv a sine, random the sign of the place times a number of the voice's own), its rotation, DETUNE at x^2.5 of RANGE (not the readout's x²), STACK's patterns by distance from the middle, WIDTH as alternating sides at one pan (not a fan), BLEND's two gain curves, the warp spreads' halving pairs; the curve family the matrix's curves and the glide share (256 exponential tables, a slot's knob picking round(256x)); every warp mode's amount law and the phase maps of sync, the bends, PWM, the asyms, flip, mirror, the remaps and quantize; even/odd; the filter warps' 9.9-octave sweep and WARP VAR's four slopes; a filter's DRIVE (1 + x)⁴, LEVEL 4x², MIX and STEREO; an oscillator's level and pan law.
- Read, partly. The glide is linear in semitones over its time, SCALED per octave, but which curve table its knob picks was not found; the FM family's terms are read but not the step's units; AM's and RM's sign convention.
- Not reached. The reverb's vintage, abyss and space networks, the filters' resonance laws, the noise's pitch on its synthesized kinds, the envelopes' and LFOs' curve shapes. Measurement against the plugin is left for those.
- What changes, not made here. In the program, the detune modes' formulas, DETUNE's law and RANGE (dropping the
0.3 fit), the stack patterns, the unison's pan and blend, the spreads' placement, the warps' formulas in
warped; in the reader, the matrix's curves drawn from the family (its bend may run the wrong way).
Serum's knob laws in the readers and the program (November 2026)#
The readers and SuperSynth's program take the knob laws read from the Serum 2 demo's parameter records (serum2.md,
"The parameters' records"; serum2-gaps.md §16), each law one function (serum/knobs.ts, serum/preset.ts) or the
program's taper, with a doc comment that states it.
- Rates. Serum's 43 note lengths (
noteBeats, in the readers and in serum.dsp), with TRIP and DOT stepping a triplet or dotted step back to the one before; an LFO's synced step round(42 v), the arp's 15 + round(26 v) (arpStep, a sixteenth at the middle), a clip's speed (clipSpeed, no program knob reads it yet). An LFO's rate is 100 Hz × v⁴ (Serum 2 keeps hertz, 6.25 Hz unless kept; it had been read as the knob), its rise and delay 0 … 4 s linear (had been 8 s × x²). The LFOs'lengthfactor is gone fordottedandtripletswitches (TRIP and DOT in each LFO's title strip; its knob row is four). A route to the arp's rate is −26/27 along the program's knob (1/128 … 4 beats), always within it. - The noise. Serum 2's
kParamColoris the noise's PITCH (±64 semitones along it), its tracking the noise oscillator's switch;noise.fineis new (Serum 1's VST 29, slot 29); the guessed colour tilt (noise.tone,noise.tilted) is removed. - The racks. Chorus depth √(ms/26), feedback /95; flanger feedback a percent along its knob; distortion band
√((x − 0.075)/7.5); hyper unison 0 … 7 (none plays as one); the compressor's threshold 20 log10((1 − t)³) dB, its
bands' 4t² (48u − 24 + c) dB against it, RATIO BELOW 0 and the low crossover 128.3 Hz unless kept (the program's
defaults too, with Serum 2's deadbands); the reverb's knobs by type (
REVERB_KNOBS: a plate's DELAY its pre-delay, 0 … 250 ms squared, a hall's and vintage's its decay, a space's and an abyss's its feedback, FEED and WIDTH the damping and width or the spin or mod rate and depth), PRE DELAY its own knob (reverb.preDelay, 0 … 2.5 s × v⁵). - The program's tapers. Glide 8 s × v⁵, coarse ±64, LFO rate 100 Hz × v⁴, the effects' rates 20 Hz × v⁴, the
chorus's delays 20 ms × v² and filter 50 Hz … 20 kHz, the phaser 20 Hz … 18 kHz, the delay's filter 40 Hz … 18 kHz
and times 1 ms + 500 ms × v⁴, the EQ 21.5 Hz … 20 kHz, the compressor's threshold to −120 dB and attack and release
0.1 ms + 999.9 ms × v², the reverb's pre-delay 0.25 x², hyper unison 0 … 7, an LFO's rise and delay 0 … 4 s. The
compile is 2,195 parameters and 40,471 registers (from 2,180 and 39,456: the note lengths in ten LFOs); the pack
fixture's program is
1ce1266f…. - Serum 1's list past its knobs. Read from 134 Serum 1 presets outside the repository against Serum 2's import:
VST 0 … 247 are at
0x3460, the rest of the list at0x4ae0+ 4 (i − 228) by the state's version (0x4994; 260 … 272 from 0.13, 273 … 298 from 0.158, 32 lower in the first run before 0.13), mod slots 17 … 32 at0x50e0. The reader had read 248 … 298 at0x3460, NaN there, as 0. It now reads LFO 5 … 8's rates, the rises and delays (the newer layout's copies beside the count the other way about: the vibratos' 0.75 is a rise), the pans, the compressor's wet and bands, the effects' levels, the reverb's type (a hall in most: its knobs by it) and 32 mod slots, a destination past the knobs at the program's knob for it. - The matrix skips a slot with no destination, and a route to a reverb knob its type has not, as Serum does.
- The import run (626 factory presets): 551 clean (549 before), none throws, median 0; no value outside its parameter (an oscillator's coarse −64 was); the 985 synced LFOs each on one of the 43 lengths; the arp's six-octave note and the unassigned slot's gone.
- Tests. Each law against synthetic values (test/serumLaws.test.ts, 13: the LFO's 6.25 Hz at the middle, an eighth at 11.19 Hz synced, the arp's sixteenth at the middle, the compressor's −18 dB, the chorus's 26 ms at the top …), and the Serum 1 reader's list past its knobs on states built in the test (serum.test.ts); 434 pass in SuperSynth's suite (and its typecheck), 38 in the plugin's and 46 in the Swift core's (which read the remade pack fixtures).
Serum 2's engine laws in the program and the reader (November 2026)#
SuperSynth's program and its Serum 2 reader take the voice engine's laws read from the demo plugin (serum2.md, "The
engine's laws"; serum2-gaps.md §16), each law one function with a doc comment that states it (serum.dsp, filters.dsp,
voice.dsp; program-editor/routes.ts for the curves), tested at the notes' anchors by folding the program's own
functions while compiling (test/engineLaws.test.ts, 18).
- Unison.
detuneOf: linear u, super tan(u)/tan 1, exp u·|u|, inv sin(πu/2), random sign(u) × the voice's own number (the fixed sixteen taken by size);detuneSemitones, place × DETUNE^2.5 × RANGE (the 0.3 × x² fit gone; the sample kinds and the cloud too). Seven voices at full detune and 12 semitones play −12 −8 −4 0 4 8 12, super −12 −6.06 −2.67 0, exp −12 −5.33 −1.33 0, inv −12 −10.39 −6 0.stackOfby the distance k from the middle (the middle one or two stay; center −12/−24 lower them, a lone voice too), against the engine's own nine- and eight-voice tables.unisonGains: the voices alternate sides from the first on the right, every side voice at the one place WIDTH gives, a channel at p² + 1.416p, BLEND's 0.044 + 1.284b² − 0.738b⁴ on the sides and 0.998 − 0.554b² on the middle (0.53 and 0.69 at 0.75), two voices 0.708;unisonLevel, the sum at 0.5e^(−0.0288n) from two voices up (read from the code by the oscillator's pan gains; it had been 1/√n). A Serum 2 preset's negative WIDTH plays as its size.unisonSpreadAt: the warp and position spreads at 0, ∓½, ∓¼ … of σ.unisonVoicegives each copy's place, distance, side and part as a choice of the count's, so the machines fold it to the copy's constants. - Warps.
warpAmount(sync 1 + 15w³, bends and asyms ½ ∓ 0.4w and 0.1 + 0.8w, PWM 1 − w, flip 2w, mirror 0.05 + 0.9w, quantize (1 − w)⁵, FM-family w⁴, self-PD 0.6w², diode 2 0.05 + 0.95w) and the maps (bendPhase,pwmPhase,asymPhase,mirrorPhase,remapPhasein n parts, each the whole wave, the last mirrored;quantizePhase,syncWindowat Serum 1's half and full windows,flipSign,evenOdd,warpCutofffrom the note up e^{6.834w}). Kept as ours: the FM family's step scale, self-PD reading the oscillator at its phase, AM and RM's depth, and WARP VAR (no parameter; the filter warps at 12 dB). - Filters.
driveGain(1 + x)⁴ into the voice filters (+14 dB at the middle: the notes had said +7),drivenIntosaturating what is past full scale as a softclip,filterMix(1 − cos πx)/2 wet and 1 − wet² dry,stereoOctaves±2(s − ½)³ of the cutoff's travel. LEVEL OUT was already 4x². - Pan.
panned, Serum 2's 1 − p + 0.416p(1 − p) and p + 0.416p(1 − p) over its 0.604 at the middle, for the oscillators, the noise and the sub. - The curve family.
curveTableandcurveTableOf: a slot's CURVE IN and aux curve drawn as table round(256x) (bentCurve), read back bybendOf; matched outside the repository against the demo's 256 × 2048 tables to 3e−8 (Serum holds c and c′ to 1e−12 … 1 − 2e−12; its point i is x = (i + 1)/2048). The bend runs the other way from the reader's old power law: up rises quickly. - Cost.
explain: 40,471 registers → 41,976 (+3.7 %), builtin instances 3,072 → 3,072, the frame stream 12,194 → 13,440 instructions, the wavetable unison's body 524 → 786 a copy (the options of the count's and the warps' choices, which the machines fold or skip as they run). Rendering three seconds of an eight-note chord on the JavaScript machine (the best of five): Init 141 → 137 ms, seven-voice unison 689 → 713 ms (+3.5 %), with a warp and a driven filter 1,156 → 1,129 ms. Random settings render finite, their peaks at or under the old program's. - Tests that leaned on the old levels now hear the new laws: the stack test (the middle stays under 12 (1x)), the sample unison and slice tests (their DETUNE, one voice), the sources' floors, the convolution's size test (the tail against the start).
- The import run (626 factory presets): 551 clean, none throws, median 0, no value outside its parameter, the
notes the same as before. The pack fixture's program is
ed891358…; the Init render's peak 0.14 a side (0.20 before: oscillator A's three voices at Serum's gains). - Tests. 452 in SuperSynth's suite (and its typecheck), 38 in the plugin's, 46 in the Swift core's.
The code editor's completions#
CodeEditor takes completions, a list of suggestions under the caret, with completionTriggers (., which opens it with an empty word) and onCompletionAccept. An update op replaces an element's props whole (docs/ops-protocol.md), so a prop that changed at each keystroke would carry the text over the bridge each time; the app is asked once per word instead and the view does the rest (completion.ts states the contract, docs/notes/textkit.md "The view"): as a word begins, at a trigger character or at Ctrl-Space the view sends a completion event with a request number and the word's range, the app-side wrapper (view.ts) calls the app's function there in the app's JavaScript with a CompletionContext (the mirror's text, the caret, the word so far, its line, whether the user asked, an AbortSignal the next request aborts) and hands the answer down as the completions prop naming the request it answers, only the latest request's answer going down; a function that answers at once answers inside the event's dispatch, so its list goes down with the pass the event makes, and one that returns a promise answers when it settles. The prop is never cleared and the view applies an answer only to the request it has open, so a stale one is dropped by its number rather than the text's version (the edits while the list is open are after the word's start, filtered locally), and { items, incomplete: true } asks again at each keystroke of the word, as the Language Server Protocol's does. An app whose list never depends on the word gives an array, which goes down once as completing.items, keyed by what it says as marks is. Filtering and ranking are the view's; Arrow Up and Down pick, Return or Tab take, Escape puts the list away; an item (label, insert, caret, detail, kind, filter, from) goes in as an ordinary edit, so undo takes it back and the app hears a change and then a completionAccept. On a page the list is an element over the lines; natively it is the view's own, drawn over the text view, driven by the hardware keyboard or a tap. The types (CompletionItem, CompletionContext, CompletionAnswer, CompletionSource, CompletionKind) are exported from both entries, as types alone, so @swiftbrowser/code/react still reaches only the component. The Showcase's editor completes Swift's keywords and the names its file already uses (a capitalized one as a type, the word being typed left out when only it has it); SuperSynth's code pane completes the language's words, the program's declarations and every function the ADD palette lists (catalog), each with its parameters beside it and taken as name() with the caret between the parentheses, a module imported whole offering its functions after its name and a ., the list made when the editor asks for the graphs as they are then.
SuperSynth: a screen's data is a sound's state, and the React Compiler (November 2026)#
- Data edits compile nothing. Adding a note to the ARP page's PATTERN took about 1.35 s under V8 (longer in the
app, whose QuickJS has no worker): the edit was written into the program's text, the whole program recompiled when
the text rested, the node reloaded, and only then did the grid, which read the pattern from the compiled program,
show it. A pattern, a drawn shape or table or a sample is a sound's state, as a knob's value is, so it is live data
in the session now: the text keeps the declaration's default, the node gets the data at once, the compiled program
the screens and SAVE read has it merged in, undo restores it through the document's history, and nothing compiles
(
play(document); test/session.test.ts). A note shows in about 56 ms. Two render costs went with it:shownParamsonce a render rather than once a parameter, and the edited check no longer copying every value. scripts/arp-bench.mjs measures it. - The React Compiler.
swiftbrowser-native build --react-compiler(andREACT_COMPILER=1for Vite and vitest) runs babel-plugin-react-compiler over an app's own modules before esbuild (packages/native/src/reactCompiler.ts), saying what it left as written and why;--react-compiler-strictfails the build where it left any. On SuperSynth it first left 30 functions as written, the Knob, the root and SynthView among them (??=on a ref, suppressed dependency lints over render-time mutation, refs written in render, member defaults), for 10–15 % less React work; with those gone (refs written in layout effects or made state,useEffectEventfor run-on-change effects, the node's tempo and volume set from effects through helpers, aDockBarchild for the edit bar, defaults computed in the body) all 211 compile, the renders byte-identical, and under V8 a knob event's React work is a quarter less, a page tab's a quarter, a root re-render's a third, a pattern tap's two thirds (54 → 18 ms). It is on for the release builds (npm run build,build:web, so the iOS app, the page and the plugin's editor) and CI's tests, and off indevanddev:web: Babel adds about 14 s to a cold minified build (over a second each for the four big files), which caching by content hash and worker threads would cut before it could be the default. scripts/render-bench.mjs times the mount, a knob drag, the page tabs and a root re-render with and without it.
SuperSynth's EDITOR as a file tree and the code (November 2026)#
The graph editor (docs/notes/graph-editor.md) and the parsed statement list beside it, the declarations each module brings in under its import, came out of main: their code is kept on the branch supersynth-graph-editor, pushed at the commit main was at before the change (1e8edce9), and graph-editor.md stays as the design record with a note saying where the code is. EDITOR is now the program's files and its code, as an IDE has them: a file tree on the left, with new file and new folder, rename, duplicate and delete, the folders made from the files' paths, and the code editor filling the rest, its completions, documentation, diagnostics, signature help and hover coming from the .dsp language service in a worker (docs/notes/language-service.md); the modules and the panel's panel.ui are files in the tree like the program's source, shown and edited as text. Nothing a program is changed: the text was always the program and the graph a view of it, so the compilers, the session's one document, compile and history, SYNTH and the packs are as they were. The pack format keeps the <name>.dsp.layout.json entry where the graph's nodes sat (docs/notes/packs.md), so a pack saved on the branch opens on main and goes back to the branch with its layout. docs/notes/program-ui.md, docs/notes/dsp-language.md and SuperSynth's README say what EDITOR is now.
SuperSynth's launch on an iPad: the first frame right, and less to parse (November 2026)#
A recording of the iPad app launching showed three seconds of black, then the phone layout, three and a half seconds later the iPad grid with every screen blank, and a second after that the screens. Each had a cause of its own:
- The first frame knows the window. A native app's first React render ran inside the bundle's evaluation, before the host had said anything, so it rendered for
DEFAULT_ENVIRONMENT(compact, light) at an unknown width, and the panel laid itself out as a phone's until the scroll view's geometry report came.NativeAppnow sets__sbEnvironmenton the context before evaluating the scripts (color scheme, type size, size class, platform and the root view's size, whichNativeRootViewmeasures behind the tree with a load waiting for that report, a second at most),run()creates the root from it, and the environment event carrieswindowSizefrom then on, as the page renderer's does.useWindowSize()reads it; SuperSynth'sSynthViewstarts its viewport from it, so the first frame is the grid (docs/native.md, "The first frame"). - A launch in the app's color.
swiftbrowser native init --launch-background <#rrggbb>writes aLaunchBackgroundcolor set and anapple/Info.plistwhoseUILaunchScreennames it (the generated launch screen key is left out then), andNativeRootView(app:background:)draws the same color behind the tree from its first frame; SuperSynth's project is regenerated with its backdrop. The bytecode cache JavaScriptCore could keep for the bundle is not done: the call that runs a cachedJSScriptis not in the public headers. - Nothing compiles at launch. The app shipped its program compiled for the first frame's metadata and compiled it again a quarter second later, on the app's thread: 500 to 830 ms under V8 with a JIT, several seconds in a phone's JavaScriptCore, which has none, and every touch and geometry report waited behind it. The shipped compile is now what a compile gives, the parameters' names in the source included (
parameterSources.jsonbeside each snapshot,npm run snapshotsafter a.dspedit, the snapshot test saying when they are stale), and the session plays it as a compile's landing when the rest timer fires on the shipped text, compiling nothing until the text changes. An edit's compile runs in acompileworker natively, as the language service does, falling back to the app's thread where there is no worker. - Half the bundle was shiki. SuperSynth's
app.jswas 7.3 MB, 3.3 MB of it the highlighter's 43 grammars and 18 themes: the client owned them asimport()s, which one script for JavaScriptCore cannot split. The client knows the built-ins by name now (highlight/catalog.ts, each theme's chrome colors written down), the native worker entries carry and load them, a page's workers leave that to the client (Vite's workers cannot import dynamically; a page splits each grammar into a chunk as before), and a native build with thehighlighterworker stubs the client's inline engine and loader in the app's script: 4.0 MB. The worker then keeps only the grammars and themes the app's own sources name as whole quoted strings, as the page keeps the icons an app names, plus--language/--theme(highlighter: { languages, themes },allfor every one), and says what it kept and why; SuperSynth names only its owndsp, so its worker is 200 kB rather than 3.4 MB, and Showcase keepsswiftandmarkdown. - Screens drawn whole, two reports to settle. After a reflow each
Screenprinted its labels only once its own geometry report came, eachTracewas a custom shape the renderer drew only after the element reported its size, and one plate's natural-height report keyed every band anew, so everything measured again.Shapetakes asize(the path drawn for it on the same render, no probe, no report); screens take their width from their plate where the panel knows it (ScreenRoom) and hand their size down so labels, grids and traces (ScreenShape) draw in the screen's own pass;SynthViewkeeps one set of measures per layout key, a plate's report changing only its band and remounting nothing. The main page at an iPad's width takes the viewport's report and one for bands and plates together, tested headless with the host's reports sent by hand (test/panelSettle.test.ts; docs/notes/program-ui.md, "How the page settles").
SuperSynth's shipped program: a resource, a format, and nothing parsed twice (November 2026)#
After the launch work above, 4.0 MB of app.js remained, 2.5 MB of it program data parsed as code by an interpreter at every launch, and the first render parsed every module of the program twice over. Measured first: NativeApp logs the launch's timeline (subsystem swiftbrowser, category launch: each script's size and evaluation time, how long after the app started, what its first render drew, whether the window size was known; run logs its first render; the first frame with the app's views). Then:
- The shipped program is a resource the engine loads. The compiled JSON, 1.4 MB, was an object literal in the script: parsed by JavaScriptCore, stringified across the bridge, parsed again in Swift, and read by JavaScript for little.
DSPNodetakes a program reference ({ resource, url?, sha256? }): natively the engine reads the named file from the app's bundle and checks its digest, on a page the worklet's host fetches it and replays what was set meanwhile, a plugin's editor never sends one and its host says so if one arrives. The session plays the reference and then the live data through the per-datum messages, which the engine applies as a merged load would; the script keeps the reference, the data declarations and the controls' inputs (<name>.shipped.ts, written bynpm run dspbeside the compact copy it puts next to the bundle and the page); a save reads the whole text once through the host'sreadResourceor a fetch.app.js: 4.2 MB to 2.6 MB. - Format 10. The streams of opcodes and gate regions, 750 KB of decimal integers, are base64 of little-endian 16-bit words (registers fit by the format's own limit; the gates signed; a stream a word cannot hold stays an array). Both compilers emit it byte-identically, the JavaScript machine, the Swift core,
explainand the pack reader take 9 and 10 alike, so saved snapshots and older packs load. SuperSynth's program is 1.15 MB compact, 22 % less, parsed twice as fast.choicesstays: its options are the registers each value was computed into, repeated and not consecutive. Whole-binary was weighed and not taken: three decoders and a dump tool for tens of milliseconds, once the program is a resource. - Generated metadata as JSON.
swiftbrowser-dsp compile --tswritesparameters,metaand other large exports asJSON.parseof a string, the types kept exactly: a tenth more bytes, half the time to evaluate. - A shipped program's first render parses none of its text. The panel parsed every module for its data declarations and the preset's live data was stamped by parsing them again, 120 ms before the first render in Node and more inside it. The declarations and their texts ship beside the program; where the document is a bundled program as shipped,
SynthViewanddeclarationTextstake them from there, and any text that differs parses as before. A cold start is a quarter faster in Node; the panel file's parse (30 ms) is what remains. - Left for later: the module texts loaded lazily (the panel file and the shipped-compile comparison still read them at startup), the parameter docs and matrix lists as resources, and the panel file pre-read.
SuperSynth's launch on an iPhone: the header's row that did not fit (November 2026)#
A recording of the iPhone app launching, after the two rounds above, still showed two passes after the first frame: the header's name for a frame, then the page tabs in its place with everything 6 points further out at each edge, then the plates again, 12 points wider. One cause: the header learned the pages from the panel in an effect, a round trip after the first frame, and the row it then drew, even at its smallest (the tabs small, no name), is wider than a 393-point phone; SwiftUI gives a ViewThatFits its last candidate when none fits, the row outgrew the window, the app's stack grew to the row and every row and the page with it, and the page's scroll view reported the width it then had, so the panel laid itself out again for it. The header now reads the pages from the panel file as the panel does (pagesOf), so the first frame has the tabs, and its phone row has a fifth candidate whose tabs scroll in whatever room is left, which always fits. test/launchFrame.test.ts mounts the app headless at a phone's size and checks both.
SuperSynth's page switch in a phone's browser: measured, and two quick wins (November 2026)#
Switching to MAIN in iOS Safari was slow. Measured in headless Chromium at an iPhone's size and scale (scripts/page-switch-bench.mjs, the built page in device mode, FX tapped then MAIN): the tap's task runs a second of JavaScript on a fast core, five at 4× CPU throttling, and then the browser paints. MAIN is built anew each time: 4,000 elements added (9,500 to 13,500, about 49 a knob) through 33,000 mutations. Of the second: React's render 0.1 s; the renderer's own layout engine 0.24 s; the DOM about 0.15 s; the browser's style pass for the new page 0.32 s, run inside the task when the page is scrolled to its top; the browser-history sync 0.1 s, asking each of the 33,000 mutation records' subtrees whether it held a stack, sheet, split or row; the OUTPUT plate parsing the panel file again 25 ms, its memo gone with the plate's remount. Painting is what Chromium's software raster shows (4.4 s at 3×, 0.8 s at 1×), and Safari paints on the CPU: MAIN has 216 SVGs with 41,100 path segments against FX's 6,900 (the two wavetable meshes' 64 shaded rows each) and 168 drop-shadow filters. Animations are not the cause (none changes with them off).
The two quick ones went first: panelOf keeps the last four files read by their text (the app reads one file in several places, each memoized on its own), and the history's shownNow asks the root once, for anything navigational, when a commit brings more than 256 records; a root holding none shows depth 0 and no selection whatever the records touched. The tap's task is about a tenth shorter: 0.95 s against 1.09 s, medians of three alternating rounds, with runs on the shared machine spreading 15 % either way. What remains is structural: keeping MAIN mounted but hidden while another page shows (a show, not a rebuild), lighter screens on phones (fewer shaded rows, no filter shadows on knobs: the only lever on Safari's paint), and fewer wrapper elements a knob, which is the ops protocol's.
SuperSynth's page: half the elements were never seen (November 2026)#
Counting where a phone's MAIN page put its 13,514 DOM elements, after the quick wins above: 4,843 (36 %) were the keyboard's eleven unchosen ViewThatFits boards, built hidden on every page and again at each deck render; 1,035 were sixteen menus' items (the wavetables, the samples, the programs, the banks), built before any menu opened; 526 the header's unchosen rows; and of the visible rest, 29 knobs at 49 elements each (32 of them styled wrappers), 2,810 styled wrappers holding only another, and three screens carrying 90 to 285 thousand characters of path data. Two of these went in one change:
- One keyboard board.
Keyboarddraws the boardwhiteKeysForgives for its keys' width, as touch mapping always did, rather than handingViewThatFitstwelve. The first frame knows the width from the window (useWindowSize): theDeckpasses what its row leaves the keyboard (a phone's wheels, toggles and gaps; a wide deck's wheels and tray), the measured size taking over once it lands, and the page's layout engine agrees with the hint at every window size tried. The old choice and the touch mapping disagreed at fractional widths just under a threshold; followingwhiteKeysForends that. A phone's keyboard is 252 elements, from about 5,000. - Lazy React menus. The protocol's lazy menus (
deferred, themenuevent) had only the Swift producer behind them.@swiftbrowser/react'sMenuand.contextMenunow build their items while they are open and drop them after (packages/react/src/lazyMenu.tsx), eager withlazy={false}, inside another menu's items, in a headless host whose scripts tap items unopened, and in a native app, where SwiftUI wants the items as the menu appears and the host asks for them then. The in-memory renderer sends a chosen row's event beforeopen: false, as the page does.
The DOM is 7,601 elements on MAIN and 4,555 on FX (from 13,514 and 9,533); the switch builds 3,046 elements rather than 3,981 and its task is about 7 % shorter (0.90 s against 0.98 s, medians of three alternating rounds). The passes were looked at and left: the profile puts the two commits that follow a switch at no measurable JavaScript (the screens' own size reports, a few ops each), so there was nothing to cut. The knob as one Canvas element is the next change.
SuperSynth's knob as one canvas (November 2026)#
A knob was forty-nine elements: nine circles, the ticks and the pointer, each in the styled wrappers its modifiers make, three stacks turning them, and the gestures. The dial is one Canvas now (Knob.tsx drawDial): the ring, the groove and track, the lit arc with its glow, the ticks, the cap with its shadow, rim and pointer and the matrix's dot as commands in the knob's own coordinates, the gestures on that one element, the title and value beside it as before; fifteen elements. Canvas takes a size for it, drawn on the render that makes it, with no reader to wait for, as a Shape given its size is, so a knob is in the first frame. The in-memory renderer casts a canvas stroke's shadow from the stroke, as the page's drop-shadow filter does; it cast only a fill's. The arcs sit where SwiftUI puts a centred stroke, half a line further out than the page's and the in-memory renderer's inset strokes drew them, so the page's knob now matches the iPhone's. test/knob.test.ts holds the dial's commands by state. On a phone's MAIN page the DOM is 7,072 elements (from 7,601; a canvas's commands are SVG nodes of their own), and the FX → MAIN switch is about 13 % shorter (0.76 s against 0.87 s, medians of three alternating rounds).
SuperSynth's wrapper elements: neighbouring modifiers share one styled (November 2026)#
Serum presets open on an iPad (November 2026)#
SuperSynth's iPad app greyed every .fxp out in its file picker. The importer asks for .fxp, .fxb, .SerumPreset and .json; the native host made a UTType of each extension with UTType(filenameExtension:), which for an extension nothing on the device declares returns a dynamic type rather than nil, and the document picker matches a dynamic type to no file. The app's Info.plist declared no imported types, and the page build matches by extension, so only it worked. swiftbrowser native init --import-type <identifier>=<.ext>[,…][:<description>] writes UTImportedTypeDeclarations into the app's Info.plist; SuperSynth's projects.json declares Steinberg's .fxp and .fxb and Serum's .SerumPreset, and its Info.plist is regenerated with them. The native host's picker offers a dynamic type as .data, any file, with a logged warning naming the extension, so an undeclared type can never grey the picker out again. The Swift compiles only with an Apple SDK, so CI's macOS and simulator jobs check it first, and whether the picker enables the files is the device's to show.
Every modifier that changes layout or style wrapped the view in its own styled element, as the Swift shim does, so <Text font foregroundStyle lineLimit fixedSize /> was four styled around one text. SuperSynth mounted headless at 1194 × 834 had 12,374 layout nodes, 6,003 of them styled, in 3,261 chains, of which 1,438 were longer than one and held 4,180. One styled with several fields already applies them in a fixed nesting, the same in the layout engine, the raster painter and the page's styles: the transform outermost (one matrix, offset · rotation · scale, about one origin), then the layer effects in their fixed order, the clip, the box (its background and the area that takes input), and the layout (frame, padding, fixed size, aspect ratio); inherited context (font, foreground, line limit, tint…) and the hints read through a chain (layout priority, z-index, a list row's insets) sit anywhere. So wrap in packages/react/src/modifiers.tsx now keeps a run of styled modifiers open and gives them one styled, with all their fields, as long as each member may sit inside the next as that nesting has it and no two write one field (font and bold; cornerRadius and clipShape). .padding().background() is one element, .background().padding() two; an effect commutes with layout; a background is not merged around a hitTesting: false written inside it; scale and rotation never share one, as they would share one origin; a frame keeps its own element over a fixed size or an aspect ratio, because a flexible frame that grows past its child proposes the grown size again, which the separate element would still have fixed. position, containerRelativeFrame, ignoresSafeArea, alignmentGuide, gridCellAnchor, matchedGeometryEffect, contentTransition, rotation3DEffect, a background given a view, and every modifier that wraps the view in something else close the run; those that put nothing around it (a title, onAppear, a sheet) do not. Joins are decided by the modifiers written, never their values, so a modifier turned off keeps its place (an empty contribution to its run) and the view under it. The inherited styles a sheet replays are each modifier's own, not the run's, and their context providers go around the merged element, so chains through containers merge too. The native views apply one styled's fields in their own fixed order (StyleModifier.swift), which the rule respects too: the shadow, which they draw before the filters where the web draws it after, shares an element only with the fields that commute, inside an opacity and the blend; colorMultiply, first on the web and last natively, never; and the area that takes input (contentShape, help, pointerStyle), which they apply outermost, only with the layout and background inside it and the effects that commute. Their aspect ratio step moved inside the fixed size, where the protocol nests it. The native round trip (scripts/native-roundtrip.mjs) splits each side's styled chains one field per element and sorts them, since the shim sends the native views' order back, not the order written. Nothing else in the protocol, the renderer, the engine or the painter changed.
SuperSynth's MAIN page: 10,097 nodes (−18 %), 3,726 styled, the same 3,261 chains of which 461 are longer than one (457 of two, four of three); mount ops 49,581 to 40,532, a page tap's 9,794 to 7,813. The other pages and Sylenth1's lose the same share (FX 9,310 to 7,614, MATRIX 10,076 to 8,140, ARP 7,726 to 6,446; Sylenth1 MAIN 9,614 to 7,714). The nine panel screenshots (both programs × four pages at 2×, MAIN at a phone's 390 × 844 at 3×) are byte-identical to those before. Medians of three in scripts/render-bench.mjs, plain and compiled: mount CPU 4.29 s and 3.97 s before, 3.73–4.16 s and 3.38–3.57 s after; a page tap's CPU 673 and 627 ms before, 576–617 and 463–500 ms after over two rounds; knob turns and switches unchanged within the machine's noise. The Fidelity test compares the React tree to the Swift core's with each styled split one per modifier (expandStyled), since the Swift side still emits one per modifier. Those numbers are from the tree before the keyboard's one board and the knob's canvas (the two entries above); with them in, MAIN mounts with 5,550 nodes and 23,089 ops without the collapse and 4,368 nodes (−21 %) and 18,272 ops with it, 2,902 styled becoming 1,720.
The native host's lazy menus (November 2026)#
The native host asked a deferred menu for its items as the menu came on screen and never let them go, so a React app's lazy menus saved nothing on an iPhone, and the React side kept every menu eager there. On iOS the host now asks when SwiftUI presents the menu: SwiftUI builds a menu's items as it presents it and lets them go as it dismisses it, so the items' own appearance is the signal (Controls.swift MenuItems, MenuPresence). Until the items arrive a deferred menu lists one disabled row in their place, whose appearance sends open: true; the app answers inside that call and the presented menu shows the items. A second after the last item went, the host sends open: false, so a chosen item's tap, which a context menu may send only as its dismissal ends, comes first. macOS keeps the request at appearance, since it is not known there that a menu's items are built at presentation. React no longer treats a native app as eager. None of it has run on a device: the SwiftUI views type-check against the Linux shim, and a simulator test (LazyMenuTests.swift) presents a menu through a private interaction call and checks the two events; whether SwiftUI calls the items' onAppear at presentation and refreshes an open menu as items arrive is for the simulator and a device to show, and if it does not, a lazy menu shows its placeholder row instead of its items.
SuperSynth's screens draw what the pixels can show (November 2026)#
A phone's MAIN page carried 518,000 characters of SVG path data in 481 paths, 42,000 segments against FX's 7,000, and Safari paints paths on the CPU at 3×. The traces themselves were mostly already under a point per device pixel; the weight was the centred fill: a Trace with fade="center" draws ten traceArea layers a side and two strokes, twenty-two paths each carrying the whole trace, so the LFO's 1,024-point table was 286,000 characters, OUTPUT's scope 115,000 and SUB/NOISE's 91,000. Two changes (Displays.tsx): traceArea draws a stretch held to its layer's line by the stretch's ends alone, the points between lying on the line already (a centred fill's outer layers pass the line only at the peaks, so they are a few points each); and Trace thins its points to the screen (screenTrace, decimateTrace): a column every two device pixels (the scale the page's devicePixelRatio, else a phone's 3 and a wide screen's 2, useDisplayScale), a smooth column drawn by its mean, a steep or noisy one by its lowest and highest in the order they come, a step's edge kept upright, the ends kept as they are, as an audio editor draws a long sound. MAIN's path data is 172,000 characters and 14,000 segments; the LFO plate's 55,000 from 287,000. The raster renderer's phone and iPad shots differ by a band a pixel wide along the LFO's line and nothing else; the switch bench in headless Chromium, which rasterizes in software, shows no change outside its noise, the saving being Safari's paint and the bridge's bytes. test/screens.test.ts holds the decimation's rules.
An effect's screen follows its knobs again (November 2026)#
Turning a knob on SuperSynth's FX page no longer redrew the effect's screen: the distortion's curve, the hyper's fan, the EQ's response stood as they first came up. EffectScreen read its knobs' positions through a closure over the value store, with a useValuesSelector beside it only to be re-rendered as they changed; the React Compiler, which the app's builds run (npm run build, build:web), memoizes that read on the closure's inputs, which never change (the store is one object), so the compiled render kept the first positions, and the uncompiled tests passed. The screen now draws from the selector's answer: the positions and the effect's own parameters' values as it read them, parsed from the string it answers, so a compiled render sees them change. A collapsed effect's readouts (LeadReadouts) read their values the same way now. test/effectScreens.test.ts turns knobs headless and expects the screen's paths and a strip's readouts drawn anew; it means what it says under REACT_COMPILER=1, as CI runs SuperSynth's unit tests.
SuperSynth's Serum program is serum2 (November 2026)#
The bundled program the Program menu calls Serum 2 was supersynth everywhere else: its id in BUNDLED_PROGRAMS, its file (src/program/supersynth.dsp, so supersynth.dsp.json, .program.ts and .shipped.ts beside it), and its document's name, which the EDITOR shows as its file and a saved state carries. It is serum2 now: serum2.dsp and what npm run dsp writes from it, the id the menu, the init fallback and live.ts's shipped declarations key on, and the document patchProgram makes. The app's own name stays SuperSynth (EDITOR_APP, a preset's editor.app, the plugin's id, the storage keys and the fixture pack's name, test/fixtures/supersynth.dspk). The compiled program names its source file, so its hash moved (37c5692d… to ed5e365e…) and npm run snapshots wrote snapshot.json and the pack again (the program in them naming serum2.dsp, its rendered output the same); the plugin's build.rs compiles serum2.dsp under that name, as the fixture's hash needs. No id was ever stored (a document is matched to a bundled program by its text), but a state, sound or plugin project saved before names its document supersynth: documentOf (program-editor/snapshot.ts), the one place a saved program's name is read, opens that name as serum2.
SuperSynth's iPad launch: the page first seen is the page settled (November 2026)#
A recording of the iPad app launching showed the page first at its bands' natural heights, a short gap above the keyboard; a moment later the bands stretched to the window, every screen in them stretched with them (the filter's decades halfway up its screen); and a moment after that each screen drawn again for the size it took. That is the page's settle cascade (docs/notes/program-ui.md, "How the page settles") working as written, in plain view: the viewport's report, the bands', the stretched screens', and one more for MAIN's output scope, which a Fitted measures before its screen does. Headless at a 13-inch iPad's window, as the native host launches it (the window's size before the first render), the page changed in four commits after its first.
- Every host says when it has laid out. A new event,
laidout(docs/ops-protocol.md): once a host has laid out every commit it was sent and sent what that layout reported, it says so, last in the pass'sbatchor alone. A host reports a size only when it changed, so alaidoutwith no report since the last one says the layout moved nothing the app reads. The page's renderer sends it after each commit's layout (flushGeometry), the in-memory one after each round of its commit (report), and the native views after the SwiftUI update that drew a commit: they no longer send each size or custom layout's measure as a task of its own, but keep an update's reports (NativeApp.report) and send them as one batch once it is over, withlaidoutlast where it drew the tree's last commit (a small view behind the window,PassMarker, hears the commit counter change in that update), so an app renders once for a pass rather than once for each view it measured. The Swift core ignores the event. - A tree that knows its layout has settled. The host tree notes each
laidoutand whether a layout report came since the one before (HostTree.lastQuietLaidOut), anduseLayoutSettled(active)in @swiftbrowser/react is true from the first quiet one after the view's first render, or after a second and a half whatever the host said. Two things made a quietlaidoutarrive early, both in hosts that lay a commit out at once, from inside React's commit (the page's renderer, the in-memory one): an event dispatched there cannot render at once, so a layout's reports were answered a scheduler's turn later, after another commit's quietlaidout; and alaidoutcan be about a commit the app has since followed with another. The root now holds what a host sends while it is handed a commit's ops (HostTree.handing) and delivers it once the render or event that made the commit is over (a microtask after a commit React made on its own), so a layout's reports are answered at once, as those sent between commits are; and alaidoutcounts as quiet only when no commit has been handed to the host since it was sent (HostTree.commitsSent). Tested with the host's events sent by hand, from inside the commit and between commits (test/layoutSettled.test.tsx), in the in-memory renderer and the page's (the raster session's test, Web/e2e/laidout.spec.ts), and on the iOS Simulator (Native/Tests,LaidOutTests). - The page waits for it at launch. SynthView puts a wide page there from the first render behind
LaunchVeil, at no opacity, laid out and reporting all the while, and shows it once the hook says so: a component of its own, so showing it renders it alone and the page under it is the element it was given. Headless at both iPads' windows the page is unseen for five commits and shown in a sixth of two ops, its pixels the same as the frame the cascade used to end on, at about the time the cascade used to end. A phone's first frame is its page as it settles, so a phone is not made to wait (a phone kept waiting stood blank for more than a second for a change of a few hundred pixels); nor is a page shown after launch. - Two drawings that waited for reports of their own. The keyboard deck's wheels drew their ridges, and the header's scope its grid and middle line, a report after everything else: each a
Shapewith no size in a box of a size known to the view. The wheels' ridges take their boxes' sizes and the header'sScreenits width, so they are drawn on the first pass; a phone's first frame is now the same, pixel for pixel, as its last.
The Fidelity test's and the native round trip's trees are unchanged: the window's commit marker stands inside the window's own background, which the round trip leaves out.
Reopened on the iPad, the page came back with its bands far taller than the window. iPadOS lays an app it puts away out at its other sizes too, for the app switcher's snapshots, and the native views laid the page out at the snapshot's size and at the window's again before the app heard either: their reports came in one batch, the page's scroll view at the snapshot's size and then at the window's. Every reader in @swiftbrowser/react (GeometryReader, onGeometryChange, a canvas or shape reading its size, visualEffect, coordinateSpace) took a report against its render's value, so the second, back at what the render had, was dropped, and the page stood laid out for the snapshot. Each now takes a report against the one before it (a functional update), and the native views keep one report an element a pass, its last (NativeApp.report). Headless, the window at the other orientation and back with both layouts' reports in one batch now leaves the page as it was, pixel for pixel; test/geometryBatch.test.tsx holds it.
SuperSynth is Codon (November 2026)#
The synthesizer is called Codon now, everywhere its name was: the app (Native/Examples/Codon, its Xcode project and app, Codon.tsx), the header's wordmark (CODON, in one weight, where SUPER was heavy and SYNTH light), the plugin (Codon.clap and Codon.vst3, the codon-clap crate, its exported codon_clap_* entry points), the workflows (codon.yml, codon-ios.yml), the scripts, tests, fixtures (test/fixtures/codon.dspk) and notes. The identifiers changed with it, with no migration, by choice: the iOS bundle ID is dev.swiftbrowser.native.Codon (a new app beside any SuperSynth installed; the ad hoc workflow registers the ID and makes its Codon Ad Hoc profile through the App Store Connect API), the CLAP ID app.noya.codon and the AUv2 subtype Codn (a DAW project that used SuperSynth does not find it as the same plugin), the tag saved sounds and plugin states carry (Codon, Codon.program, codon.sound: those saved as SuperSynth are not read as the app's own), the app's stored settings (codon.*, so its view and deck choices start afresh) and the Cloudflare Pages projects (swiftbrowser-codon: the web app and the ad hoc install page at new addresses, made on their first deploy). What stays is history: this file's earlier entries keep the name they were written under, and the Serum 2 program's own earlier name, supersynth, is still read as serum2 where an old state carries it. The program sources' comments name the app too; the program compiled from them is the same (its hash did not move), and the snapshot fixture differs only in the tag it carries.
RevenueCat's patch is for 5.102.3 (November 2026)#
Ice Cubes went red on main: its pinned commit asks for RevenueCat from 5.x, SwiftPM resolved 5.102.3, and the patch, written for 5.92.0, named a file that release no longer has (StoreKit2ConfirmInOptions, the scene or window a purchase is confirmed near). 5.102.3 keeps that in a PresentationContext whose scene and window are under #if canImport(UIKit) and #elseif canImport(AppKit), so an iOS build needs nothing there. Only its sheet window, under canImport(AppKit) alone, reads the window a build for macOS (where both hold) does not have; the eighth edit gives it the #elseif's condition. RevenueCat still does not build for macOS, as with 5.92.0 (its Mac App Store check calls Security's code signing, and it uses AppKit names the shim does not have), and nothing builds it so. 5.102.3 also downloads with URLSession.download(from:), which the shim now has: the body is written to a file of its own in the temporary directory, which the caller moves or removes. The patch is written for 5.102.3 and the CLI's RevenueCat fixture is pinned to it; the other seven passages are unchanged. Ice Cubes builds again, and the fixture configures, fails its offerings and finds no products headless, as before.
laidout only while the app listens (November 2026)#
After #552, a code editor scrolled choppily on an iPad, in the Showcase as in Codon, where a build from just before it scrolled smoothly. Scrolling, the editor asks for the highlighting of the lines it shows every 80 ms, and each answer is a commit; since #552 every commit also bumped the count the root view's pass marker watches (NativeApp.commits, PassMarker), an update of its own, and sent laidout after it, for an event only useLayoutSettled hears, and only while it waits. The native host now counts commits for the marker only while the app listens: run says it listens for none as it starts (wantsLaidOut(false)), the tree asks while it has a laidout listener (HostTree.onLaidOut, the root's onLaidOutWanted) and stops when the last one goes. Asking counts as a commit, so the next update ends with laidout even when none comes, and the first one after the ask counts only the reports since. A bundle that never says (one from before the call) hears them on every commit, as before. The web renderer and the raster session send them always.
A context menu opens on its items (November 2026)#
On an iPad, Codon's file rows opened their context menu on Loading…, the row that stands in for a lazy menu's items until the app sends them: a context menu presents with a preview, and the presentation showed that row before the app's answer reached the open menu. A Menu asks as SwiftUI presents it and shows the items in the row's place; a context menu now asks as its content comes on screen and keeps the items, on iOS as already on macOS (ContextMenuElement, MenuPresence.menuAppeared(always:)). Its items are few, unlike a Menu's, whose thousand were why menus went lazy.
The native host reads JSON from its bytes (November 2026)#
A test build's readout over Codon's code editor found its scroll's stutter in applyOps: each highlighting answer, about a dozen a second, took 7 to 18 ms to apply on an iPhone. The ops cross the bridge as JSON, which JSONValue.parse read with JSONDecoder through JSONValue's Codable conformance, a value at a time, each value trying Bool, then Double, then String, then an array and an object, every failed try a thrown error: an answer's few thousand numbers were the cost, not the file's 46 KB of text beside them. Codon's launch, 1.1 MB of ops in six batches, decoded in 372 ms on the Linux VM; the editor's answer for 200 lines in 25 ms. JSONValue.parse now reads the UTF-8 bytes in one pass (JSONParser, SwiftBrowserProtocol): 17 ms and 0.4 ms, the same values (every op snapshot, Codon's launch and random documents read both ways). It refuses what JSONDecoder refuses (leading zeros, NaN, a number past a Double's range, trailing commas, nesting past 512), and a lone surrogate reads as U+FFFD. The JavaScript side stays JSON: JSON.stringify of the whole launch took 6 to 9 ms in Node, where a binary encoder written in JavaScript would have cost more than it saved.
The code editor's gutter moves its numbers instead of drawing them (November 2026)#
With the native host's JSON read from its bytes, a scroll of dense code in Codon kept every frame, and the timing readout's largest line was the gutter: 36 to 40 ms of an iPhone's second, in about 110 redraws, each walking the fragments on screen, making and measuring a string per number and drawing them all into a bitmap the editor's height. On iOS each number is now a layer, drawn once as it comes near the screen and kept while it stays near, in one layer whose bounds follow the text view's offset: a scroll moves them all at once, draws nothing and lays nothing out. Where they go is read from the fragments (EditorModel.numbers, a wrapped paragraph's one number at its first line) for a window a screen taller than the view above and below, and read again only when the view leaves it, the fragment at its top is not where the window has it, or what the places depend on changes (an edit, the size, the font, wrapping). A first try, following the offset with the gutter view's own bounds and reading every place each frame, cost as much as before (26 to 50 ms, and the host laid out again each frame, 15 to 18 ms); this one took 9 to 12 ms of the same scroll, the host 0 to 1. A change of font, color, appearance or scale draws the numbers again; the Mac's ruler draws as it did.
The native host hears an element's changed props alone (November 2026)#
An update op carried an element's props whole at every change: a code editor's 46 KB of file text with each highlighting answer, a dozen times a second while it scrolled. The protocol has a patch op now (set, the props that changed, top-level keys whole; unset, those gone), which the React host sends in place of update to a host that takes it: the native one says so (opPatches()), run passes it on (patches), and OpTree merges a patch into the element's props. The web renderer, the raster session and RemoteTree apply one too, though the React host sends them updates still. Measured headless, Codon's launch sends 157 patches where it sent 158 updates, and the batches after its first (which is all creates) go from 154 KB to 131 KB; a code editor's highlighting answer from 69 KB to 22 KB, which the native host's JSON parser reads in 0.2 ms rather than 0.4.
Markdown as a document, on the code editor's text system (November 2026)#
@swiftbrowser/code gains MarkdownEditor: the text is Markdown, and the editor shows the document it makes (headings in their sizes, bold in bold, bullets, tasks with boxes to tick, a quote's bar, a rule's line, a fenced block in the code font), hiding the syntax until the caret touches it. It is built on the text system the code editor runs on rather than on the rich TextEditor's runs: the storage holds the Markdown as written, and the layout asks a presenter how each paragraph is shown. The plan, the alternatives weighed and the milestones are in docs/notes/markdown-editor.md.
- The engine learned presentations (Web/src/textkit).
TextLayoutManager.presenteranswers aParagraphPresentation: the paragraph's font, line height, spacing and indents, and runs in a font of their own, with rendering attributes, or replaced by other characters (''hides a marker,'• 'stands for a dash). The layout measures, breaks and hit-tests the paragraph as shown while locations stay offsets into the stored text; a replaced run is one unit for the caret, a click, a line break and a deletion; line fragments carry their own height and x, and vertical moves go by line fragment. Without a presenter the layout is the code editor's, unchanged. - The presenter and the rules (packages/code/src/markdown).
markdownPresentationreads a line, its place among the fences and the caret in it;editing.tshas Return going on with a list, the inline and block styles as edits of the text, and a task ticked. Both are pure and tested as strings. - The page's view (markdown/page.ts) is the code editor's registered view asked for
presentation: 'markdown': the same storage, layout, viewport controller andEditorController. Its spans keep the stored characters (a hidden run is a span of no size, what stands for one is CSS), so the browser's offsets are the storage's, and it draws its own caret fromcaretRect. - Natively the view does not know the presentation yet and shows the Markdown, colored and wrapped; the component makes the toolbar's edits over the text it mirrors. The native view is the next milestone.
- The Showcase's Markdown example: the document, and beside it (or in its place on a phone) the same string as its source in the code editor, either one edited.
The gutter's last numbers stay on their lines (November 2026)#
At a file's end, the code editor's last line number stood a line and a half below its line on an iPhone, and off the screen on an iPad. The gutter checked only its first number on screen against TextKit's fragments, and a line below it laid out afresh (an estimated height made exact, as the highlighter's attributes land) moved the lines under it unseen. It checks its last number on screen too now, and each line keeps one number, on its first fragment.
Codon's editor: settings, redo, folders and main.dsp (November 2026)#
The pitch wheel's title is BND, which fits its narrow column. The top bar has a redo arrow beside undo, and the session keeps what an undo took back until the document changes again (redo, canRedo). The editor's WRAP chip is a gear menu now, with Wrap Lines, Line Numbers, the text's size (a list, and Bigger and Smaller) and the indent a Tab inserts, each kept across launches. The file tree's rows are taller, their names and icons larger. A program's main file is main.dsp by convention: in the tree (where it is not renamed: the toolbar's field names the program), as it compiles, and in a pack, which keeps the program's name in main.dsp.program.json. New Folder makes an empty folder, which the document lists (folders, kept in a pack and in a plugin's state) until it is deleted, and a folder renamed or moved takes its empty folders with it. Each bundled program is a folder in the repository as in the app: src/program/serum2/ (main.dsp, panel.ui, and its modules in modules/, which its top imports by path, import "modules/oscillators" { … }) and src/program/sylenth1/ (main.dsp, sylenth.dsp, panel.ui), compiled to main.dsp.json and main.program.ts beside their sources; the app's resources keep the programs' names (serum2.dsp.json). Nothing names a main file any more: the bundled programs list their files alone (no source, no mapping from other names), and a pack opens on its main.dsp or not at all (one saved before, its source named after the program, is refused: no compatibility was kept). The program's file actions are the app menu's now, under Program (New Program, Open Program…, Save Program…, above the bundled programs), so they work from the synth's view as from the editor's; the editor's toolbar keeps the program's name, UNDO and REDO, and its pack is made when Save Program… is chosen, the program whole read then, as Save Sound… does. The editor has no bar of its own over the code: the program's name is the file tree's title (a double tap or its menu renames it), undo and redo are the top bar's arrows, and the settings' gear stands at the tree's foot; a phone keeps a row for its two panes (FILES, CODE and the file shown) alone. Typing is a step of the app's history now, a burst at a time (a keystroke after a second's pause, or in another file, starts one), so the top bar's undo takes back what was typed as it takes back a file made or renamed.
The native code editor shows Markdown as a document (November 2026)#
MarkdownEditor in an iOS or Mac app showed the Markdown itself, colored by the highlighter, as SwiftBrowserCode's text view did not know the presentation. It knows it now (milestone 2 in docs/notes/markdown-editor.md); written without a device to try it on: its TextKit code is compiled only by CI's macOS and iOS jobs, and it is not yet verified running.
- The presenter stays in JavaScript, as the highlighter does (markdown/nativePresentation.ts).
NativePresenterfollows the native view's text by its revision through the change and viewport eventsCodeEditornow passes on (onNativeEvent), keeps the fences, hears the selection and the focus, and sendsmarkdownPresentation's answers for the lines on screen down as thepresentationsprop, by revision, a stale one dropped by the view. A list item or a quote also says where its text starts, so the view hangs its lines from the marker as it draws it. The colors are resolved on the app's side; the highlighter is not run for a document. - The view shows each paragraph through TextKit 2's own hook: the model is the content storage's delegate, and
textContentStorage(_:textParagraphWith:)answers the paragraph's characters in the presentation's fonts, line height, spacing, indents and colors. Nothing in the storage is edited to show it; a hidden marker keeps its characters at a size of next to nothing in no color, and a replaced run shows as many of its replacement's characters as it has (-as•), so locations stay the stored text's. A paragraph whose presentation changed with nothing edited (the caret entering it) is asked for again with an attribute edit of no attribute, the scroll position and selection held; between an edit and its answer each line keeps its presentation, moved with the edit, so typing in a heading does not flash it plain. A fenced block's ground, a quote's bar and a rule's line are drawn by a layout fragment of the layout manager's delegate's. Withoutpresentationthe view is the code editor it was. - A toolbar's command goes down as its edit (
edit), worked out over the text at the view's revision and made by the view through its input system, one undo step, where the app used to set the whole text anew. - SwiftBrowserCodeCore reads the new props and holds the pure parts (a presentation cut into spans over its line, the store of the lines' presentations through edits, the edit between two texts), with 13 tests on Linux; nativePresentation.ts has 7. Not there yet natively: a tap to tick a task or follow a link, Return going on with a list, a hidden marker as one step for the caret.
Markdown's blocks on the page: code colored, images, tables (November 2026)#
The Markdown editor's third milestone, on a page (docs/notes/markdown-editor.md). A fenced block whose fence names a language the highlighter knows is a document of its own in the page's highlighter: its lines go over once, an edit in it as the lines that changed, and the shown lines' tokens come back as rendering attributes, colors only, so a block colored or recolored lays nothing out again; a block is known by its opening fence, moved with the edits above it, so typing in one does not reopen the others. Its fences fold to the block's padding while the caret is outside it and are written out while it is anywhere inside, and arrows step through them either way.  is drawn as the picture, alone on its line as a block scaled into the column (at most 400 tall) and in a line at the line's height; the view loads it once by address and lays its paragraphs out again when it settles, a placeholder's box standing in until then, and the picture is the background of its source's span, which keeps the characters at no size; a relative address or a failure shows the alt text. GFM pipe tables are found for the whole text as the fences are, their columns measured once a version: each cell's text where its column and its alignment put it, the pipes and the spaces round the cells replaced runs as wide as the room they leave, the header bold, the delimiter row a rule. The row the caret is in, and an image the caret touches, are written out as their source.
The engine gained two things for it, both additive: a run's advance (the width it takes in place of its measure), and line breaking that never breaks at a space inside a replaced run (a task's [ ] could be split at its space before). markdownStylesAt(text, selection) answers what a toolbar shows lit, read as the commands read it: Bold now also takes a bold span's stars off with the caret anywhere in it, not only beside them. The Showcase's toolbar lights its buttons and ticks its menu, and its sample shows a picture and a table.
The rich TextEditor on the text system (November 2026)#
The page's rich TextEditor (a texteditor with runs) was a contenteditable of a span per run that the browser flowed and edited in place. It is now drawn and edited through the text system the code and Markdown editors run on (docs/notes/textkit.md, "The rich editor"), with the wire protocol unchanged. The storage holds the plain text; the app's runs are each paragraph's presentation, a run's font, slant and kerning as a presentation run's font and its colors and lines as rendering attributes (Web/src/richEditorText.ts); the layout breaks the lines; and a core view (EditableTextView, Web/src/textkit/view.ts) draws the fragments in view as rows of spans, sized by the layout, and feeds the keyboard to the EditorController, which moved from @swiftbrowser/code into Web/src/textkit (the package re-exports it).
- One editing logic. Typing, deleting by character, word and line, the arrows, selection, undo and redo are the controller's, as in the code editor. Undo is new in this editor: Command-Z (Control-Z elsewhere) takes a step back, an ordinary edit the app hears as
text, and the app's echo, equal to the editor's text, leaves the steps alone. - The echo draws nothing. Typed text takes the attributes of what it replaced, else of the character before it, as
AttributedText.replacingCharactersgives it, so the app's runs come back as the lines already are. An echo the editor has typed past is let go rather than applied as someone else's edit; a text from outside is applied where it differs, the caret kept. Reports go out once the edit is done, so an app answering inside the event (Notes' next bullet after a Return) sets its text and caret without the edit's own caret overwriting them. - Sizing by construction. Under
.scrollDisabledthe layout engine measures the lines with the view's own presenter, measure and layout, in the width it hands the view, so the box is the lines' height. A line is now as tall as the largest font on it, as UITextView spaces lines: a note's title line has its font's leading, where the span-drawn editor gave it a few pixels by the inline boxes' offsets and the engine counted every line a leading. Pages' documents draw pixel for pixel as before. - Long documents lay out and draw only the lines in view: a scrolling editor its own, a fitting one the window's, drawing more as the page scrolls.
- The lines are blocks in the flow. The first version placed each line and row absolutely. WebKit, asked for the caret nearest a point (a tap beside a line's text, a selection handle dragged past one), looks only among boxes in the flow, and left the caret at the paragraph's start: on an iPhone the caret could not be put at a line's end, and a selection moved unpredictably. A line and its rows are now blocks in the flow, each the size the layout gave it (the paragraphs not drawn above the first are its top margin), and a row spans the editor, its text set in by padding, so the room beside a line's text is its row's; the lines draw where they did. A tap is also checked against the layout: where the browser's caret after it is in another row than the one under the point, the layout's location for the point is taken; below the last line that is the text's end. A caret left at the end of a wrapped row stays on that row.
- Marks stay CSS highlights, a range a paragraph among the lines drawn; compositions run in the browser's line and come back as one edit; copy and cut take the selection's text, pastes are plain; Tab moves the focus. The text system's paragraphs gained an alignment (for
multilineTextAlignment) and a run's line height.
Web/e2e/rich-editor.spec.ts drives it: typing into runs through the echo and an echo behind, a selection the app sets and a text from outside, Return with an app going on with a list, undo through the echo, marks over lines scrolled in, five thousand paragraphs drawing a few dozen, mixed sizes under .scrollDisabled ending at the bottom inset, copy and paste, and a composition.
A panel's plates written once (November 2026)#
Codon's panel.ui was 1,083 lines, most of them one plate written again: OSC A, B and C, the four envelopes, the ten LFOs, and every effect's plate for the main rack and each bus (which a script wrote out). A plate there are several of is a function now, fn oscPlate(o, title, remap, stack = none, tab = none) { plate(title, power: o.on, …) }, called for each (const oscB = oscPlate(oscB, "OSC B", remapB, stack: osc, tab: "B")): the reader puts the call's arguments in the body (a name's members follow it, text reads a parameter in braces, none is a field left out, a list a function gives stands as its items), with no change to the language or its parsers. The file is 455 lines and reads to the same panel, plate for plate, as does Sylenth1's (191 lines to 156); scripts/panel-racks.mjs writes a line a plate. Edit mode changes such a plate in its function, so the others it makes change too (the call's names written back as the parameters, unchanged text kept, a title in the call), and writes the plate out in its call's place where the function cannot say the change.
The native Markdown view ticks tasks, follows links and goes on with lists (November 2026)#
Three gaps of the native Markdown view closed (docs/notes/markdown-editor.md, milestone 2), the view still knowing no Markdown; written without a device, its UIKit and AppKit code compiled only by CI.
- Return, Tab and Shift-Tab. The text view answers Return as the key comes, before the app could, so the presenter says ahead of it, as it says the presentations, what each key makes at the caret: the
keysprop, each an edit worked out bycontinueLine, the page's Tab rule and the controller's outdent (indentItem,outdentLine, new in editing.ts). The view makes one through its input system, one undo step and onechange, only while its text and caret are those it was said for; otherwise the key is the code editor's. - A tap on a task's box or a link. A tap (a click on the Mac) that lands on a box while the editor can be edited, or on a link read-only or with Command, is taken from the text view's own taps, which would have put the caret in the marker and written it out, and is sent as a
tapevent with the run's role and value; the presenter answers a box's with the edit of its one mark, the caret at the task's text as the page leaves it, sent as theeditprop, and a link's by callingonOpenLink. - No moment unpresented. A key's edit and a tick bring the presentations of the lines they make, for the revision they make, and the view takes them as the storage makes the edit: a new item shows its bullet and a ticked box its tick at once, and the answer that follows says the same.
- The caret steps over a hidden or replaced run, as on the page: where the selection changes, a caret inside one goes to its start when it went back along its line and to its end otherwise (SwiftBrowserCodeCore's
caretStop, the web layout'sboundaryover the line's runs). Once the caret's line writes a marker out it is text, and the caret may stand in it.
SwiftBrowserCodeCore has 8 more tests on Linux (46), the presenter and the editing rules 4 more (103), and the iOS Simulator job three more: the caret over a hidden marker, a press on a box and the tick that answers it, Return on an item as one edit and one undo step.
Codon's editor: a file comes back where it was left (November 2026)#
Choosing another file in the editor's tree put its text in the one code editor, which stayed scrolled where the last file was. Each file shown has an editor of its own now, by its path, kept open behind the one shown (hidden, the last six): a file comes back at its place with its caret, and one shown for the first time starts at its top. A phone keeps them open under its file list too, where the code was taken away before. What went wrong is said at the code's foot, a bar the height of the tree's foot beside it and always there, so the two rules stand in one line and a problem coming or going moves nothing (a phone has the bar only while there is something to say). The settings' Indent is gone: a Tab is two spaces.
A stack's tab changes nothing the page has laid out (November 2026)#
On an iPad, choosing another LFO or envelope made Codon's whole page jump. The page's layout was keyed by its tabs, so a tab chosen made every band of plates anew and measured the page again: the bands at their natural heights, the host's report, then each stretched to its share of the page. A page does that within one frame; natively each step is a frame seen. The layout is keyed by what each shown tab gives its plate's height now (heightShape: its power switch, its strip's widths, its rows' kinds and knob sizes), so a tab that stands as the last did changes its own plate and nothing else; one that does not (FILTER 2, with knobs where FILTER 1 has switches) is still a new layout.
The editor colors what a string holds in braces; programs set each param apart (November 2026)#
A string's {…} was coloured as the string it is in, so "LFO {n}" and "MACRO {k + 1}" read as plain text. Both of Codon's readings colour it as the code it is now: the lexer's (highlight, which lexes each part again) and the code editor's grammar (an interpolation includes the language itself, its braces punctuation, its own strings and braces matched), and the test that holds the two to one reading covers the panels' files as well as the programs'. And Codon's programs are set out with a blank line before each declaration that has a /// comment or attributes above it (each param, with its comment and its @ lines), 540 lines of space in eleven files and nothing else: the compiled programs and their TypeScript are byte for byte what they were, and a test keeps the files so.
The Markdown editor on the text system's view (November 2026)#
The Markdown editor's page view drew its lines itself: rows placed absolutely in a contenteditable, with a selection sync, input, keys and compositions of its own, the shape the rich editor's view had before its lines went into the flow for WebKit. It now runs on that view, EditableTextView (docs/notes/textkit.md, "The rich editor"), so the rich and Markdown editors share one implementation of the drawing, the selection, the input, compositions, copy and cut.
- What is the Markdown's is the view's options. A line's kind and its ground (a fenced block's, a quote's bar, a rule's line) are put on after its rows are drawn, outside them (
decorateLine); a fenced block's colors are fetched for the lines about to be drawn (willDraw); a task's box and a link take their click before the view (click), the browser's Bold and Italic their input (input); Return, Tab and the format keys go before the controller's. The editor still draws its own caret, now at a wrapped row's end where a tap left it (caretAffinity), and writes out the syntax under the caret as the lines are drawn, still never while a pointer is down. - Its lines are blocks in the flow. A tap beside a line, below the text or at a wrapped row's end lands there, and a tap the browser placed in another row than the one under the point is put right by the layout, as in the rich editor; on a phone WebKit gave the paragraph's start, since it finds the caret nearest a point only among boxes in the flow. Each line is a stacking context with its ground under its rows, and the editor has no scroll anchoring, so it draws and scrolls as before: the Showcase's Markdown example compares pixel for pixel with the placed lines on an iPad and an iPhone, at rest, scrolled, and with the caret in a word, a link and a code block.
- A tap's caret is read at its click. With a touch, the browser moves its selection at the mouse events that follow the pointer's release, after the view had read it; the view left that caret alone at the click and the next draw put the old one back, so a tap after a scroll did nothing. The view reads it at the click now (the rich editor too).
Web/e2e/markdown-editor.spec.ts gained the rich editor's tap test (beside a line, at a wrapped row's end, below the text, a browser played that leaves the caret in the wrong row) and two with a touch screen. Not run in WebKit here: only Chromium is installed.
Codon's editors stay the views they were (November 2026)#
On an iPhone, a file opened again from the files came back uncoloured, and at its top. Each file's editor was kept open behind the one shown by hidden, a modifier that is there or not: natively a modifier coming or going changes what the view is, so SwiftUI makes it anew, a text view at its top whose highlighting the app had already sent. (A page keeps its element and only hides it, so it showed on a device alone.) An editor not shown is unseen by its opacity and under the one shown by its place in the stack now, modifiers it has either way, and a phone's code is covered by its files with nothing hiding it; a test holds each editor to the same element in the same modifiers, shown or not.
The native Markdown view's blocks: code colored, pictures, tables (November 2026)#
What the page's third milestone shows, shown by the native Markdown view too (docs/notes/markdown-editor.md, "The native view"), the view still knowing no Markdown; written without a device, its UIKit and AppKit code compiled only by CI.
- A fenced block's code colored. What
@swiftbrowser/codeinstalls into the native presenter (markdown/nativeCodeBlocks.ts) opens each block whose fence names a language the highlighter knows as a document of its own, as the page does, the app's bundledhighlighterworker answering, and the presenter makes the tokens the code lines' runs' colors. A block shows plain first and colored once they come, for the revision the view has; the view needed nothing new.@swiftbrowser/code/reactstill carries no highlighter. - Pictures. The view loads each address once for every editor, off the main actor (a
data:URL's bytes or the web's, decoded by ImageIO), and tells the app its size with animageevent; the presenter answers with the line sized, scaled into the column the viewport now says, or with the alt text where it failed. The stored characters stay in the display paragraph, hidden: a run'sadvanceis made natively as its last character's kerning, and the layout fragment draws the picture over the hidden source. - Tables. JavaScript cannot measure the platform's text, so the presenter asks the view to: the cells go down as the
measureprop, the view answers once with their widths in its fonts (measured), and the page's own column maths runs over them. The room between cells is the hidden pipes' advance, a spacer in their last character's place (kerning it, the first try, came out at half the width in the simulator's tests); the delimiter row's rule and a body row's line under it are the layout fragment's.
SwiftBrowserCodeCore has 6 more tests on Linux (52), the presenter 9 more (112), and the iOS Simulator job four more: a code line's colors in its display paragraph, a picture loaded and drawn the right way up in its box, one in a line taking its width, a table's second cells at one x.
The Markdown editor reads a line in its place (November 2026)#
The Markdown editor read each line by its own characters, with one piece of state from above: inside a fenced block or not, found for the whole text at each edit, and an edit near a fence laid out every line after it again. It now keeps the block structure (docs/notes/markdown-editor.md, "The block structure"), the first half of milestone 4.
- State from above, kept by line.
MarkdownBlocks(markdown/blocks.ts) reads each line from the state the line above leaves, CommonMark's block parse simplified: the fence open and its container, the list items open and the column each one's content starts at, the paragraph open, whether indented code is. A line's place says its fence state, its quotes, the item it is inside and a role: a setext heading's text or underline, indented code, a table's row. An edit is derived again from the start of the paragraph the edit is in down to the first line whose state is what it was, and the page lays out again the lines whose place changed and no others: typing in a line reads that line, a fence typed reads to the next fence. The native presenter keeps the same structure, and an edit it predicts for the view (a Return in a list) is tried on a copy of it, with no prediction where it changes a line beyond its own. - What it shows. A line of text underlined with
===or---is a heading, the underline out of sight until the caret is in the heading (as a fenced block's fences are); code indented four spaces is code on its ground, the indentation out of sight; a quote in a quote has a bar of its own; lists, tasks, headings and fenced blocks go inside a quote; and a paragraph, a quote or a fenced block inside a list item stands at the item's text. Return in> - itemgoes on with> -, an empty one steps out to the quote and an empty nested quote out a level; Tab and Shift-Tab move an item in a quote; the toolbar's block styles keep the quote a line is in; a task's box in a quote ticks. - No new kinds natively. A line in a quote is a
quote, so the native view draws its bar, whatever it holds; indented code iscode; a setext heading isheading1orheading2. What the page draws more (a bar for each level, a block's ground from its container, indented code's rounded ends) is in fields the native view does not read yet. - Soft line breaks: designed, not built. Joining a paragraph written over several lines needs the layout to flow several storage paragraphs as one fragment, a change to every contract of the text system and, natively, a content storage of our own; the note sets out what each part would need and the cheapest first step, the layout's half alone behind a
joinsquestion.
The note says where the reading differs from CommonMark, on purpose: an underline is at least two characters, so a list item being typed under a paragraph does not make it a heading for a keystroke; indented code is read only outside lists and quotes. The code package has 19 more tests (122), among them a comparison of the structure kept through 1,800 random edits with the whole text read again, and Web/e2e/markdown-editor.spec.ts three more; the Showcase's sample shows the new constructs.
The code editor says where it is scrolled, and goes where it is told (November 2026)#
Codon kept each file's place by keeping an editor per file open behind the one shown, six text views for one on screen, and the place held only as long as each view did. CodeEditor has the place itself now, topLine, a binding as focused is: the line at the view's top, which the view says as it scrolls and goes to when the app gives a new text or names another line. One editor shows every file again, each file's text going into it with the line it was left at.
- Down, a place by its id. The line goes to the view as
scroll: { id, line }, made once by its id aseditis, and carried by every later update: a new id for a new text (the first included, so a view made anew opens where the file was left) and for a line that is neither where the view was last sent nor where it last said it was. The line the view says, coming back through the binding, sends nothing. - Up, the line at the top. With the binding given (
reportsScroll), the view sendsscrollevents,{ line, version }: at most four a second while it scrolls, where it comes to rest, after a layout (the lines above wrapping at another width move the top with no scroll) and after going where it was told. The version is the app's text's, so what a view says of the text before, still scrolling as the file changed, is dropped. - An exact place. TextKit 2 estimates the heights of what it has not laid out, and the page's layout does too, so the lines above the one asked for are laid out first and its fragment's top read; near the text's end the rest is laid out as well, and the view stops at the end. Before a view is on screen with a size the place waits, and the view says nothing of where it stands meanwhile.
- A view already there stays. Where the view's top is in the line asked for, nothing moves: an undo from the app's bar sets the text over the viewer's and names the line the view said, and the view stays to the pixel.
- Codon. The editor's places (the file shown, each file's line) are kept outside it (
places.ts), by the program's name: it is closed while the synth's panel shows, and opens again on the file it was on, at its line. A file renamed takes its place with it; a new file, a copy and another program's files open at their tops.
On iOS and the Mac (CodeEditorHost, EditorModel.place(ofLine:)), and on a page (page.ts). SwiftBrowserCodeCore reads the two props (47 tests on Linux); the iOS Simulator job has four tests of the view on the real text view (ScrollViewTests.swift: a view made with a place, another text's place and the same place gone to once, the line said while scrolling and nothing said unasked, the text's end), written here and first run in CI; Web/e2e/code-editor.spec.ts has the page's, which found the first drawing placing a line before the view's width was known; Codon's test/editorFiles.test.ts drives the binding headless (the view's events sent by hand). Not run on a device.
A phone's Safari showed the page editor's gutter through Codon's files, which lie over the code there (since the code stays as it is under them). The gutter stands over the lines by a z-index, and the editor made no stacking context of its own, so that z-index was weighed against the editor's siblings: over a later one with none. The editor isolates its stacking now (isolation: isolate), and what an app lays over it covers all of it; an e2e test puts a color over the editor in a stack and reads what is on top at a line number.
A stack's plate is as tall as its tallest tab (November 2026)#
Choosing FILTER 2 still made Codon's page measure itself again: its knobs stand taller than FILTER 1's switches, and the page's layout was keyed by its tabs' shapes, so a tab of another shape was a new layout, every band made anew at its natural height and stretched back. A stack's plate no longer changes height with its tab. Where its sections stand at more than one height, one of each shape is laid out in the plate unseen (stackShapes: hidden, taking no touch, the same ones whichever tab shows), so the plate is as tall as the tallest, and the chosen section is shown over them at that height, its screen taking the slack (FILTER 1's response is a little taller than it was). The layout key has no tabs in it: a tab chosen changes nothing the page has laid out or measured, on a phone as on an iPad. Stacks whose tabs are one shape (LFO, ENV, OSC) lay out nothing more than they did; FILTER lays out two sections more.
A first version kept each shape's section in the plate and showed one by its opacity; under a scroll view a stack proposes no height, so the shown one stood at its own height with a gap under it (seen in a browser at a phone's width). An overlay is given its base's size, which is what the shown section needs. test/panelSettle.test.ts holds the page to the same bands, measures and heights across FILTER 1, 2 and 1 again, and the unseen sections to the views they were; looked at in Chromium at a phone's and an iPad's size (the other plates' places read before and after a tab). Not run on a device.
The code editor's lines follow a new font size on the web (November 2026)#
The code editor's page view spaced its lines at the line height it was made with: an app that changed fontSize afterwards drew each line at the new size but placed it at the old size's spacing, so at a larger size the lines overlapped (28 pt rows 34 px tall, 15.67 px apart), and the text's height, which the scroll bar reads, stayed the old size's. Natively TextKit lays the lines out from the font, so only the web showed it. The text system's layout manager now takes a new lineHeight: every paragraph is laid out again at it, and the ones not yet laid out are estimated at it. The code editor sets it when fontSize changes, and the Markdown view when documentFontSize does (its laid-out paragraphs took their presentation's height already; its estimate for the rest did not). The Showcase's Code example has a text size menu (11 to 28 pt) to try it.
CI's Linux jobs run on Ubuntu 24.04, by name (November 2026)#
GitHub moved ubuntu-latest to Ubuntu 26.04, which has no libxml2.so.2, and every Linux job that runs the Swift 6.4 toolchain (built for 24.04) stopped before it built anything: swift-build: error while loading shared libraries: libxml2.so.2. The workflows named ubuntu-latest everywhere; they name ubuntu-24.04 now, the image the toolchain and its cache were made on. Moving to 26.04 waits for a toolchain built for it.
One .dsp compiler (November 2026)#
The .dsp language had two compilers: the first in TypeScript, which @swiftbrowser/dsp ran, and a second in Rust, written so the plugin's build could compile Codon's program, held to the first's bytes. Every change to the language was made twice, and the Rust one trailed: it read no asset literals and kept no probes or account of a build. It has those now and is the only one (notes/dsp-language.md, "One compiler"); lower.ts is deleted, 3,600 lines, with the tool that compared the two.
- As WebAssembly.
packages/dsp/rust/capiis a C ABI over the compiler, built for wasm32 intodist/dspc.wasm(860 KB).compileDspruns it: Node compiles the module as the first program is compiled, a page awaitsdspCompilerReady()once, a native app's worker takes the bytes inlined. A file or an asset the program names is read by the caller's own reader while the compiler waits. - As a library. The same crate natively, with a header and a module map for Swift. The CLAP and VST3 plugin's editor runs in QuickJS, which has no WebAssembly, so the plugin links the library and the package asks it (
useDspCompiler, a compile as JSON, the host given each file as the compiler asks for it); the raster window host gained a synchronous native call for it. The AU has the library and the header, and no bridge yet. - The same programs. Before the first compiler went, the Rust one gave its bytes for 45 programs, the same probes (309 for Serum 2) and the same account's text for 44. Codon's shipped programs regenerate unchanged. Serum 2 compiles in about 175 ms where it took 630.
- What stays TypeScript. The lexer and parser (the language service, the graph editor and the text edits read a source without compiling it), the names they need (
names.ts, held to the compiler's by a test), the TypeScript an app imports and the account's text.ProgramBuilderis a helper of the machine's tests now (test/builder.ts), no longer exported: 838 lines of those tests build programs with calls. - Building. A checkout needs a Rust toolchain to run the package's tests or build Codon: the scripts that compile build the module first (
packages/dsp/scripts/build-wasm.mjs, fifteen seconds cold, a tenth of a second after). The site's screenshot Worker, which opens programs compiled, bundles a stand-in for the module.
Not tried: the module in a real browser or on Apple's hosts (the tests run it in Node, and the plugin's test runs the native path through QuickJS).
The engine as WebAssembly, a start (November 2026)#
There are two engines as there were two compilers: Machine.swift, which a native app and the plugin play, and machine.ts, its mirror, which a page's worklet plays, each change made twice and held together by the parity fixtures. The Swift one now also builds as a WebAssembly module, and a page plays its programs on it wherever the module is there: Codon's page, the Showcase's and the Codon site's synth do. machine.ts plays where it is not, and is still what the fixtures and the tests are written by.
- The module.
Native/Packages/SwiftBrowserDSP/Embedded/wasm/build.shcompiles the core as Embedded Swift for wasm32 with SIMD, unchanged, and links it with a small Rust library under it (the C math fromlibm, memory fromdlmalloc, a few stubs):dist/engine.wasm, 675 KB (250 KB gzipped), which imports nothing and exports the C API. - The C API does all a machine does. It had events at the next block only and no way to replace the program's data as it plays. It has events at a beat (
…_at), a wavetable, a shape, a pattern, a sample or a route list replaced (sbdsp_machine_replace_…), and a probe's kept values. Every parity case through C is the samples it is through Swift, to the bit. - A refusal says why in Embedded Swift. A refused program's reason came out of the embedded build as "(cannot print value in embedded Swift)", in the plugin as here: the C API interpolated the error. It asks the error by its type now.
DSPEngine(packages/dsp/src/engine.ts) putsDSPMachine's interface over the module: made at once from a compiled module, as a worklet must, with noTextEncoder(a worklet's scope may have none).- Held by the parity fixtures: all 36 cases through the module are within the bar the Swift machine's own parity test holds (at most one frame in a hundred more than 1e-5 from the fixture, none more than 1e-3), their events at their beats and their data replaced as they play. CI builds the module and runs it (the Native workflow's
engine-wasmjob); the package's tests skip it where it is not built, since it takes a Swift toolchain. - Speed, in Node on a 2.1 GHz Xeon, four notes held, ms per second of audio, the module against
machine.ts: the example synth 6.9 against 20.7, the big patch 49 against 120, Sylenth1 18 against 85. - In the worklet, by default. The first program node a page makes looks for the module beside the package's script, and every node plays on it: the worklet's script carries the wrapper's classes (written, as
machine.tsis, with no class fields or module helpers, so each class's own text is whole), the compiled module goes to the processor in its options, and the processor makes each program's machine from it. A page with no module, a browser that cannot compile it or will not hand it to a worklet, and a program the engine refuses play onmachine.ts;read('engine')says which plays, anduseDspEngine(null)asks formachine.ts. - In a browser. In Chromium's AudioWorklet a program with a filter, a shape replaced, a note at a beat and a delay after the voices is within 4e-7 of
machine.ts's on both sides (an offline context), and a live context plays a held note and takes another program as it plays. Codon's built page, opened in Chromium, fetches the module and plays Serum 2 on it: a key held, the scope and the meter moving, nothing said of falling back. - Making a machine is faster too: Serum 2's in 128 ms against 267, on the thread that plays.
- The build downloads Swift.
npm run build:engineleaves a module alone whose sources have not changed (a stamp beside it holds their hash), and on Linux, where no toolchain has Embedded Swift for wasm32, downloads Swift 6.4.0 with swiftly and builds with that: the same bytes. The workflows that deploy a page with a synth build the module in their setup and keep it in the Actions cache by the sources' hash (sb-web.ymltakes the paths and what they are made from), so a deploy that changes no engine source needs no Swift. - Found on the way: Codon's page had stopped building when its workers began loading the compiler (a worker's bundle is one script, and the compiler's inlined module was imported as it runs, a chunk of its own). A worker's bundle takes what it imports into itself now, and a built page leaves the inlined module out, since it fetches the module.
With it came the fix it needed first: a patch gone silent no longer slows on denormals (delay lines and state fed back on themselves are flushed once a block where they have decayed: a tail that cost 95 to 181 ms per second of audio costs 11 to 21), in both engines.
Left: Safari and Firefox (only Chromium is here), the impulse of a sample replaced under a convolution (made on the audio thread by the engine, off it by machine.ts), and then machine.ts itself: the parity fixtures and the packages' tests are written by it, so it goes when they are the engine's, which wants the module in every checkout.
A native app compiles with the compiler linked (November 2026)#
A native app compiled a program with the compiler's WebAssembly module: in a web view started for the purpose, since the app's own script runs in JavaScriptCore with no JIT and no WebAssembly to count on, with the module inlined in three bundles. The plugin links the compiler instead. Now a Swift app can too.
- The library for Apple's platforms.
Native/Packages/SwiftBrowserDSP/scripts/build-compiler.shbuildspackages/dsp/rust/capias a static library for iOS, the simulator and the Mac (five Rust targets; a static library needs no linker of Apple's, so Linux builds them too, which is how they were checked here) and makesBinaries/DSPC.xcframeworkof them with the header and a module map. Not committed: the package's manifest takes it as a binary target where it is there, and definesSWIFTBROWSER_DSP_COMPILERfor the code that uses it, so a checkout without it builds as before. SwiftPM keeps what a manifest evaluated to by the manifest's text, which hid the XCFramework's arrival; the script drops the kept manifests once it has made it. - Two native functions.
SwiftBrowserDSP.install()registersdsp.compile, called inline, the same function a plugin's editor has, anddsp.compileAsync, the same compile off the main actor (Compiler.swift). The library is built to unwind, so a fault of the compiler's own is an answer, not the app's end. - The script's side.
compileDspModuleThrough(@swiftbrowser/dsp/lang) is the host loop as a promise: the same requests, the caller's readers, and the modules it already has given with the first one. Codon's background compile asks the host first (dsp.compileAsyncthroughcallNative), then the web-view worker, then its own thread, as each fails or is not there; Codon's main script already calleddsp.compileinline where a host had it. - CI. The Native workflow's macOS job builds the XCFramework before the DSP package is first resolved; the package's tests then compile a program, a program that does not compile, a module asked for and given, and eight compiles at once through what
install()registers, and fail (not skip) where the compiler is not linked. The Showcase's build in that job links it. Codon's iOS build builds the device's slice in its setup.
Checked on Linux: the five libraries build; Compiler.swift's DSPCompiler against the Linux library gives the answers the Mac's tests expect (rust/capi/tests/hosts); the registration type-checks in Swift 6 mode against the real NativeFunctions and JSONValue with the Apple guard lifted; Codon's tests ask a stand-in host for its own program and get the program its thread compiles, in one request. Not run anywhere yet: the XCFramework, the package's build with it, and its tests, which need a Mac (CI's).
Left: the inlined module in the native bundles (the language service's worker and the fallbacks still load it), the language service on the linked compiler, the Showcase's own releases (it compiles nothing, so its release workflows do not build the library), and the published @swiftbrowser/native copy of the package, which carries no XCFramework.
One engine (November 2026)#
machine.ts and arp.ts are deleted, 5,400 lines: the machine a page played, the Swift one's mirror instruction for instruction. A page and Node play the Swift machine itself now, as the WebAssembly module (notes/dsp-language.md, "One engine"), and a change to the engine is made once.
- The fixtures are the engine's. The parity and snapshot fixtures are the module's renders in Node (they were
machine.ts's); the native builds are held to them as before, within the same few millionths, their difference now the C library under the same code. Codon's 740 tests and the package's 450 passed on the engine with their expectations as they were, but for one test that sent a velocity of 0.8 (a whole number through C: no note). - What the tests asked of
machine.ts's insides they ask the engine:running(stream)(the opcodes a stream runs now: what a region that is off or a fold took out is not there),register(r, lane, frame),parameterTarget(name), andkeepNotes()/takeNotes()(the voices' starts and ends with their beats). The arp's 27 tests, which watched the JavaScript machine's voices, pass on the Swift arpeggiator note for note through the last. Tests of the JavaScript machine's own workings alone (its tables, its schedule's segments, its class rebuilt from its text, its denormal scan) went with it; the Swift tests hold the same. - Memory. A machine keeps what it needs in the module's memory until it is destroyed (Serum 2's: 190 MB, of 2 GB at most), where
machine.ts's were collected. The worklet frees the machine before as a program takes its place; tests take theirs frommachineOf(src/testing.ts), which frees them with the test, keeps its newest four, and has one freed sooner say so where it is used, since Codon's tests make dozens in a test. - The page. A program node says nothing to its worklet until the engine is loaded (
dspEngineReady, which it awaits itself); a wavetable's samples are made by the page's own instance of the engine. There is no fallback: without the module, or in a browser that cannot compile it, no program plays, and the console says so. In Chromium the worklet renders a program to the sample as Node does. - Building. Every script that tests or builds a page builds the module first (quick where nothing changed), so a checkout needs a Swift toolchain with Embedded Swift for wasm32: downloaded on Linux, swift.org's on a Mac, none on Windows. CI restores the module from the Actions cache by its sources' hash (
.github/actions/dsp-engine).
Not tried: Safari and Firefox.
A native app's bundles carry no compiler (November 2026)#
Codon's native app linked the compiler and still shipped its WebAssembly module, inlined as text in three bundles: the app's script, the compile's worker and the language service's worker, 3.4 MB of the app's 7 MB of script. The module is gone from all three, and the compile's worker with it: 3.3 MB of script now (notes/dsp-language.md, "One compiler").
- The app's script asks the host:
dsp.compileAsync, off the main actor, anddsp.compileinline where that fails or is all the host has (a plugin's editor). It starts no worker for a compile and has no module to fall back to: an app whose host links no compiler compiles nothing, and the compile's result says so, with the script that makes one. - The language service lowers each document for the compiler's checks, in a web view, where the app's native functions are not. Two things it needed: the service takes a compiler that answers later (
new DSPLanguageService({ compiler }): the document's modules go with the one request, the report follows the answer, an answer about a text since edited is dropped), and a worker calls a native function (callNativein a worker: the call and its answer are two of the worker's own messages, made by the app's script, so neither engine's host changed). - A page is as it was: its workers fetch the module. The page's language worker reads the worker's call from its scope (
__sbCallNative) rather than importing the native package, whose runtime would have added 46 kB to it for nothing. - Building.
build-compiler.shleaves an XCFramework alone whose sources have not changed (a stamp beside it holds their hash and its platforms), and Codon'snpm run buildruns it first on a Mac (--kept: the platforms it has, or every one where there is none), since the bundle has nothing to fall back to. - Held by Codon's tests: the compile in a host with both functions, with the inline one alone and with neither, and the language worker end to end over stand-in bridges (the real worker scope and the app's
Worker, each message as text), lowering Codon's own program in one request and reporting a refusal over its token.
The module inlined as a script (@swiftbrowser/dsp/dspc.inline, which the package's build wrote beside the module) had no other use and is gone with it.
Not run here: the app itself (there is no Mac).
The picker's wavetables are sheets, as the oscillator's (November 2026)#
A wavetable's tile in the asset picker looked like a block cut in steps: a pulse table a staircase, a sine a slab. The tile is not the oscillator's shader (a page has a GPU surface for only a few) but a sketch of the same stack in paths, and the sketch filled each frame down to the floor to hide the frames behind it, which made a solid of what the shader draws as a sheet with no side and nothing under it.
The sketch is the sheet now (WavetableSketch in Codon's Displays.tsx): filled between each two lined frames, from the back to the front, at the shader's own cover (0.6), darker where it is seen from under; the frames' lines on it, fainter the further back, as the shader's; the lit frame over all of it. The floor's grid and the sheet behind show through, as on the oscillator's screen.
Seen in Chromium, the built page's picker before and after. Held by tests of the sheet's pieces: which way each faces, and that none leaves its two frames' lines.
The compiler runs the panel (November 2026)#
Codon's panel.ui was written in the language's syntax and read by the app, with a reader of its own that walked the parsed text. The reader had become a second, smaller language: a function was its text with the arguments put in, if and match were read in a subset (no else, no !=), a name was whatever was written (oscA.level right or wrong), and what it did not understand it left out and said above the plates. The panel is a module now, the compiler runs it against the program, and the app is given a tree (notes/program-ui.md, "The file" and "How the file is run"). The reader is deleted: src/panel/model.ts was 1,868 lines and is 458.
- A panel imports what it binds.
import ui { plate, page, knob }for what it is made of,import "modules/oscillators" { osc }for what it shows, and the program exports that (exporton the sections, data and enums a panel reads; nothing reads past it). It reads the program as the program does (osc[1].level,lfo[k].fade.delay) and the compiler names each parameter for the app, so a panel no longer spellsoscB.leveland hopes. - Its own words are cases, the file's are text.
accent: .osc,format: .seconds, checked against the set;zone: "sources",stack: "lfo". An item shown by a parameter stands in anifor amatch, withelseand any comparison; the fieldsonly:andis:are gone, and the tree says the condition aswhen. - A plate is named for what it is.
oscAPlate,lfo1Plate: a plate's const is its id, and the program's own names are the file's to import. The racks' plates, which a script wrote a line each for (scripts/panel-racks.mjs, retired), are made in a loop over what the program says each rack holds, and keep the ids the loop gives (hyper,bus1.hyper). - In the language, for every file: a section is a value (
oscPlate(osc[1], …), a function'so.level), a parameter's default reads the parameters before it, and the Rust parser reads a call's last labeled arguments in braces and a list's items a line each, as the TypeScript one did. Every program and all 36 parity fixtures compile to the bytes they did. - For a panel alone:
ui,none, and conditions on parameters kept where a program would have a region. Amatchon an oscillator's kind is one list of rows, a control several kinds share one control. - One request. A compile that names the panel's file answers with the program and the tree; a panel that does not run is said beside a program that compiled, with its file, line and column, and does not fail it. A panel-only request runs the panel against the declarations with no stage lowered. The wasm-only handle the prototype had is gone: everything goes through
dspc_request. - One schema.
ui's functions and fields are one table in the compiler; the TypeScript types and the language service read a file generated from it, and a test fails when they differ. The code editor underlines the compiler's error inpanel.uiand completesui's names and words. - The app. The session has the panel with the compile. A change to
panel.uialone runs the panel and compiles and plays nothing; a panel that does not run leaves the last that ran showing, its error over the page and at the editor's foot. A bundled program's tree ships with its compile, and a program's file keeps it beside the compiled program (main.dsp.panel.json), so nothing is run at launch and the site's screenshot Worker, which has no compiler, draws from the file. - Edit mode is off, and honest about it. The writer that put a changed plate back into the file's text went with the reader. EDIT still selects an item or a plate and says what it is; it changes nothing. The compiler can say where each plate and item was written, through which calls and from which argument (
origins, off unless asked for), which is what the editor to come will change the text by.
Held by: the reader's tests as the same behaviours through the compiler; the two panels recorded as lines (test/fixtures/panels), first made of what the reader read of the old files, which the compiler's trees of the new files matched but for the plates' ids; the session's panel (with the compile, alone, failing, shipped, a program opened in another's place); and screenshots of five pages (Serum 2's MAIN, FX, MATRIX and GLOBAL, Sylenth1's MAIN, at an 11-inch iPad's size) before and after, the same bytes. They were not at first: Sylenth1's MAIN stood eight points off, because a program opened in another's place showed the last program's panel for the quarter second its compile waits, and the page measured those plates as its own. The session's panel is the document's own now, at once where the app holds its tree.
Left: the panel editor; more than the first error; a chain's effects checked against the program's chains.
The synth's library is uploaded by the deploy (November 2026)#
The site was built to take the synth's own things as uploads under an account (POST /api/uploads), and nothing sent them. Codon now makes that upload from its build (src/presets/siteUpload.ts): its library as published assets, each wavetable, noise and impulse made from its recipe and tagged with what it is and its family; a listing for Serum 2 and for Sylenth1, published and offered; and a preset for each of the four factory sounds with the asset files it names. scripts/site-upload.mjs asks which files the site lacks and sends those with what to list, the library a part at a time, and fails where an item is refused, a program does not open, or the token is not an admin's. What to send can be named, and the site's deploy names the library alone (assets), after the Worker, where the codon-site environment has the secret CODON_ADMIN_TOKEN.
The library is 384 files and 97 MB: 144 wavetables (2 MB, as harmonics), 205 noises (57 MB) and 35 impulses (38 MB), the samples WAV files of 32-bit floats.
Run against the Worker locally (bun run dev, an admin's token made there): the library went up in nine uploads and was listed, read back by its listings and by a file's hash; sent again, no file went and nothing changed; all three kinds sent together made the two listings and the four presets; a write token was told offered and default were refused, and a wrong token and a site not there each ended the script saying so. The screenshot Worker, run locally too, drew both program files. Not run: the two Workers bound to each other (a local copy takes a program's version as pending, and draws no thumbnail).
Every library wavetable is a wavetable of its own (November 2026)#
Making the library's files for the site showed 18 of its 144 wavetable names coming to the file another name made: "Pulse warm 1" was "Pulse bright closing 1", "Vowel dark 3" was "Vowel dark 5". The pulse generator read only how far a recipe morphs and the voice's only its odd share, so recipes that differed in how bright they are, or in their seeds alone, were one wavetable.
Both read the whole recipe now (src/library/wavetables.ts, and the plugin's port bit for bit). A pulse is built from its harmonics, which roll off as a saw's do by how bright each frame is; it starts as near a square as the recipe is odd harmonics and narrows as far as it morphs, its widest and thinnest a little its seed's. A voice starts on the vowel its seed chooses and glides round the vowels as far as it morphs, in a voice the size its seed chooses, its harmonics falling steeper the darker the frame. The seed's choices are drawn for these two generators alone, so the other 106 wavetables are the bits they were.
Held by tests: no two names come to the same harmonics; a brighter pulse and voice keep more of their upper harmonics, an all-odd pulse starts all but a square, and two recipes alike but for their seeds differ in every frame. The plugin makes all 144 to the hashes the app records.
The 38 pulse and vowel wavetables have new hashes, and the list of hashes kept by hand for saved projects (test/fixtures/wavetable-hashes.json) was changed for them, once: a project saved in a host before this which plays one of them names a hash no recipe makes now. No recorded sound in the tests plays one, so no fixture changed.
A picture on its way turns a spinner; a busy screenshot Worker waits for the first pass (November 2026)#
The library's upload put 384 assets on the site at once, and their pictures showed two things. A page waiting for a picture showed an empty tile, then "Picture on its way" in words, then "No picture": nothing said that something was happening. And 22 of the samples, most of them impulses, were failed with "nothing was drawn", though each draws when it is asked for alone (locally, and on the site one at a time, where a draw takes two to three and a half seconds against a little over half a second locally).
The page turns a spinner now wherever a picture has not loaded (components/Picture.tsx): over the image while it is asked for, and in the tile that stands in for it between the times it is asked for again. The tile says "No picture" only once it is asked for no more, or the file could not be drawn.
The screenshot Worker took its picture once the view had sent nothing for half a second, and counted that from the mount: a view that had not sent its first pass in that half second was given up as drawing nothing. It counts the rest only once something is drawn, up to the twelve seconds a draw may take, and a draw that fails says its passes, its nodes and how long it took. The synth's upload asks for the library's failed pictures again after it has sent the library, one at a time.
Seen in Chromium against the site run locally: the spinner in the middle of the tile on the assets page and an asset's page, gone once the image loads, and the tile saying "No picture" after the three retries of an address that keeps answering 503. The screenshot Worker's checks in workerd pass. Run against the local site with two pictures set failed: the upload asked for both again and said they were not drawn in time (a local copy has no screenshot Worker bound), and ended well. Not seen: the cause on the deployed Worker itself (there is no reading its logs from here), so that the 22 draw now is the next deploy's to show.
The screenshot Worker takes a picture when it is done, not half a second later (November 2026)#
Every picture the screenshot Worker drew waited half a second with nothing sent before it was taken. Timed in the Worker, an asset's view sends its three passes within 25 to 50 ms and nothing after, so nearly all of a thumbnail's 580 ms was that wait; the whole synth sends its eleven within 320 ms (Sylenth1) to 620 ms (Serum 2), all before the Worker's first look.
The Worker's prelude now counts what the app has asked the event loop for and that has not run: its timers (those due within two seconds) and its immediates, which is how React schedules its work there (setImmediate is given where the runtime has none, so the scheduler never takes a MessageChannel, which is not counted). A view is done when it has drawn something, has sent nothing since it was last looked at, five milliseconds before, and nothing is outstanding. An asset's view, which draws from its numbers alone, waits for no more than that. The whole synth still rests its half second, since it may wait on what is not counted, a promise an answer settles; and the half second without a pass is still enough by itself, so a timer that sets itself again holds no picture up.
One thing the count showed: unmounting leaves React's scheduler a turn to run, and a request that has answered runs nothing more, so it never ran. It is run before the request answers now.
Drawn before and after, locally: 27 of the library's assets (wavetables, noises, impulses) and both programs are the same bytes. A noise's picture takes about 70 ms where it took 580, an impulse's the same, and a wavetable's stack about 640 ms, which is its shader. The Worker's checks pass, with one that a sample drawn again takes well under the old wait. Not seen: the deployed Worker.
The arp's roll draws the keys held, not a chord of its own (November 2026)#
The ARP plate's roll always drew what the arp makes of four held notes, a seventh chord, whatever was played. With the arp switched on and one key down, the roll showed a climb of four notes and the synth played one note again and again, which is what an arp does with one key: the picture was of something else.
The roll draws the keys held on the app's keyboard now (playing.ts keeps them, in the order they went down, as the engine is told them): one key is a level line of that note, moved only by the arp's octaves and its range; a chord is its run over its lowest key, and the order "as played" is the order the keys went down in. With LATCH on it draws the notes the latch keeps, which start over when a key goes down with none down. With no key held it still draws the chord of four, and says so in its corner: "NO KEYS HELD · SHOWN FOR A CHORD OF FOUR".
Held by tests: one key is one pitch each step under every order, three octaves of it climb, a chord struck out of order is drawn low to high and as played in its own order; the keys as the screens see them through strikes, releases, a latch and a finger slid from one key to the next. Seen in Chromium by touch: the example with its caption, one key's level line, three keys' run, and the example again once they are let go. Not changed: a host's notes, which the app does not see, so a plugin played from its host shows the example.
A screen takes what it draws, and the panel places every control (November 2026)#
The panel's screens had grown inputs that were not about their drawing. An oscillator's wavetable took its start phase and its random phase and drew them as two dragged values in its row (the program does not even read either: they are kept for a preset); it and a sampler could take the oscillator's kind and draw its menu; a sampler took its root note and its slicing threshold and drew both in its row; an impulse drew a strip of its three shaping settings under itself; the output's display drew the master knob. So where a control stood was the screen's choice, not the panel file's.
A screen's fields are now the data it shows and the parameters that change its picture (packages/dsp/rust/src/panel.rs, KINDS). Gone: a wavetable's phase, rand, type, format and names; a sampler's type, format, names and root; a shape's label; the output's master and its chain. A sampler keeps threshold, which changes the slices it draws: it slices its sample again when the value changes, whoever changes it, and only for the sample it already had, so a preset opened keeps its own slices. An impulse keeps its three shaping parameters for the same reason and draws no controls for them.
Both panels place what the screens gave up (src/program/*/panel.ui). Serum 2's oscillator plates have a fourth strip, PHASE and RAND; a sample, a grain cloud and a spectral oscillator have ROOT beside CRS (one control across the three kinds, as CRS is across all five); a sliced sample's THRESH stands beside its SLICE menu, its SLICE ROOT and TO END in the strip under; the convolution's ATTACK, DECAY and ϕ MIN are in its plate's title strip with its sync; in both panels the OUTPUT plate's row is three items, [output(), effects("fx"), knob(master, "MASTER")]: the scope, which takes nothing; the effect chain's chips, a new item (effects, the chain's name its argument) that stands as one group and shows a tapped effect's plate on whichever page that plate is on; and the master's knob. A screen with company in its row stands beside it on a wide page and runs across the plate over it on a phone, which is what the output's display did by itself before, and it is told the room its company leaves it, so the scope still draws whole on its first pass.
Two things follow that are not layout. The master is now a knob of a plate as any other, so the macro editor suggests it as a destination after the page's first knobs. And a file written with the removed fields does not compile: the compiler says which fields the display takes.
Held by tests: the screens' fields in both recorded panels; PHASE and RAND in the oscillator's last strip, read in degrees and as a percentage; ROOT one control across three kinds; the OUTPUT row; a sampler mounted on the panel slicing again when its threshold is set, and not while its slicing is off. Seen in Chromium at a desk's and a phone's size: MAIN, each oscillator kind, a sliced sample with its threshold dragged, the convolution's plate open, the phone's OUTPUT plate, the scope across it and the chips and the master under.
Left as they are, for the owner to say: the row over a wavetable, a sampler, a noise and an impulse that names and picks its data (and a wavetable's pencil), which takes no parameter, and the sub's shape buttons under its screen (the owner: keep both). Still open: the FX rack's screens, which the app draws by the effect's name and the panel's file does not place.
Screens are display's, and an effect's screen is one its plate places (November 2026)#
Two things the last pass left. An effect's screen in the FX rack was not in the panel's file at all: the app took the effect's name from its plate (effect: "fx.chorus"), drew one of twelve drawings by that name, and fed it the plate's knobs by their position (the first is MIX, the second DRIVE) and a few parameters by Codon's names (<effect>.delay1, split.kind). And a screen's name was the program's too: a panel imported filter from ui and filter from the program.
Read against the plates, the positions had drifted. Serum 2's hyper drew its DIM as its mix and its RATE as its dimension (the plate's knobs are DIM, RATE, DETUNE, SIZE, MIX); its compressor and Sylenth1's drew ATTACK as the make-up gain; its effect's filter drew FREQ as its mix; Sylenth1's EQ drew its bass frequency as its treble gain. The second convolution of a rack showed, and set, the first one's impulse.
Now every screen is in a module of its own, display, imported whole and read through it: display.wavetable(…), display.filter(…), display.output(). ui is the plates and the controls. A screen named in ui's braces is refused with where it is. And each effect drawing is a screen a plate places, given what it draws from by name: display.chorus(mix: e.mix, rate: e.rate, depth: e.depth, feedback: e.feedback, delays: [e.delay1, e.delay2]), and hyper, distortion, flanger, phaser, delay, compressor, reverb, eq, lowpass (an effect's filter), bands (a splitter's) and utility beside it (packages/dsp/rust/src/panel.rs, KINDS and DISPLAYS). A convolution's plate places display.impulse with the sample its instance plays, which the program now exports. The bode shifter had no drawing of its own (a plain sine stood in) and places none.
An effect's plate writes its screen as its first row. On the FX page the rack stands that screen beside the plate's knobs and draws it small where the effect is collapsed (rackScreen, SynthView.tsx); it no longer chooses a drawing. The drawings themselves are the app's twelve, as they were (EffectGlyph): a panel places and feeds them, it does not define one.
The language service knows display: a module a panel may import, its screens after display. with what each takes, their hovers and their calls' signatures.
Held by tests: the compiler's (a screen from ui refused, display with no control); both recorded panels; every rack plate's first row its screen and the rest one row of knobs, the bode's none; the chorus, hyper, compressor and an EQ's screens' inputs by name, and each convolution its own impulse; the service's completions, hover and signature on Sylenth1's panel. Seen in Chromium: MAIN unchanged, the FX rack as it was but for the hyper's and the effect filter's small screens, which now draw from the right parameters, and the bode's strip without one.
The rack is a page's to ask for (November 2026)#
Any plate with an effect: was taken out of its page's layout and stood in the rack, whatever page it was on: a program could put an effect on another page, but not as anything but a rack.
A page says it now: page("FX", plates, layout: .rack) (packages/dsp/rust/src/panel.rs; pageRacks, model.ts). On a page that asks, the effects' plates are the rack as before. On one that does not, an effect's plate is a plate as any other, in its zone or in the flow of plates, its screen in its first row (the one its plate places, display.chorus …) and its knobs under it. Both bundled panels' FX pages ask. A panel with no pages of its own, one a program's metadata implies, racks what effects it has, as it did.
The output's chips already show a tapped effect's plate on whichever page it is on, so an effect placed elsewhere is reached from them.
Held by tests: the compiler keeps a page's layout in the tree and refuses one that is not .rack; of Serum 2's pages only FX racks; the FX page's plates laid out without the rack are all ordinary plates and none a rack's. Seen in Chromium with the FX page's layout: .rack taken away for the look: the effects three across as plates, each its screen over its knobs, its switches and menus in its title strip.
The plugin workflow compiles the engine once (November 2026)#
The plugin workflow took about 21 minutes, and most of it was compiling. Read from one run's log (the Linux job, 15 m 53 s): the plugin crate's build script compiled the engine as Embedded Swift twice, about 2 m 40 s each time, once for the plugin and once more for the tests' build, which has a feature of its own (test-keys) and so an OUT_DIR of its own; the DSP compiler's tests and the sign-in crate's each compiled their crates from nothing, a minute each, for a second or two of tests, their target directories not being in the job's cache; and all three platform jobs waited for the Windows engine's job (4 m 50 s), which only Windows uses. Timed here, the engine's compile alone is 187 s.
- The engine is kept by what it is made from (
Native/Plugins/clap/build.rs,kept): under<target>/codon-engine/, by a hash of the core's sources, the script or manifest that builds it, the compiler's version and the flags. The tests' build links the one the plugin's build made, and since the job's cache holds the target directory, a later run whose engine has not changed compiles none. A checkout's new file times no longer matter: the script runs again, finds its engine and goes on. - The Windows engine's job keeps its library the same way, in the workflow's cache by the same inputs, and on a hit installs no Swift and compiles nothing.
- The job's cache holds the other two crates' target directories (the sign-in's and the DSP compiler's).
- Linux and macOS wait for the plan alone. Windows' entries are a job of their own (
clap-windows), with the same steps (one list, written once and named twice), which waits for the engine.
Timed here on four cores: the plugin's build 232 s (the engine compiled and kept), the tests' build after it 79 s where it would have compiled the engine again, the build after that 8 s; a Swift source touched and not changed, 28 s. The plugin's unit and host tests pass on the engine that was kept.
On GitHub's runners, with the caches filled: 18 m 36 s where it was 20 m 50 s. Linux 9 m 05 s (was 15 m 53 s), macOS 3 m 37 s (was 8 m 30 s), the Windows engine's job 8 s (was 4 m 50 s). Windows is what the whole now waits for, 15 m 04 s, and it is no shorter: 5 m 32 s of it compiles the plugin crate and its test programs for the tests' feature, with the crates it depends on already there.
A rack, an output's scope and a routing diagram are told what they read (November 2026)#
Three screens still read the program by guessing, after the pass that gave each screen its inputs: the output's scope looked for the page named main, for the wavetables on it, and for the knob titled LEVEL beside each; the rack found an effect's mix by the knob labelled MIX, an effect's chip from a table of effects' names, a chain's tab from its name's prefix (bus1.fx was BUS 1), and a splitter's bands' titles from a table of Serum 2's kinds; and the routing diagram, the largest of them, was Serum 2's mix written out in the app: five sources by name, filter1, filter2, bus1, bus2, and each parameter's name spelled there (oscA.toFilter, noise.out).
Each is told now, in the panel's file (packages/dsp/rust/src/panel.rs, Native/Examples/Codon/src/panel/):
- The output's scope sums the parts it is given:
display.output(sources: [display.part(oscA, position: osc[0].position, level: osc[0].level, on: osc[0].on), …, display.part(shape: sub.shape, …)]). A part is a wavetable at its position or a sub's shape, at its level, while it is on. - A rack reads an effect from its plate and its tabs from its page: a plate's
mix:(ormeter:, a compressor's gain), itscode:for the chips, a splitter'ssplit:andbands:by the kind's cases; a page'sracks: [rack("fx", "MAIN", input: "VOICES"), …]. - A routing diagram is its boxes:
display.routing(sources: […], filters: […], buses: […], rack: "FX", direct: display.node("DIRECT", volume: directVolume), out: "OUT"), each box adisplay.node(title, …)with what routes it (a source'son,filtered,balance,outandsends; a filter'schained,on,outandsends; a bus'soutandvolume), and eachoutwithto: where each case of its enum leads ({ main: .rack, direct: .direct, none: .none }). The diagram's columns, its rows and its height follow from the boxes it has (signalFlow,flowSize, Routing.tsx), so a program with two oscillators, one filter and no buses draws its own.
Writing the diagram's inputs out found it wrong. Serum 2's filters chain by two switches, each the other filter's output into its own: filter 2's is 1 → 2 (the panel's switch), filter 1's 2 → 1. The diagram read them the other way about, so with 1 → 2 on it drew filter 2 into filter 1 and left filter 2 unlit. And the program chains only while filter 2 plays (filter2Used), which the diagram did not know: filter 2's box names its switch now, and no chain is drawn while it is off.
Held by tests: the compiler writes each of these into the tree and refuses what does not fit (a part that is both a wavetable and a shape, bands for a case the kind has not, an out whose to leaves a case out, a box with a field its kind does not take); Serum 2's diagram is the boxes its panel gives it, every parameter one of the program's; its boxes stand where they stood (the page is the same picture, pixel for pixel, at a desk's size and a phone's); the chain is drawn as the program plays it; and a diagram of another program's boxes (two sources, one filter) is laid out and routed from them alone.
A program says what holds a voice, what MIDI drives, and what a sampler fills (November 2026)#
A survey of the audio side, after the screens were given their inputs, found the same kind of guess in three places, each a way a program other than the bundled two would be played wrong with no error.
- A voice lasted as long as every envelope in it. The machine waits for a released voice's
adsrs, all of them (Machine.swift), so a filter or modulation envelope with a long release held a silent voice, and its lane, long after the level had gone.adsr(…, holds: false)is an envelope the voice does not wait for: the compiler lists them by instance (free,builder.rs), the machine leaves them out of what it waits for and frees a unison's copies' with the body's. Serum 2's first envelope holds its voice (it is the voice's level) and its other three and its sample zones' own do not; Sylenth1's two amp envelopes hold and its modulation envelopes do not. - The wheels were found by name. The plugin looked for parameters called
modwheelandpitchwheel, and the app's deck set them by those names; a program that called them anything else had a dead mod wheel in both and, for the bend, the machine's two semitones in the plugin and nothing in the app. Sylenth1'saftertouchparameter was driven by no host at all. A parameter says what MIDI sets it now:@midi(.bend),@midi(.pressure),@midi(cc: 1)(lower.rs; the parameter'smidiin the metadata). The plugin's slot table carries it (snapshot.rs,Table::midi_slot) and its MIDI handling reads it for the bend, the channel's pressure and every controller; the deck's wheels read it too (midiParameter,midiValue), and where a program gives the bend to no parameter both fall back to the machine's bend. - The sampler's helpers were Serum 2's.
library/zones.tsandlibrary/slices.tsimported the zone map's layout, the count of zones and the count of slices from Serum 2's generated program, and the sampler screen named a multisample's other zones by rewriting its first's name (oscA.zone1tooscA.zone2) and its loops parameter by rewriting its map's (oscA.zonestooscA.zoneLoops). The layout is the sampler's own now (ZONE_FIELDS,ZONE_LOOPS), the counts are arguments (the screen's from what its item names, the Serum importer's from its program), and the panel names the rest:display.sampler(o.zone[0], zones: o.zones, zoneSamples: o.zone, zoneLoops: o.zoneLoops).
Held by tests: a voice with a freed long envelope ends with its level's, one without it does not, and a unison's copies follow (packages/dsp/test/machine.test.ts); the compiler writes midi and refuses an input it does not know, a bool, preset state and a second parameter for one input (language.test.ts); the plugin sets the declared parameters from CC 1 and the pitch bend and moves nothing for a controller the program gives to none (tests/host.rs); the helpers import nothing from a program, Serum 2's ZoneField and ZoneLoop are the sampler's layout, and Serum 2's panel names each oscillator's eight zone samples (sampled.test.ts). The Init preset renders the same samples as before.
The app asks the program, not its name (November 2026)#
After a program said what holds a voice and what MIDI drives, the app itself still compared a program's id and read parameters and sources by their names, so a program other than the bundled two (or one of them renamed) was shown wrong with no error. Each is said now, by the program, its panel or the list of bundled programs.
- The bundled programs are a list (
src/program/programs.json): each one's folder, title and listing on the site, and the one a new synth starts on (startsOn). The build's scripts read it (program-sources.mjswritesBUNDLED_PROGRAMSandSTARTS_ONfrom it;program-resources.mjsmakes each one's file and writescurrent.json's default from it), and so does the site's upload (SITE_LISTINGS). What is a bundled program's own is its entry inBUNDLED(src/program/bundled.ts): a new sound on it (Codon's Init patch on Serum 2's, the defaults on Sylenth1's) and the factory sounds made on it, which the upload sends on its file. The app asks the entry where it compared'sylenth1'and'serum2'(the sound it starts on, a new sound, the browser's New sound). Each program'sparameterSources.jsonis in its own folder now. - The bend range is the tray's:
tray(pitch: […])is the items the PITCH group stands over the keyboard's octave (packages/dsp/rust/src/panel.rs;PanelTray.pitch). The deck readbend.upandbend.downby name, so Sylenth1, whose range is one parameter (bend.range), had no cell for it; its tray givesvalue(bendRange, "PB ±", format: .int)now, Serum 2's its two. The tray's labels are never cut short (wholeLabels), as the deck's own cells' were not. - An envelope's screen says its source:
display.envelope(…, source: .env1). The app took the source from the attack's name (env1.attack'senv1) and read the engine's level only for sources namedenv1,env2…, so none of Sylenth1's four (ampEnvA,ampEnvB,modEnv1,modEnv2, whose parameters areampA.attack…) followed the voice: its playheads went by the knobs alone. What the engine is asked for is what the panel's screens draw (drawnLive: each envelope's source, each oscillator's position, each filter's cutoff and resonance), where it was a pattern on names (.position,.cutoff,.resonance). - Whether a voice plays is the machine's count: a filter's screen hid its played response while the level of the source named
env1was nothing. It reads how many voices sound now (the machine's register for it,REGISTER_SOUNDING, which a probe reads as 0 once none does): a voice lasts as long as the envelopes that hold it, whatever they are called. - A macro's source is the one that is its parameter: the compiler lists the matrix's sources that are a parameter as it stands (
source macro1 = raw(macro[0]): the matrix'sparameters,lower.rs). The macros' editor found a macro's routes by the source namedmacro1and its own knob by a labelMACRO 1, and left parameters namedmacro1… out of what a macro can move; it reads the metadata now (macroSource), and a macro that is no source of the matrix has no handle to drag (a route from it could not play). The matrix's preview marks where a source that is a parameter is turned by the same list. - The tempo's cell takes what the machine does, 1 … 999 beats a minute (
TEMPO_MIN,TEMPO_MAX), not 60 … 200.
Held by tests: both panels' trays give their bend range by the program's own parameters, and their envelopes the sources the program keeps (Sylenth1's none of them env-named); the probes are the panel's (playing.test.ts); a macro's source and destinations from the metadata, one by its old name not taken (panel.test.ts); the compiler lists the source that is a parameter (language.test.ts); the upload lists each program by programs.json and sends the factory sounds on theirs. Seen in Chromium: Serum 2's deck reads as it did, Sylenth1's with its bend range under PITCH, and a build that starts on Sylenth1 by its list alone.
A chain says how it is routed (November 2026)#
The compiler named a chain's routing parameters <chain>.in.<effect> and <chain>.out and listed a chain's effects by name, and the app built the parameters' names again and read the rest of the chain's shape off its effects' names: a family's later member was a name ending in a number whose stem was another effect (eq2 of eq), the ADD menu's next of a family the same name with the number one more, a splitter's bands the effects named band, band2 …, and Serum 2's importer and its rack routing wrote fx.in.… and defaulted to the chain fx. A program whose effects were called otherwise (a tone2 of no family, bands called low and high) had a rack that hid effects, offered the wrong ones and could not split.
- A join names its bands:
effect join(on: split.on, bands: band) { low, mid, high in … }, a family by its name or a list of the chain's effects (bands: [low, high]), as many as the join's inputs, each of one input (lower.rs,chain). Serum 2's join saysbands: band. - The metadata says the chain (program.ts
ProgramChain): itsout, and each effect'sinput(or a join'sinputs, one for each), a family's member'sfamilyandindex(the first written apart is the family's index 0), and a join'sbands. - The app reads it (
src/panel/rack.ts):orderOfandroutingOftake the chain and set the parameters it names,splitOfis the join that names bands,isLaterandearlierOfare a member's index, andmemberOffinds a family's member for Serum 2's importer; Serum's rack routing reads the same (rackRouting(items, chain), its chain always named). No name pattern is left in the rack, its chips or the importers.
Held by tests: the compiler writes each effect's parameters, families and a join's bands, refuses bands that are not the chain's, are too few or are a join's (language.test.ts); Codon's three chains as the program declares them (program.test.ts); a chain and a split read and written by the metadata alone with bands called lo and hi and a join called sum, an effect named like a later member that is none (panel.test.ts). Seen in Chromium: the FX page and its ADD menu the same picture as before, pixel for pixel.
What changes for what is saved: nothing a preset keeps. The routing parameters keep their names and their values' meaning. The metadata's shape changed, and a program's file (.dspk) carries its metadata: one written before this (a user's own program saved to the library) has chains the rack no longer reads, and is written again by saving its program again; the bundled programs' files are the build's and are new.
A parameter says how it glides; a host reads the matrix's names (November 2026)#
The machine glided every parameter to a value set over the same 20 ms (Machine.swift, one step for all), an enum's and a whole number's too: an oscillator's wave switched from its first case to its sixth played the four between, a block or two each, and an octave knob slid its pitch. And the matrix's own parameters were named by every host that set them (route${i}.amount in packages/dsp's routeValues and routeShapes, in Serum's importer, in the app's tests for what is no knob), so the compiler's naming was a contract no metadata stated.
@smooth(seconds)on a parameter (0 … 10,lower.rs) is how long the machine glides it to a value set;@smooth(0)jumps. Saying nothing, a number and a switch glide over the machine's own 20 ms (SMOOTH_DEFAULT) and a whole number and a case jump, as do a chain's choices of input and the matrix's choices of source. The program carries it (the parameter'ssmooth, where it is not the machine's own; program.tsProgramParameter), and the machine steps each parameter by its own (parameterSmooth): the machine's own step is worked out once a block, as before, and another's only for a parameter moving.- The matrix names its slots' parameters: the metadata's
slotNamesgives each slot's amount, source, aux and output (its rise, fall, delay and curves where it has them) by name.routeValuesandrouteShapesset them by those names, the app leaves them off its knobs by them (slotNamesOf, where it matched/^route\d+\./), and Serum's importer reads a route's amount by its slot's.
Not done, and why: the machine's other fixed choices stay the machine's. Controllers 64, 120 and 123 are MIDI's own meanings (the pedal, all sound off, all notes off), and the plugin's controller 74 is MPE's slide, which a voice reads as slide; a program that wants either as a knob says @midi(cc: …) and gets both. The machine's own bend (±2 semitones) is only for a program that gives the bend to no parameter, and one that wants another range declares its bend (@midi(.bend)) and bends by what it likes. The arp's orders, modes and step count, the 50 filter types, 16 lanes and 16 unison voices are the engine's capacities and its built-in library's, not a program's numbers: a program already chooses among them, and a larger capacity is a change to the engine's tables, measured, not a declaration.
Measured: the Swift package's two release timings (swift test -c release), the big patch 0.427 … 0.484 ms a 256-frame block over four runs after (0.439 before) and 16 voices 0.110 … 0.123 ms (0.113 before), within one run's spread of another; and Codon's Serum 2 program with eight notes and 64 parameters set every block (the wasm engine) 3.69 and 3.70 ms a block after, 3.66 and 3.71 before. Nothing renders otherwise: the parity cases, the snapshot fixtures and Codon's Init give the same samples; their programs have smooth and slotNames where they had none.
Held by tests: a parameter glides by its own time, a whole number and a case jump unless they say otherwise, and @smooth takes 0 … 10 seconds (machine.test.ts); the metadata names each slot's parameters, its rise, fall, delay and curves where the matrix has them (language.test.ts).
A sample says how much of it plays (November 2026)#
The app's screens made data a program plays, and three of the numbers they made it by were the app's: a sampler took six seconds of a file at 44.1 kHz (SAMPLER_MOST, panel/widgets.tsx), its zones twelve between them, and an impulse 24 seconds at 48 kHz (IMPULSE_MOST, library/impulses.ts), what Serum 2's program plays; and an impulse's decay was "off" at 40 seconds (DECAY_LONGEST, library/shaping.ts), the top of Serum 2's knob. A program whose convolve played two seconds was given 24, and one whose decay knob stopped at 10 was never left unshaped.
- A sample says the longest of it that plays:
@longest(6)on asample(lower.rs), and aconvolvesays it of its impulse by its ownlongest(builder.rs,convolved), the shorter where both say. The metadata lists them (longest, program.tsProgramMeta). Serum 2's oscillators' samples say six seconds and their zones12 / ZONESeach; its impulses are 24 seconds by its convolve. - The screens cut to it (
longestFrames): a sampler's file and an impulse's at the file's own rate, a multisample's zones to the room their samples make together at the rates the program declares them at. Serum's importer takes its oscillators' and impulses' most from the same metadata. - A decay is off at its knob's top, whatever its parameter's top is (
decayAt, library/shaping.ts): the shaping knows no 40 seconds, and Serum 2's reader clamps its decay to its program's parameter's range.
Decided against, and why. The shaping (minimum phase, the attack's half cosine, the decay to −60 dB and its cut at −120 dB) and the slicing (onsets in 5 ms windows at least 30 ms apart) stay the app's: they make data, as a wavetable's editor does, from parameters the program declares and the panel names (display.impulse(attack:, decay:, minPhase:), display.sampler(threshold:, count:)), and a program wanting another curve declares another parameter, not another algorithm. Moving them into the language as facilities run while a program plays would let a host's automation of a decay reshape the impulse in the plugin (which has no JavaScript, and plays the shaped impulse a preset carries until its editor shapes it again); that is the real gap they leave, and it is an engine feature (a convolution that shapes its impulse), larger than this pass. The plugin's Rust copies of the library's recipes (impulses.rs, noises.rs) make the app's library, not a program's data, and are held to the app's by the library's hashes.
Held by tests: the compiler lists a sample's @longest, a convolve's longest of its impulse (the shortest of several, and the shorter of the two where both say) and refuses @longest on anything but a sample (machine.test.ts); the screens' cut (panel.test.ts); no decay at the knob's top whatever the top (convolve.test.ts). Seen in Chromium: MAIN and FX the same pictures as before, pixel for pixel. Nothing a preset keeps changes.
A slot is the host's; an index is what an importer reads (November 2026)#
@slot(n) was two things. It was the plugin's host parameter id, and the importers also read it as the parameter's number in the instrument the program models: Serum's reader took a slot below 299 to be a Serum 1 VST index (serum/knobs.ts, serum2/reading.ts, serum/preset.ts, serum/program.ts's route destinations), and Sylenth1's a slot below its 244 parameters to be Sylenth1's index (sylenth/program.ts). So both programs pinned every knob to the foreign plugin's numbering, and their host slots could be nothing else.
@index(n)is the parameter's index in the presets of the instrument the program models (lower.rs; the metadata'sindex): a whole number from 0, one parameter's each,@index(from: n)on a section numbering its items as@slot(from: n)does and counted apart from it. Preset state takes an index of its own (Serum's menus are state and have one), not a section's, and not where@state(c)holds (the copy no foreign preset numbers). Every importer readsindex(INDEX_OF,NAME_OF_INDEX,indexName,SERUM_KNOBS,AT_INDEX).- Both programs' foreign numbers are
@indexnow, every@slotin their text (Serum 2's 294 and Sylenth1's 146: the same numbers, each the same parameter's, checked by compiling the text before and after). Their host slots are the plugin's (slotMap): the route amounts the programs pin (amountSlots, from 310 and 300), every other control the lowest free slot in the order declared, sticky by name from the program loaded before and from a project's saved map. The macros' knobs take no slot of their own (the host's Macro 1 … 8 reach them). - The plugin compacts a drawn shape by its numbers, not its name (
assets.rs,drawings): a shape the editor state's drawings (an LFO's points, a remap's, a shaper's) or a drawn shape's start renders exactly is carried as that drawing (where that is the smaller: a two-point line stays its numbers), whichever list it is in, where it was matched by name (lfoNtolfos[N − 1],remapAtoremaps[0]…).
Kept, and why: the macros' slots (500 … 507). They are the host's contract with every program (Macro 1 is one id whatever loads, so its automation survives a program switched), not a program's numbering; the importers no longer have anything to do with them. Serum 2's sends are no longer packed under them (their numbers are indices now, which have no pool).
What breaks: a host project's automation of Codon saved before this is on the old slots (the cutoff was 45, now another): its parameters' values come back by name from the snapshot, its automation lanes point at other parameters. Presets and the factory sounds are by name and load as before; the Init fixture renders the same samples.
Held by tests: @index numbered on its own, a section's and a member's, state's own and not @state(c)'s, and refused twice (language.test.ts); Codon's slots pin only the route amounts, give every other control one in order, none to a macro's knob, and are sticky by name (snapshot.test.ts); the importers' tests read indices; the plugin declares the program's slots and saves, restores and renders by them (tests/host.rs).
The editor's JavaScript engine is quickerjs (November 2026)#
The CLI, the desktop window and so the CLAP plugin's editor ran Codon's bundle in QuickJS-NG through rquickjs. They run it in quickerjs v0.2.0 now (github.com/noya-app/quickerjs, from its tag): QuickJS 2026 ported to Rust, with a tail-call interpreter, a baseline JIT and an optimizing tier, and a tracing collector, embedded through quickerjs::embed, which has rquickjs's shape without the 'js lifetimes.
- The port (
packages/raster/cli:host.rs,engine.rs,main.rs;packages/raster/window/src/engine.rs): the same bridge, function for function. Native functions areFunction::new(ctx, f)in place ofFunc::from(f); a typed array's bytes are read withoutunsafe;hostRequestBytescalls its receiver with a vector of values in place of rquickjs'sArgs; an exception is described by the samedescribewhere rquickjs hadCatchResultExt. It was written against 0.1.0 and builds unchanged against 0.2.0. - The allocator: the CLI's and the window's binaries register the engine's small block allocator (
quickerjs::alloc::SmallAlloc) as theirs. The plugin keeps the system's, as quickerjs recommends for a library a host unloads: the engine releases what it reserved at an unload only when its allocator is not the program's (docs/notes/plugins.md, "The engine is quickerjs"). - The toolchain: the three crates that embed the engine pin
nightly-2026-11-04in arust-toolchain.toml(the engine's tail-call interpreter and JIT need it); the workflows that build them (ci.ymlraster,raster-window.yml,plugin.yml,plugin-windows-debug.yml) runrustup toolchain installfirst, and their caches key on the file. The engine's repository is private, so those jobs read it with a read-only deploy key (theQUICKERJS_DEPLOY_KEYsecret,.github/actions/quickerjs-access). The renderer's crate, its WebAssembly build and the DSP compiler stay on stable. - The plugin's tests find the library by the profile folder's lock file (
tests/common/mod.rs): the nightly's cargo puts a test binary undertarget/<profile>/build/<crate>/<hash>/out, nottarget/<profile>/deps, so its parent's parent was no longer the profile folder. The plugin'sbuild.rsfound the profile folder three up from itsOUT_DIRthe same way, and wrotecodon-link.cmake(which the packaging, the VST3's CMake and CI read) intotarget/<profile>/build; it takes the nearest folder with the lock file too.
Measured with node packages/raster/bench/knob.mjs --runs 3 (Codon at 1194 × 834 points, 2×, the OSC A level knob dragged ten steps; each binary twice, alternating, x86-64): a ten-step drag 57 to 61 ms under rquickjs, 27 to 29 under quickerjs 0.1.0 with the system's allocator (16 to 17 with its own), 11 to 12 under 0.2.0 with the system's (10 to 12 with its own); a knob commit about 310 ms, 175 to 182, and 69 to 82; start-up 7.6 to 7.9 s, 5.3 to 5.4, and 2.6 to 2.8. With 0.2.0 the allocator no longer matters, so the plugin, on the system's, gets the CLI's speed. With the JIT off a drag is 13 ms and a commit 180; the optimizing tier changes little here (11 and 75 without it). A drag's worst time is 66 to 83 ms with the JIT against 16 without (the first drags pay for its compiles). The CLI is 20.3 MB stripped against 17.5.
Held by tests: the CLI's (14) and the window's unit tests, the renderer's 128 with the new binary (shot.test.ts draws what the Node session draws, pixel for pixel), the plugin's 58 unit tests and its host tests (the editor opens in a host's window and draws Codon's screen, 1194 × 834), and the window opened on Codon under Xvfb; Codon's start, a knob drag and the FX page taken by both engines are byte for byte the same PNGs.
The plugin's editor carries the icons Codon names (November 2026)#
The session script the plugin's editor runs was the CLI's (packages/raster/dist/session.js): 10 MB, 9.6 MB of it every SF Symbol icon of the set as one object literal, which QuickJS builds at every start (about 100 ms) whatever the app draws. The web pages already carry only the icons their sources name (openSymbols, Web/plugins/symbols.ts); the session now can too.
packages/raster/scripts/session.mjswrites the session: every icon by default (dist/session.js, whichbundle.mjsstill writes byte for byte as before, for the CLI and the window, which run any app), or with--content <dir>and--framework <dir>the icons an app's sources name, by the same scan as the pages (openSymbolsEsbuild), the renderer's own always kept.- Codon's
npm run buildwritesdist-plugin/session.js(npm run plugin-session: its sources, and the React and Native hosts' symbol arguments): 115 icons, 761 KB. The plugin'sbuild.rsbundles it in place of the CLI's, and the plugin workflow builds and uploads it.
Codon draws icons in its program editor (the file tree, its menus) and the header, so the plugin needs some. Codon's main page, the program editor and the save menu drawn with each session are the same PNGs byte for byte; the CLI starts Codon in 2.12 s with the plugin's session against 2.39 s with the CLI's, and the plugin's library (Linux, release) is 16.4 MB against 18.4 (its pack is compressed). The editor opens in a host's window and draws its first frame as before. A name the sources do not spell out (put together at run time) is drawn as its placeholder; --safelist keeps one.
CI: the long jobs split, the Windows core's tests found again (November 2026)#
The CI workflow took about 29 minutes and the Plugin workflow about 28, each held up by one or two jobs that ran independent work in turn (main's runs 44131996364 and 44188746167).
- The Windows DSP job built the core twice and tested nothing (native.yml
dsp-windows, 28.6 of its 30 minutes).swift build -c releasecompiled the core module (12.6 minutes on the runner's two cores), thenswift test -c releasecompiled it again with testing on (13.6) and reported "Test run with 0 tests": the 52 Swift Testing tests were not found, since at least 12 November (the job passed all 30 of its tests in release on 2 November, before they were Swift Testing's). Linking with/OPT:NOREFfound none either, so it is not the release link dropping their records. The job runsswift testalone in debug, as the Linux job does, and fails when no test runs; the plugin's Windows jobs compile the engine in release. - The Linux web job is three (ci.yml
web,web-unit,web-e2e): the type-check, the unit tests and the mock-mode e2e ran in turn for 16.6 minutes; side by side each takes its own few minutes and about one of setup. Codon's unit tests (6 of the 16 minutes) run only in the Codon site workflow, which runs them with the React Compiler on whenever Codon or what it is built from changes;packages/native/**joins its paths. - Each plugin platform is two jobs (plugin.yml):
packagebuilds the plugin as it ships, tests the DSP compiler and packages and validates the CLAP and the VST3;testbuilds it with the tests' key and runs its tests. One job did both in turn, building the plugin twice (Windows: 24.7 minutes after the plan's 3); the second build, without the tests' key, is gone. The test leg's artifact iscodon-plugin-<platform>-tests.
The job names changed (CLAP and VST3 (<platform>, package|test), Type-check every workspace (Linux), Unit tests (Linux), Mock-mode e2e (Linux)): a branch rule that requires a check by its old name needs the new ones.
Start-up relayouts: a change invalidates what it can change (November 2026)#
Codon's start in the CLI took 2.4 to 2.6 s over 12 commits, and three of them laid out most of the tree again for a change that moved little. Traced: commit 2 set two scroll views' scrollOffset and nothing else, and placed 3,936 nodes again (139 ms); commits 5 and 9 changed the frame height of eight styled panels, and placed 4,043 and 4,380 (260 and 210 ms). The session invalidated every update up and down, so a panel's new height threw away every plan inside it, though a child's context depends only on the style keys it inherits.
LayoutPass.invalidateProps(node, before)(Web/src/layout/engine.ts) invalidates by what changed: nothing when the props are what they were, nothing for a scroll view'sscrollOffsetalone (the engine never reads it; the session scrolls after layout), only the node and its ancestors when astylednode's style changed in keys no child inherits (a child's context reads the font, italic, the line limit, the text alignment, the image scale, whether scrolling is off, the list row height and the safe area), and up and down otherwise. A child under a changed frame is placed again where its proposal changes, as any child is.- The tree tells its observer what the props were (
TreeObserver.updated(node, before), packages/raster/src/tree.ts), and the session callsinvalidatePropsin place ofinvalidate.
Commit 2 is 0.1 ms of layout now; commits 5 and 9 place 3,193 and 3,530 nodes (187 and 73 ms); the start is 1.9 to 2.2 s (2.1 to 2.4 s before, the same machine, alternating). What is left is not the session's to save: about 1,350 to 1,600 of each commit's nodes are subtrees kept whole but moved (a panel above them changed height), placed again because a plan is kept only at the same origin (moving such a subtree's frames and chrome whole instead, where its placement read nothing of where it is and the move is whole points, was tried: commits 5 and 9 then placed 2,336 and 1,936 nodes, but took the same time within the noise, since placing a moved subtree again reads only memoised measures, and it was taken out); and Codon itself sets its panels' heights after the first layout (379 to 370, 306 to 297) and re-renders most of its tree twice (commits 4 and 8, 8,872 and 1,292 ops). A knob commit is unchanged (27.5 ms, 508 nodes placed).
Held by tests: phase9-incremental.test.ts (a style change no child inherits keeps the subtree, a frame change gives a fresh layout's frames, a font change places the subtree again, a scroll offset and props set to what they were place nothing), the renderer's 128; Codon's start, a knob drag, the FX page, the program editor and its menu drawn with incremental layout and with --full-layout are the same PNGs byte for byte.
The web renderer invalidates its updates the same way (renderer.ts): an updated element is in the DOM pass's dirty set whatever the layout kept, so its inline style, reset by the update, is written again from the kept frame and chrome; a scroll view's scrollOffset is carried out after layout from its props (performOffsetScrolls), as before. Held by the Web unit tests (999) and the mock-mode e2e (251): scroll-geometry.spec.ts sends a scroll view scrollOffset-only updates and checks that it scrolls and keeps its box, and that a frame changed around it sizes it again.
The in-memory renderer's first render knows the window (November 2026)#
A native app sets __sbEnvironment before it evaluates the bundle, so the app's first render is for the window it has (see "The first frame knows the window" above). The CLI, the desktop window and the plugin's editor did not: the session told the app its environment only at start, after the first render, and without the window's size. Codon's panel rendered first for no width and a compact size class (a phone's page, 4,306 nodes laid out), was told it was regular, then laid itself out again for 1194 points when its scroll view reported its size, remounting every band (layoutKey holds the width), and again once its bands were measured: 12 commits, two of them all but the whole tree made anew (8,872 and 1,292 ops).
configuresets__sbEnvironment(packages/raster/src/sessionEntry.ts) fromSession.initialEnvironment: the appearance, the text size, the size class the screen's width gives and the window's size. Every host callsconfigurebefore it evaluates the app, soruncreates the root from it anduseWindowSizeanswers from the first render.startsends the same, the window's size now included, for an app that rendered before.
Codon's start in the CLI (1194 × 834 points, 2×) is 7 commits and 1.30 s, against 12 and 1.9 to 2.2 s; the first commit lays out the page for its width, and what follows is the panel's own settling (its bands measured, then given their heights). Its main page, a knob drag, the FX page, the program editor and its menu are the same PNGs byte for byte as before, and with --full-layout. The plugin's editor gets it with its session (npm run plugin-session).
Held by tests: shot.test.ts runs a small app (test/apps/FirstRender.tsx) that says what its first render was told: 1194 × 834 and regular in a 1194-point window, 393 × 852 and compact in a phone's, which fails without the change; the renderer's other tests (128).
An importer is its program's, and runs in a sandbox (November 2026)#
The importers that turn Serum's and Sylenth1's preset files into Codon presets were the app's: each named its program by the hash of the bundled file, imported that program's generated module and the app's own code, and wrote a preset's file itself. So an edit to a program orphaned its importer, and nobody but the app could write one. docs/notes/importers.md is the contract now.
- An importer is a file in its program's package (
src/program/<program>/importers/, withimporters.jsonsaying what files each reads): Sylenth1's in Sylenth1's, Serum 1's and Serum 2's in Serum 2's. It is bound to its program by being in it: a fork takes its importers with it, and nothing names a hash. The app's list is put together from the programs it has (presets/importers/packaged.ts,presets/importHost.ts). - It imports the program as a module (
../main.program, orprogram), which a host makes from the program's file. The file keeps what the program exports for this (main.dsp.exports.json: its enums and exported constants), and the module has the part of the compiled program its controls are worked out from (controlProgram,@swiftbrowser/dsp), so an importer asks the program what follows from a set of values without the whole of it. - It answers with sounds by name, not a preset's file:
{ name, values, routes, data, macros, tags, dropped }. The host makes the preset (presets/importers/build.ts), brings values into range and says what the program has no place for, which had been lost silently. - Shared pieces are libraries:
codon:audio,codon:files,codon:import(src/importlib), which re-export the app's own pure functions from where they are written. The Serum patch model (src/serum,src/serum2, about 5,700 lines) moved into Serum 2's package with its imports turned to these; the app's own uses of it (a new sound, factory sounds, old projects) go through re-exports at the old paths. - It runs in a sandbox (
presets/importers/sandbox.ts): jseption (QuickJS in TypeScript), with nothing to import but its package, the program and the libraries, no host global, its TypeScript stripped as it loads, and a deadline. - A host knows what an importer needs without running it: each library export is a leaf (the hash of its name and signature), a library's root is the hash of its leaves,
src/importlib/api.jsonis committed and held to the sources by a test, and the build records in each package's list the leaves its importers use (requires), which a host is held to before it runs one.
Held by tests: each importer's answer in the sandbox is exactly its answer run outside it, over the fixtures; a fork of Sylenth1 with two parameters' @index exchanged is read by its own importer as the fork has itself; an importer cannot import anything else or see a host global and is stopped at its deadline; the real Sylenth1 importer type-checks against the declarations made of the program's module (moduleTypes.ts). Under Node a Serum 2 preset takes about 90 ms in the sandbox, 12 ms outside it.
In a worker, and checked where it runs. The sandbox is asked for in a worker where the host has one (a page's, the Apple app's importer worker), on the app's thread where it has none (presets/importers/runner.ts). swiftbrowser-native build --worker-only <module> keeps a module out of the app's script, so the engine is the worker's bundle alone (app.js 3.94 MB to 3.28 MB). A program's importer stays loaded under its file's hash between imports; an importer's requires is stamped whenever the app makes a program's file. The site's island has importFiles, and its browser test imports through it in headless Chromium: 23 presets in the worker with the page's thread free, the same under a Content-Security-Policy (five times slower where the worker's own file may compile nothing). That run found the page builds refused the worker (Vite's workers were IIFEs; they are modules now) and that making twenty presets held the page for a second (they are made one at a time now). Under quickerjs, the plugin's engine, the sandbox answers the same and about eighteen times slower than the importer run by quickerjs itself; the plugin's editor has no file chooser and no workers, so nothing imports there, and its sandbox should be a quickerjs context of the shell's own.
Stand-ins named, the plugin's own sandbox and file chooser, the editor. A sound's data may say which piece of Codon's library it is in place of its numbers (library: { wavetable | noise | sound }), and the host makes them once a piece (presets/importers/libraryData.ts); Serum's importers do so for the factory sounds a preset only names, and the preset is the same to the byte. The plugin's shell has a sandbox of its own, a quickerjs runtime apart from the editor's on its own thread (Native/Plugins/clap/src/importer.rs, the native function importer.run): the same three imports, deadline and refusals, a memory limit, and an importer at the engine's own speed (a Serum 2 preset in 29 ms where jseption under quickerjs took 470). It also answers the file chooser (src/dialogs.rs: the common dialog on Windows, NSOpenPanel on a Mac, zenity or kdialog elsewhere), so Import… has files to hand over there. The program editor colours an importer's files by TypeScript's grammar and completes them from the text alone (program-editor/importerCompletions.ts).
Not done: the Apple app's worker has not been run on a Mac (what crosses to it is tested as text); the plugin's dialogs on Windows and a Mac are type-checked for those targets and have opened nothing, and nobody has clicked Import… in the plugin's editor in a host; the plugin's editor waits while an importer runs; a program's document is about twice the size with its importers in it (Serum 2's are 282 KB of text beside 234 KB of program); the completions read no types and underline no mistake; no page of the site calls the island's import; the island's browser test fails at its mount as it does on main (it asks the site for a preset's assets, which the test's server does not answer).
The engine in Rust (November 2026)#
packages/dsp/engine is the DSP engine's core translated to Rust, file by file, so that what is not a Swift app needs no Swift (the note, and packages/dsp/engine/PORTING.md for the rules). The page's module (packages/dsp/dist/engine.wasm) is now built from it (packages/dsp/engine/wasm/build.sh): 612 KB where the Swift core's Embedded Swift module was 682 KB, and the same samples.
- The plugin's engine too.
Native/Plugins/claplinks the crate by default (itsrust-enginefeature), so its build needs no Swift toolchain and the Plugin workflow installs none: the job that compiled the Windows engine as Embedded Swift on Linux is gone, and Windows is a platform of the one matrix again.--no-default-featuresstill builds the plugin over the Swift core (the Plugin Windows debug workflow does). On Linux its tests pass, the editor's and the sign-in's among them; macOS and Windows have their first build in that workflow. - The same bits as the Swift engine.
tests/differential.rsloads the Swift engine beside the Rust one and plays both through the C API they share: the parity programs in blocks of every size, random events at three sample rates, the snapshots, the programs both refuse. Every sample's bits agree, with the streams each runs. - Swift's
Float.piis not Rust's. Swift rounds π toward zero; Rust'sf32constant is the nearest, a unit in the last place above.math::PI_F32is Swift's. - Rust's support library has a
cbrtfof its own, which a linker takes before glibc's and which differs from it by a unit in the last place now and then. On glibc the engine asks forcbrtf32. - The interpreter is tail calls (
become, on a pinned nightly): a function an opcode, each jumping to the next instruction's. WebAssembly gets a loop instead unless built with its tail-call feature, which Safari before 18.2 lacks. - Three faults of the Swift core, found on the way and fixed in both. A looping resynthesis read one frame past its sample's end (or one before its start) where rounding left the read position a hair outside it: that position is the seam, the sample's first frame. A power taper's exponent too large for an
Intstopped the process: an exponent is now a whole number up to 2³¹ − 1 (the page's module has 32-bit words), in the JavaScript validator too. A packed program claiming billions of arrays had room asked for all of them, which stopped the process: it is cut off where its bytes end. - The Swift engine's other builds are gone. With the plugin and the page on the crate, nothing played the Swift core but a native Swift app, so what built it for anything else was removed: the plugin's build over it (build.rs's
swift buildand Embedded Swift paths withSBDSP_SWIFT_RUNTIME,scripts/embedded-core.sh,src/embedded.rs,codon-link.cmakeand what the wrapper andpackage.mjsread from it, therust-enginefeature: the crate is simply a dependency), the core's module for a page (Native/Packages/SwiftBrowserDSP/Embedded,npm run build:engine:swift), the core's#if hasFeature(Embedded)branches, and the Plugin Windows debug workflow, whose questions were the Swift runtime's on Windows. The core stays as whatSwiftBrowserDSP's node plays in a Swift app and as the referencetests/differential.rsholds the crate to. That comparison had run nowhere in CI, nor had the crate's own tests: the Native workflow'sdsp-enginejob now builds the core as a library and runs them against it on Linux, macOS and Windows, in the place of the job that tested the Swift core alone on Windows (dsp-windows), which was there for the plugin. - Then the Swift engine itself. One engine in two languages is every change made twice, and what the Swift one was still for was the Swift apps. They link the Rust one now, and SwiftBrowserDSPCore is gone with its tests (11,000 lines).
- The last comparison, on each platform. The Native workflow built the Swift core as a library on Linux, macOS and Windows and played both engines through the C API. Windows gave the same bits at its first run. macOS gave them for every parity case and for 48 of the 50 programs under random events; the two with the resynthesis were a few units in the last place apart in a frame here and there, at 44.1 kHz. On Apple's platforms Swift's build joins a
sinand acosof one angle into one call (__sincos_stret), whose results are not always the bits of the two apart, and the transforms' sine and cosine tables were made that way.math::sincosis that call there, and with it macOS gave the same bits too. (The first try, at the resynthesis's own sines and cosines alone, moved nothing: it was the tables.) - A library an app links (
packages/dsp/native): the engine's machine functions, its renderer behind C (sbdsp_renderer_*: the handoff to the audio thread that the Swift node called as Swift), a program read once for its names, and the.dspcompiler, as one static library, since two Rust static libraries in one app would each carry the standard library. The compiler's crate is a plain Rust library now (what is built of it for a page or a host says so as it is built), because a crate that names a dynamic library is linked as one wherever it is a dependency, which wants the target's linker. - The XCFramework is put together without Xcode (
Native/Packages/SwiftBrowserDSP/scripts/build-library.sh, in the place ofbuild-compiler.sh): static libraries for five targets, joined a platform and stripped by Xcode's tools or LLVM's, in folders with a property list the script writes. So Linux makes the one a release ships in@swiftbrowser/native(sync-swift.mjscopies it; the publish workflow builds it and refuses to pack without it), and an app made from npm needs no Rust. An older LLVM'slipostopped at the LLVM bitcode the standard library's objects carry beside their code; the script strips it first. - SwiftBrowserDSP holds the engine's handles in Engine.swift, which has no Apple framework in it and is built and run on Linux against the library (
packages/dsp/native/tests/hosts). The package does not build on a Mac without the library and says what to run; the apps'npm run buildruns it. The compiler comes with the engine, where it was optional. - The tests. The renderer's are Rust's, through C, and hold what the Swift ones could not: the thread that renders allocates and frees nothing, counted. The parity programs and snapshots are rendered natively and held to the fixtures; the vectors recorded from the Swift core stay, and the one that is a C library's to the last bit (an arp's decayed velocity is
exp) says so where the C library is another. - Not built where this was written: anything of Apple's. The Swift node, the views, the two apps and an app made from the npm package are the Native workflow's on a Mac, the last against the XCFramework its Linux job made.
- The last comparison, on each platform. The Native workflow built the Swift core as a library on Linux, macOS and Windows and played both engines through the C API. Windows gave the same bits at its first run. macOS gave them for every parity case and for 48 of the 50 programs under random events; the two with the resynthesis were a few units in the last place apart in a frame here and there, at 44.1 kHz. On Apple's platforms Swift's build joins a
A release does not ship the DSP library (November 2026)#
@swiftbrowser/dsp is not published, by design, so nothing made from npm plays a program, and the Swift side alone is no use to an app. "The engine in Rust" had the publish workflow build SwiftBrowserDSP's XCFramework and refuse to pack @swiftbrowser/native without it, which put 7 MB (20 MB unpacked) in every install of the native package and five Rust cross builds in every release, for a package no one can use from npm. The workflow no longer builds it, and checks that the packed native package carries none. What ships it is kept for the release that publishes dsp: sync-swift.mjs copies a library where it has been built and --require-binaries refuses to pack without one, and the Native workflow still builds an app made with native init --with dsp against the copy with a library made on Linux. The published copy of SwiftBrowserDSP stops at its #error on a Mac, which now says so.
The DSP engine a third faster natively, the page's module nearly twice as fast (November 2026)#
With the Swift engine gone the Rust one need not give Swift's bits, only its own twice and the page's fixtures, so what a block costs was taken apart (the note, "Faster"): Codon's presets under callgrind, eight notes held. Most of it was not arithmetic.
- The same samples. A stateless instruction's handler is a loop with nothing to ask as it runs (it saved six registers and asked whether its result was an input): groups of eight natively, a loop over slices that cannot overlap in WebAssembly, whichever the target's compiler makes vectors of. The block's sums of the voices are written out for the lanes that sound. The envelope keeps its state in locals over a chunk and runs each stage in a loop of its own where its gate is held. The comb reads a chunk before it writes it, eight frames at a time, and a stereo's two lanes side by side. The wavetable oscillator's frame is vectors, its samples fetched by 32-bit index, and a position on a frame fetches that frame alone. A
sin, apowor another of the C library's calls over a chunk whose inputs do not move is worked out once a lane. - 2^x is the engine's own, the same on every target and eight at a time, where the C library's was a call a voice a frame: the one change that moves a sample's last bit. The page's fixtures were written again (2 of 76 series, by 4.5e-8 at most), and
tests/decode.rsrecords a fixture file's digest again when it is (SBDSP_RECORD_FIXTURES=1). - Measured. Instructions a frame: Init 7,329 to 4,218, Pluck 5,623 to 3,015, Warm Pad 10,381 to 5,969, Mono Bass 2,735 to 1,858. A block, timed against the engine before, in turn on one core: the plugin's build takes 36 to 42% less on the three presets of eight voices and 29% less on Mono Bass; the page's module in Node 46 to 51% less and 15% less. The module is 674,640 bytes where it was 615,490.
- The form is the target's. The groups of eight that made an AVX2 build's multiply 40% cheaper left the page's module a third slower than the loop they replaced: WebAssembly's compiler took the group an element at a time. The loop over slices is the page's, and is up to 9% behind the groups on AVX2. (What the compiler makes of a loop cannot be read from a crate compiled for thin LTO: it leaves the vectors to the link, and a 64-bit ARM build looked scalar until it was compiled without.)
- Left: fused multiply-add (not tried: little arithmetic is left where the time is, and it would part a native build from the page's in every sample), the processor's flush-to-zero (the engine's own scan is not to be seen in a profile), and the transforms (no preset runs one).
- On 64-bit ARM (a hosted macOS runner, an M2 Pro; the "DSP engine timing" workflow, run by hand) a block takes 22 to 38% less, and the two forms of the arithmetic handlers are within a run's noise of each other, so it keeps the groups.
The DSP engine, a second pass (November 2026)#
What the first pass left on top of a block, taken in turn (the note, "A second pass"). All of it the same samples: the presets' checksums and the page's fixtures hold.
- A wavetable's samples lie a frame at a time, each frame's cycle with its first sample again after its last, where they lay a sample at a time with the sample's frames side by side. That layout kept a read between two frames in one cache line and put a frame's next sample a frame count away, so a note going round its cycle touched a new line every sample once a table had many frames: with 64 (Codon's own have two; a table brought in has up to 256 between a program's) a block of Warm Pad took 0.55 ms where it now takes 0.30, as with two. The bench makes a preset's tables longer to say so (
SBDSP_FRAMES,SBDSP_POSITION). - The envelope's lanes side by side, eight at a time, in any chunk but the one a note starts or ends in; the comb's eight frames read as one span; a handler's ending out of the handlers (the page's module is 33,017 bytes smaller for it); a mono patch's oscillator and filter, which were a lane at a time with the chunk's work a frame at a time around them.
- Tried and put back: the filter's lanes side by side by hand, which the compiler already did better.
- Measured against the first pass: instructions a frame down 8 to 15%; a block of the plugin's build 4 to 17% less (the best of ten rounds; 7 to 10% by the middle one), of the page's module 1 to 22% less, and on 64-bit ARM 6 to 16% less for the three presets of eight voices and the same for Mono Bass.
- Left: the serial part's own interpreter (38 instructions an instruction a frame, 2 of them arithmetic) and several instructions made one where a stream is made.
A stand-in is an asset the program names (November 2026)#
An importer said which piece of Codon's library stood in for a factory sound by the piece's name, and the host made its numbers from the recipe. The library is on the site as assets already, so a stand-in is now the asset itself.
modules/serum.dsplists each stand-in as an asset literal (["Analog/4088.wav", #wavetable(9ac2…, "Saw dark 1")]), its hash the file the upload makes of that piece.npm run librarywrites them;test/standinAssets.test.tsholds them.- A literal in a constant is a reference (packages/dsp's compiler): it is exported as its kind, hash and name, and no file is read for it.
assetLiteralssays which a literal is, and only what a program plays is fetched for a compile and listed in its file. - An importer answers
asset: { sha256, name }, and the preset names the file with none of its numbers, to the byte the file a kept preset is. Nothing of a stand-in is rendered by an import; the name-based form andlibraryData.tsare gone. - It plays when the file is at hand: from the folder, else the site by hash. Nothing is made from a recipe in its place, so a sound imported offline opens once the site is reached.
An importer is handed what it must read. What it shapes or measures of a stand-in (an impulse, a multisample's zones, a sample's length or slices) it reads from the asset's file, which it has not: it answers needs, its host fetches the files (the folder, else the site) and asks again with them. codon:audio has none of the library's generators any more, and no recipe runs in an import, in the page's sandbox or the plugin's.
The picker shows assets, and where each is. Its three places are the site's published listings, this computer's assets that the site has, and this computer's that it has not yet; the section made from the app's recipes is gone, a row's arrows step through the assets on this computer (presets/assetShelf.ts), and a shaped impulse keeps the asset it was made from. The app's script and the importers' worker have none of the library's generators (src/library/pieces.ts is the upload's and the tests').
The plugin's saved state names an asset by its file. Where a sample or a wavetable is one of the library's (the shell bundles src/library/assets.json, the list of their files' hashes), the state holds {"sha256":…,"name":…} as a preset's file does, and anything else whole. The shell reads the file from the account's folder, where it keeps each one it names as it saves, and asks the site for one it lacks (GET /api/assets/<sha256>), waiting as it waits for a program. Its Rust ports of the recipes (wavetables.rs, noises.rs, impulses.rs) are gone: no synth makes a piece of the library, and a state saved with the older names (a hash of a piece's numbers) no longer reads them.
The plugin bundles no program and no preset. Its pack is the editor's faces and scripts, the importers' libraries and the library's list of hashes. A new instance plays the account's default program where the folder has one, and has nothing to play until then: silence, no parameter in any slot, {"empty":true} for its editor and in the state a host saves. It starts on the default when a sync names it (the shell wakes every such instance as the editor's library writes programs/current.json), and fetches a default the folder lacks as it fetches a snapshot's program. The editor shows "Getting ready" in the panel's place while there is nothing, or while a project's program or sound is on its way. CI validates the CLAP both ways: with nothing to play (no parameter a host can set, so clap-validator's flush test is left out) and on the default program in a folder of the step's own. preset-discovery offers nothing of the plugin's own; the bundle's older program names, the seeding of the folder and the factory presets by name are gone, and the tests play fixtures of their own.
A program's package carries its starting sound. Serum 2 at its own defaults is silence (its knobs are Serum's at zero; Codon's Init differs in 233 of them and in its wavetables), so an instance started on the bare program would have played nothing. A package may now hold init.sound.json: what a new sound on the program sets, in a preset's members, with only what is not the program's own (43 KB for Serum 2's Init, where its whole preset is 430). The shell starts an instance on it; it is in the program's file, from the site, so no sound is bundled. npm run library writes Serum 2's from the app's Init and a test holds it. The app's script still carries the two programs' text and compiles (the app's bundle), and its own new sound is still made by its code.
A program picker. New Sound… opens a palette of programs, as the preset browser is one of presets: tiles of the site's picture of each program's panel, from the published listings, the account's own, and the files on this computer. A tile tapped plays a new sound on the program (its starting sound, read from its file), auditioned as a preset is; tapped again, or Return, takes it. A plugin with nothing to play opens on it, in the panel's place, where the "Getting ready" screen was (that screen now stands only while a project's program or sound is fetched): its first sound is a program picked, a preset from the browser, or the account's default when the sync brings it. A synth's token now reads the site's program listings, as it reads the asset listings. The well's New Sound submenu of the app's two programs is gone.
No program is a default. A new instance of the plugin always has nothing to play, and its editor is the program picker: its person picks a program or a preset, and that is its first sound. The admin-picked default is gone from the site (program_listings.is_default and its index dropped by migration 0007, default out of the listing, of GET /api/programs/current, of a pull's programs and of an upload) and from the synth (programs/current.json lists what the site offers and nothing more). The shell no longer starts an instance on anything: the look for a default, the wake when a sync named one, its reading of a program's starting sound and its slot map (src/slots.rs) are removed. A default, if there is one again, would be a person's own choice.
The app carries no program. The app's script had Serum 2's and Sylenth1's text, panels, metadata, declarations and patch models in it (3.4 MB), the Apple app and the page had their compiled programs beside it, and the site's island shipped them too: a plugin's editor could not play them, but the page and the Apple app started on the Init the script made, and an import looked for importers in them. All of that is out (the script is 1.6 MB). Every synth starts on a program of silence with no parameter (src/presets/empty.ts) and opens on the program picker; a program is a file from the library's folder or the site, and its file now carries its data's declarations (main.dsp.declarations.json) so that opening one parses nothing, as the bundle's did. The Apple app asks the site as anybody (it has no sign-in), the page asks its own origin, and the island opens on the picker where it is given neither a preset nor a program; its describe gives a program's bytes only where the page has read the file, and its importFiles is told which programs to look in. An import in the app looks in the program playing and the programs in the library's folder. The sources of the two programs stay in the repository, for the build (their files, the site's upload, the factory sounds) and for the tests, which have a path of their own to them (<Codon program sound>, test/setup/bundledPrograms.ts, and web/island-test/server.mjs, now a stand-in site that also serves the built page: the island's checks run to their end against it, which they had not since the stand-ins became assets). test/noProgram.test.ts holds the app's entries to reaching none of it. A project a plugin saved before programs were files is still played by the plugin; its editor says it cannot show it. Two races between a host's load and the editor came out with the plugin's test loading a real preset, and are mended: the editor lets a newer state supersede one whose program's file it was still reading, and the shell refuses the editor's plugin.update of a sound the host has replaced since the editor last asked for the state (it had been written over the new state's own editor state).
A person's programs sync. A program was on a second computer only once a preset on it had synced there, and one made in a synth reached the site only as a file a preset named. Programs are now in a person's library as presets are: their own listings and the published listings of other people's they keep, on every synth they sign in, with or without a preset. The site stamps a listing's change in its owner's library and a keep or a drop in the keeper's, by the counter the presets go by (program_listings.library_rev, the new library_programs: migration 0008, which stamps the listings there already); a pull answers programs beside the presets' records and brings their files; a push says programs (a program made in a synth: a private listing made under the id the synth gave it, its next version where its file changed) and keptPrograms. In the synth a program has a record beside its file (src/presets/programRecord.ts); the program picker's places are Published and My library, a program taken there is kept, a preset saved on a program made here puts the program in the library under its name, and REMOVE takes one out. The picker's On this computer and Mine are gone with it.
The site puts no program forward. offered, the mark an admin set on a published listing so that a synth's sync brought its file, is gone with the default: the column and its index (the same migration 0007), the field of PATCH /api/program-listings/<id> and of an upload (and an upload's refused), GET /api/programs/current, a pull's programs object and the offered programs' files in a pull, the badge on /programs and the admin's control on a program's page. No field of a listing is an admin's alone now, so the synth's own upload needs a write token and no more. On the synth, the folder's programs/current.json is not read or written, the picker's On this computer lists what the folder holds (a program picked before, what the presets are on, what an app ships), the browser's program choices where it reaches the site are the programs of the presets the site lists, and an import looks for importers in the program playing and the ones the app ships. A pull still brings the files of the programs its presets are on; a new account's first pull brings none, and a program picked is fetched by its hash.
Not done: a constant that holds an asset and is then given to a declaration compiles in the compiler but is not fetched for a compile in Codon (write the literal as the declaration's value); a project saved before presets were files that names a stand-in no longer opens in the plugin's editor (it would need the asset handed to the app's own patch model).
The program format's tables, written once (November 2026)#
With the engine in Rust beside the compiler, the format's tables were written three times: program.ts, the compiler's program.rs and the engine's program.rs each listed the opcodes with their arities and state, the machine's registers and the bounds a program is checked against, and each had a pack's magic and tags. An opcode was added in all three.
packages/dsp/formatis those tables once: the format's numbers, the opcodes, the stateful builtins with the words each keeps, a pack's kinds. No standard library, no dependency, no nightly feature, so the engine (no_std, a pinned nightly) and the compiler (std, any toolchain) both build with it. The engine'sDSPOpcode,DSPBuiltinand packKindare its types; the compiler's tables and its pack kinds are its own.src/format.tsis generated from it (dspc --format-ts, asuiSchema.tsis from the compiler's table ofui), each row's doc comment its comment, and a test of the compiler's holds the file to the tables.program.tsgives it on, so nothing that importedOPCODESor a constant changed.- The two stay two crates. The engine has no standard library and a page loads it alone in a worklet; the compiler folds constants in JavaScript's arithmetic where the engine computes in the platform's; a plugin and a native app already link both into one library. The pack reader, JSON and
evaluateare each still their own (docs/notes/engine-rust.md, "What it shares with the compiler"). - Nothing changed in what is computed: the presets' checksums are the ones before, and the page's module renders its fixtures exactly. The engine's module is 638,921 bytes where it was 641,623.
The app's last words of Serum's (November 2026)#
With no program in the app, what was left in its script of any one synth was a few lists and a name, and they are out.
- A warp's picture is the panel's to name. The wavetable's display drew a warp by Serum 2's own list (its kinds' names, and which of them each number of its mode was, copied into
src/warp.ts; modes 1 to 17 by number in the display). The panel language now has the display's own words for the ways it bends a cycle, each named for what it does (repeat,stretchEnd,shorten,tiltEarly,invertEnd,reflect,curve,ease,stepsand their kin: docs/notes/program-ui.md, "A warp's shapes"), anddisplay.wavetabletakeswarpShapes, one word for each value of the mode. The compiler holds the list (a word that is none of them does not compile), the schema is generated from it, and the app's is held to the schema's. Serum 2's program maps its modes itself (WARP_SHAPESin serum.dsp); the display knows no program's menu or order. What it drew before it draws now. - Import… offers what the importers read. The chooser's file types were written out (
.fxp,.fxb,.SerumPreset); they are the extensions the rules of the importers a synth has accept, with the sound files those want handed beside their own for a folder (importTypes), so another program's importer adds its files by being there, and a synth with no program yet offers a preset's own file alone. Asking for the playing program's file no longer makes a file of the silence a synth with nothing to play holds. - Gone: the name
supersynthread asserum2(projects from before the rename), the program a new synth started on (startsOn, which nothing read), and Serum and Sylenth by name in the browser's empty text.
A project references any file the site holds (November 2026)#
The plugin's saved state wrote a sample or a wavetable as a reference to its file, a line where the numbers are megabytes, only where the file was one of Codon's own library: the shell bundled a list of those 385 hashes, and on every save wrote each piece's file from its numbers and hashed it to look it up. A person's own uploaded sample was never on the list, so it was carried whole in every project that played it; and "the library" was a special case in a system that otherwise has only assets.
- The shell remembers; it does not look up. A snapshot arrives with some pieces as references (
{"sha256":…,"name":…}: the hash finds the file, the name is a label). The shell reads those files to play, remembers which pieces they were (assets::referenced, onLoaded), and the state it saves writes them back as they came. A piece that came as numbers is saved as numbers. The list is out of the bundle (14 entries, 3.8 MB as 1.3 MB), with the shell's own writer of asset files (assetfile.rs) and the hashing on save. - The editor decides, by two things it already knows. It sends a reference where the numbers are a file as it is and the site is known to hold that file. The first is remembered by the numbers themselves (
knownAsset, aWeakMapon the wavetable's or sample's own object, noted when a file is read, picked, saved, or reported by the plugin), so an edit forgets it by making new numbers, and nothing is hashed in QuickJS to find out. The second is the library's (onSite): what it fetched from the site, sent to it, found referenced by a preset the site holds, or was told by the site. - The plugin tells the editor what it was sent.
plugin.statehands over the numbers as before, andassetsbeside them: which pieces came as references. Reopened, the editor sends them back the same way. - What it costs. A piece made on this computer stays numbers in the project until its preset has synced and the sound is sent again; the editor does not go back and rewrite a project. A project never references a file nobody could fetch, which is the rule the whole thing is built to keep.
- A preset's file a host loads by its path is saved as numbers. That file may be one made here and never synced, and the shell cannot tell (
host_preset); a state and the editor's snapshot were written by something that could. src/library/assets.jsonis gone: nothing reads it.
The DSP engine, a third pass: what a stream runs (November 2026)#
After an audit of the opcodes and the compiler (nothing to add or take away; the pairs still worth fusing are ones only a machine sees), the two things the second pass left and one more (the note, "A third pass"). All of it the same samples: the presets' checksums and the page's fixtures hold.
- The engine runs a tightened copy of each per-frame stream (
machine/tight.rs): a product read once by a sum is one instruction with it, and a sum read once by a product, however far apart (the compiler fuses only the pairs it writes side by side); and a temporary's register is one a temporary before it no longer needs, so a chunk of Codon's voices writes 15 registers over and over where it wrote 73 to 115 once each. The streams as they are stay (running, the serial part), and while a probe tap has probes the copy is the stream as it is, so the editor's previews read every value where the program has it. Nothing is allocated as streams are made. - What may be read as the chunk before left it keeps its own register (
looped, found as a program loads: through a choice turned to a value made from its reader, a ring of choices, a region's result), and past a short chunk's end such a register holds its last frame. - The serial part's handlers are told which of their registers are state, in words of the instruction, where each asked four times an instruction a frame: plain arithmetic there is 43 instructions a frame where it was 56.
- An operand set once a block is read once a chunk, in native builds, where a chunk has 4, 8 or 16 lanes side by side: a multiply by a parameter read eight lines of memory a chunk for sixteen values.
- Measured against
main(x86-64, AVX2): instructions a frame down 2 to 7%; simulated first-level cache misses down 12 to 33%; a block 5 to 7% less by the clock for Init, Warm Pad and Mono Bass, and Pluck the same; the page's module 0 to 3% less, and 648,676 bytes where it was 638,921. On 64-bit ARM (the timing workflow) Init 6% less, Warm Pad 17% less, Mono Bass the same, and Pluck within the runner's noise. - Tests: every parity fixture, and Codon's whole program with its knobs turned at random, play the same bits tightened and not, at three rates.
- Left: the chorus's loop is frame by frame because its second delay is shorter than a chunk; a chord of three or five voices runs the handlers that read every operand whole.
A formatter for .dsp (November 2026)#
A program's source can be written one way: swiftbrowser-dsp format, dspc --format, formatDsp (the language's note, "The formatter").
- Prettier's document commands, in Rust (
packages/dsp/rust/src/doc.rs):group,indent,line,softline,hardline,if_break,fill,line_suffix,break_parent,conditional_groupand the printer that lays them out in a width. Nothing in it knows the language. - The language's layer on it (
src/fmt.rs): the tokens read by the parser's own rules for where a line's end matters, so a line is only broken where the parser carries on (inside parentheses, between a list's items, before a binary operator, which leads its line). - What a writer chose is kept: every comment and every literal's spelling; whether a body's braces are on one line or open; a list's own lines where it was opened over several (a table's rows stay rows, a panel's rows with no commas stay so); at most one blank line. A list on one line that does not fit is packed to the width.
- It cannot change what a program says: before any text is given back it is parsed and held to the source, the same tree and the same comments, and anything else is an error with nothing changed.
- Everywhere the compiler is: the C API's
dspc_format(and aformatrequest, for a host with no WebAssembly), the module@swiftbrowser/dsploads,formatDspandformatDspThrough. The lexer gives each token its extent and, asked, the comments; the parser is as it was. The page's compiler module is 1,190,722 bytes where it was 1,065,218. - A chain of calls (
knob(x).label("A").size(30)) that does not fit goes a call a line; a path of plain members is never broken. - The repository's programs are not formatted yet: twelve of Codon's 21 files would change, by about 600 lines of 6,870, nearly all of them lines wider than 120 (and a program's file is named by its hash, so each would be a new version of its program). That is a change of its own, to make when nothing else is open on those files.
- Tests: each rule; every
.dspand.uifile in the repository at four widths (it formats, it parses to the same tree, and formatting it again changes nothing); and Codon's files as they are by hand, kept as fixtures with what the formatter makes of each recorded beside it. - Not done: formatting the repository's own programs, and a test that holds them to the formatter; the editor has no Format command yet.
The import libraries, audited (November 2026)#
An importer imports the program it writes for and the codon: libraries, and every export of those is a promise to importers other people will write. Three libraries had grown by need: 52 exports, 33 of the 36 in codon:audio used by one importer, Serum 2's.
codon:programis new, for reading the program. A third ofcodon:audiowas no audio: tapers, controls, the matrix, two limits; andcodon:importhad the effect chains' helpers. They are one library now.codon:audiois the numbers of a sound,codon:importthe contract and a preset's name and tags. The program itself has one name,../main.program; a bareprogramis refused.- What one importer needs is that importer's. Out of the libraries and into Serum 2's package: its curve family, its grain windows, its first LFO shape, its arp pattern's name.
zonesOfwrote the import's report itself, a sentence of it saying a multisample "is Xfer's"; it answers with facts (zones merged, stand-ins played, samples cut) and the importer says them. Dropped as promises nobody used or should:harmonics,WAVETABLE_FRAMES,programPattern,shapingKey,decayAt. - The editor bends a slot's curve by the app's own curve. The matrix editor's bend bar drew Serum 2's family, 256 tables read from its engine. It draws
easednow, the curve a drawn shape's segment bends by, which leaves the app one curve. A route carries its curve as points, so every preset sounds as it did; a curve of Serum's family reads as DRAWN in the bar until it is bent again. - Readers read.
readAudioFile,readSfz,readAsset(they wereparseSfzanddecodeAsset);layerAt(regions, velocity)wherelayerAt100had its velocity in its name;portableExpandportableSinfordexpanddsin. - A type is a promise too. A leaf was the hash of a signature as TypeScript prints it, which is its types' names: a field added to a type changed no leaf, and the contract itself (
ConvertResult) had none. A leaf now takes in the declarations of the types it is written in, each exported type has its own, an importer's package records the types it imports, and a host is held to them.
52 exports are 41, in four libraries.
The app's last words of Serum's, and an envelope's corner that left the finger (November 2026)#
After the import libraries, what the app's own code still said of Serum and Sylenth1 was comments, some forty of them ("as Serum's matrix has", "Sylenth1's arp time"), and one thing that was not a comment.
- A stage dragged on an envelope's screen set the wrong time. The screen turned the seconds a corner was dragged to into a place along a knob that runs 32 s by the fifth power (Serum's time knobs), and the panel set that place as the parameter's value. The parameters are seconds: a corner dragged to two seconds set 0.57, and was drawn there, away from the finger. A program whose times are not that knob's (Sylenth1's run 0 … 10) got a number between 0 and 1. The screen hands over seconds now (
stageSeconds,stageLayoutthe other way), and the panel sets them held to the parameter's own range; no knob's curve and no 32 is in the screen. - The comments say what a thing does, not whose it is like.
Codon.tsx's first line still called the app's soundprogram/serum2/main.dsp, which the app has not carried since programs came from the site.
What is left by name in the app's sources is src/presets/bundled.ts, which is about the two programs this repository holds the sources of, and is the tests' and the build's.
An envelope's screen still read its parameters as seconds, which Sylenth1's are not: the next section.
A program says what its time knob comes to (November 2026)#
Sylenth1's envelope times are a knob, 0 … 10, that comes to 0.027 × (1000^(knob / 10) − 1) seconds. Its envelopes' screens drew the knob's number as seconds (its attack at 0.5, about 11 ms, as half a second), and a stage dragged set the seconds it was dragged to as the knob.
display.envelope takes seconds:, tables of numbers: what a stage's time parameter comes to at evenly spaced places along its range. Sylenth1 exports them from the arithmetic it plays by (33 places each) and its panel hands them over; the screen reads a value's seconds from its stage's table to draw the stage, and a stage dragged back to its value (src/panel/times.ts). A program whose times are seconds, Serum 2's, says nothing.
The tables are by stage, seconds: { attack: …, decay: …, release: … }, since a program's stages need not run by one measure: Sylenth1's attack lasts 0.95 of its knob's time and its falls 0.97, and each has its own. (It was one list for the envelope for a day; a field's shape is not one to change once programs' files carry it.) The compiler's field is a record of tables by name (Field::Tables).
What an importer needs is the program's file's to say (November 2026)#
A program's file recorded what each of its importers uses of the import libraries by writing it into the package's own list, importers/importers.json, as the file was made. The list is a file a person writes, a dozen lines: in a program opened in the editor it was twelve kilobytes of hashes, reformatted, and an importer edited rewrote the file beside it.
It is an entry of the file's own now, main.dsp.importers.json (by importer id), beside the assets' list and the rest a file works out for itself, none of which is a file of the package's or in the editor's tree. The list is in the file as it is in the folder, byte for byte; stampImporters is importerRequires, which answers and rewrites nothing.
A program's file opened in the code editor as a pack listed what the file had worked out for itself among its files (main.dsp.exports.json, main.dsp.assets.json and the rest); it lists the package.
Before the first synths go out (November 2026)#
Once a synth is on someone's computer, a change costs what it does not cost now: every build already out goes on reading the same files and asking the same site. These are the changes made while they were still free.
- 1024 slots, the macros the first eight. A plugin's parameters are a fixed pool of host slots, which a host is told once and a project's automation is written against: neither the number nor which of them are the macros' can change later without a new plugin id. It was 512, the macros' eight at 500 … 507, of which Serum 2's program already shows 350. It is 1024, and the macros are slots 0 … 7: a host lists Macro 1 to 8 first, at the same places whatever the program, and a program's parameters have the 1016 after (the first at slot 8). The numbers are the format crate's (
SLOTS,MACRO_SLOT), and the plugin's shell takes them from there where it had its own copy. The snapshots the engine's recorded vectors are of keep the slots they were recorded with (from 0: an engine reads any slot for any parameter, and which are the macros' is a host's to hold a snapshot to). - The two programs are "Serum 2 Compatibility" and "Sylenth1 Compatibility". A title is what a preset names its program by, and what the site lists: it is in every preset made on one. Their ids (
serum2,sylenth1: folders, listings) are as they were. - A synth says which build it is. Every request to the site carries
x-codon-client:codon/<version>from the app's code,codon-plugin/<version>from the plugin's shell. The site can then tell a build too old for something it has changed to update (CLIENT_MINIMUMS, unset: 426,client_outdated, in words the synth shows), in place of answering it with what it would misread. Nothing is refused today; the header had to be in the first builds for the site ever to be able to. (docs/notes/access.md.) - A file a newer Codon made says so. A program's file is read by builds older than the one that wrote it. A later pack, program, entry or panel tree version was "not a program's file: invalidProgram: version 11 is not 9 … 10"; it is "Bass Station was made with a newer Codon than this one. Update Codon to play it." And a panel with a kind of item, a field or a word this build has no name for drew that item as nothing and said nothing: it draws the rest and says what it left out. (docs/notes/presets.md, "A file a newer Codon made".)
- What only read what was made before is gone. The plugin loaded a state that was plain JSON, as it saved one before states were packs: a state is the pack. Codon's editor state of version 1, and of the names its data had before the program's own, was still read: one version is, the one written. The site swept the preset files it kept before files went by their hashes. A project "saved before Codon kept its programs as files" is now said as what it is, a snapshot that carries its program with no text of it, which is still a thing that can be made. Left: a machine still reads a program of version 9 (
PROGRAM_VERSION_OLDEST), which the engine's recorded vectors are written in.
The readers, fuzzed#
Everything that reads a file from elsewhere (a pack, a compiled program, a snapshot, an asset, a preset, a sound file, another synth's preset, what is sent to the site) is now run in CI on damaged copies of real files, a few seconds a suite, each held to reading the file or refusing it in its own words (docs/notes/packs.md, "Checked"). What it found, all fixed:
A snapshot that ended the host. A snapshot's wavetable was checked as frames and, apart, cosines; a program's is held to a cosine for every sine. The engine makes a wavetable's levels by reading one for each: given a snapshot whose cosines were short of its frame, it read past them, which in Rust is a panic, and a panic inside the engine's C API ends the process: the DAW, for the plugin. Both validators hold a snapshot's wavetable as a program's now, and the levels read no further than they were given. (The Swift core had the same hole: four of its recorded vectors said
okto such snapshots, and say the refusal now.)A count that asked for 46 GB. A packed program says how many arrays follow it, and the plugin's reader set aside room for that many before reading one. A count is now held to what the file could contain. A pack's entry likewise claims the size it inflates to: the TypeScript reader set that aside first (four gigabytes, for a few bytes), and now refuses what its stored bytes could not come to, and any entry past 1 GiB.
Refusals in the language's words. The TypeScript program and snapshot validators walked what they expected to be lists: a number there was "program.constants is not iterable". A pack's program or metadata that was not JSON was a
SyntaxError. A damaged FLAC or Sylenth1 bank was "Offset is outside the bounds of the DataView". Each is the reader's own refusal now, and a pack's metadata is held to the shape its readers take on trust.An importer's inflate stops.
codon:files'sinflategrew its output for as long as the stream went on, and a megabyte of deflate comes to a gigabyte: a preset of another synth made for the purpose cost the importer's sandbox its memory. It takes the most a stream may come to (inflate(input, most?), 256 MiB unless the importer says) and refuses there. The Serum 2 importer's own Zstandard reader set aside whatever a frame said it held, up to 2^64, before reading it; it has the same bound.
The plugin's wavetable display on a GPU (November 2026)#
Codon's plugin drew its one shader, a morphing wavetable's stacked display, on the processor; it is built with the renderer's gpu feature now (the note, "Measured: the wavetable display on a GPU").
- Measured at the display's size, the pixels read back as a view needs them: on a Mac runner's Metal 1.6 ms a draw at 1× and 1.7 at 2×, where its five cores take 6.8 and 25 ms and one core 34 and 132.
- A software adapter is declined (
Gpu::hardware): llvmpipe draws it in 22 and 60 ms on a machine whose four cores take 11 and 35 with the renderer's own interpreter, and Windows' WARP in 76 and 247 on a runner whose two cores take 38 and 140. A machine with no GPU draws as it did. - The cost: 3 to 4 MB of the .clap (a Mac 15.3 MB where it was 12.2, Linux 19.4 where it was 15.5, Windows 20.0 where it was 15.9), and once, at the first shader, about half a second on the Mac runner's virtual GPU (239 ms for the device, 217 for the pipeline). Most of it is naga (the shader's translator, 1.5 MB) and wgpu-core (0.9).
- One backend a platform: Metal, DX12, or Vulkan on Linux. The renderer's
gpufeature compiled every backend wgpu has for a platform, which was 1.8 MB more on Windows and 0.6 on Linux;gpu-gladds GL where it is wanted (a container's Mesa, for the tests). - The Mac's VST3 and AUv2 link Metal, which the wrapper has to name.
- The VST3 and AUv2 are the .clap's size: the wrapper's link kept every Rust function by name, reached or not, with the standard library's debug information (a VST3 of 40 MB on Linux, 27 on a Mac). It now exports the C entry points alone, drops what nothing reaches and strips the names: 20.1 MB and 16.1, and the AUv2 15.9.
- A bench (
the_cost_of_codons_wavetable_display, packages/raster/cli), which the Plugin workflow runs in its test jobs when started by hand. - Not done: making the device before the first shader needs it, off the editor's thread; a number from a real GPU, and from Windows and Linux with one.
A new sound is the program at its defaults (November 2026)#
A program's package could carry init.sound.json, a sound laid over the program's defaults for a new sound to start on, and Serum 2's did: its defaults were every knob at zero, which is silence, and the file turned 233 of them, gave the three oscillators a table and the LFOs a shape, put one route in and said which effects the rack shows. So what a program starts as was said in two places, and a host's reset of a knob went to the zero and not to the sound.
The file is gone, and the code that made it, read it and held it to the Init. A new sound is the program at its own defaults (docs/notes/presets.md, "A program's starting sound"), as Sylenth1's always was.
- Serum 2 Compatibility's defaults are a sound. Oscillator A on the library's Basic Shapes, one voice, through nothing: no second oscillator a fifth up, no unison, no filter, chorus or reverb, no route, which the Init it had added. What is off rests where turning it on is heard: the envelopes have a sustain and a second of decay, filter 1's cutoff and mix are filter 2's, an effect's knobs are where Serum rests them. The oscillators' tables are the library's Basic Shapes, named by its asset's hash (
wavetable oscA = #wavetable(8ba1…, "Basic Shapes"): a sine where the position knob starts, then a triangle, a sawtooth, a square and a pulse), and the LFOs' shape a triangle,[0, 1, 0]. Every compile of the text now reads that asset (docs/notes/assets.md, "Programs"). The app has no recipe of the library's, as since nothing was bundled: it fetches the table from its folder or the site as any asset a text plays, for a compile, for a panel's run alone (which did not fetch), and for the code editor's language worker, which the editor now hands each asset. The language's service takes areadAssetand says nothing of an asset it cannot read (it reported "no readAsset" on any program that played one). The build's compiles and the tests' make the piece from its recipe, as the upload does: an asset reader is told what the text calls the asset (readAsset(sha256, name)), and the file made is held to the hash. A compile through a host is given what the texts play with its first request. (For an afternoon the app's compiles made the piece themselves, which put the library's recipes back in its script; test/noProgram.test.ts now holds the script and its workers' to having none.) The program's file lists the asset and is 350 KB longer for the three tables. spare:. A rack's line at first was every effect written, in order, and Serum 2's racks are written with room for five compressors: the Init said which were in. An effect is now writtenspare: truewhere the rack holds it and plays nothing through it until a sound puts it in (docs/notes/dsp-language.md,chain), and each of Serum 2's racks starts with its first of each effect.- What an importer leaves unsaid. An importer lays a preset's values over the program's defaults, so a default is also what a preset gets for a part it has no word of. Serum's sets every knob a Serum preset has and every rack's order it reads; the six sounds this repository makes with it (the four factory ones and the Serum 2 fixture, twice) play sample for sample as they did. One default is as it was for that reason: oscillator C does not go to the filter, which a Serum 2 preset that says nothing of it means. Serum 2's 626 factory presets (the demo's, not in this repository) were imported on the program as it was and as it is: each plays the same samples (two notes held half a second and let go, 48 kHz, both sides), and holds the same wavetables, shapes, samples, routes and slots. Of their parameters the ones that differ are spare effects' knobs (133 knobs of 30 effects: a second chorus, a third compressor), each effect off in every preset where one differs: where a preset puts a second of an effect in a rack the importer sets every knob of it, so none plays on a default. A spare effect a player then switches on rests where the first of its kind does, where it was at zero.
No factory sound is named Init any more: a new sound is what that name meant, and the three that remain (Warm Pad, Pluck, Mono Bass) are sounds with something to them. The importer's Init patch stays as what the tests' fixtures are made of, under its name: the engine's and the plugin's tests play it. (The preset of that name already on the site is not removed by an upload, which only adds and replaces.) The engine's recorded digests of that fixture (codon) are its own now, all three: Serum 2's program is part of each.
Another program starts at its own defaults (November 2026)#
New Program and Open Program… put another program's text in place and left every knob where it was: the session kept its values by name, and so did the node, so a cutoff at 8000 Hz became the next program's cutoff at 8000 of whatever it counts in, and what was heard first on a new program was whatever the last one left. (A program picked in the picker, and a preset opened, were given the program's defaults already.) Session.replace with no values now rests the knobs at the new program's defaults when it first compiles, forgetting the others (docs/notes/presets.md, "A program's starting sound"); an edit of the program's text keeps them, as does a preset moved to its program's newer version. A step that puts a program or a sound in place is kept to undo with the knobs' values, so undoing it is back to the sound before and redoing it to the one left: until now such a step took back the document alone, and a preset opened and undone left the earlier program playing the later one's values.
Signed in to play, everywhere but the site's own pages (November 2026)#
Codon's page, deployed apart from the site, asked its own origin for the site and had none behind it: it had nothing to play, and no way to be anybody; the Apple app asked the site as anybody. Both open on the sign-in now, as a plugin always has (docs/notes/presets.md, "Signed in to play"): there is no panel and no picker for someone signed out. A plugin's shell trades its code for a license as before. The page and the app sign in in script (src/SiteSignIn.ts): a six-digit code traded for a synth's token, or an access token pasted in, kept in the app's storage and sent with every request, the library that account's from then. The page is built for the site's origin (npm run build:pages), and the site answers a token, and a code's trade, from another site's page readably (Access-Control-Allow-Origin, and the browser's preflight), which it did for nobody: a token is no cookie, so a page that sends one was given it (docs/notes/access.md, "From another site's page"). A request with a cookie or with nothing from another site's page is as it was. The site's island is as it was too: mounted by the site's pages as whoever their session is.
(The first cut of this was a Sign In… in the page's menu, with the picker shown to anybody. A browser showed what the tests had not: a synth with nothing to play is all picker, its menu out of reach. The sign-in first is simpler than a picker that has to offer it.)
The bar follows undo too. A step that put another sound in place (a preset opened, a program picked or put in place) was undone with its knobs since "Another program starts at its own defaults", and the bar went on naming the sound undone: it names the one returned to now, with its resets and its edited mark, and the one left again when the step is redone.
Taps, and a spectrum of one (November 2026)#
A panel can show the spectrum of the sound at a point of its program, moving as it plays: display.spectrum(of: .filter1), on a page, in the Mac and iPad app and in the plugin's editor (the language, "Statements"; the engine, "Taps"; the panel).
tap name = ein a stage names a value for views, and for the rest of the body as aletdoes. It makes no instruction: the program lists its taps with the registers they are in, and a machine keeps those registers as the program wrote them and copies one out only while a view watches it, a voice's summed over the voices that sound.output, what plays, is every program's.- The engine keeps and analyses (
DSPTaps): eight slots, a ring of a watched tap's frames each, written by the audio thread with no lock (atomics; the probes' try-lock would drop a chunk now and then, a click across a spectrum), and a spectrum of a slot as bands spaced evenly in pitch, in dB, tilted and falling as asked. One implementation, where the engine runs: a page's worklet, the Swift node, the plugin. SpectrumView(@swiftbrowser/dsp) is the registered view that draws the bands: a canvas on a page, SwiftUI's in an app, a path in the software renderer, which now tells its host what its views watch and redraws when it is handed their values (a scope's frames too, which nothing marked for redrawing).display.spectrumin a panel, its tap checked against those the program writes. Codon's programs name each filter's sound and the voices' sum (and Sylenth1's its oscillators'); their sounds are the samples they were.- Tests: the statement and what it refuses; the engine's taps through C against a program compiled with four; the worklet's posts; the renderer's drawing and its watches; the plugin's feed, turn by turn; a panel against the bundled programs' taps.
- Not done yet: a tap's value is computed whether or not it is watched; a stereo is mixed to one; no plate of the bundled panels shows a spectrum. The Swift views were written where they could not be built: CI builds them on a Mac and their packages' tests pass (one mistake found there, a lock's state that was not Sendable), and nobody has yet looked at one drawing.
A program's own shader, fed by its taps (November 2026)#
A program can carry a shader and put it on its panel, drawn from the sound: display.shader("flame.shader.js", textures: { spectrum: display.texture(.filter1, bands: 96, rows: 64) }, uniforms: { cutoff: filter[0].cutoff }) (program-ui.md, driven-values.md). The steps under it, in the order they were built after the taps:
- Driven textures.
ShaderView'sdrivenTexturesnames, for a texture, a source of many values the host reads each display frame with no render of the app's;dsp.tap(tapTexture) is a tap's bands or frames. Withrowsthe texture is a history, the newest row first, andemptyis what it reads where nothing was given yet (a spectrum's silence, −140 dB: a spectrogram reading 0 there started as a lit block). A page's canvas, the Metal view and the software renderer (fed by its host, as its spectrum views are) each fill it. - The shader compiler reads its language itself. It parsed with the TypeScript compiler, nine megabytes beside its own sixty kilobytes, so it could run where an app is built and nowhere an app runs. Its own parser (
packages/shader/src/parse.ts) reads the same subset, JavaScript's semicolons and past TypeScript's annotations; the old and the new were held to each other over Codon's shaders, the tests' and the README's before the old one went: the same output, and the same messages at the same places but for three that now say more. Codon's native bundle, minified, is 1,713 kB with the compiler and all of the taps' work in it, where it was 1,624 before any of this. - A stranger's loops are counted.
compile(source, { iterations }): each loop from a constant to a constant by a constant, nowhile, and the counts multiplied through nested loops and the helpers called in them come to that many loop bodies a pixel at most. A step a 32-bit float would lose is refused (a loop from 16,777,216 by 1 never arrives). The compiler's output is its own text in every language, so the JavaScript a page without WebGL2 runs is the compiler's, not the file's. display.shaderanddisplay.texturein the panel language, the texture's tap checked against the program's and its sizes against what a view is given. Codon compiles the file when the panel shows it (32,768 characters, 1024 loop bodies a pixel), draws it with the parameters' values as uniforms, and says on the screen why a file is no shader.- Tests: the two compilers against each other (then the old one removed); the parser's forms and the counted loops' refusals; the panel's kinds in the Rust compiler and through the app's; the item mounted, its view's textures by slot and its uniform following the parameter; and the item in the software renderer, handed tap values and read back as pixels (silence, the newest row at the top, the history coming down).
- Found on the way:
Math.toString(x)threw from inside the shader compiler (a builtin was looked up among everything an object has); the compiler folded a constant by writing JavaScript and running it, which Codon's island may not under its content security policy, so it works the value out itself now; and the engine's recorded digests of Codon's fixture had not followed the programs' taps. - Then the three it left (the same week):
- A uniform follows its parameter as the voice plays it. The panel's shaders' parameters are among what the node keeps as probes; where the host drives its views it sets the uniform itself each display frame (a tapered parameter's through its taper: the probe is its place along its knob), and elsewhere the app gives it at its clock's frames.
useEngineValuesreads several of the engine's values as one text, so a screen with as many as its panel names renders when one changes. - A shader's problems are diagnostics. The panel's compile reads the shader's file where it can, so a name that is no file's is the panel's error at its place; a
.shader.jsfile has its own language service in the code pane (the app's compile of it, underlined at the word, and the language's names to complete); and the editor's foot says the first shader the panel shows that is none. - A shader drawn on the CPU is paced by its cost. The software renderer times a fed shader's draw and waits four times that for the next (400 ms at most, nothing under 4 ms), as Codon's clock paces its own frames; the rows handed meanwhile are queued, so a history loses none, and a timer draws the last. A page without WebGL2 paces its JavaScript frames the same way.
- A uniform follows its parameter as the voice plays it. The panel's shaders' parameters are among what the node keeps as probes; where the host drives its views it sets the uniform itself each display frame (a tapered parameter's through its taper: the probe is its place along its knob), and elsewhere the app gives it at its clock's frames.
- And a filter shows what it filters.
display.filter(…, spectrum: display.spectrum(of: .filter1))draws that tap's spectrum behind the response, on the screen's own span of frequencies: the host's view under the app's curve, nothing of it rendered by the app. Codon's two programs give each filter its own output's (the taps were there from the first step). At rest the screen is as it was: the spectrum's foot is sunk under the screen's, so silence draws no line. - And so do six effects. The flanger's, the phaser's, the EQ's, an effect's filter's, the splitter's and the utility's screens take the same
spectrum:, the sound behind the drawing on the drawing's own frequencies. Three things were missing, and were added:- The sound at an effect. A chain makes a tap of each of its effects by its name and the effect's (
fx.eq,bus1.fx.flanger2,fx.join): what the effect gives, or what it is given while it is off. One inside anif(the bus racks', which run only while their bus is used) is carried out of it as the region's values are, silent while it is off. The big program has ninety-four taps where it had three, Sylenth1's eleven where it had four. The first way cost a copy a tap a block, a fifth more time on a patch that plays little else; a tap of a region's result is now read where the program reads it (the engine follows its renamings, and pins what they may lead to), and the taps cost nothing: 31.0 ms for eight seconds of the Init chord where it was 31.7, 180 for Sylenth1's where it was 182 (the page's engine, medians of five). - A linear spectrum. A flanger's screen is even in Hz, 0 to 5 kHz.
SpectrumView'sscale: 'linear'(display.spectrum(scale: .linear)) asks the engine's finest bands, which lie evenly in pitch, and draws the loudest in each stretch of Hz: on the page, in the software renderer and in SwiftUI.decades: falseleaves out the view's own lines over a screen that has its own. - Room for them. Sixteen taps are watched at once where eight were: a rack with every such effect on has more than eight screens.
- The panel takes a chain's tap as text (
of: "fx.eq"), as it takes a plate'seffect:, since the program makes the name as it compiles. The engine's vectors for damaged packs keep the pack the Swift core read (tests/vectors/decode/parity.dspk): the parity cases' pack is written again whenever the compiler's output moves, and what a decoder says of damaged bytes does not wait on that.
- The sound at an effect. A chain makes a tap of each of its effects by its name and the effect's (
- And a shader is given the panel's colours, and its time runs. A shader's uniforms took a parameter, a number or a colour written out, so one could not follow the look.
uniforms: { line: .accent, body: .ink, ground: .background }gives it the app's accent, the ink its plate is lit in (grey while the plate is off) and its screen's ground, each as shown then: a uniform is text, which goes past the filter every other colour is turned by (appearance.ts), so the app says them in the theme and accent in force, as the wavetable's shader's are.timestood still on a panel (the view was never animated) and stood at 0 in the software renderer whatever a view asked: the compiler now says whether a pixel reads it (shader.time), Codon draws those every frame, and the software renderer runs an animated view's time from its first draw, a display frame apart or as far as its draw's cost says, on a timer that marks it and moves the scene's revision (the window's loop wakes for it; a tool that paints once has its first frame). Found on the way: the spectra behind the screens, and the header's scope, were given their colour as text too, so in the light theme they were the dark theme's ink on a light ground; they are said in the look now. - And what plays. A shader's uniform takes a source of the matrix by its handle (
swell: source(.env1)), the newest note's.gate,.noteand.velocity, how many.voicessound, and the transport's.tempoand.beat; and two more colours,.labeland.grid. Each is a probe of the node's (the machine's own registers, and the registers the matrix keeps its sources in), which the host reads each display frame where it drives its views; where it cannot (the plugin's editor), Codon's clock, which ticked only while a note played, ticks on for as long as such a shader is shown, and gives what the engine last said. A source is written as its handle because the matrix's are named as the panel's own are (velocity,note). Found on the way: a probe of the beat in a program with no master stage read past what the voices wrote (0, with one voice), and nothing while the program was silent; a master stage's probe there now reads the voices' first lane, and the silent path writes the beat it counts. - And a shader can be a control.
display.shader(…, drag: { x: filter[0].cutoff, y: filter[0].resonance }): a press on the screen sets those parameters by where it is, along each one's taper, and goes on as it moves. Nothing of it is the shader's: a shader is a function of what it is given and keeps nothing, so what a press changes is the program's parameters, which the shader already draws from..pointergives it where the pointer is and whether it hovers or presses, for what is only shown. A press let go where it was put sets them too, as a tap: the software renderer begins a drag only once it moves, and takes a press that does not as a tap. A shader given neither still takes no touch. - Handles, their menus, and print. One press setting two parameters is an XY pad; a screen like a parametric equaliser's has a point for every band, each dragged on its own, each with a menu, and figures along its edges.
handles: [{ x: band[0].freq, y: band[0].gain, menu: band[0].kind, label: "1" }, …]puts tokens on a shader's screen, each standing where its parameters are set and dragged from there by as far as the drag goes (so it does not jump to the pointer), put back by a double tap; its menu chooses among the parametersmenunames, and has Reset.labels: [{ text: "1k", x: 0.57 }, …]prints over the screen at shares of it. Both are the app's to draw, not the shader's: a handle is a control (hit, held, with a menu, the same on every screen), and a shader has no text. The shader still draws what they mean from the same parameters, and.handletells it which is held. The tokens are views of their own with a drag each, in the window's coordinates since a token moves as it is dragged. A label is a box of the room it has, placed:Screen's own labels are padded text in its stack, and one given less room than its text needs made the screen six points wider on every layout pass, without end, which a screen's own print never asks for and a panel's file could. No equaliser is built on them yet: Codon's EQ is still its two-band screen. Dragging a handle, choosing from its menu and the print are tested in the software renderer; not on a page or natively. - Not done yet: compressor and distortion want a level, not a spectrum, and the output's scope a trigger; no bundled program carries a shader; a shader's mistake is underlined in its own file and said at the foot, not under the
display.shaderthat names it inpanel.ui; nobody has looked at any of it on a machine with no GPU, where the pacing is by the clock's millisecond.
A pattern's rows are places in the chord, and wrap as Serum 2's do (November 2026)#
The arp's pattern screen named its rows 0, +1, +2, which reads as intervals, and with one key held each row did sound an octave above the last: so "are the rows octaves, or scale tones?" was a fair question, and neither was the intent. A row is a place among the held notes. The screen says so now (1, 2, 3 with no key held; the note each row plays while keys are held), and the question was taken to Serum 2 itself: its user guide, its twelve factory arp patterns, the 626 factory presets, and the plugin's own row-to-note function read from its machine code (docs/notes/arp.md, "What Serum 2 does with a row").
Three things were not as Serum does them, all in what an imported preset plays:
- The wrap's range. A row past the held keys is transposed by the wrap's pitch
floor(row / n) rem (range + 1)times, and the range is 0 unless a pattern sets it: no transposition. The arp took a range of 0 for no limit, so every row past the chord climbed an octave, and a preset like Harmonic Twist, whose rows run to 12 over one key and mean one note, ran up twelve octaves. The engine's rule is Serum's now (row_pitch), the language'swrapRangesays so, the program's WRAPS knob (it read FOLD) is that range, and 64 of the arpeggiator's 290 recorded scenarios were recorded again by the engine itself, by a test kept for the purpose (records_what_this_arpeggiator_plays). - Row −26. It was read as "every held note at once", a guess from its 204 notes in the factory presets. It is the strum lane: each event has a
strumTypeand no note. Read as a chord it played a whole chord over the notes it only staggers. It is left out, and the import says its strums are not played. - The wrap's modes are Normal, Phantom and Muted (the import compared against a mode named Wrap, which is none of them). Phantom and Muted still play as Normal, and are said; what each does is in the note for whoever builds them.
The arp plays Serum 2's three wraps, its strums and its own defaults (November 2026)#
The check above left three things unplayed (the Phantom and Muted wraps, the strum lane) and two unchecked (the order the held keys are counted in, a row of 48 or more). All five are settled, from more of the plugin's code: the function that plays a pattern's event, the one that plays a note, the list of held keys, and the table of its parameters' ranges and defaults (docs/notes/arp.md, "What Serum 2 does with a row").
- The two questions. The held keys are sorted by pitch, lowest first, for every shape but Played, so a pattern's rows count from the lowest key, as the arp's did. And a row never reaches 48: it is held to −24 … 23 once the offset is added, before it is looked up. The import holds a preset's rows to the same.
- The wraps. The arp has a
wrap(ARP_WRAPS: around, keyboard, silent; Serum's Normal, Phantom and Muted) and the note a keyboard wrap counts from (wrapFrom, Serum's phantom note, 60 unless set). Keyboard: the rows run over the held notes' pitch classes in every octave from that note, so the pattern stays at one place on the keyboard whichever octave is held. Silent: a row that is not one of the held notes plays nothing. Codon's PATTERN plate has them as ROWS and FROM. - Strums. A pattern has strums, which are notes whose row is
strumUporstrumDown(PATTERN_ROWS, besidechord): for as long as one lasts, the notes that start together start one after another, lowest or highest first, a quarter of the strum's length times its speed apart. The arp keeps the late ones in a list of its own, a block ends at the next of them, and the pattern screen has two rows for them. A packed note's seventh number, which said whether its row is the chord, is its kind (0 … 3). - What else the code said, and the arp does now. A Chord step is the held notes from the row's up and the ones below it an octave higher, each the transpose shift further for its place (it was rows r … r + n − 1 through the wrap, which since the range's fix did not lift the lower ones at all). A note's velocity spread moves its velocity up or down (it only took away). The arp's transpose is read (
pitch, on every note; two factory presets set it). The accent lane (row −25) is in the notes' velocities. A note plays at twice its velocity lane times its key's velocity, so a pattern follows the keys' velocities, where it played every note at its lane's alone. - The defaults. Where a preset keeps no value the import took the gate for 50 %, the transpose shift for 12, the velocity target for 127 and the retrigger rate's sixth length for a bar. The plugin's table says 100 %, 0, 1, and fifteen lengths from 1/16 of a bar to 4 bars with the sixth half a bar and the default a whole one. Codon's own shift starts at 0 too.
The arpeggiator's recorded scenarios were recorded again where a voiced chord or a spread is played (41 of 290; with those two put back as they were, only the two that load a note of kind 2 or 3 differ). The engine's recorded digests of decoded programs are as they were: a program without the new settings digests as it did.
Left, and said in the gaps: the velocity lane's decay as Serum eases it (a straight line over time, to the target and held there; here by steps), the step actions that play only new notes, and the octave and semitone lanes no factory note sets.
The arp's last four: the velocity lane, new keys, a note's own jumps, three more routes (November 2026)#
What the entry above left for later, done, again from the plugin's code (docs/notes/arp.md, "What Serum 2 does with a row").
- The velocity lane. Serum gives each key an age (samples since it went down, or since a retrigger with the lane's own RETRIG) and moves a note's velocity to the target by age over decay: a straight line, then the target for good. The arp eased by e^(−steps/decay) from the run's first step, which is neither the shape nor the clock, and with no decay not at all, where Serum is at the target at once (Pacific Rain, quiet from its first note).
decayis seconds now, each key's own, withdecayRetrigger; the arp counts them on a clock of its own from the beats and the tempo the machine gives it (tempo), so a seek does not move a velocity. - New Only, Chord (new). A list of the keys that went down at this very tick, emptied when the tick ends: a note plays those alone, and nothing where there are none.
stepNew: a note's pool is the keys that went down at its own beat. - A note's own jumps. The lanes no factory note sets: an octave jump (a chance, and how many octaves a draw may go either way) and a transposition (a chance, and semitones). A pattern's note has
octaves,octavesChance,transposeandtransposeChance; a note without them is written, packed and digested as it was (a machine takes them after the notes, four numbers each, where any note has one). - Routes to the arp's chance, velocity target and phantom note, which four factory presets have: the three parameters are modulatable, the note along its knob.
24 of the arpeggiator's recorded scenarios were recorded again, the ones with a velocity decay (with the old easing put back, none differ), and one parity case (arp, which sets one).
The arp, checked a third time against Serum 2's code (November 2026)#
With everything played, the claims the notes still marked as guesses or inferences were each looked up in the plugin (docs/notes/arp.md, "What Serum 2 does with a row"). Confirmed as they stood: the velocity lane's decay is seconds (its divisor is the sample rate), the retrigger rate's fifteen lengths are bars of four beats, an arp's synced rate is step 15 + round(26 v) of the note lengths, and its module is Arp in a route. Not as they stood, and changed:
- A Pattern's rate is a clip's, step round(42 v), not an arp's. The two agree at the middle of the knob and at most places a preset sets it, and not with DOT or TRIP on: 303 Die Treppe and Harmonic Twist played a third too fast.
- A rate free of the tempo played as a sixteenth, said. Serum has two laws for it, a step's time for the shapes (a second at the bottom of the knob, a tenth of a millisecond at the top) and 440 × v⁴ beats a second for a pattern. The arp takes
hertz, steps a second whatever the tempo, and Codon's program keeps Serum's knob (arp.free) and works both laws out in its own text. - A key down starts the arp over only with NOTE. Without it, which is how 26 of the 33 factory arps are, the pattern goes on with the transport and the keys only say what sounds; the arp started over at the first key every time.
retriggeris.first,.everyor.never, and never puts the run on the transport's grid, counted from beat 0. - Repeats count an order's rounds times its range and one more, and a pattern's rounds alone (they counted the transposition walk's own period for both).
- A route's reach is the whole knob in Serum, for every parameter of the arp. The gate and the range took a route in their own units, which was half and an eighth as far; they are along their knobs now.
- The random playback modes jump by their TIME, a beat unless set, where the walk's cell was always a step.
Eight of the arpeggiator's recorded scenarios (the ones with repeats) were recorded again; with the old count put back none differ. Not traced, and said in the note: which velocity a route from Velocity into the arp reads, and the launch quantization.
Serum 2's swing in the arp; its launch quantize; what is left (November 2026)#
The three things the last entry left untraced. Two are read from the plugin now (docs/notes/arp.md, "What Serum 2 does with a row").
- Swing. Serum does not swing an arp by its steps: it moves every position the arp plays within a window of the transport, two of the swing division's notes long, whose first half takes the swing's share. So the arp has the transport's swing beside its own (
swingShare,swingBeats;swingstays Sylenth1's), a pattern is swung as an order is, and the import reads the global swing, which five factory arps set. None of the recorded scenarios moved. - Launch quantize is when the arp starts after it is switched on or its slot changes, the next multiple of a length on the transport. A key has no part in it and nothing plays it.
- Which velocity a route from Velocity into the arp reads is still not known. The matrix's audio path was not followed that far, and the demo takes no routes from a host, so the measuring host cannot ask it either; a licensed copy would say in a minute.
Serum 2 played under Wine: the arp's velocity source, and an order's steps on the grid (November 2026)#
The last thing the arp's notes left untraced, which velocity a route from Velocity into the arp reads, could not be read out of the plugin's code, and the demo takes no preset, so it was measured: the demo run under Wine by the measuring host (tools/vst3-harness), its editor open, a route set by hand in its matrix and the result rendered and read off the audio (docs/notes/arp.md, "Measured").
The host had to become more of a host for the editor to open. It "stopped Wine" before for two reasons, neither Wine's: the host had not initialised COM on its thread, so the plugin's image loader was null (it reads its skin through WIC and does not check), and it gave the editor no frame and no size, so the editor's window was 0 by 0. With
OleInitialize, anIPlugFrameandonSize, Serum 2's editor draws under Wine 9 on a virtual display (software rendering; its menus are Windows' own, so they can be clicked by their places). Alivecommand keeps the editor open and the processor running and takes renders by file, since what is set by hand lasts only as long as the process. The harness keeps what ran it, so that it runs again from an empty machine:setup.sh(Wine, the compiler, the display and its tools),live.sh(the editor, the clicks, the renders),pitches.py(the notes heard) and, for Serum 2,serum2/(its install from the installer, where its editor's controls are, and the velocity measurement as a script, which gives the same notes from a fresh prefix in under three minutes).The velocity is the arp's own last note's: the note as the arp sent it, a step late, kept after it ends. That is what the program's
velocityin the master stage already is, so nothing changed; the same experiment played here gives the same answers.The swing, read from the code last time, measures as read.
An order's steps are the transport's. Not looked for, and found on the way: with NOTE on, an order (Up, Down …) does not start at the key as a pattern does. Its steps stay on the transport's grid, a key between two steps sounds at the next, and the order starts from its first note at a key with none held whether NOTE is on or not. The arp has
onGridfor that (a run a key starts waits for the grid; an order's only), the Serum 2 program sets it, and its import reads an order without NOTE as.firstwhere it read.never: 26 of the 33 factory arps are without NOTE, and the orders among them began wherever the transport's count put them. A pattern is as it was read: from the key with NOTE, with the transport without.An order keeps its place as the held notes change. Heard beside the last: a key that joins is played in its turn, and with a key let go a place past the notes left goes back to the first. The arp counted its steps and took the count's remainder by however many notes were held now, so a change of the held notes (or of the octaves) threw the order to another place; it keeps its place in the cycle and its rounds now, for every program.
onGrid changed none of the arpeggiator's recorded scenarios (none sets it); the order's place changed 65 of the 290, the ones where the held notes or the octaves change while an order runs, which were recorded again, with the parity fixtures.
The arp's key zone; what the launch quantize is (November 2026)#
Asked for the launch quantize, the plugin was measured again (the measuring host's render takes a parameter change at a time and a place for the transport to start from now). The launch quantize turned out to be nothing a single arp does: it is when a slot starts once it is launched, by its play button or a key of the arp's own keyboard, and a preset has twelve slots of which this plays the active one. Measured on the way, and said in docs/notes/arp.md ("Measured"): an order's grid is the transport's own wherever the transport started; an arp switched on under held keys leaves them sounding.
What a single arp does have that was missing is its key zone: keys outside it play as themselves, or folded are taken for keys of the zone by its size. The arp has keyLow, keyHigh and keyFold, the Serum 2 program has them on its panel and its import reads them. Five factory arps set a zone that matters, Breakwave's the lowest octave alone, which until now arpeggiated every key. None of the arpeggiator's recorded scenarios differ.
What is still not here is listed in the note ("What Serum 2's arp has that is not here"): the other eleven slots and their launching, and beside the arp the clip player, which 83 factory presets have on.
The in-memory renderer and the shader package are published (December 2026)#
@swiftbrowser/raster joins the release (.github/workflows/publish.yml), so a repository other than this one can draw an app with no browser, as Codon's screenshot Worker does: the run builds the Rust rasterizer for WebAssembly, the package's bundles and its declarations, runs its tests on them and checks what is packed. @swiftbrowser/shader joins it too (its compiler, ShaderView and command; its Metal view was in @swiftbrowser/native already, and native init --with shader names the package), as an optional package beside @swiftbrowser/code.
The renderer does not depend on the shader package all the same. Its bundles already carried the code of it they draw a ShaderView with, and a host that only draws (a Worker) should not be asked for a React package's peers: so it is a development dependency, and the one module of it the declarations name is declared beside them (packages/raster/scripts/declarations.mjs, which also refuses a declaration that names any package the manifest does not depend on). Two more things stood in the renderer's way: its fonts could not be imported by name (exports names each, ./fonts/*), and the session script of the screenshot binary, ten megabytes of icons for a binary npm does not carry, is left out of the package.
What a second screenshot host would have written again is in the package: @swiftbrowser/raster/headless is the count of what an app has asked the event loop for and the wait for it to be done drawing (settle), taken from codon-site/apps/shots (its prelude.ts and the loop of its render.ts), which now uses it; the Worker draws the synth's own programs in workerd as before, to the byte. The session answers measureText, for a host whose app is in a sandbox and asks it.
@swiftbrowser/dsp stays unpublished, and now cannot be published by a slip: its manifest is private, which npm refuses, and scripts/release-packages.mjs stops a release, before anything is built, that names it, that publishes a package depending on it (or on any package of this repository the release leaves out), or that finds it no longer private. The first publish of a new package name needs the NPM_TOKEN secret: npm's trusted publishing is set on a package that exists.
A scroll request waits for room; a reader's content waits for the reader's size (December 2026)#
A carousel in NoyaOS's Store opened a picture short of the one tapped. It was a horizontal ScrollView bound to the tapped picture with scrollPosition, inside a GeometryReader, and two things here made that go wrong.
- A scroll request was carried out against a layout with no room. A
scrollTo(and an offset by point) ran once, after the pass that brought it. In a pass that laid its scroll view out at no width the offset was worked out among pages of no width, and stayed when the view got its size. The web renderer and the in-memory one now keep a command while a scroll view it would move shows nothing along the axis, and carry it out after the first pass that gives the view room (without animation; a newer command for the same element or the element's removal drops it). A view in no room reports no position. - A reader's content ran before the reader was measured. The size comes from the renderer after layout, so the content was made once at zero size and again with the real one. Everything the content did once with the first size stayed: the scroll position above, a value kept in state, an animation's distance (the reason
onAppearalready waited forlaidout). SwiftUI never does this: a reader's content runs with the size the reader was given. Now the pass that makes a reader makes it empty (it fills its proposal whatever is inside), and its content is made in the pass that renders its firstgeometryevent: with that size, zero included when that is what was measured.@swiftbrowser/reactdoes so for every host, as itsCanvasandonGeometryChangealready did; the Swift core does for a host that says it lays out (SB_LAIDOUT=1, or alaidoutheard), and a headless run, which has no size to give, makes the content at once at zero size as before. The shim'sonGeometryChangelikewise runs nothing before its view's first report: the one-value form's first value is the measured one, and the two-value form still hears it as a change from what no size makes.
What still starts from a zero size: a visualEffect's closure and an anchor preference's value, which are values the page draws or the app reads again, not actions taken once.