OK, I appreciate all the help - I'll try and clarify it more but to be honest, this particular problem is just one of loads of little issues I get with Sonar, which is why I didn't give every last detail. Even if I can fix this, there are still so many things that slow down my workflow and mean I'm trying to work around software issues rather than composing.
On this particular issue, I'll give the simplest example:
First,
everything is patched to its latest version - all soundcard drivers are most recent, all updates to Sonar applied, all Win 7 updates applied, all updates to Stylus applied. I even have new shoes on.
Let's say I have a simple 2 bar loop which contains 1 track of midi piano (say Truepianos, but it's not specific to that VSTi) playing a simple repetition of 8 quarter notes (quantized exactly on the beat). Then on another track I have a 2 bar loop of a generic Stylus RMX loop (again, it's not particular to any loop). I set the loop region to those 2 bars and start playback. For the first few times it plays the loop around, the 2 parts will be perfectly in sync, but slowly on successive cycles the timing starts to drift so they're no longer in time with each other. The Stylus loop will now be out of time with the piano loop (maybe a few split seconds behind) and it gets progressively worse.
* this example is with one midi channel being routed to one stereo audio output in Stylus
* tempo sync is checked in Stylus
* tried various midi playback buffer sizes including 100/250/500/1000 milliseconds
scook - thanks, I tried your suggestion of switching on the metronome and if I do that, they do seem to stay in time with each other. Strange but not really something I can (or should have to) do in a real world example.
Yet another issue this reminds me of, looping is rarely seamless - I'll often hear pops at the start/end of a looped region. Even if there are no effects/reverb tails to cause it and the audio (or midi) has perfectly trimmed loop points. Sometimes it will loop without clicks, other times it won't, using the exact same source.
All these 'sometimes', 'ifs' and 'buts' are frustrating just make it a complete pain to work with. I just want something solid to work with so I can get on with my job of composing :(