xaudio2 - support for loop points for sound files.

This forum is currently in read-only mode.
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • by loop points i mean custom start and end of loop in samples rather than the currently available "play from start to finish" loop type.

    once the music/sound effect reaches the start loop point, the "intro" part ends and the "loop" part starts. from that point it goes on until it reaches the position noted in the finish loop point, so once it does it returns to the position set in the start point and continues from there, giving an infinitely looping music/sound fx, like in most modern games.

    would it be possible to include something like that?

    i tried to simulate it with a variable that was increasing itself every frame and once it reached certain point the music positon was changed, but that doesn't work right if the framerate isn't perfect 60fps all the time, and all it'd need would be a slight hickup or pause and the faked synchronization would be over.

  • System object -> compare -> get position. Then when that = something, set the channel position to something else.

    Haven't tried that, but it should work I think.

  • i'm not sure how, since i don't see a compare option in the system object. do i need some extension?

    even then as far as i know it'd be possible only in seconds, which is very inaccurate, when the loop is done in samples or at least miliseconds.

    i think having the program do it natively would be the best anyway rather than implementing workarounds.

  • i'm not sure how, since i don't see a compare option in the system object. do i need some extension?

    even then as far as i know it'd be possible only in seconds, which is very inaccurate, when the loop is done in samples or at least miliseconds.

    i think having the program do it natively would be the best anyway rather than implementing workarounds.

    go new event -> system, scroll down -> compare

    it may be in milliseconds (should be since everything else in the program is measured in milisenconds)

    It's only 1 event feature, not that hard for people to implement (I think, could be wrong)

  • alright, that worked. thanks.

    it's in seconds, but you apparently can use the decimals as some sort of miliseconds i think and get the more less correct position. more less because i had to make the loop end .020 or so earlier than what goldwave shows as the correct place to end the loop (the loop in the ogg file ends at 57.163 seconds, but to get a correct loop i had to set the loop point at 57.142). not sure if it's simply different calculation or something.

    it still ocassionally goes out of sync though.

  • maybe you could just seperate the sounds? when the first intro sound finishes, play the other sound that needs to loop?

  • i tried that, but the change's too noticable. it's kind of like either a slight silence or static, lasting for few miliseconds or so, but long enough to break the flow.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:17kogi31]

    i tried to simulate it with a variable that was increasing itself every frame and once it reached certain point the music positon was changed, but that doesn't work right if the framerate isn't perfect 60fps all the time, and all it'd need would be a slight hickup or pause and the faked synchronization would be over.

    Use timedelta for this. Working with timedelta. However, I doubt this is a very accurate method.

    To make a perfect loop, I always manually cut the file. But first things first, what format are you using? OGG is the best format if you want things to loop (it's also the best format overal). Also, when you want to loop, you want to make sure that the waveform is at the 0dB line at the beginning and the end of the file. This is usually a pretty good guideline to make good loops.

    I do that with Audacity. Be sure to remove all the silence at the beginning and the ending by zooming in an incredible amount. Also, like I said, make sure that the waveform is at the 0dB line at the beginning and the ending. Then save the file as an OGG file. For me OGG has always looped perfectly, unlike MP3 for some reason.

    I hope that helps you a bit

  • i use ogg only. mp3 format has that nasty problem where it adds silence at the start and end of the file upon encoding, effectively messing up loop points and making the "two pieces loop" trick useless.

    but even with ogg the two piece thing didn't work for me. there was a noticable silence while the first file stopped, then it was detected that channel 0 no longer plays music, then the next track, the loop part starts up.

  • Looping audio is tough even with a perfect splice.

    Have you considered a small fadein/out in each sample? that's what editing software does to avoid jumps.

    Just start up the new sample a little bit earlier, about 1ms is enough but you could even go for 5

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)