Mirror of storytold/craft-libs
  • Rust 98.4%
  • Max 1.3%
  • Python 0.2%
Find a file
Aleksander Helgaker 38740b43a9
craft-audio: core types, WAV/AIFF read and write, peaks, symphonia (#441)
* craft-audio: core types, WAV/AIFF read and write, peaks, symphonia

The new crate without any codec module: what every later codec plugs
into.

- Shared types: `AudioBuffer`, `AudioInfo`, `ChannelLayout`/`Speaker`,
  `AudioError`, `EncodeOptions` (built with `new` and `with_*`),
  `EncodeFormat`, `BitDepth`, `BwfInfo`, `SampleFormat`.
- WAV/BWF/RF64 and AIFF/AIFF-C reading and writing from SoundCraft's
  `soundcraft-audio-io`, kept over EffectCraft's and FilmCraft's
  smaller writers (only it has BWF, dither, any speaker mask and
  streaming without a known length). `encode` and `FileEncoder` behind
  `pcm-encode`; `lossless-encode` and `encode` turn it on.
- `decode`, `probe`, `tracks` and the streaming, seekable `Decoder`
  (feature `decode-native`). The native path reads WAV, AIFF, and PCM in
  MP4/MOV and Matroska through craft-media's demuxers, packet by packet,
  with edit lists and `CodecDelay`/`DiscardPadding` applied.
  `TrackDecoder` decodes PCM; each codec PR adds its codec to it.
- symphonia 0.6 (MPL-2.0, used unmodified) behind the `symphonia`
  feature, part of `decode`: the fallback for every format with no
  native decoder yet. Its size fields are checked before it reads, and
  its panics are caught where they unwind.
- `peaks`: the min/max/RMS pyramid for waveform drawing.

Workspace: craft-media is a workspace dependency without default
features, so an encode-only craft-audio does not build the MP4
demuxer, and `symphonia-bundle-flac` builds without overflow checks in
dev profiles (its 32-bit LPC restore wraps on valid input).

CI: `audio.yml`, with clippy per feature, rustdoc, WASM, MSRV, and the
tests with ffmpeg oracles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-audio: review fixes (CodeRabbit on #441)

- Reading: AIFF that declares frames without an SSND chunk is Malformed; a Matroska PCM track's
  length counts from its first frame; seek targets saturate; an empty FLAC has one track; a
  failed header read is an Io error; deinterleave allocates fallibly; concealed silence is capped
  like a decoded packet, and symphonia's uses the damaged packet's own duration when known.
- Peaks sum squares in f64, so loud float samples give a finite RMS.
- Writing: .aifc maps to AIFF; BWF text is cut at a character boundary; a WAV byte rate past
  32 bits is an error; the FileEncoder docs say nothing may follow the sink's position.
- README: the Limits list says which codecs go through symphonia and which MP4 edit lists apply.
- Tests for each, alias and dither coverage, and a FLAC case in the routing oracle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-audio: review fixes, second round (CodeRabbit on #441)

- Every header read is checked: `Native::open`, `native::tracks` and the no-symphonia error read
  it with `head_checked`. craft-media demuxer errors that are I/O failures (not a file ending
  early) are returned as `AudioError::Io` instead of sending the file to the other path.
- A Matroska track's presented length runs from its first frame plus `CodecDelay` (unclamped,
  in timestamp ticks with the delay rounded to one) to its end.
- symphonia's concealment allocates fallibly, and a damaged first packet is concealed when the
  demuxer gives its duration. `deinterleave` reserves its channel list fallibly too.
- `TrackDecoder::conceal` documents its cap at the decode limit.
- Tests: an I/O failure past the first 64 KiB, codec delay with the first block at -20, 0 and
  50 ms (checked with `probe`), a seek back after an overshoot, and the loud-sample RMS value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-audio: TrackDecoder::conceal returns a Result

Concealment allocates fallibly and fails with TooLarge when the silence would pass the 2^30-sample
decode limit, instead of returning less than the packet's length. The native path, the README,
the packets example and the doc example pass the error on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-audio: review fixes, third round (CodeRabbit on #441)

- Concealed silence is held to the decode limit inside pcm::silence, so symphonia's path checks
  frames × channels too, and symphonia's decoded audio is copied into fallibly allocated planes.
- TrackDecoder::reset forgets the last packet's length.
- Without symphonia, a damaged MP4, Matroska or Ogg file (truncated, invalid, no moov) is
  Malformed instead of Unsupported; a feature the demuxer does not read still names the build.
- Tests: an MP4 with no moov in a native-only build, conceal after a reset and past the limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-audio: review fixes, fourth round (CodeRabbit on #441)

- A file the native demuxers find damaged is Malformed with symphonia too, when symphonia calls
  it unsupported; before, an ftyp-only MP4 was Unsupported in symphonia builds.
- symphonia's decoded blocks are held to the 2^30-sample decode limit before allocating.
- Symph::seek forgets the last packet's length, so a lost packet after a seek is not concealed
  with the length of one before it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-audio: review fixes, fifth round (CodeRabbit on #441)

- The damaged-file test covers Matroska as well as MP4, and fails when either branch of
  native::damage is removed.
- native::damage leaves out Ogg: ogg::open reports no damage (it skips damaged pages and calls a
  file with none it can read not Ogg), and symphonia reports damaged Ogg as malformed itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* craft-audio: run the ffmpeg oracle tests on ubuntu-26.04

ubuntu-latest's apt ships ffmpeg 6.1.1, which writes MP2 and E-AC-3 in
Matroska with ends a few milliseconds early, so the routing tests on the
later codec PRs cannot pass on it. ubuntu-26.04 ships ffmpeg 8.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 10:25:57 +01:00
.github craft-audio: core types, WAV/AIFF read and write, peaks, symphonia (#441) 2026-11-04 10:25:57 +01:00
crates craft-audio: core types, WAV/AIFF read and write, peaks, symphonia (#441) 2026-11-04 10:25:57 +01:00
docs keymap: test the UK ISO key; the Turkish Q item applies to Windows and Linux 2026-11-01 03:31:51 +00:00
licenses craft-ui: interface fonts, text direction, IME composer, localized widgets and screen testing 2026-10-25 19:08:59 +00:00
scripts craft-crw: Canon CRW (CIFF) raw decoder, moved from LightCraft with its clean-room record 2026-10-26 08:20:01 -06:00
vendor Merge pull request #532 from storytold/fix/sec-color-space-depth 2026-11-02 22:40:31 -05:00
.coderabbit.yaml Skip CodeRabbit reviews on Dependabot PRs (#195) 2026-10-20 11:41:43 -04:00
.gitattributes plate-test: keep short arrays and objects on one line in the scene files 2026-10-20 03:51:04 +00:00
.gitignore fix(hayro-syntax): read full /W[0] xref entry type width (#241) 2026-10-23 11:14:16 -04:00
AGENTS.md docs: tidy AGENTS.md and clean-room doc 2026-10-31 04:17:35 +00:00
ATTRIBUTION.md CP1.2: English without Language data uses the whole Moby list and every installed English dictionary 2026-11-01 18:37:02 +00:00
Cargo.lock craft-audio: core types, WAV/AIFF read and write, peaks, symphonia (#441) 2026-11-04 10:25:57 +01:00
Cargo.toml craft-audio: core types, WAV/AIFF read and write, peaks, symphonia (#441) 2026-11-04 10:25:57 +01:00
CLAUDE.md Enforce Rust coding standards via Clippy (#372) 2026-10-27 13:49:38 -04:00
clippy.toml Enforce Rust coding standards via Clippy (#372) 2026-10-27 13:49:38 -04:00
LICENSE-APACHE Rust workspace and MIT OR Apache-2.0 license (#1) 2026-10-09 12:02:40 -04:00
LICENSE-MIT Rust workspace and MIT OR Apache-2.0 license (#1) 2026-10-09 12:02:40 -04:00
NOTICE CP6.13: craft-libs#482/#485/#488 review — NOTICE carries the embedded Portuguese patterns' BSD notice; README: the usage example defines text, the eight-candidate limit, what the default build embeds; en_words writes under crates/proof 2026-11-02 00:27:37 +00:00
README.md craft-audio: core types, WAV/AIFF read and write, peaks, symphonia (#441) 2026-11-04 10:25:57 +01:00
rustfmt.toml Rust workspace and MIT OR Apache-2.0 license (#1) 2026-10-09 12:02:40 -04:00
sonar-project.properties Share browser download resource ownership (#226) 2026-10-22 20:49:41 +02:00

Craft App Libraries

Scanned by SonarCloud

This repo contains libraries used by the various Craft Apps. It's a Rust monorepo workspace, and the libraries can be included by any Craft Apps that need them.

In the future this may grow to include non-Rust library code.

If any libraries grow beyond Craft App usage, eg. RAW format support, they may be promoted out and into their own libraries for the broader ecosystem to take advantage of.

Layout

A Cargo workspace (edition 2024, resolver 3). Each library is a crate under crates/<name>, named craft-<name>, with version, edition, license and repository inherited from the workspace (license.workspace = true, and so on) and [lints] workspace = true. Register each crate in [workspace.dependencies] in the root Cargo.toml.

Apps depend on a crate by git:

craft-<name> = { git = "https://github.com/storytold/craft-libs", rev = "<commit>" }

Libraries

  • craft-platform: optional native dialog lifecycle, Linux/BSD desktop appearance observation and browser download ownership; application policy stays in the apps.

  • craft-ai-core: the data model and contract for AI in the Craft Apps (connections, models, tools, requests, jobs, consent, history, route spec). Pure, no I/O, wasm-safe. Contract in docs/ai-shared-layer.md.

  • craft-pdf: independently optional PDF parsing, interpretation, rasterization and guarded authoring. Apps retain layout, fonts, editing and export policy; writer-only consumers do not enable the shared reader.

  • craft-atomic: Crash-safe atomic file writing and replacement with same-directory staging, directory fsync, Apple F_FULLFSYNC fallback, transient lock backoff, and fault injection for the Craft suite.

  • craft-cms: pure-Rust ICC v2/v4 colour management: profile parsing and writing, transforms, rendering intents, black point compensation, soft proofing, gamut checks, 3D LUTs and built-in profiles (sRGB, Display P3, synthetic coated CMYK and others).

  • craft-crw: clean-room Canon CRW (CIFF) raw decoder, from LightCraft: the heap container, the entropy coding derived by black-box analysis (frozen code tables), sensor black and white levels and as-shot white balance. The complete derivation record (plan, sources log, scripts, verification) is in crates/crw/clean-room/. Colour stays in each app.

  • craft-dialogs: native file and message dialogs that never block the event loop: queued requests shown at the end of the frame and answered on a later frame, free-standing Open and Folder panels and Save sheets on macOS, case-insensitive filters. What to do with the answer stays in each app.

  • craft-doc: reads PhotoCraft .pcraft, VectorCraft .vectorcraft and EffectCraft .ecproj documents without the apps: the kind and version, the previews and PDF they carry, and their pages and layers. Rendering and editing stay in each app.

  • craft-docpath: decides whether a path or file: URL stored in a document may be opened. Paths stored in documents are followed only when they are local or on the document's own network share; other network paths, device paths and non-file URLs are refused.

  • craft-ecproj-format: the envelope of EffectCraft .ecproj project files: savedBy, the schema version and its check, and the file object with the project and its saved view as type parameters. The project model stays in EffectCraft.

  • craft-font-catalog: the installed fonts on every platform (font folders, fontconfig and Flatpak host folders, CoreText, DirectWrite, the font store), lookup by family, style, localized, legacy, full and PostScript names, family loads shared between threads, and rescans when fonts are installed or removed.

  • craft-font-manager: Craft Font Manager as a library: search and filters over the Google Fonts index, installed fonts by family, the font store interface, and (egui feature) FontsPanel, the whole interface as one panel for the launcher's Fonts tab and the standalone app.

  • craft-font-store: the suite's font store: the pinned Google Fonts and Noto indexes plus indexes the user adds (never curated), exact lookup by family and style or PostScript name, and installs from each source's URLs (jsDelivr, then raw GitHub) checked by size, sha256 and parsing, with the licence, a manifest, and removal. Off until the user turns downloading on; agents can't.

  • craft-fonts-build: embeds the optional craft-fonts faces from an app's build.rs (CRAFT_FONTS_DIR, CRAFT_FONTS_REQUIRED, script filters) as a table of EmbeddedFaces. No dependencies; the app picks the faces.

  • craft-i18n: translations over the embedded craft-i18n catalogs: lookup with fallback (pt-br → pt → English), plurals, language names, the system locale and a pseudo locale. The catalogs stay a fully optional build input; apps keep tl! and their language setting.

  • craft-jpeg: clean-room decoder for 12-bit and arithmetic-coded JPEG (T.81 SOF0/SOF1 at 12 bits, SOF9, SOF10), from PhotoCraft, and a frame probe for routing. Metadata stays in each app.

  • craft-keymap: keyboard bindings: chords and their text forms, scopes, conflicts, user overrides stored through craft-settings and import of other applications' shortcut sets. Command catalogs, file readers and the shortcut editor UI stay in each app.

  • craft-audio: audio file I/O and codecs (WAV, AIFF), streaming and seeking, and packet decoding for any demuxer. See its README for formats and features.

  • craft-media: bit-level I/O (bitstream), clean-room MP4/MOV (isobmff) and Matroska/WebM (matroska) demuxers and muxers, an Ogg demuxer (ogg), from FilmCraft, and an ISO BMFF box reader. Containers only; codecs are in craft-audio, and video codecs will go in a separate crate.

  • craft-menu: an app's menus as a macOS menu bar: the Mac layout (app menu, Window, Help, system-key clashes), a platform backend trait, and key equivalents fed back to egui as the input egui-winit would have made. Commands and their enabled state stay in each app.

  • craft-pcraft-format: the envelope of PhotoCraft's .pcraft bundle: Manifest<D> with the document as a type parameter, TileRef, the entry paths, the manifest decode limits and the migration runner. The document model stays in PhotoCraft.

  • craft-print: PDF submission to CUPS and Windows, printer discovery, duplex/copies/colour and driver preferences. PDF generation stays in each app.

  • craft-proof: proofing per language (spelling, suggestions, grammar, hyphenation, a Hunspell reader, user words, Language packs). The word lists and patterns are craft-i18n's language-data/, embedded at build time from CRAFT_I18N_DIR: English and the carry-over locales by default, the set CRAFT_PROOF_EMBED names otherwise (en for English only); other languages come from installed Language packs.

  • craft-quit: native macOS quit, egui close handling and an optional app menu. Unsaved-document decisions and save prompts stay in each app.

  • craft-settings: config.toml settings storage for every app: platform folders, portable mode and overrides, atomic saves while running, backup, damaged-file recovery and schema migrations. Policy in docs/settings-storage.md.

  • craft-text: text processing below the composer. Its hyphen module finds hyphenation points, with a bundled US English dictionary and patterns and optional hypher patterns for 47 more languages (one cargo feature each).

  • craft-ui: SVG catalogs, icon buttons, tabs, pane controls, transactional docking, print settings and theme helpers for egui frontends; assets, themes, localization and command handling stay in each app. Requires Rust 1.95 or later.

  • craft-vectorcraft-format: the envelope of VectorCraft's .vectorcraft file: its members, versions, embedded images and the data after the JSON, with the document as a type parameter. The document and its migrations stay in VectorCraft.

  • Shared UI component audit: source inventory, extraction priorities and compatibility boundaries across the Craft suite.

  • Theme infrastructure: eight-app comparison and the small shared widget-state styling boundary.

  • Panel docking: validated panel moves, floating groups, workspace adapters and an optional egui docking surface.

License and credits

craft-libs is dual-licensed under MIT or Apache-2.0, at your option. Copyright (c) 2026 ArtCraft Team and the craft-libs contributors. Required notices are in NOTICE.

Bundled fonts, icons, images and other assets keep their own open licenses; each one is listed with its author, source and license in ATTRIBUTION.md.