OpenTTD

Tasklist

FS#5473 - Allow Callback 33 (sound effect) to trigger continuous (looping) sound effects

Attached to Project: OpenTTD
Opened by David Dallaston (Pikka) - Saturday, 16 February 2013, 05:46 GMT
Last edited by andythenorth (andythenorth) - Saturday, 19 August 2017, 09:43 GMT
Type Feature Request
Category NewGRF
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Callback 33 states that event 7 and 8 are "called every 16 engine ticks", which if I'm right is every 432ms.

However, playing a sound using those events causes the sound to be played - at least on my machine - at intervals of 372ms (short) or 560ms (long), in the pattern

lllsllsllsllslls

Can this be fixed? Better yet, can we get an event that will play a sound /every/ engine tick, and grf authors may use the animation counter to choose their own interval?

Test GRF attached.
This task depends upon

Closed by  andythenorth (andythenorth)
Saturday, 19 August 2017, 09:43 GMT
Reason for closing:  Won't implement
Additional comments about closing:  Flyspray clean up: more than 5 years old, and not obvious what should be done with this next, so closing. If this offends, discuss with andythenorth in irc. Thanks. Also hi Pikka.
Comment by frosch (frosch) - Saturday, 16 February 2013, 12:04 GMT
I have the impression that you are trying to play a sound continuously by starting it over and over and giving it the duration until it is started next.

I don't think that is the right solution to the problem. Instead there should be a way to enable looped playback, which makes a sound play repeatedly until the GRF says something else. The "something else" part could also only take affect when the sound finished the next time, so it is not interrupted and the next sound effect is appended smoothly.

Making the GRF try to figure out when a sound might be finished to start a new one will easily break if something in OTTD is delayed.
Comment by David Dallaston (Pikka) - Saturday, 16 February 2013, 21:18 GMT
I have no problem with delays, I'm not trying to get perfect looping. But the pattern in the irregularity is striking; it makes me think there's a counter that's not quite working properly.
Comment by David Dallaston (Pikka) - Saturday, 23 February 2013, 06:25 GMT
lllsllsllsllslls is 16 "events" long, so it seems the pattern repeats every 256 ticks. So what's creating this pattern? Something in the sound playback thread? And is it the same pattern for everyone, on every computer?
Comment by frosch (frosch) - Saturday, 23 February 2013, 10:57 GMT
This is for sure platform specific. Assuming you are using windows, the interval between ticks is controlled by GetTickCount().

The msdn documentation at
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724408%28v=vs.85%29.aspx
says: "The resolution of the GetTickCount function is limited to the resolution of the system timer, which is typically in the range of 10 milliseconds to 16 milliseconds."

Loading...