xaudio2 - support for loop points for sound files.

New releases and general discussions.

Post » Tue Oct 06, 2009 6:12 pm

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.
G
3
Posts: 6
Reputation: 812

Post » Tue Oct 06, 2009 10:56 pm

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.
B
76
S
48
G
11
Posts: 1,558
Reputation: 13,247

Post » Wed Oct 07, 2009 12:40 am

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.
G
3
Posts: 6
Reputation: 812

Post » Wed Oct 07, 2009 1:42 am

[quote="Serio":2vi7zlx0]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.[/quote:2vi7zlx0]

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)
B
76
S
48
G
11
Posts: 1,558
Reputation: 13,247

Post » Wed Oct 07, 2009 2:24 am

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.
G
3
Posts: 6
Reputation: 812

Post » Wed Oct 07, 2009 2:28 am

maybe you could just seperate the sounds? when the first intro sound finishes, play the other sound that needs to loop?
B
76
S
48
G
11
Posts: 1,558
Reputation: 13,247

Post » Wed Oct 07, 2009 4:57 am

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.
G
3
Posts: 6
Reputation: 812

Post » Wed Oct 07, 2009 4:12 pm

[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.
[/quote:17kogi31]

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 :)
B
1
G
5
Posts: 40
Reputation: 1,305

Post » Fri Oct 16, 2009 4:23 pm

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.
G
3
Posts: 6
Reputation: 812

Post » Sun Oct 18, 2009 9:39 pm

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
B
2
S
1
G
4
Posts: 1,445
Reputation: 4,490

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 0 guests