Possible Delay Function Bug

13 views
Skip to first unread message

Maximate

unread,
May 6, 2026, 7:51:29 AM (8 days ago) May 6
to Lightjams
I believe I've discovered a bug in the delay(time, value) function.

The function behaves differently according to the time input in a seemingly arbitray way.

For any time input less than 28.794 seconds, the delay function starts a periodic time based function for a shape as though that time were 0. For example, delay(4, triangle(2)) will start at a value of 0 and increase to 100 over the span of one second for the first half period.

However, for time inputs equal to or greater than 28.794 seconds, the delay function appears to act as though the periodic time based function had actually "started" at 0 seconds but just change all the values before the input time to 0. For example, delay(28.794, triangle(2)) will start at a value of 79.4 instead of 0, and it will be exactly in sync with a triangle(2) function that was activated at the same time. 

If this is intentional, is there anyway to avoid or toggle this behavior to be consistent? If not, it would be greatly appreciated if it could be remedied.

One way I've found to avoid the bug right now is to avoid delay times equal to or above 28.794 seconds by simply breaking up the delay into smaller components that sum up to the desired time. For example, delay(1, delay(27.794, triangle(2))) reverts the behavior back to the way it works below 28.794 s. 

I don't know what the significance of 28.794 is. The only thing I noticed is that it is the product of 6 and 4.799, and 4.799 does not seem like a random number. But I don't really know what's going on under the hood here.

Mathieu

unread,
May 6, 2026, 8:00:47 AM (8 days ago) May 6
to Lightjams
Hi,

The delay function has a maximum buffer size and if the delay time is greater than it, the older data is just forgotten. The maximum delay time depends on the Lightjams output rate * input rate, but in your case it seems to be around 28 seconds. 

If you want to delay periodic math functions like triangle, you can calculate the phase offset with a formula like:

let(delaySeconds, 30,
map.triangle(sawtooth(3)+50+delaySeconds/60*100))

This makes the triangle functions start like if there was a 30 seconds delay. 

Maximate

unread,
May 10, 2026, 9:04:10 PM (4 days ago) May 10
to Lightjams
Hi Mathieu,

That helps a lot. Thank you
Reply all
Reply to author
Forward
0 new messages