Skip to content

Extract the procedural-music engine into a reusable s&box asset/package #3

Description

@Gamah

Package the skafinity / rotaliate procedural-music engine as a standalone s&box asset that other s&box developers can drop into their own games to get endless, deterministic procedural ska/reggae music from a shareable vibe:tag:n seed.

This is the inverse direction of the rest of this repo: skafinity is the web port of the rotaliate-client engine; this issue is about re-extracting that same engine from ../rotaliate-client into a clean, reusable s&box library/asset. The algorithmic source of truth stays the C# in reference/ (and the live rotaliate-client).

Plausibility: ~8/10

The hard part is already done. The generator is effectively a dependency-free library; the only real work is wrapping the playback driver and severing two game-specific hooks. PRNG parity is already pinned and proven (the skafinity web port reproduces it bit-for-bit), so the determinism contract is solid.

Scope

Tier A — generator (drop-in, ~0 effort)

  • MusicGen.cs and VibeCodec.cs import only System.* — no Sandbox/Rotaliate/SoundStream coupling. Lift verbatim into the package.
  • Public API is already library-shaped: GenerateSamples(), the chunked BeginPlan → RenderPitchedRange → FinishMono path, and VibeCodec.Encode/Apply/Fields, all over a plain MusicGen.Config.

Tier B — playback driver (~1–2 days)

Fork MusicController.cs into e.g. SkafinityMusicPlayer : Component and strip the two rotaliate-specific dependencies:

  • PlayerData persistence (~20 call sites: tag, vibe, MusicN, volume, enable) → replace with component [Property] fields + an optional Action<int> onAdvance / persistence callback.
  • LobbyNetworkManager admin-follow (SyncWithAdmin/ApplyFollow/CanFollowAdmin, ~80 lines) → delete, or expose as an optional hook.
  • Keep the s&box SoundStream/SoundHandle/Mixer plumbing, GameTask.RunInThreadAsync worker fan-out, and the [Property] inspector knobs — that plumbing is exactly what makes this an s&box asset rather than the web port. The crossfade/look-ahead logic (PushTransition, FillAhead, WriteSongBody) is self-contained and reusable verbatim.

Deliverables

  • Package MusicGen + VibeCodec unchanged.
  • SkafinityMusicPlayer : Component with the two hooks abstracted out.
  • Minimal example scene + inspector-authorable vibe knobs.
  • (optional) Port the MusicScreen.razor vibe-editor as a sample UI.
  • (optional) A parity test asserting the packaged engine still matches the captured golden vectors.

Open question — monetization (resolve before publishing)

Whether you can charge for this as an s&box asset is unconfirmed. s&box (Facepunch) distributes via its own registry (sbox.game / historically asset.party) and has leaned toward free community sharing with game-centric payouts rather than a paid per-asset store, but its commercial terms have shifted during development. Verify before relying on it:

  • sbox.game and the official s&box docs/wiki publishing + licensing pages
  • Facepunch's ToS / monetization & payout policy
  • s&box Discord / forums for the current practical answer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions