How to reset a sine wave each time the grid is activated?

61 views
Skip to first unread message

Mathieu

unread,
Apr 13, 2017, 4:44:08 PM4/13/17
to Lightjams
This is a popular question, so here's the answer. 

Only the sawtooth function has a reset parameter. So you can use the map.sin function to get a sine wave out of the sawtooth: 

map.sin(sawtooth(10, grid.onactivated))

This generates a sine wave with a period of 10 seconds and it resets each time the grid is activated. The map.sin function takes a percent value and map it to a sine wave. It's also wrapping the value, letting you offset the wave like this:

map.sin(sawtooth(10, grid.onactivated) + 25)

Adding 25 means the sine wave has an offset of 25%. This way, you can generate multiple sine waves with different offsets, all restarting when the grid is activated. For example, add multiple sources with this formula:

map.sin(sawtooth(10, grid.onactivated) + px)

The offset is the horizontal position of the source in percent. Pretty fun :)

Mathieu

unread,
Sep 19, 2017, 8:14:07 AM9/19/17
to Lightjams
As of version 442, all wave generators automatically reset when the grid has just been activated.
Reply all
Reply to author
Forward
0 new messages