Page 1 of 1

Looping sound

Posted: Sun Aug 31, 2014 4:45 pm
by Rado1
If wanted to achieve seamless looping of a relatively short sampled sound (e.g. ticking of watches), the first thing coming to mind is usage of looping Timer of which Interval is set to the length of the Sound. Unfortunately, this does not work properly as demonstrated in the attached example sound_test1.zgeproj. (For illustration I used a generated sound, not a sample.)

I came up with a trick: setting the Sound.Length to a very high number causes seamless looping of the sample when used in PlaySound. The problem is stopping of such a sound... but if you set the Sound.Length to 0 and play the sound again, it is stopped. Of course, both sound playings must have the PlaySound.ByReference set to 1 (true). This is illustrated in example sound_test2.zgeproj, which stops the looping sound, of length 1 second, after 5 seconds.

I'm not telling this is the ideal solution, but it works. BTW has anyone a better trick for seamless looping of short samples?