How to Loop a Music Track that has an Intro

  Рет қаралды 28,924

PixelatedPope

PixelatedPope

Күн бұрын

Пікірлер: 122
@alecacosta
@alecacosta 4 жыл бұрын
this tutorial was so useful for overlaping sounds at perfect times (i'm testing dynamic music) thank you!
@bengelman2600
@bengelman2600 2 жыл бұрын
Yeah I just used it x2 to split a song up into intro-loop,intro-loop to spread the song over a level so it doesn't all come out on the first half. So if you doddle on the first section the song doesn't progress onto the second half and will when you pass a trigger.
@Edlandish
@Edlandish 6 жыл бұрын
Thank you, messed around with this for two hours today thinking it'd be a quick, easy job. Finally got it working now :)
@NeverduskX
@NeverduskX 6 жыл бұрын
So simple and effective it blows my mind that I've never thought of it before. Thanks a lot for this!
@saito853
@saito853 7 жыл бұрын
OH MY GOD SIR THIS IS AWESOME
@nxtmaster
@nxtmaster 7 жыл бұрын
Another great video, I will definitely be referring back to this in the future!
@KoKoKen
@KoKoKen 5 жыл бұрын
Apologies for the major necro, but I was having trouble with an audio system of my own, and when I saw part of your code something clicked with me and I got it working. Thanks dude!
@PixelatedPope
@PixelatedPope 5 жыл бұрын
Glad it could help! And don't worry about the Necro. All comments on any videos are welcome :D
@gamingreverends-devcorner1379
@gamingreverends-devcorner1379 7 жыл бұрын
Awesome as always. Watched the thread on the forums to see what solutons come up and this is really a great way to handle it.
@UltraHealthyVideoGameNerd
@UltraHealthyVideoGameNerd 2 жыл бұрын
Hey friends for those implementing this system, I would indeed recommend keeping your music tracks checked as "uncompressed - not streamed". Maybe it's just because I was testing in the temporary build and not exporting, could be different between mp3 and wav, who knows, but I was getting a lot of random behavior when I had the tracks checked as compressed.
@italianissimobaldi5720
@italianissimobaldi5720 2 жыл бұрын
how can you do it with audacity?
@kaniprogames8229
@kaniprogames8229 2 жыл бұрын
@@italianissimobaldi5720 The issue I'm talking about is only related to settings in Game Maker Studio, not Audacity. When you create a sound asset in Game Maker, there are several compression settings you can choose from in the asset window. Theoretically you should match the compression with the file type you've imported, but for whatever reason it seems to be best to stick with the uncompressed setting even when you've imported an mp3. You can export any file type you want from Audacity but songs should generally be mp3 as wav files are quite large
@dmas7749
@dmas7749 6 жыл бұрын
Oh man. I like the -= loop_length solution for seamless looping. Good job there. However, I'd suggest double-checking the loop part itself in your preferred music program by selecting it and looping it there.
@clairebun
@clairebun 7 жыл бұрын
Hey, awesome! I remember having to use an FMOD extension in order to accomplish this in previous versions. Glad we've got a clean vanilla solution this time around.
@PixelatedPope
@PixelatedPope 7 жыл бұрын
In my Zelda project I used FMOD exclusively for this feature, lol. 300 some odd scripts added to my project for one, stupid feature.
@johntreaton6986
@johntreaton6986 6 жыл бұрын
Thank you for this amazing tutorial, really help me a lot. Once again, thank you, sir.
@cloakedgames
@cloakedgames 7 жыл бұрын
Excellent video. Not gonna lie, I watched in the first place entirely because of your excellent choice in music. But this is something I'm gonna be doing some time in the next year, so it was very useful information.
@Vexnatos
@Vexnatos 6 жыл бұрын
How would one go about getting GMS to check the metadata tags of a track, so you only have to specify the variables on the track itself? (Like how with PRG Maker VX Ace, you label the LOOPSTART and LOOPLENGTH tags, so when the playhead sample position is greater than those two combined, it jumps back to the sample marked by LOOPSTART) Also, if you hold shift while either clicking the play, pressing the space bar, or clicking the timeline (with quick play enabled), this allows you to test your loop without having to copypaste it.
@_bubblezzzzzz_
@_bubblezzzzzz_ 9 ай бұрын
Thank you for your amazing idea!
@SubparFiddle
@SubparFiddle 7 жыл бұрын
Nice, thanks for this! Do you have any experience with dynamic tracks in Gamemaker? like for example in Super Mario World when you ride Yoshi it adds a drum loop to the current track. Would that be difficult to add on to this system?
@PixelatedPope
@PixelatedPope 7 жыл бұрын
No experience, but it shouldn't be difficult. GM has built in audio synch groups that should support exactly this. gamemaker.communitymanual.com/docs/game-assets/sounds/audio-synchronisation
@naelpontes8444
@naelpontes8444 11 ай бұрын
Nowadays we can just use audio_sound_loop_start and audio_sound_loop_end
@JordnD
@JordnD 2 жыл бұрын
For the longest time I couldn't get this too work properly on most tracks. Even tho I had the exact times, the loop was usually a little bit off. It's because I stored the times under a ENUM which I only realized today can't store decimal values 😖
@PixelatedPope
@PixelatedPope 2 жыл бұрын
OOOF. Yeah. Enums are "integers" only. You could use Macros as an alternative. Those can hold ANYTHING. Glad you got it working for you. Even then, it's never going to be "perfect." I continue to pester yoyo to this day to give us a proper way to do this.
@JordnD
@JordnD 2 жыл бұрын
@@PixelatedPope I was looking up audio buffers and I almost got it working. Main problem is for some reason my GameMaker won't play an audio buffer if the buffer it is trying to play was created/formated as a grow_buffer. So I can't load any files for the audio buffer since buffers loaded in GM are created/formated as grow_buffers. I haven't seen any other people having this problem on any forms and I've seen people post code for loading wav files into audio buffer, they don't seem to get the same problem. might just be a newer bug in GM, so this is best solution for now.
@meganinja456
@meganinja456 2 жыл бұрын
@@PixelatedPope The more technology improves the more it gets worse lol. Palette swapping, loop points, things that were much easier in the old days but now are a big pain in the butt.
@PixelatedPope
@PixelatedPope 2 жыл бұрын
@@meganinja456 I know, right?
@TheRomanAbbasid
@TheRomanAbbasid 3 жыл бұрын
Thanks for this tutorial! I know this is an old topic but I had a question - I'm trying to do this in GMS2 and the looping works, but for some reason the audio quality becomes noticeably worse and I'm not sure why. The regular .ogg is fine, but the looped .ogg sounds terrible. Any ideas?
@PixelatedPope
@PixelatedPope 3 жыл бұрын
I honestly have no ideas, sorry. I haven't messed with audio in... years at this point. This solution was never perfect (despite my claims in the video), so I've been waiting for a better solution to be made available. I've been told that sequences will eventually be expanded to support music looping like this, but it is still a "future" feature as of right now.
@WebCamCartmell
@WebCamCartmell 6 жыл бұрын
thank you for this, i am your 5001st sub!
@PixelatedPope
@PixelatedPope 6 жыл бұрын
Thanks for watching and subscribing! I should be getting some new videos out soon!
@miguelpescado
@miguelpescado 2 жыл бұрын
I can't figure out what I'm doing wrong, but the music just refuses to loop. The music gets to the little extra loop point at the end, but then it just stops completely, not going back to the start of the loop. I followed this tutorial almost to the letter, rewatched it five times to make sure I wasn't missing anything, but nothing's worked. I realize that this video was made years ago, so I'm wondering whether the problem is with the software, since it doesn't seem we're using the same version of GameMaker.
@PixelatedPope
@PixelatedPope 2 жыл бұрын
Yeah, this video was definitely made for a much older version of GM, and I haven't used this method myself since making this video, pretty much. But there have been recent comments of people getting it more or less working, so I honestly can't be sure what's going wrong with your project. Hopefully GM will support this natively at some point in the near future (I've been begging for it for years at this point)
@stedl8974
@stedl8974 7 жыл бұрын
Works amazingly. Thanks for sharing!
@PixelatedPope
@PixelatedPope 7 жыл бұрын
Glad it worked for you!
@atomicmelodies
@atomicmelodies 7 жыл бұрын
Extremely helpful. Thank you.
@Champol
@Champol 6 жыл бұрын
Great solution for this common problem! :) thanks!
@dergeilste7926
@dergeilste7926 2 жыл бұрын
hello I got a pretty nasty problem. I got the same idea like you got, but on mine the sound pops when it changes the position. Any idea what causes that problem?
@PixelatedPope
@PixelatedPope 2 жыл бұрын
Unfortunately, despite what I claim in the video, this solution is NOT perfect. You can try setting your audio file compression method, but even that's not guaranteed to work. All we can really do is wait for yoyo to give us better audio features. It's on the roadmap, but who knows when it will happen.
@Lefty7788tinkatolli
@Lefty7788tinkatolli 2 жыл бұрын
9:10 - There was a very slight hiccup there.
@ABHMughal
@ABHMughal 5 жыл бұрын
I've tried it but I'm getting a problem. The problem is that when the _pos is greater than total_length then my game starts to play music track double times, one from the beginning and other from the looping start position. Edit: I just found the problem, I made a mistake of setting priority of the music 1 instead of 0. I'm using 1 for my sound effects so maybe many sound playing at once was making my music to be replayed again.
@climaxf775
@climaxf775 2 жыл бұрын
Came back here again because some music doesn't work. Any ideas on how to fix it?
@PixelatedPope
@PixelatedPope 2 жыл бұрын
Not sure why it would work for some and not for others, but there really isn't anything too much more I can suggest. The GM audio engine is a fickle beast and until it gets more robust, stuff like this will always be more or less a "hack"
@bradleebowers8203
@bradleebowers8203 7 жыл бұрын
great video, hope you have another in the works!
@PixelatedPope
@PixelatedPope 7 жыл бұрын
Thanks! New one should be up today!
@drsquash2003
@drsquash2003 4 жыл бұрын
freaking brilliant!
@moongoat6026
@moongoat6026 7 жыл бұрын
Excellent tutorial, although I think the suggested data structure for all the looping values of all songs is unnecessary. One could just write a "loop_into_song" script, and have it able to pass the "intro_length" and "loop_length" as arguments: loop_into_song( music, intro_length, loop_length).
@PixelatedPope
@PixelatedPope 7 жыл бұрын
Depends on your project, I suppose. I liked being able to just say "play_song(song)" and have it know how to loop and everything all by itself.
@WolfrostWasTaken
@WolfrostWasTaken 7 жыл бұрын
Really good nice and smart flexible system!
@Corilo91
@Corilo91 Жыл бұрын
Hey! I was wondering... With the last updates GMS2 got new audio functions. Is this still the better way to loop music that has an intro? 🤔
@PixelatedPope
@PixelatedPope Жыл бұрын
I haven't actually played around with the new audio functions yet. There's also a possibility that using the relatively new time sources feature could make this more accurate. But I think we can both agree that if this 5 year old tutorials is STILL the best way to do this, that's really sad
@Corilo91
@Corilo91 Жыл бұрын
@@PixelatedPope Absolutely. Nonetheless, I'm grateful for your tutorial!
@Noah_2008
@Noah_2008 4 жыл бұрын
Simple trim it a bit to make it fit
@ZwipZwapZapony
@ZwipZwapZapony 6 жыл бұрын
I'm not sure whether to feel good about having had this exact same idea already (though only storing loop start and loop end variables, not loop start, length, and end variables) and seeing a tutorial promote it, or feel sad about basically not learning anything from the video because I already had that idea. (But I did learn something nice from a comment of this video, so it hasn't been a waste of time for me, at least.) Either way, I'll say that this video does seem to be nice and easy to follow along, so though I didn't learn much from the video, I still want to thank you for taking your time to make it.
@retrooffroadBR
@retrooffroadBR 2 жыл бұрын
Will this method work if i add it to a game thats not made in GMS2?
@PixelatedPope
@PixelatedPope 2 жыл бұрын
I honestly don't know. It sort of worked in GMS1.4. It kinda works in GMS2. I imagine the same logic could work in other engines, but I would hope there's just a better way to handle it in those engines.
@thorndust5329
@thorndust5329 6 жыл бұрын
Is there a way to make like a .ogg that would loop in Unreal Engine 3?
@silverus3617
@silverus3617 5 жыл бұрын
I'm trying to loop a track to use in Wallpaper Engine, and I assume it's different business looping it there. Any way I could solve this?
@PixelatedPope
@PixelatedPope 5 жыл бұрын
Sorry, I've never used wallpaper engine.
@michaelhallett2842
@michaelhallett2842 3 жыл бұрын
Thank you so much!
@vividlegends4487
@vividlegends4487 7 жыл бұрын
What determines the length of the buffer at the end of the track?
@faokie
@faokie 7 жыл бұрын
I think it just needs to be long enough for the object to update. It could be as short as 1/60 of a second but it's better to put a few seconds extra, just in case the game lags for any reason.
@PixelatedPope
@PixelatedPope 7 жыл бұрын
Yup, this is the right answer. It could be VERY short, but a few seconds of an MP3/OGG file is not going to significantly impact the size of your game... so better safe than sorry.
@Iinneus
@Iinneus 7 жыл бұрын
As a small optimization, if you have a few seconds worth of buffer, you could replace your audio manager's step event with an alarm that goes off every second. That way, rather than running the code every frame, it runs it every second, and thanks to this method, the loop will work no matter where in the buffer the code is run.
@drsquash2003
@drsquash2003 4 жыл бұрын
is the code the same for gm studio 2?
@nutzdeez3947
@nutzdeez3947 7 жыл бұрын
awesoooooooooooooooooooooooooooooooooooooooooooooooome!
@yadielgaming5337
@yadielgaming5337 5 жыл бұрын
I set up the code exactly how you did it but its not looping.
@PixelatedPope
@PixelatedPope 5 жыл бұрын
Hmm. Not sure why that would be happening. While this isn't the perfect solution, it does at least sort of work. I'd have to see the project itself to know why yours wasn't working.
@yadielgaming5337
@yadielgaming5337 5 жыл бұрын
@@PixelatedPope Oh okay, maybe it could be because I already have a built in project, I might test it out on a new one to see if it works
@ftrgstudio2254
@ftrgstudio2254 6 жыл бұрын
how do you make this work with different songs? each one has different lengths.
@PixelatedPope
@PixelatedPope 6 жыл бұрын
I would have a data structure that manages all the different lengths. Likely, each song would be a single ds map with a key for each data point per song, and then I would have a ds_list or just an array that holds the "track list".
@zvorakfan2023
@zvorakfan2023 6 жыл бұрын
I did what you said, and looking at the code it should work... But once it gets to the looping point it just stops
@PixelatedPope
@PixelatedPope 6 жыл бұрын
Well, that certainly shouldn't happen. Hit me up on Discord and I'll try to help you out: discord.gg/njmppc
@zvorakfan2023
@zvorakfan2023 6 жыл бұрын
I found what I did wrong, I did something stupid. Thanks for replying though!
@iodinex64
@iodinex64 5 жыл бұрын
@@zvorakfan2023 what did you do wrong?
@zvorakfan2023
@zvorakfan2023 5 жыл бұрын
@@iodinex64 I wish I could help but it's been quite a while and I don't remember. Sorry.
@oronsnibben
@oronsnibben 5 жыл бұрын
Wow, makes you wonder why the built-in function doesn't opporate like this xD
@robertlupa8273
@robertlupa8273 6 жыл бұрын
Does it work in Game Maker 8.1? (Not studio)
@PixelatedPope
@PixelatedPope 6 жыл бұрын
No. The 8.1 sound engine does not support getting the current position of the track nor setting the position of the current track. So unless you are using some external audio dll, this isn't going to work.
@theonesuperx
@theonesuperx 6 жыл бұрын
For some reason, it will not loop for me. This is my code Create event: global.music = "password.ogg" global.stream = audio_create_stream("music/"+ global.music) bgm = audio_play_sound(global.stream,0,false) //if loop = true{ // audio_play_sound(global.music,1,0) //} //Which looping track is playing. intro_lenght = 6.466 loop_lenght = 17.556 full_lenght = intro_lenght+loop_lenght Step var pos = audio_sound_get_track_position(bgm) if (pos > full_lenght) { audio_sound_set_track_position(bgm,pos -loop_lenght) }
@PixelatedPope
@PixelatedPope 6 жыл бұрын
Hmm. Not sure why that wouldn't work. According to the documentation, the audio index returned from audio_create_stream() should work just like playing any other sound... but it might not be. Put this in your step event right below your "var pos = " line: show_debug_message("Audio Position: "+string(pos) +" / " +string(full_lenght)); Then run. You should see your position down in your output window. If your position isn't incrementing, then this is a bug in GM that should be reported to yoyo. If it is incrementing, but never gets past full_lenght, then you need to look at how you've pieced your audio file together as you seem to have forgot to add the little tail end of the loop that I describe in the video. If all of that seems to work, you might want to DM me your project and I'll take a look at why it isn't working.
@andrew_stamps
@andrew_stamps 6 жыл бұрын
subscribed
@kiukle
@kiukle 6 жыл бұрын
Will this work in GMS2?
@PixelatedPope
@PixelatedPope 6 жыл бұрын
Should, but I haven't tried it yet personally.
@kiukle
@kiukle 6 жыл бұрын
I will let you know once I have time to try it out, thanks!
@kiukle
@kiukle 6 жыл бұрын
PixelatedPope It works!!!! Thanks so much!
@PixelatedPope
@PixelatedPope 6 жыл бұрын
Nice!
@undefinedusername
@undefinedusername Ай бұрын
This is a great and simple technique. I've used this, forgotten how to do it, and come back to watch the video again a few times. This can also be used for sound effects. For example, I have used it with a continuous laser beam that has an initialization sound that transitions into a continuous beam sound afterwards. Thanks for the video.
@RedAvery1
@RedAvery1 Жыл бұрын
I make music. Inform me what would help make the looping process simpler for game developers . What can I do to make life easier for you guys?
@AlastairGames
@AlastairGames Жыл бұрын
thank you, useful theory even if I'm using "Construct 3" and not "game maker"!
@charredaxolotl6595
@charredaxolotl6595 Жыл бұрын
Six years later and they finally added a native function for this.
@drewsaldana6449
@drewsaldana6449 2 жыл бұрын
Set by step user friendly. Extremely helpful
@UltraHealthyVideoGameNerd
@UltraHealthyVideoGameNerd 2 жыл бұрын
Yep, it works! Incredibly easy, just need to go check the lengths of the intro and loop in each of your songs in some sound editor. Thank you as always.
@leungpuifai
@leungpuifai 2 жыл бұрын
Is this a tutorial of looping music for specific programme only? (Not work in normal music player?)
@PixelatedPope
@PixelatedPope 2 жыл бұрын
It's intended for GameMaker Studio 1.4
@fnafstuff801
@fnafstuff801 5 жыл бұрын
Thank you for the tutorial, but I have run into a bit of a problem. I have a music object that has individual alarms based off of whether to pause, fade in, out, resume, or play a track. The looping works when the variable is set to audio_play_sound(). But when I exit a room, and then go back, the song pauses, and then resumes. I want the song to start in the same position it was left in. But game maker does not let setting the variable to audio_resume_sound() count as the actual song, and it won't loop after I have exited and entered back into a room. What can I do?
@larryinc64
@larryinc64 6 жыл бұрын
I'm trying this method in GMS2 (newest update) and it seems kind a hot or miss if it will actually jump back to the right point, it sometimes does but other times will be off by a little, missing the first 1-3 beats.
@PixelatedPope
@PixelatedPope 6 жыл бұрын
I certainly wouldn't expect it to be 1-3 full beats off... but it also isn't perfect, either. A tiny hiccup is actually expected, but not much more than what you can hear in the example in the video. If you are hearing a large difference like that, you may want to double check all your numbers for your lengths.
@bunnybreaker
@bunnybreaker 7 жыл бұрын
Slick tech.
@TheBreakingBenny
@TheBreakingBenny 6 жыл бұрын
in Audacity is clearly not supported by GameMaker, nor GameMaker Studio.
@KoniWorx
@KoniWorx 4 жыл бұрын
There's a clear sound pop there tho?
@PixelatedPope
@PixelatedPope 4 жыл бұрын
Yeah, there is. Unfortunately this is still the best method I've found to do this sort of thing, even all these years later. The pop may be fixable with more precise loop numbers, but ultimately until we get actual control over the audio thread (rumored 2.3.2) this is the best we can do without using something like GMOD.
@ethank6452
@ethank6452 Жыл бұрын
Thank you so much for this! I'm really glad somebody else figured this out, because this is something I'm probably going to need a lot.
@RanDieBam
@RanDieBam 4 жыл бұрын
Such a cool way of achieving your goal, but as an audio guy I have to tell you that this isn't very seamless sounding :( Double parts and little dropouts all the time as can be heard in the video, unfortunately
@angeldiaz7554
@angeldiaz7554 5 жыл бұрын
Ty for the solution, it was great and i tried to apply it to Unity, not working though :c
@Diegovz01
@Diegovz01 6 жыл бұрын
I got a weird but, after some loops of the track the audio just stop.
@thedarksnow3771
@thedarksnow3771 Жыл бұрын
what is GM? and how do i get it?
@PixelatedPope
@PixelatedPope Жыл бұрын
Gamemaker is a game engine like Unity or Unreal but more geared towards newer developers/beginners and primarily focused on creating 2D games. Get it here: gamemaker.io/en/get
@bengelman2600
@bengelman2600 2 жыл бұрын
Still works. Thank you so much!
@rjb8545
@rjb8545 6 жыл бұрын
So if I want the track to keep going when i go to another room, how would I go about that, because when I do go to the next room the track stops when it reaches the end of the track.
@PixelatedPope
@PixelatedPope 6 жыл бұрын
Just make your music manager persistent.
@RoddyDev
@RoddyDev 5 жыл бұрын
I don't know why, when I try to get the current track position, it always stays at 0. Getting the audio length returns the value just fine.
@PixelatedPope
@PixelatedPope 5 жыл бұрын
Are you checking the position of the sound instance, or the sound resource?
@RoddyDev
@RoddyDev 5 жыл бұрын
@@PixelatedPope yeah, I first assigned the sound resource to my bgm variable. Like "global.currentSong = song1;" and then played the sound from that variable. I realized that I need to play the audio when I'm setting the variable like you did in the video. "global.currentSong = audio_play_sound(song1, 0, false);" to get the audio index. I spent like an hour trying to solve a single problem. I'm so lazy. Thanks for your help, it works perfectly now. Thank you very much.
@maestradebobobo767
@maestradebobobo767 5 жыл бұрын
thanks!
@KlemoneDeal
@KlemoneDeal Жыл бұрын
what about outro?
@PixelatedPope
@PixelatedPope Жыл бұрын
That's probably going to be pretty difficult, but I assume you would just decide when not to loop and let the song play out from that point? Maybe?
@KlemoneDeal
@KlemoneDeal Жыл бұрын
@@PixelatedPope but I want the song to end when you beat the level/boss
@XiaoLux
@XiaoLux 7 жыл бұрын
Genius
@flashjaysan1
@flashjaysan1 6 жыл бұрын
Fantastic!
GM Anatomy 1: Booleans, Comparisons, & Conditionals
9:41
PixelatedPope
Рет қаралды 3,3 М.
Oxford University Mathematician REACTS to "Animation vs. Geometry"
31:06
Tom Rocks Maths
Рет қаралды 251 М.
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 24 МЛН
How to Write Music for Video Games
21:18
Guy Michelmore
Рет қаралды 149 М.
GMS2 Cameras: As Simple as Possible
13:27
PixelatedPope
Рет қаралды 66 М.
Bedrock. Why?!
22:37
FundyLIVE
Рет қаралды 415 М.
The 15 Commandments of Game Maker
16:32
PixelatedPope
Рет қаралды 124 М.
How Cuphead Was Made and Struggled Finding The Right Protagonist
24:05
ThatGuyGlen
Рет қаралды 1,8 МЛН
DS Map Based Save System
18:56
PixelatedPope
Рет қаралды 36 М.
How to Create Game Music Loops
17:55
Steven Melin
Рет қаралды 10 М.