FORUMS: list search recent posts

# Dots and Streamers - BPM Calculator

FAQ   •   VIEW ALL
 Dots and Streamers - BPM Calculator on Apr 15, 2016 at 5:51:37 am

Hey Guys,

Tried looking for something with similar functionality but have had no luck.

I'm looking to make a punches and streamers kind of effect, that can be added to a layer in a certain BPM (that is adjustable) but for some reason == doesn't work but >= and<= work fine... is it something to do with it being a float value or something?

At the moment I have:

-A BPM slider - Manually adjustable
-Bars input slider - Manually adjustable
-FPS slider that automatically works out the framerate
-Calculation slider - that works out how many frames for one beat
-BeatCounter - that deduces the frames in a beat down to a whole beat counter.

All this drives what I had hoped to be a pretty simple bit of code that says if it is equal to the beats count, make a dot on the screen opacity 100%, if not make it 0%.

I'm probably going about it wrong and should be using a "for loop" right?

```on = 100.0; off = 0.0; a = thisComp.layer("Adjustment Layer 1").effect("BeatCount")("Slider"); b = thisComp.layer("Adjustment Layer 1").effect("Beats")("Slider"); Value = 0; if(a == b) { [on] } else{ [off] }```

"==" expects a perfectly matched value. If your slider are animated or derived by expressions, you may have to take the framerate into account and figure out how much the value can change within one frame. For instance if you're going from 0 to 100 in one second, you have a "window" of 4 units per frame. You're going to have a better chance of hitting that window with your values if you take it into account. Perhaps you can do it with a "when the difference is less than" calculation rather than "equals". As in `Math.abs(A-B)<X` where X is the threshold value under which the effect is on, A is one slider value and B is the other slider value.