Jepael wrote:Monkey Island did calibrate the delay based on calibration loop. Something along the lines of how many push/pop operations in some period between timer interrupts and then some math to come up with a magical value how many loops of push/pop should be done between port writes.
Perhaps they were also 'lucky' that most people had a clone with OPL3 rather than a real OPL2 😀
For OPL3, the delays aren't required.
Jepael wrote:Yes it's just best to waste the IO wait time for simplicity. Clever thought on staggering the updates, but wouldn't it require far greater clock than just locking on to vsync period? I mean if original code is called once per vsync, using say 3 channel groups it would require 3*vsync timer then, and thus notes on same row could be 5 to 11 ms apart if vsync rate is 60Hz.
Yea, that's the whole idea.
Jepael wrote: So perhaps the timer rate should be much higher to alleviate that. Wolf3D uses 700Hz OPL IMF music (286 required), Monkey Island 473 Hz for OPL MIDI music (8088 playable).
To be honest, I have no idea why they'd choose such high update rates. Sounds like whoever designed that was on crack 😀
SID music generally updates at 50 Hz (okay, there's some 'multispeed' stuff that updates multiple times per frame, but that's not generally used in games, aside perhaps from title screens and such, for the simple reason that it takes too much CPU time, and messes up routines that have to be synced to screen position).
MOD music updates at 50 Hz.
Edlib updates at 50/60/70 Hz depending on your choice.
So why would you possibly go a factor 10 above that? I don't really see what it would add musically, aside perhaps from some really esoteric super-fast instrument parameter updates to trigger weird effects that you can't pull off at 60 Hz.
I mean, I can somewhat understand MIDI, since it is basically 'free tempo', it just records music data in realtime, never designed to run inside a game engine, let alone synced to a display refresh rate. The MIDI standard has a ~31 kbps bandwidth, so theoretically you could have pretty high resolution.
But I don't think MIDI is a good choice in terms of efficiency.
Jepael wrote:Another issue is the overhead the timer interrupt takes.
Yup, more 3-4 timer interrupts per frame is a no-no on 8088-class PCs. The interrupt overhead is really high.
I've been experimenting with background replay routines for MODs, and at 8 KHz you lose more than 50% of your CPU time to just playing the samples.
8 KHz would be 8000/60 = 133 interrupts per frame. Each interrupt takes more than a scanline worth of time.