Formula to move a source forward every Xth beat

150 views
Skip to first unread message

Mathieu

unread,
Oct 5, 2025, 6:48:57 PM10/5/25
to Lightjams
Here's a handy formula to move a source forward on every Xth beat. 

let( beatDivisor, 4, // move forward every Xth beat
signal, music.1.beat, // the input for the beat detection, like an audio band
xtopercent(floor(counter( 0,
(grid.lastx+1)*beatDivisor-1,
onbeat(trigger(signal,0,10,30,0.2)), // clean the signal with the trigger and detect beats
0,
grid.onactivated // reset the counter when the grid is activated
)/beatdivisor)))

Use this formula for the X slider of a source. Replace the music.1.beat by your signal.

Jeff Drees

unread,
Oct 18, 2025, 11:08:26 AM10/18/25
to Lightjams
Hey Matt and all, 

I am long time user of lightjams. I read all of the posts here, thanks to everyone using lightjams and solving problems together. Thank you Matt for always coming through with solutions. 

This brings up a common issue I have. How would I fade this function between steps? I know I could use the grid fade feature but I want to be able to change the fade on the fly, ideally connecting it to my global fade sliders that are connected to midi controls. Is there a way to use the fade function on the grid activation and have the formula for the x moving reset the grid with each step? I am specifically trying to fade hue. 

I think one solution, that I see you suggest often, would be to have each set of hue attributes in their own grid and create attribute and then make a sequencer by moving a source along the x axis. Then each activation slider for each separate grid would be connected to my global fader slider. Would that be the same issue I am having now? 

One solution I see would be a new feature. My idea is to make the grid fade feature at the top of each grid more like the other features of lightjams. Have it able to controlled by a formula, midi, etc. I know that would be a fair bit of coding and a lot of debugging though.  

Thanks, 
Jeffrey Drees 

Here are some examples of how I use lightjams if anyone is interested. 

Mathieu

unread,
Oct 18, 2025, 11:49:14 AM10/18/25
to Lightjams

Hi Jeff,

You can set the fade in and out time of a grid with a formula by using the grid.fadeintime(time) and grid.fadeouttime(time) functions. This way, you can use the value of a midi control to set the fade times. You need to use these functions in a source that is on the grid you want to control.

Let me know if this is what you were looking for.

Daniel Profir

unread,
Oct 26, 2025, 10:28:38 AM10/26/25
to Lightjams
Hi all,
I’m new user of Lightjams and I try to learn how to use this complex program. This forum helped me a lot to start to make the lights ‘dancing’.  I done some testing projects. I appreciate some suggestions, critics too. 
I uploaded few samples on YouTube and few people view them. I don’t know how many supposed to be (in 4 days was 3.9k). Also this is first time when I use YouTube. 


Please let me know your thoughts. And I am sure I will have a lot of questions to ask in the future.

Have a nice day/night :)
Daniel  

Mathieu

unread,
Oct 27, 2025, 9:25:37 AM10/27/25
to Lightjams
Hi Daniel,

You are really good actually! It's pretty entertaining to watch.

Daniel Profir

unread,
Oct 29, 2025, 3:47:47 AM10/29/25
to Lightjams
IMG_9947.png
Thank you. 
It looks like people are interested in this. 


Lennart Schiesswohl

unread,
Dec 15, 2025, 1:55:13 PM12/15/25
to Lightjams
Hey Matt and everyone,

Thanks for that input, really helps a lot!

I'm new to Lightjams and currently exploring it's capabilities for a future project. I'm already really enjoying the customization and flexibility it offers.
Thank you for creating such a versatile piece of software!

Now to my question: I can imagine this might have already been answered; I’ve searched the forum and the command-line information but didn’t find anything.

I understand that this formula allows me to move a source every Xth beat. What I want to do is create a 16-step sequencer where each step can either be turned on or off, or have a specific effect applied from a pool of available effects.

For example, I have 6 effects for Fixture type 1, 6 effects for Fixture type 2, and so on. I want to be able to:

  1. Press a button on my MIDI controller to select an effect.

  2. Choose which steps the effect should apply to.

  3. Let the sequencer move through every Xth beat, but only trigger the steps that have been turned on and have that effect assigned.

  4. Using different effects from multiple fixture groups on the same sequencer could get a bit cluttered, so the idea is to create separate rows for each fixture group that the sequencer moves through simultaneously.

    All of these rows would also be represented on the MIDI controller, with LED feedback showing which steps have been toggled on.

Is this possible? I’ve been trying to figure it out but got stuck. Maybe you could point me in the right direction.

Thanks already and best regards,

Lennart

Mathieu

unread,
Dec 15, 2025, 3:23:30 PM12/15/25
to Lightjams
Hi,

Creating a sequencer where each step can be enabled via MIDI is possible but can get a bit complex. Here's a sample project showing how to toggle the activation of each column of the sequencer by pressing the MIDI notes from 1 to 16 on channel 1. The activation state of each column is also saved into the project file since the source last value is saved.

The formula for the source that is computing what column of the sequencer to activate looks like:

xtopercent(

let( beatDivisor, 4, // move forward every Xth beat
signal, pulse(0.5), // the input for the beat detection, like an audio band

let( lookAt,
floor(counter( 0,
(grid.lastx+1)*beatDivisor-1,
onbeat(trigger(signal,0,10,30,0.2)) // clean the signal with the trigger and detect beats
| grid.powerat(x,0)==0, // skip disabled steps

0,
grid.onactivated // reset the counter when the grid is activated
)/beatdivisor),

// update the memory only when the step is enabled
if(grid.powerat(lookAt,0)>0, mem(0, lookAt), lookAt)
)
)
)

For testing purpose, I'm using a pulse(0.5) signal. Replace it by the audio if you want.

You need to put the attributes corresponding to the effects on the grid. I don't see a way to do this only via MIDI.
sequencer with midi toggle for steps.ljp

Lennart

unread,
Jan 9, 2026, 4:45:02 PM (10 days ago) Jan 9
to Lightjams
Hi Mathieu,

happy New Year, and thanks for your help so far!

I’ve made some progress but I’m a bit stuck now. I’m currently using an APC40 mk2 (may switch later). I’ve set up an FX selection using radio buttons, and switching between effects works fine. However, I’m struggling to create separate “patterns” per effect, since they all share the same MIDI toggles. Is there an easy solution other than assigning different rows on the controller?

I also changed the moving source to advance every step, even when toggled off, for visual feedback on the controller. Before that, skipped steps felt slightly off in timing (i might be wrong on that)

Regarding MIDI feedback on the APC40 mk2: I saw another thread suggesting using a sine wave in a small range around the target color value to drive the LEDs. This works sometimes, but it’s unreliable, especially when trying to layer another color on top to indicate a selected state. On the sequencer I opted for one toggle and one momentary switch, as it didn't seem to work with just the toggle.

Finally, about MIDI feedback in general: I don’t want the LEDs to be affected by the master fader. Is there a way to exclude certain grid LEDs from the master fader?

I've attached the project file.

Best regards 

Lennart




sequencer_test_4.ljp

Mathieu

unread,
Jan 9, 2026, 4:55:11 PM (10 days ago) Jan 9
to Lightjams
Hi,

>>  However, I’m struggling to create separate “patterns” per effect

I'm not 100% sure what you mean exactly, but to create a different sequences, you'd need multiple sequencer grids. So basically, duplicate the sequencer grid.

>>   I don’t want the LEDs to be affected by the master fader. Is there a way to exclude certain grid LEDs from the master fader?

You can patch the midi LED using generic effect instead of generic dimmer as effect aren't affected by the master intensity.

Lennart

unread,
Jan 9, 2026, 5:11:58 PM (10 days ago) Jan 9
to Lightjams
Thanks for the quick response!

At the moment, I’m working with four different effects. I can create a pattern, for example, Effect 1 active on steps 1, 5, 9, and 13. However, when I switch to a different effect, that same pattern is still applied (e.g., to Effect 2). What I’d like instead is for each effect to have its own independent pattern: I want to select one effect, set its pattern, then switch to another effect and define a different pattern on the sequencer without affecting the others.

I’m also a bit confused about how this would work when using different grids. If the same MIDI notes are used to trigger the sequencer, I don’t quite understand how the patterns would remain independent. Sorry if this is obvious, I’m still fairly new to working with MIDI and Lightjams in general.

One more thing I forgot to mention: since changing how the sequencer works, steps that are deactivated still move on the grid but aren’t actually triggered. Because of this, the last activated step remains active until the next triggered step occurs.

Is there a way to change this behavior?

Mathieu

unread,
Jan 12, 2026, 9:07:08 AM (7 days ago) Jan 12
to Lightjams
>> However, when I switch to a different effect, that same pattern is still applied (e.g., to Effect 2). What I’d like instead is for each effect to have its own independent pattern

If you are using the APC40, then you could create a 8x4 (or 8x5) sequencer instead of 16x4 as it is in your project file. Then you need to assign the midi note corresponding to each button of the APC40 instead of the midi.note(1,x+33) in the current formula.

You can see an example of using the APC40 along with the way to send midi feedback to it: https://groups.google.com/g/lightjams/c/IcL9KfhXuEs/m/GA4tFpRJBgAJ

Reply all
Reply to author
Forward
0 new messages