Seeking a Sound?

Blitz3D Forums/Blitz3D Programming/Seeking a Sound?

Jürgen(Posted 2004) [#1]
Does anybody of you knows how or if it is possible to seek a sound loaded with PlaySound (similar to seekfile)?


jfk EO-11110(Posted 2004) [#2]
You mean to position the soundplayer at a certain (time)position?

There is no such function, but you could maybe do it using a trick. I didn't test this myself and maybe it isn't possible due to the way the hardware works, but anyway:

Calculate the frequency, the sound must be played to reach the desired position in 1 millisecs, then play it with this frequency for exactly one millisecond. Of course, you need to know the currently used samplerate. In THEORY you should be able to seek the sound this way.

If you don't want to wait one millisecond, you could also use the average fps time and use this to calculate the required frequency, then "fastforward" the sound during the next frame. Of course, this method may be not so accurate.

But to be honest, I really never tried to play a sound with a sample frequency like, say, a million hertz.


Jürgen(Posted 2004) [#3]
This will never work, be sure! I think the maximum is at 80.000, not more.