About this
Most game engines allow you to set “loop points” on audio clips. This lets you have a piece of music where an intro section seamlessly leads into a looping main melody. However, Resonite doesn't have this feature, so I had to figure out a workaround.
Since it took a nonzero amount of effort, I decided to publish this system for anyone to use, under the usual CC BY-NC-SA license.
Downloads
Resonite package (v1)
…or find it in my public folder
Setting it up
First, you'll need to create two separate audio files. One will contain the song's opening segment, plus a few extra seconds, and the other will just be the looping segment on its own. Make a note of exactly where the loop starts, down to the millisecond.
Next, import those clips into Resonite, and spawn in the Custom Audio Looper object. Open it in the inspector, and find
the slot named Intro playback. Drop the intro clip into its AudioClipPlayer's
Clip field. Then do the same for Loop playback.
Finally, go to the var LoopStart slot, and set its value to the loop point you found earlier.
Test your settings using the demo UI. If it works, great! You can now grab the Kaizo's Custom Audio Looper slot from the inspector and drop it into whatever you're making.
Controlling playback
The Custom Audio Looper is controlled through dynamic impulses:
PlayFromStart: Starts playback from the beginning.Stop: Stops playback completely.PlayFromPosition<float>: Jumps to the given point in time and begins playback. The input time value is in seconds, relative to the start of the loop. To jump to a point before the loop, use a negative value.
Additionally, these slots contain useful fields (“var” denotes a writable value, “out” denotes a read-only value):
var LoopStart: Loop start point in seconds. (You probably won't need to modify this outside of setup.)var Volume: Volume level for audio output.out Position: Current playback position, as a time in seconds, relative to the loop start point. Negative values refer to points within the intro section.out LoopLength: Length of the loop clip in seconds.
To pause, store the current value of Position somewhere before calling Stop, then use PlayFromPosition to resume.
Tutorial: Creating loop clips in Audacity
I'll write this later, probably. For now, here are some pointers:
- You'll have to find the rough loop points by ear, but afterwards, you can usually dial in the exact position from the shape of the waveform.
- Use label tracks to create markers that your cursor will snap to.
- Drag on the time ruler (above the audio clips) to define a loop region, then hit Play to see if it sounds correct.