Mark Kriegsman : People asked for something like beat8( BPM, uint8_t low,

@Mark_Kriegsman : People asked for something like
beat8( BPM, uint8_t low, uint8_t high)
I was surprised to learn that it is not implemented yet. Any specific reson for that? Cheers!

I made one a while back, but then didn’t end up using it. It’s pretty simple to take beatsin8 and swap out sin8 for any of the other wave generators: https://github.com/evilgeniuslabs/bloom/blob/5c766397c19e3a0cf874adba41bc03c67a81d87f/Bloom.ino#L615

Yes, sure it’s easy to write it. I just wondered why it’s not part of the library already. Beginners might like it.

I sometimes think about the general case:
a = beatwave8( BPM, lo, hi, waveFn);

Where waveFn is any function that takes a one byte ‘phase’ and returns a one byte ‘amplitude’, e.g. sin8, or triwave8, or quadwave8, or user-written functions like attackDecay8 (as seen in TwinkleFOX).

So beatsin8( BPM, lo, hi) could be defined as beatwave8( BPM, lo, hi, sin8). But passing functions as arguments to other functions? Not exactly for “beginners”…

I see your point. But one general wave function makes the necessary user code longer - nice to read, not nice to write. I basically just wondered why beatsin8 allows upper/lower limits and beat8 not.

As written, beat8 is the base generator of a one byte “phase”; everything else builds on that. beatsin8 builds a sine wave on top. There’s nothing wrong with your suggestion, it just wasn’t how I was thinking about it.

What’s the application you have for a value that goes 0…255 over and over (or some other set of values), but isn’t processed into a waveform? Just curious!

Not sure if I get the question / context right. I have no answer to that. At the end it´s all a waveform. I meant that beat8( 120, 23, 42) is simply shorter to write than a general function beatwave8( 120, 23, 42, sawtooth). Anyway your logic would cover any thinkable waveform, which is nice.
Btw. an ADSR envelope is a powerful thing to change the appearence/groove of a light / fade / movement / … completely.

Ah, I see. You want an up and down wave:
23 24 25…40 41 42 41 40 39… 24 23 24 25 26…

But that’s not what the output of beat8 is like. beat8 goes up and then starts over. If it allowed a range, you’d get:
23 24 25…40 41 42 23 24 25…40 41 42…

You can probably see now why I was confused about why you might want it, and why I was suggesting that you pretty much always want to compose a wave function like triwave8.

So maybe what you’re asking for are convenience functions like:
beattriwave8, and
beatquadwave8

The one case I can think of where you might want a value that ramps up and then starts over, but in a limited range, is if you want to loop between five modes, or sixteen colors, or seven shapes. Then the 0 1 2 3 0 1 2 3 0 1 cycles would be useful, but I can’t think of a realistic case where you’d want that to be, say, 23-based, instead of 0-based. I mean, I could invent one, it it seems very rare in real life; that’s why I asked what application you had in mind.

So I think you really want “beattriwave8”, or similar, yes?

I really mean beat8. 41 42 23 24… A sawtooth.
I explained a guy beatsin8 and he was happy. He used the function for position control (knight rider style). leds[beatsin8(…,0,NUM_LEDS)]=… Then he wanted to try a chasing light based on beat8. He was surprised that he couldn´t specify limits. So he has to scale down the result and add an offset now.

Ok! Got it!

I think I might call it beatlinear8 or something else, but ok, I see the use!

yes this function is cool, but at the same time with the new approach Daniel is adding to fasted , most of our way to think will then change , and change for better ,
im waiting for that new functionality to work on leds array …

What are you talking about @Gustavo_K ? And what has it to do with wave functions/oscillators? Did I miss something?

Stefan. You are much more knowledgable than myself to judge ,
What I see in this new paradigm is that being much easier to build complex effects , and confine effects to any extent , duplicate , mirror, invert , you name it , that the way think at the actual functions will change …
Marry Christmas !