this tutorial was so useful for overlaping sounds at perfect times (i'm testing dynamic music) thank you!
@bengelman26002 жыл бұрын
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.
@Edlandish6 жыл бұрын
Thank you, messed around with this for two hours today thinking it'd be a quick, easy job. Finally got it working now :)
@NeverduskX6 жыл бұрын
So simple and effective it blows my mind that I've never thought of it before. Thanks a lot for this!
@saito8537 жыл бұрын
OH MY GOD SIR THIS IS AWESOME
@nxtmaster7 жыл бұрын
Another great video, I will definitely be referring back to this in the future!
@KoKoKen5 жыл бұрын
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!
@PixelatedPope5 жыл бұрын
Glad it could help! And don't worry about the Necro. All comments on any videos are welcome :D
@gamingreverends-devcorner13797 жыл бұрын
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.
@UltraHealthyVideoGameNerd2 жыл бұрын
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.
@italianissimobaldi57202 жыл бұрын
how can you do it with audacity?
@kaniprogames82292 жыл бұрын
@@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
@dmas77496 жыл бұрын
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.
@clairebun7 жыл бұрын
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.
@PixelatedPope7 жыл бұрын
In my Zelda project I used FMOD exclusively for this feature, lol. 300 some odd scripts added to my project for one, stupid feature.
@johntreaton69866 жыл бұрын
Thank you for this amazing tutorial, really help me a lot. Once again, thank you, sir.
@cloakedgames7 жыл бұрын
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.
@Vexnatos6 жыл бұрын
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_9 ай бұрын
Thank you for your amazing idea!
@SubparFiddle7 жыл бұрын
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?
@PixelatedPope7 жыл бұрын
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
@naelpontes844411 ай бұрын
Nowadays we can just use audio_sound_loop_start and audio_sound_loop_end
@JordnD2 жыл бұрын
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 😖
@PixelatedPope2 жыл бұрын
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.
@JordnD2 жыл бұрын
@@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.
@meganinja4562 жыл бұрын
@@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.
@PixelatedPope2 жыл бұрын
@@meganinja456 I know, right?
@TheRomanAbbasid3 жыл бұрын
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?
@PixelatedPope3 жыл бұрын
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.
@WebCamCartmell6 жыл бұрын
thank you for this, i am your 5001st sub!
@PixelatedPope6 жыл бұрын
Thanks for watching and subscribing! I should be getting some new videos out soon!
@miguelpescado2 жыл бұрын
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.
@PixelatedPope2 жыл бұрын
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)
@stedl89747 жыл бұрын
Works amazingly. Thanks for sharing!
@PixelatedPope7 жыл бұрын
Glad it worked for you!
@atomicmelodies7 жыл бұрын
Extremely helpful. Thank you.
@Champol6 жыл бұрын
Great solution for this common problem! :) thanks!
@dergeilste79262 жыл бұрын
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?
@PixelatedPope2 жыл бұрын
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.
@Lefty7788tinkatolli2 жыл бұрын
9:10 - There was a very slight hiccup there.
@ABHMughal5 жыл бұрын
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.
@climaxf7752 жыл бұрын
Came back here again because some music doesn't work. Any ideas on how to fix it?
@PixelatedPope2 жыл бұрын
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"
@bradleebowers82037 жыл бұрын
great video, hope you have another in the works!
@PixelatedPope7 жыл бұрын
Thanks! New one should be up today!
@drsquash20034 жыл бұрын
freaking brilliant!
@moongoat60267 жыл бұрын
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).
@PixelatedPope7 жыл бұрын
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.
@WolfrostWasTaken7 жыл бұрын
Really good nice and smart flexible system!
@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 Жыл бұрын
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 Жыл бұрын
@@PixelatedPope Absolutely. Nonetheless, I'm grateful for your tutorial!
@Noah_20084 жыл бұрын
Simple trim it a bit to make it fit
@ZwipZwapZapony6 жыл бұрын
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.
@retrooffroadBR2 жыл бұрын
Will this method work if i add it to a game thats not made in GMS2?
@PixelatedPope2 жыл бұрын
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.
@thorndust53296 жыл бұрын
Is there a way to make like a .ogg that would loop in Unreal Engine 3?
@silverus36175 жыл бұрын
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?
@PixelatedPope5 жыл бұрын
Sorry, I've never used wallpaper engine.
@michaelhallett28423 жыл бұрын
Thank you so much!
@vividlegends44877 жыл бұрын
What determines the length of the buffer at the end of the track?
@faokie7 жыл бұрын
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.
@PixelatedPope7 жыл бұрын
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.
@Iinneus7 жыл бұрын
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.
I set up the code exactly how you did it but its not looping.
@PixelatedPope5 жыл бұрын
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.
@yadielgaming53375 жыл бұрын
@@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
@ftrgstudio22546 жыл бұрын
how do you make this work with different songs? each one has different lengths.
@PixelatedPope6 жыл бұрын
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".
@zvorakfan20236 жыл бұрын
I did what you said, and looking at the code it should work... But once it gets to the looping point it just stops
@PixelatedPope6 жыл бұрын
Well, that certainly shouldn't happen. Hit me up on Discord and I'll try to help you out: discord.gg/njmppc
@zvorakfan20236 жыл бұрын
I found what I did wrong, I did something stupid. Thanks for replying though!
@iodinex645 жыл бұрын
@@zvorakfan2023 what did you do wrong?
@zvorakfan20235 жыл бұрын
@@iodinex64 I wish I could help but it's been quite a while and I don't remember. Sorry.
@oronsnibben5 жыл бұрын
Wow, makes you wonder why the built-in function doesn't opporate like this xD
@robertlupa82736 жыл бұрын
Does it work in Game Maker 8.1? (Not studio)
@PixelatedPope6 жыл бұрын
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.
@theonesuperx6 жыл бұрын
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) }
@PixelatedPope6 жыл бұрын
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_stamps6 жыл бұрын
subscribed
@kiukle6 жыл бұрын
Will this work in GMS2?
@PixelatedPope6 жыл бұрын
Should, but I haven't tried it yet personally.
@kiukle6 жыл бұрын
I will let you know once I have time to try it out, thanks!
@kiukle6 жыл бұрын
PixelatedPope It works!!!! Thanks so much!
@PixelatedPope6 жыл бұрын
Nice!
@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 Жыл бұрын
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 Жыл бұрын
thank you, useful theory even if I'm using "Construct 3" and not "game maker"!
@charredaxolotl6595 Жыл бұрын
Six years later and they finally added a native function for this.
@drewsaldana64492 жыл бұрын
Set by step user friendly. Extremely helpful
@UltraHealthyVideoGameNerd2 жыл бұрын
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.
@leungpuifai2 жыл бұрын
Is this a tutorial of looping music for specific programme only? (Not work in normal music player?)
@PixelatedPope2 жыл бұрын
It's intended for GameMaker Studio 1.4
@fnafstuff8015 жыл бұрын
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?
@larryinc646 жыл бұрын
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.
@PixelatedPope6 жыл бұрын
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.
@bunnybreaker7 жыл бұрын
Slick tech.
@TheBreakingBenny6 жыл бұрын
in Audacity is clearly not supported by GameMaker, nor GameMaker Studio.
@KoniWorx4 жыл бұрын
There's a clear sound pop there tho?
@PixelatedPope4 жыл бұрын
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 Жыл бұрын
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.
@RanDieBam4 жыл бұрын
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
@angeldiaz75545 жыл бұрын
Ty for the solution, it was great and i tried to apply it to Unity, not working though :c
@Diegovz016 жыл бұрын
I got a weird but, after some loops of the track the audio just stop.
@thedarksnow3771 Жыл бұрын
what is GM? and how do i get it?
@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
@bengelman26002 жыл бұрын
Still works. Thank you so much!
@rjb85456 жыл бұрын
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.
@PixelatedPope6 жыл бұрын
Just make your music manager persistent.
@RoddyDev5 жыл бұрын
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.
@PixelatedPope5 жыл бұрын
Are you checking the position of the sound instance, or the sound resource?
@RoddyDev5 жыл бұрын
@@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.
@maestradebobobo7675 жыл бұрын
thanks!
@KlemoneDeal Жыл бұрын
what about outro?
@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 Жыл бұрын
@@PixelatedPope but I want the song to end when you beat the level/boss