Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how to seamlessly loop music
- eaeaeauiuiui3
-
27 posts
how to seamlessly loop music
I want to seamlessly loop a music track because naturally there is a slight pause before replaying the song
how do i fix!!
excuse me i have no question marks because keyboard broke
how do i fix!!
excuse me i have no question marks because keyboard broke

- bRuHbRuHmEmEmAn
-
500+ posts
how to seamlessly loop music
I don't think this is possible. It's naturally how Scratch handles its audio (as a music producer who posts here, I can confirm). No matter if you shave off the I want to seamlessly loop a music track because naturally there is a slight pause before replaying the songtiniest bit of your audio file, it'll still have a very short pause.
how do i fix!!
excuse me i have no question marks because keyboard broke
- eaeaeauiuiui3
-
27 posts
how to seamlessly loop music
tiniest bit of your audio file, it'll still have a very short pause.that really sucks I don't think this is possible. It's naturally how Scratch handles its audio (as a music producer who posts here, I can confirm). No matter if you shave off the
sorry no periods either
Last edited by eaeaeauiuiui3 (Aug. 14, 2024 00:11:55)
- alebro6DW
-
100+ posts
how to seamlessly loop music
foreverBecause scratch ticks (one thirtieth of a second, and everything (except run without screen refresh myblocks) runs like this:
play sound [music1 v]
wait [length - 0.02 or more] secs
end
thing
1 tick wait
thing)
(don't quote me, I might be wrong)
Last edited by alebro6DW (Aug. 14, 2024 09:59:18)
- eaeaeauiuiui3
-
27 posts
how to seamlessly loop music
There is still a slight pause but thank you anywaysforeverBecause scratch ticks (one thirtieth of a second, and everything (except run without screen refresh myblocks) runs like this:
play sound [music1 v]
wait [length - 0.02 or more] secs
end
thing
1 tick wait
thing)
(don't quote me, I might be wrong)
- han614698
-
1000+ posts
how to seamlessly loop music
Theoretically you can figure out how long that pause is and start your next repetition while the other one is still playing.
- DerpyHead0
-
1000+ posts
how to seamlessly loop music
you can't loop music seamlessly. code can run at most once per frame, and all that's a tiny amount of time compared to the time taken to draw the screen, during which you can't start audio. how long every frame lasts depends on how laggy the computer is, so you can never start the music at the right time to make it loop. even in turbo mode, there are large gaps in time when the scripts don't run so that scratch can draw all the things on screen and various other tasks.
most other audio software solves this problem by setting a precise time for the audio to start later, and then the actual low level code that's handling audio handles it. that code runs constantly extremely fast to actually control the speaker in real time, so it actually can play audio at precise times.
if you want to reduce the amount of times you can hear a gap in the loop, repeat the audio several times in an audio editor (perhaps 10 times if it's a short loop), then you only need to loop it in scratch once every 10 times.
if your music has any point without drums or clear rhythm, you might be able to loop there by crossfading. make the start of your audio fade in make the end fade out (this should be the same point in the loop to match up) and set a wait block to the right time so that it plays the audio right when the last one starts fading out. it won't be *exactly* the right time but close enough, and there won't be a full gap in the audio. if it's not in the place you want then add the audio twice, once to start at the beginning and end at the crossfade, and another that has the crossfade on either end.
most other audio software solves this problem by setting a precise time for the audio to start later, and then the actual low level code that's handling audio handles it. that code runs constantly extremely fast to actually control the speaker in real time, so it actually can play audio at precise times.
if you want to reduce the amount of times you can hear a gap in the loop, repeat the audio several times in an audio editor (perhaps 10 times if it's a short loop), then you only need to loop it in scratch once every 10 times.
if your music has any point without drums or clear rhythm, you might be able to loop there by crossfading. make the start of your audio fade in make the end fade out (this should be the same point in the loop to match up) and set a wait block to the right time so that it plays the audio right when the last one starts fading out. it won't be *exactly* the right time but close enough, and there won't be a full gap in the audio. if it's not in the place you want then add the audio twice, once to start at the beginning and end at the crossfade, and another that has the crossfade on either end.
- MillionOfficial
-
500+ posts
how to seamlessly loop music
Turbowarp has custom fps, you should try it.
- Discussion Forums
- » Help with Scripts
-
» how to seamlessly loop music