using global memory for beat

27 views
Skip to first unread message

Matthias Waldorf

unread,
Jun 8, 2024, 2:33:49 AMJun 8
to Lightjams
Hello everyone,

we want to use different methods for beat detection depending on the setup (e.g. ableton link, midi). For this, we use a global variable for the beat input like this:

// global beat pulse

gmem(0, abletonlink.beat)


However, if we use the variable in a different grid we often loose beats:


// show beat with short fadeout

fadeout.log(0.2, grecall(0))


 Unbenannt.GIF

Is there a better way to do this in LightJams?

Mathieu

unread,
Jun 8, 2024, 7:34:05 AMJun 8
to Lightjams
Hi,

That's a good observation! The problem is that grids are evaluated in parallel (by multiple CPU core) and the evaluation order can change. So you can't never be sure that the gmem function has been evaluated before the grecall function is used in your other grid.

This is a problem in this case since you want to store the result of abletonlink.beat, which has a duration of exactly one frame. You could mitigate the problem by making the beat lasts longer by using the trigger function like this:

gmem(0, trigger(abletonlink.beat,0.05, 0,100,0))

Then in your other source, you can use the onbeat function to still generate  a single pulse and fade out:

fadeout.log(0.2, onbeat(grecall(0)))

However, you might want to use the global sliders (view/sliders menu) to store the beat. These sliders are evaluated before any grids and always in order from the first slider to the last. You could even use a slider with your initial formula and it should work:

gmem(0, abletonlink.beat)

That also means that instead of using grecall(0), you could use slider(XYZ) in your grid:

fadeout.log(0.2, onbeat(slider(1)))

So my suggestion would be to put the logic for your different beat sources in the global sliders.

Matthias Waldorf

unread,
Jun 8, 2024, 9:41:54 AMJun 8
to Lightjams
Thank you very much  for the explanation and your help Mathieu!

Both solution should be able to solve our problem :-)

Matthias Waldorf

unread,
Jun 9, 2024, 3:24:38 AMJun 9
to Lightjams
We have found a simple solution that seems to work well for us. Instead of the beat pulse, we now store the beat phase (e.g. 0..3) in a global variable. 

This can be reliably evaluated in other grids, e.g. with onchange(grecall(0)) (every beat) or onbeat(grecall(0) == 0) (every first beat in a bar). We do the same with a variable for the double beat speed.

Could this be a useful approach?

Mathieu

unread,
Jun 9, 2024, 9:19:46 AMJun 9
to Lightjams
Hi,

Yes, that's a good approach.  If you end up doing onchange(grecall(0)) in many formulas though, you might want to avoid repeating it over and over again by putting this logic in a global slider. This isn't about performance but mainly to make it easier to understand your project when you come back at it in a few months :) But if you need it only in a few formulas, then it's perfect.

Reply all
Reply to author
Forward
0 new messages