Patch0x08 Logoassets

PatchAudio: Region Loop Tool

v1.0.0 · Updated 11/3/2025

Overview

PatchAudio: Region Loop Tool is a pure Unity C# tool for handling music with multiple looping regions (Intro → Loop(s) → Outro).

  • Define regions visually in a RegionDefinition asset.
  • Supports dynamic loop switching, crossfade, and simple API calls.
  • Designed for JRPGs, rhythm games, visual novels, or any project needing structured, dynamic looping.
  • No FMOD, Wwise, or external middleware required.

Features

  • Easy Setup: Create a RegionDefinition asset and set start/end times.
  • Multiple Regions: Intro, any number of Loops (A, B, etc.), optional Outro.
  • Dynamic Loop Switching: Switch to another loop at the next boundary.
  • Simple API:
    • musicPlayer.Play("Intro")
    • musicPlayer.SwitchLoop("Loop B")
    • musicPlayer.End()
    • musicPlayer.Stop()
  • Editor Timeline Preview: Region bars, playback cursor, preview controls.
  • Optional Crossfade on loop transitions.
  • Pure Unity C# – no external dependencies.

Getting Started

  1. Open the demo scene: Assets/PatchAudio/RegionLoopTool/Demo/Scenes/RegionLoopDemo.unity
  2. Select the region definition asset: Assets/PatchAudio/RegionLoopTool/Demo/Data/DemoRegionDefinition.asset
  3. Assign an AudioClip.
  4. Configure region markers (start, end, loop flag, crossfade length).
  5. Enter Play Mode and use the on-screen demo UI or inspector buttons.

Example Region Layout:

RegionStart → EndNotes
Intro0s → 4sPlays once
Loop A4s → 16sDefault loop
Loop B16s → 28sAlternate loop
Outro28s → 32sOne‑shot ending

Demo UI

When you press Play in the demo scene, buttons appear:

ButtonAction
Play IntroPlays Intro then enters Loop A
Loop ASwitch (or stay) to Loop A at next loop boundary
Loop BSwitch to Loop B at next loop boundary
EndPlay Outro when current loop finishes, then stop
StopImmediate stop (no Outro)

(You can also control playback via the RegionMusicPlayer inspector quick buttons.)

Core API Summary

MethodDescription
Play(string regionNameOrIntroAlias)Starts playback; if region is non-looping (e.g. Intro) and a looping region follows, it will continue into the first looping region.
SwitchLoop(string loopRegionName)Queues a switch to another looping region at the next loop wrap.
End()Schedules Outro after the current loop completes, then stops the AudioSource.
Stop()Immediately stops playback.

Region names must match those defined in the RegionDefinition.

Tips for Clean Loops

  • Trim leading/trailing silence in your DAW.
  • Export at 44.1kHz or 48kHz (matches Unity defaults).
  • Ensure loop boundaries align with zero-crossings.
  • Optional: set BPM in the asset (UI hint only).

Key Assets (Demo)

Assets/ PatchAudio/ RegionLoopTool/ Demo/ Scenes/RegionLoopDemo.unity Data/DemoRegionDefinition.asset

License (Summary)

Commercial use inside your game is allowed. Redistribution of the source as a competing standalone tool is not permitted.

FAQ (Quick)

Q: Does it support multiple simultaneous music layers? A: Not in this version (single AudioSource).

Q: Can I fade between loops? A: Yes, enable crossfade in region settings.

Q: Do I need Addressables? A: No. Standard AudioClip references are used.

Q: Does it work in builds? A: Yes, fully runtime safe.