@Raul: he’s not suggesting a fundamentally different approach. Simply that the script (when called through the timer) picks up the previous and current position and compares those. As mentioned earlier, it will guard you against those missed lines.
And you really need to plan for worst case scenarios. Believe me, a missed line here and there is nothing. Try to load a heavy plugin into the song and see how that affects your timers? Most likely, your script will start missing whole beats instead of just a line here and there. So, since you can’t prevent the timers from suddenly stopping, you can at least make sure your script can deal with this.
Yes, this is good idea when the “follow player” mode is enabled. You will most likely receive those notifications (that the pattern has changed) before the idle notifier is able to pick up this change. I’m using this trick myself for realtime-critical tools.
But you don’t need to handle it in any special way. Just point to the same function that the idle one is calling - they are basically doing the same thing: responding to changes in the playback position.
Really, I do not know how to add a “line tester”. I start from a function (F1) that works with a timer (T1).This function (F1) only returns errors on the first line, practically in all the passes (every time a new pattern starts). Adding a “line tester” will also depend on the timer (T1). Then, I do not know how to approach it to avoid errors, since it is inside a timer (T1) that is the cause of such errors. Maybe the function F1 that depends on the timer T1reads too fast the first line in the pattern change process. That’s why I add a patch (a function F2 that takes care of this line, the first).
I’ve almost finished the tool, and I’m pleasantly surprised by how well it works.I’ve tested with an Intel i7, up to BPM 700 and LPB 8, and seems to work fine.The faster you seem to run into the limits of the timer, which is set to 5ms.At first, it seemed that the tool failed more, but it was the cause of reading the first line.Now, the “patched” tool reads the first line with a pattern observable (O1) using the function F2, and the rest of the lines with the timer T1 with the función F1, without using :lines_of_range.I understand that these functions only analyze the selected pattern in question, using the timer. Are there any benefits to using lines_of_range inside the function F1 when running timer T1?It is necessary to analyze all the lines of the pattern, not a lower range.
Or… :lines_of_range is better than if .selected_line_index > 1 then?
Another issue is if there is any way to put the following to delay the reading of the first line a little: first use an “if”, and then an “elseif” to ensure that the first line is within the selected pattern to read, not the previous one.I’ll have to think about it.
On the other hand, I have not yet tested the tool on a laptop with an i3 CPU, much slower. But I get the feeling that it will work very fast too.Activating or deactivating the tool does not even involve a 0.1% increase in CPU load.After all, you are only modifying button properties and a bit of reading by timer.
This tool will be included inside GT16-Colors.Maybe I put a limiter with a warning window, to stop the tool if the BPM and LPB are very fast (for example BPM 500 and LPB 8 or equivalent).At least to me, I find it a bit exaggerated to compose with such a high pattern resolution.I find this somewhat unnecessary.But hey, the programmer has to make all the functions also in the most extreme cases.
I enclose a copy, in case yourselves want to have a look at the code and suggest improvements and changes:7391 tool_09.lua