|
Post by rosy on Oct 9, 2021 15:24:52 GMT -6
I am already reporting this problem ... I don't know how to measure the time. The following is an example where the sounds should be played at regular intervals, but this is not the case ...
for i=1 to 10 czas=timer Playsound (1,0,0) do loop until timer-czas>=500 next
|
|
J7M
New Member
Posts: 18
|
Post by J7M on Oct 13, 2021 12:23:09 GMT -6
here my solution. I measured the time with a stop watch. For playing the sound 60 times, it needs 60 to 61 seconds. For me it is a quite good timing.
WindowOpen(0, "Speedtest", 0 ,0, 640, 480, WINDOW_VISIBLE ,0) CanvasOpen(0,640,480,0,0,640,480,0) LoadSound(0,"sound.wav")
TimeStep = 0 PositionX = 0 PositionY = 200 Velocity = 50 ' 50 Pixels per second SoundTimerMax = 1 'Sound every 1s SoundTimer = SoundTimerMax
SetColor(rgb(255,255,255))
While(NOT key(K_ESCAPE)) TimeStart = Timer() ClearCanvas() PositionX = PositionX + Velocity*TimeStep if(PositionX > 640) then PositionX = 0 end if rectfill(PositionX, PositionY,50,50)
if(SoundTimer > 0) then SoundTimer = SoundTimer - TimeStep else SoundTimer = SoundTimerMax PlaySound(0,0,0) end if
update() 'Do the timing TimeStep = ((Timer() - TimeStart))/1000 if(TimeStep < 0.02) then 'Throttle to 20ms per frame -> 50fps wait(20 - TimeStep*1000) TimeStep = 0.02 end if wend
|
|
|
Post by rosy on Oct 13, 2021 13:57:33 GMT -6
It is audible that the gaps between sounds are of different length.
|
|
J7M
New Member
Posts: 18
|
Post by J7M on Oct 13, 2021 14:19:56 GMT -6
ok, that is different on my computer. Here the gap between to consecutive sounds is always the same. I don't hear any differences.
|
|
|
Post by rosy on Oct 13, 2021 14:46:22 GMT -6
Set the SoundTimer to 0.25 ...
|
|
J7M
New Member
Posts: 18
|
Post by J7M on Oct 14, 2021 3:34:53 GMT -6
Unfortunately I don't have time, but here a guess: 0.25s for the interval is shorter than your sound file is long. So the old sound is still playing and you already start to play a new sound. Try to use different sound channels to play the sounds in parallel. Something like this:
SoundChannel = 0
sub PlaySoundOnNewChannel(Slot)
If(SoundChannel < 5) then SoundChannel = SoundChannel + 1 else SoundChannel = 0 end if
PlaySound(Slot, SoundChannel, 0)
end sub
|
|
|
Post by rosy on Oct 14, 2021 6:21:35 GMT -6
Not. With a shorter amount of time, uneven playing is heard better.
|
|