beatsin8() and beatsin16() are very cool functions.

beatsin8() and beatsin16() are very cool functions.

I’m wondering if anyone has managed to change parameters on the fly without completely resetting the beat? I’d really like for the beat to continue at the current location, but with modified parameters, such as reversing the phase or changing the speed.

Here’s the parameters:

uint16_t beatsin16( accum88 beats_per_minute, uint16_t lowest = 0, uint16_t highest = 65535, uint32_t timebase = 0, uint16_t phase_offset = 0)

For instance, I modified the 16 bit phase_offset value (to change direction), but it appeared to set the absolute phase instead of the relative phase.

I really need to play with these more. Thank you for continuing to encourage their use Andrew.

What if you had two sperate beat functions and “blended” from one to the other (with the modified variables)?

That’s interesting, I’ll give that a shot. Right now, I get a pretty cool effect with led’s jumping all over the place, i.e. with an EVERY_N_MILLISECONDS(200) change of the phase. Am also combining a couple of beats to get a more complex pattern. Will see what blending does.

What I’m looking for is to combine sound reactive triggers, volume, peaks, peaks per second, etc, calculations to make some cool sound reactive routines.

I think you can do quite a lot without having to resort to an MSGEQ7 or FFT’s.

@Andrew_Tuline If you pull this off, I will be very excited. :slight_smile: My speaker box and Rings of Saturn light will definitely receive software upgrades :slight_smile:

Yeah I’m just looking at this now for a sound reactive thing I’m doing. Beat detection looking good but for sinelon style effects I was hoping to change bpm on the fly. I need more thinking time but will keep an eye out here.

After a day of fiddling, I ended up with some cool effects by changing the timebase and phase_offset on the fly, but was unable to get them to work well with sound and never did get a smooth transition. In addition, ambient noise increased significantly when I merged my sound and modified beatsin8 sketches (using APA102). Needs some debugging.

Am going to play with some sketches I made a while back that are inspired by:

I found a timebase of GET_MILLIS() and a phase offset of 49151 is doing what I requre (reset beatsin16 value to zero starting position).

Code attached is my test I made for my 10x5 matrix.
Without led matrix you can run serial monitor to see what I’m doing.

I’d love someone to explain how the 49141 figure could be calculated as I came to it by just looping values and looking at serial monitor output.

Understanding this might let me understand how OP can do what he wants… which I’m bound to want in the near future.

A bit more thinking: 3/4 x 65535 is 49151.25. I think I see.
So should be a matter of storing current Beatsin16 position, picking your bpm, and then doing millis() timebase and 0-65535 scaled phase shift on the position previously saved.

Position alone is not enough information to calculate the correct phase shift to apply if you need direction to be taken into account.For example an unscaled position of 16383 could be on the way down or on the way up.

I’ll be happy with just being able to specify the starting position

See Animation::aCylon.

I was only able to get this to work when zero-crossing. That is, you need to know when the sine functions are equal-valued, and cross-over to a new BPM/phase then.