05-05-2023, 09:53 PM
Not sure that it would make any difference but the line of code:
should be as follows to avoid doubt:
My code defined the offset as the distance of the left-hand edge of the window after the left-hand edge of the preceding line. So in the following example:
the offset would be 1. A complete repeat is defined as a line followed by a space. Because the offset (1) is <= the line width (2) the first section of the code determines that there are 5 spaces in the first partial repeat. Then it subtracts the repeat length (7) minus the offset (1) from the number of samples still to process (20) to give 14. Dividing this by the repeat length gives 2. Multiplying 2 by the width of the spaces (5) gives 10 which added to the 5 from the initial partial repeat gives an answer of 15 spaces. In this case there is no partial repeat at the end so the final two lines have no effect.
In the case of:
the offset is 0. Since the offset is zero the first 'partial' repeat is actually a complete repeat but it doesn't matter that it is treated as a partial repeat and, as the offset is <= the line width the first section of code again determines that the initial partial repeat contains 5 spaces. Then it subtracts the repeat length (7) minus the offset (0) from the number of samples still to process (20) to give 13. Dividing by the repeat length (7) gives 1 - so the middle section of the code adds 1 * 5 spaces to the previous 5 to give 10. The number of samples still to process is reduced by the repeat width (7) * the number of repeats (1) to leave 6 samples still to process. The final section of code determines that the number of samples still to process is > the line width and so increases the number of spaces in the window by the number of samples still to process (6) minus the line width (2) = 4. This should give a total of 14 spaces.
I think it may simply be a matter of where the offset is measured from. If you want to define this in another way and you are still stuck I'll rework to code to use your definition of the offset.
Hope this helps.
Code:
window_samples_to_process -= repeat_width - offset;
Code:
window_samples_to_process -= (repeat_width - offset);
My code defined the offset as the distance of the left-hand edge of the window after the left-hand edge of the preceding line. So in the following example:
Code:
SSSSSLLSSSSSLLSSSSSLLSSSSSLL 1: 15
--------------------
In the case of:
Code:
SSSSSLLSSSSSLLSSSSSLLSSSSSLL 2: 14
--------------------
the offset is 0. Since the offset is zero the first 'partial' repeat is actually a complete repeat but it doesn't matter that it is treated as a partial repeat and, as the offset is <= the line width the first section of code again determines that the initial partial repeat contains 5 spaces. Then it subtracts the repeat length (7) minus the offset (0) from the number of samples still to process (20) to give 13. Dividing by the repeat length (7) gives 1 - so the middle section of the code adds 1 * 5 spaces to the previous 5 to give 10. The number of samples still to process is reduced by the repeat width (7) * the number of repeats (1) to leave 6 samples still to process. The final section of code determines that the number of samples still to process is > the line width and so increases the number of spaces in the window by the number of samples still to process (6) minus the line width (2) = 4. This should give a total of 14 spaces.
I think it may simply be a matter of where the offset is measured from. If you want to define this in another way and you are still stuck I'll rework to code to use your definition of the offset.
Hope this helps.