How to make game music loop seamlessly for free
Short answer: a loop that does not click is a clip cut to a whole number of bars, with the music that would have come next blended into the start. Get a track from a free plan on Stable Audio, Suno or Mubert, run the free script below to cut and blend it, then switch on Loop in Godot or Unity. Check the license first: of those three, only Stable Audio's official licensing article says free-plan tracks can go in a game you sell.
Facts checked November 4, 2026 on the official pages: Stability AI's Stable Audio knowledge base, Suno's help center, Mubert's pricing page, Kenney's support page, the Godot 4.7 docs and the Unity 6 scripting reference. Free plans and terms change, so check again before you rely on a limit. The script was tested on Python 3.13.5 with NumPy 2.5.4 and FFmpeg 7.1.5, and the Ogg file it produced was played with looping on in Godot 4.7 running headless. We did not test the Unity step, and we could not listen to the result, so play your loop for a minute and listen at the seam.
Why game music clicks when it loops, in 30 seconds
- A click: the file ends at one point on the sound wave and starts at another. The jump between them is a pop.
- A stumble: the file is not cut on the beat, so after the repeat the rhythm is shifted. Music is built in bars (4 beats each in most game tunes), so a loop must be a whole number of bars.
- A dead stop: AI tracks end with an outro or a fading tail. Looped as is, the music dies and restarts.
- The fix: cut a whole number of bars from the middle of the track, then blend the audio that would have come after the cut into the first moments of the loop. The last sample then flows into the first.
Step 1: Get a track and check its license
Ask the generator for steady, repeating background music with no big intro or ending. Pads, ambient and simple loops are easier to cut than music with changing sections, though we have not measured that. These are the free options we checked:
| Source | What is free | Download | Game you sell? |
|---|---|---|---|
| Stable Audio | 50 free credits once, when you create an account, per Stability's knowledge base. Its pricing page showed no plan cards when we looked, so check the live page. Paid plans start at $12 a month for 660 credits. | Yes, as many downloads as you like, per Stability's API docs. | Stability's licensing article says commercial use is permitted on every plan, including Free, and names video games. It is subject to the Terms of Service, which we could not read. |
| Suno | 50 credits that renew daily, about 10 songs a day, per its help center. | The free plan help article lists sharing by link, and "download your tracks for use outside of Suno" is listed under paid subscriptions. | No. Free plan songs are for personal, non-commercial use and cannot be monetized. Subscribing later does not add a license to old songs by default. |
| Mubert | Free plan: 25 tracks a month, 5 downloads a month, MP3 only, fixed duration, audible watermark. | MP3 with a watermark on Free. | No. Free is non-commercial and needs attribution. "Apps, games and services" is listed only on Business, shown at $199 a month ($149.29 a month on its annual toggle). |
| Kenney (not AI) | Free audio packs. | Yes. | Yes. Kenney says all assets on its asset pages are CC0, with no attribution needed. |
So for a game you plan to sell, the honest free choices are Stable Audio (read its Terms of Service first) or a CC0 pack from Kenney. Use Suno and Mubert free plans to practice and to make prototype music. If you want a wider look at AI audio tools, read Best free AI tools for game sound effects and music. If AI-made audio goes in a shipped game, also read Can I sell a game made with AI art?
Step 2: Find the tempo and pick a loop length
- BPM (beats per minute): press play, count the beats in 30 seconds and double it. If your tool states the tempo, use that.
- Bars: a bar is usually 4 beats. Pick 4, 8 or 16 bars. At 120 BPM, 8 bars last exactly 16 seconds.
- Start time: choose a spot after the intro where a new bar begins. If your loop sounds off the beat, move the start and try again. A track whose tempo drifts will never cut cleanly.
Step 3: Cut and blend the loop (free script)
Save this as make_loop.py. It reads a 16-bit WAV, cuts exactly the number of bars you ask for, then uses an equal power crossfade to blend the music that follows the cut into the first moments of the loop, so the last sample leads into the first. It prints how big the jump at the loop point is, compared with a normal step between samples.
# Make a music clip loop without a click or a jump at the loop point.
# Run: python make_loop.py song.wav loop.wav --bpm 120 --bars 8
# Needs numpy: python -m pip install numpy (reads and writes 16-bit PCM WAV)
import argparse, wave
import numpy as np
p = argparse.ArgumentParser()
p.add_argument("src")
p.add_argument("out")
p.add_argument("--bpm", type=float, required=True, help="tempo of the track")
p.add_argument("--bars", type=int, required=True, help="how many bars the loop should last")
p.add_argument("--beats-per-bar", type=int, default=4)
p.add_argument("--start", type=float, default=0.0, help="seconds into the file where the loop begins")
p.add_argument("--fade", type=float, default=0.5, help="seconds of overlap used to blend the end into the start")
args = p.parse_args()
with wave.open(args.src, "rb") as w:
if w.getsampwidth() != 2:
raise SystemExit("Need a 16-bit WAV. Convert first: ffmpeg -i song.mp3 -c:a pcm_s16le song.wav")
ch, sr = w.getnchannels(), w.getframerate()
data = np.frombuffer(w.readframes(w.getnframes()), dtype=np.int16).reshape(-1, ch).astype(np.float64)
loop_len = round(args.bars * args.beats_per_bar * 60.0 / args.bpm * sr) # exact length of the loop
fade = round(args.fade * sr)
begin = round(args.start * sr)
if begin + loop_len + fade > len(data):
raise SystemExit(f"Not enough audio: need {(begin + loop_len + fade) / sr:.2f} s, file has {len(data) / sr:.2f} s. Use fewer bars or a smaller --fade.")
seg = data[begin:begin + loop_len + fade]
body = seg[:loop_len].copy() # what the player will loop
after = seg[loop_len:] # the music that would have come next
# Equal power crossfade: the first --fade seconds become "the end of the music fading out
# while the start fades in", so the last sample of the loop leads straight into the first.
t = np.linspace(0.0, np.pi / 2, fade).reshape(-1, 1)
body[:fade] = body[:fade] * np.sin(t) + after * np.cos(t)
def jump(x): # size of the step across the loop point, compared with a normal step
step = np.abs(np.diff(x, axis=0)).mean()
return np.abs(x[0] - x[-1]).max() / max(step, 1.0)
print(f"Loop: {args.bars} bars at {args.bpm:g} BPM = {loop_len / sr:.3f} s ({loop_len} samples at {sr} Hz)")
print(f"Seam jump before: {jump(data[begin:begin + loop_len]):.1f}x a normal step, after: {jump(body):.1f}x")
out = np.clip(np.round(body), -32768, 32767).astype(np.int16)
with wave.open(args.out, "wb") as w:
w.setnchannels(ch); w.setsampwidth(2); w.setframerate(sr); w.writeframes(out.tobytes())
print("Saved", args.out) Run these four commands. The first installs NumPy, the second turns an MP3 into a WAV, the third makes the loop, and the fourth makes a small Ogg Vorbis file for music:
python -m pip install numpy
ffmpeg -i song.mp3 -c:a pcm_s16le song.wav
python make_loop.py song.wav loop.wav --bpm 120 --bars 8
ffmpeg -i loop.wav -c:a libvorbis -q:a 5 loop.ogg The script prints the loop length and the seam check:
Loop: 8 bars at 120 BPM = 16.000 s (705600 samples at 44100 Hz)
Seam jump before: 19.3x a normal step, after: 0.3x
Saved loop.wav Tested November 4, 2026 on Python 3.13.5, NumPy 2.5.4 and FFmpeg 7.1.5, on a 19 second stereo test tune we generated at 120 BPM. The 8 bar loop came out at exactly 16.000 seconds, and the jump across the loop point fell from 19.3 times a normal step to 0.3 times. A mono file with --bars 4 --start 2 --fade 0.25 also worked, and asking for more bars than the file holds stopped with a clear message. The number is a click check, not a listening test. Use --fade to change the blend length, which is 0.5 seconds by default, and --beats-per-bar 3 for waltz time.
Know the limits. The script needs a steady tempo and enough audio after the loop to blend (loop length plus the fade). It makes the seam smooth, but it cannot fix a track whose chords or melody do not repeat well.
Step 4: Loop it in Godot 4
- Copy
loop.ogginto your project and select it in the FileSystem dock. - In the Import dock, tick Loop and click Reimport. Leave Loop Offset at 0 to loop the whole file.
- Double-click the file to open the Advanced import dialog, where Godot says you can preview the loop point in real time.
- Add an AudioStreamPlayer node, drag the file into its Stream property and tick Autoplay.
Or set it in code, using the loop and loop_offset properties of AudioStreamOggVorbis:
# In a script, after the .ogg is imported (the Import dock Loop box does the same thing)
var music: AudioStreamOggVorbis = load("res://music/loop.ogg")
music.loop = true # play again from loop_offset when the end is reached
music.loop_offset = 0.0 # 0 means loop the whole file
$AudioStreamPlayer.stream = music
$AudioStreamPlayer.play() These steps follow Godot 4.7's Importing audio samples page and the AudioStreamOggVorbis class reference. Tested November 4, 2026 on Godot 4.7 headless with the dummy audio driver: a 4 second Ogg loop made by the script, imported with Loop on, reported loop true, and an AudioStreamPlayer was still playing after 7 seconds with its position wrapped back to about 3 seconds. A .ogg without Loop ticked reported loop false. A WAV also works: Godot's docs say WAV can carry loop points, and its Loop Mode option has a Forward setting with Loop Begin and Loop End in samples, which we did not test.
Note the warning in Godot's docs: for a looping stream, the AudioStreamPlayer's finished signal never fires, because the audio keeps playing. Never wait for it to change tracks. Need help with Godot code? See How to use Claude Code with Godot.
Step 5: Or loop it in Unity
- Drag
loop.wavinto your Assets folder. Unity imports it as an Audio Clip. - Add an Audio Source component to a GameObject and set its AudioClip to your file.
- Tick Loop in the Audio Source component, or set
audioSource.loop = truein code.
The Unity 6 scripting reference for AudioSource.loop says it controls whether the clip replays after it finishes, and that the checkbox does the same without code. We did not test this in Unity. Not sure which engine to use? Read Godot vs Unity for beginners.
Licenses: what to keep track of
- Stable Audio: Stability's licensing article says commercial use is permitted on every plan, including Free, subject to the Terms of Service and Acceptable Use Policy. Its pricing page and knowledge base disagree on plan names and on whether a free plan renews monthly, so treat the 50 credits as a one time signup grant.
- Suno: keep free plan songs to personal projects. Suno's help center says songs made while subscribed to Pro or Premier get commercial rights.
- Mubert: Free is non-commercial with attribution. Games need Business.
- Steam and itch.io: if AI made audio ships in your game, say so where the store asks. See Can I sell a game made with AI art?
Free tools in this guide
Stable Audio
Generates music clips, stems and sound effects from text prompts. Stability AI's licensing article says commercial use is permitted on every plan, including Free, subject to its Terms of Service.
Pricing: Freemium, from $12/mo. Beginner rating: 5/5. Describe a sound or a track and get audio, with official docs and a prompt guide.
Of the three AI generators here, the only one whose official licensing article says free tracks can go in a game. 50 free credits on signup, and a prompt guide that lists BPM.
Suno
Generates full songs and soundtracks from text prompts.
Pricing: Freemium, from $8/mo. Beginner rating: 5/5. Type a mood and get music in seconds.
Easy and fast, with a daily free allowance, but free songs are personal use only.
Mubert
Generates royalty free music streams and tracks from prompts.
Pricing: Freemium, from $14/mo. Beginner rating: 5/5. Quick tracks with simple options.
Free tracks are watermarked and non-commercial. Good for trying a mood.
Kenney
Thousands of free 2D and 3D game assets, UI and audio packs. Kenney states all assets on its asset pages are public domain (CC0), commercial use allowed, attribution not required.
Pricing: Free. Beginner rating: 5/5. Consistent style, no sign up, and the CC0 license means nothing to track.
CC0 audio packs, safe in a game you sell, with no AI involved.
Godot
Free, open source 2D and 3D game engine with its own easy scripting language, GDScript.
Pricing: Free. Beginner rating: 4/5. Small download, no fees or royalties, and a huge beginner community.
Free engine with a Loop checkbox and a loop preview for music files.
Related
Need sound effects and voices too? Read Best free AI tools for game sound effects and music and Best free AI tools for game voice acting. Making a game trailer? See How to make a game trailer for free. Building your first game end to end? Start with Make your first game with free AI tools. Browse every music tool and sound effects tool, plus free asset libraries.
FAQ
Why does my game music click or jump when it loops?
Because the end of the file does not flow into the start. Two things cause it: the file ends on a different point of the wave than it starts (a click), or it is not cut on a musical boundary, so the beat lands in the wrong place (a jump). Cutting to a whole number of bars and blending the music that would have come next into the start fixes both. The script in this guide does that.
Can AI music loop seamlessly?
Yes, if you cut it right. AI generators return a normal song with an intro and an ending, not a loop. Pick a stretch of whole bars from the middle, then blend the end into the start. Music with a steady tempo works best. If the beat drifts, the cut will sound off whatever you do, so regenerate the track or try a different start time.
Can I use music from a free AI plan in a game I sell?
It depends on the tool. Checked November 4, 2026: Suno's help center says songs made on the free plan are for personal, non-commercial use only, and subscribing later does not give them a commercial license by default. Mubert's pricing page lists the free plan as non-commercial, with an audible watermark, 5 downloads a month and attribution required, and lists apps and games only on its Business plan. Stability AI's licensing article for Stable Audio says commercial use is permitted on every plan, including Free, and that you may use outputs as background music in video games, subject to its Terms of Service. We could not read the terms text itself, so read it before you ship.
How long should a game music loop be?
Long enough that players do not notice the repeat quickly. 8 bars at 120 BPM in 4/4 is 16 seconds, which suits a menu or a short level. Longer loops, like 16 or 32 bars, repeat less often but cost more file size. There is no rule from the engines here, so listen to it for a few minutes while you play.
Should I use WAV, Ogg Vorbis or MP3 for looping music in Godot?
Godot 4.7's docs suggest WAV for short, repetitive sound effects and Ogg Vorbis for music. They also say MP3 uses less CPU than Ogg Vorbis, which can matter on mobile and web. One difference for loops: WAV can store loop points and a loop mode, while Ogg Vorbis and MP3 only support a loop begin point (Loop Offset), not a loop end. Our script cuts the file to the exact loop length, so the end of the file is the loop end.
My AI song is an MP3. Does the script work with it?
Convert it to a 16-bit WAV first, since the script reads WAV files: ffmpeg -i song.mp3 -c:a pcm_s16le song.wav. FFmpeg is a free command line tool. If you do not want to install it, any audio editor that exports WAV works.
How do I find the BPM of a track?
Press play, count the beats in 30 seconds and double the number. If the tool that made the track told you the tempo, use that. Stability's Stable Audio prompt guide lists BPM as something to put in your prompt, but we did not test whether it follows the number, so check by counting.
Is there free game music that is safe to use commercially without AI?
Yes. Kenney's support page says all game assets on its asset pages, which include audio packs, are public domain (CC0) and free to use in commercial projects, with no attribution needed. OpenGameArt hosts community music too, but each file has its own license, so read it before you use the track.
Sources: Stable Audio subscription plans and credits, Stable Audio commercial and usage licensing, Stable Audio pricing and Stability AI Stable Audio docs; Suno: rights on the free plan, Suno: plan types, Suno: rights for songs made before subscribing and Suno: rights with a paid subscription; Mubert pricing; Kenney support; Godot 4.7 docs: Importing audio samples and AudioStreamOggVorbis; Unity 6: AudioSource.loop; FFmpeg. All checked November 4, 2026.
