DavidKinder / Windows-Frotz

Z-code interpreter for Windows, based on Stefan Jokisch's Frotz interpreter core.
http://www.davidkinder.co.uk/frotz.html
GNU General Public License v2.0
60 stars 12 forks source link

Inconsistent delays between repeated sample plays in one turn #8

Closed DavidGriffith closed 5 years ago

DavidGriffith commented 5 years ago

When multiple calls to @sound_effect are made to be played in one turn, they should be played back to back without any delays. Windows Frotz introduces inconsistent pauses between the end of one play and the next.

An easy way to demonstrate this in action is to blow the whistle on the first turn in Sherlock and then wait. A cab will arrive and a sample of hoofbeats are played back to back three times in ascending volume. If you don't get into the cab, then this happens again in descending volume.

DavidKinder commented 5 years ago

I don't get this - the sounds in Sherlock play one after the other, without any pauses. What version of Windows are you getting this on?

DavidGriffith commented 5 years ago

This happens under Wine.

DavidKinder commented 5 years ago

Could you try under real Windows? As I've not had any other reports of this, and it works correctly on all my Windows boxes, I'm going to take the view that this is most likely an oddity with Wine, rather than a problem in Windows Frotz.

borg323 commented 5 years ago

I hear small pauses between the hoofbeats in Sherlock with Windows 10 under virtualbox and with a Windows 7 laptop. The pauses seem to be less than 100ms and seem similar in duration, so maybe the inconsistency is a Wine artifact.

DavidKinder commented 5 years ago

I've had another look at the code for this, and it could be more efficient. The issue in the Windows Frotz code is not with repeated samples per se, but when an optional Z-code routine address is supplied, to be run when the sample has finished (which is how Sherlock plays the sound at different volumes). I've replaced the old implementation, which checked for the sound to finish every 100ms, with a message based approach that is pretty much instantaneous. In testing I can hear that it has made a (small) difference. Whether it makes any difference under Wine I can't say.

Anyway, this change is commited in 727239702ba5f2455f81ae46d52513486e309ba5