Skip to content

0.27.0

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 20 Nov 04:26
1196bf6

Migration guide (0.26.0 → 0.27.0)

This release has two breaking changes. As with every 0.x release, it is a pre-release.

1. Minimum Zig version is now 0.17.1

minimum_zig_version is 0.17.1, and lightmix now depends on zigggwavvv 3.0.0. Zig 0.16.x can no longer build lightmix.

After updating your toolchain, update the dependency:

zig fetch --save https://github.com/haruki7049/lightmix/archive/refs/tags/0.27.0.tar.gz

optimize option of addWave / addPlay

The type of optimize changed from std.builtin.OptimizeMode to std.lang.Optimize, and the tag names changed with it:

0.26.0 0.27.0
.Debug .debug
.ReleaseSafe .safe
.ReleaseFast .fast
.ReleaseSmall .small

The defaults are unchanged in meaning (CreateWaveOptions.optimize = .fast, PlayOptions.optimize = .debug). If you pass the result of b.standardOptimizeOption(.{}), no change is needed. Only a literal tag in your build.zig must be renamed.

2. Composer(T) is removed

lightmix.Composer, including Composer(T).finalize and Composer(T).render_stream, is removed without a deprecation period. Wave(T) is unchanged.

You have two options:

  • Stay on 0.26.0 if you still need Composer.
  • Arrange the waves yourself. Composer.finalize allocated a zero-filled buffer that ends where the latest wave ends, then mixed each wave in at its start_point. The same can be done with the public API of Wave(T):
const std = @import("std");
const lightmix = @import("lightmix");
const Wave = lightmix.Wave;

const Placed = struct { wave: Wave(f64), start_point: usize };

/// Caller owns the returned wave and must call `deinit()` on it.
/// `placed` must not be empty, and every wave must share the same sample rate and channel count.
fn arrange(allocator: std.mem.Allocator, placed: []const Placed) !Wave(f64) {
    var end: usize = 0;
    for (placed) |p| end = @max(end, p.start_point + p.wave.samples.len);

    const samples = try allocator.alloc(f64, end);
    errdefer allocator.free(samples);
    @memset(samples, 0.0);

    for (placed) |p| {
        for (p.wave.samples, 0..) |s, i| {
            samples[p.start_point + i] = Wave(f64).default_mixing_expression(samples[p.start_point + i], s);
        }
    }

    return .{
        .samples = samples,
        .allocator = allocator,
        .sample_rate = placed[0].wave.sample_rate,
        .channels = placed[0].wave.channels,
    };
}
  • start_point counts interleaved samples, not frames. For a multi-channel wave it must be a multiple of the channel count (for stereo, frame n is start_point = 2 * n).
  • Use Wave(f64).saturating_mixing_expression instead of default_mixing_expression to clamp the result to [-1.0, 1.0].
  • Replace f64 with the sample type you use.
  • For two waves with identical length, sample rate and channel count, Wave(T).mix is still available.

The examples/ directories were renumbered: 04-composer was removed, 05-practical-examples became 04-practical-examples, and 06-advanced became 05-advanced. Update any links to these paths.

What's Changed

  • docs: fix the findings of a fresh-eyes documentation audit by @haruki7049 in #401
  • docs: fix inaccurate error docs and add dependency setup to the README by @haruki7049 in #404
  • docs: describe the public API in the module docs by @haruki7049 in #405
  • test(play): run playback tests on CI with virtual audio devices by @haruki7049 in #407
  • docs: add push, issue-number and session-link rules for agents by @haruki7049 in #409
  • ci(dependabot): Create .github/dependabot.yml by @haruki7049 in #414
  • ci(dependabot): Create dependabot-auto-merge.yml workflow by @haruki7049 in #423
  • chore: bump actions/stale from 9.0.0 to 11.0.0 by @dependabot[bot] in #418
  • chore: bump ytanikin/pr-conventional-commits from 1.4.0 to 1.5.2 by @dependabot[bot] in #415
  • chore: bump actions/configure-pages from 5.0.0 to 6.0.0 by @dependabot[bot] in #416
  • chore: bump cachix/install-nix-action from 31.6.0 to 31.11.3 by @dependabot[bot] in #417
  • chore: bump actions/deploy-pages from 4.0.5 to 5.0.1 by @dependabot[bot] in #419
  • chore: bump flake-parts from 31729ca to ea2630b by @dependabot[bot] in #422
  • chore: bump treefmt-nix from 27b3b12 to 0d6d739 by @dependabot[bot] in #421
  • chore: bump nixpkgs from c7def04 to 6dadaf4 by @dependabot[bot] in #420
  • ci(GitHub Actions): Create actions.lock via gh actions-lock by @haruki7049 in #424
  • refactor(build.zig): narrow return error sets of addWave and addPlay by @haruki7049 in #425
  • chore: bump nixpkgs from 6dadaf4 to 2074cc6 by @dependabot[bot] in #428
  • chore: bump actions/upload-pages-artifact from 4.0.0 to 5.0.0 by @dependabot[bot] in #427
  • chore: bump cachix/install-nix-action from 31.11.3 to 31.11.5 by @dependabot[bot] in #426
  • feat!: migrate to Zig 0.17.1 and zigggwavvv 3.0.0 by @haruki7049 in #429
  • refactor(composer)!: remove Composer by @haruki7049 in #431
  • docs: register only issues to the GitHub Project by @haruki7049 in #433
  • build(nix): pin ZLS to 0.17 and share the Zig package with treefmt by @haruki7049 in #435
  • feat(lightmix version): Bump up to 0.27.0 by @haruki7049 in #434

New Contributors

Full Changelog: 0.26.0...0.27.0