Create a Sine or Triangle wave in sync with the beat

847 views
Skip to first unread message

TheMediaDex

unread,
Apr 29, 2013, 8:02:02 PM4/29/13
to ligh...@googlegroups.com
Hello!

Huge fan of LightJams and finally have some new equipment to really get to see what LightJams can do - and loving it so far!

Not being a programmer or mathematician, I'm still trying to dig thru examples and the help files on what all the formulas can do. So I apologize if this one seems simple.

Basically, I would like to have a constant sine or triangle waveform created that peaks from top to bottom in sync with the beat of the music. How would I go about doing this?

Thank you in advance for your help!

Mathieu

unread,
Apr 30, 2013, 8:37:29 PM4/30/13
to ligh...@googlegroups.com
Generating a sine wave exactly in sync with the beats is a bit tricky because beats are often inconsistent...

One function I like is:

sin(fade(1,60/bpmcounter(trigger(music.1.low.beat, 0.07, 10, 15, 0.15))))

I'm changing the sine wave speed based on the BPM of the low frequencies. 

> music.1.low.beat is the tracked music parameter. You can track only one frequency band using music.1.bandbeat(the band number)
> trigger(music.1.low.beat, 0.07, 10, 15, 0.15) is the standard beat detector function
> bpmcounter(...) returns the number of detected beats per minutes

However, usually I keep it simple and just use the beat detector function with a fade out:

fadeout(0.3, trigger(music.1.low.beat, 0.07, 10, 15, 0.15))

If you want something more "continuous", you can use the taptempo.pulse function:

fadeout(0.3, taptempo.pulse(trigger(music.1.low.beat, 0.07, 10, 15, 0.15)))

Hope this helps!


TheMediaDex

unread,
May 5, 2013, 10:24:49 PM5/5/13
to ligh...@googlegroups.com
Mathieu,

Thank you for the help (and amazing software) - I will give them a try!

treezius monocle

unread,
Feb 28, 2014, 4:20:19 AM2/28/14
to ligh...@googlegroups.com
how would you do it if you are sending a constant midi beat, like a C4 note hit on every beat? I tried replacing the trigger function with just a midi.note(1,73) but thats not really staying in time with the music. heres my failed function:: triangle((fade(1,60/bpmcounter(midi.note(1,73))))) any ideas?
Message has been deleted
Message has been deleted

Mathieu

unread,
Mar 1, 2014, 10:48:04 AM3/1/14
to
After some experiments, here's what I've got. Change the red source to track the note you want. You can also change the triangle wave by a sin wave by replacing the map.triangle function in the blue source by map.sin.

The general idea is to generate a 0%-100% signal based on a detected beat and use the map.X function to generate the shape you want. I think I'll experiment a bit more and I'll add something in Lightjams to ease this kind of thing.

Cheers,
Mathieu

Edit: I've updated the project to remove the use of the grid's speed. Now the formula is in one source: map.triangle( fadeout.linear(1 / taptempo.speed(recall(0))*20, taptempo.pulse(recall(0))) ). The value of recall(0) is the beat coming from the midi note.
beat sync wave.ljp

Mathieu

unread,
Mar 1, 2014, 4:17:35 PM3/1/14
to
Hi again,

I've uploaded a new beta version with a new function: taptempo.sawtooth. It generates a sawtooth wave in sync with the beat value. You can use it like that:

taptempo.sawtooth(midi.note(1,73))

Want a triangle wave instead?

map.triangle(taptempo.sawtooth(midi.note(1,73)))

You can throw the onbeat function in the mix to specify a beat multiple and offset:

taptempo.sawtooth(onbeat( midi.note(1,73), 2))

Download the beta version here:


Cheers,
Mathieu

D.M. Hologram

unread,
Apr 11, 2014, 10:06:36 AM4/11/14
to ligh...@googlegroups.com
Yes! Thanks!
These formulas are very good , particularly
sin(fade(1,60/bpmcounter(
trigger(music.1.low.beat, 0.07, 10, 15, 0.15)))).

The x/bpmcounter makes it possible to get a tremendous amount of layering of tempo sync'd fx.

I have been unable to make the "pulse" type fx look good.
Is it possible to make the wave of the pulse last longer?

Also if you have any more tempo sync -type formulas , would you mind sharing them here?

Cheers!

Brian

Mathieu

unread,
Apr 12, 2014, 10:53:38 AM4/12/14
to ligh...@googlegroups.com
To make the pulse lasts longer, you can add fade out to your grid or to your formula using the one fadeout(...) function.

D.M. Hologram

unread,
Apr 14, 2014, 10:11:34 AM4/14/14
to ligh...@googlegroups.com
fadeout! brilliant! Thank you! I was experimenting with formulas - adjusting the settings in oscillator mode and looking at the syntax to get some ideas - and used something beat related with a 70-sawtooth, which generated a saw down. Saw down looks nice , the light 'pops' on and then fades quick an smooth.

Michael Potvin

unread,
Nov 1, 2017, 2:58:19 AM11/1/17
to Lightjams
I'm having a hard time tapping the tempo in with a midi note using this method.  it works sometimes, but the onbeat function seems to take to many taps, and then if i don't use it, I think I'm trying to tap in a tempo that is too slow for the function to catch.    I'm using the formula almost exactly as posted, with my midi controller settings replaced for yours.  

Mathieu

unread,
Nov 2, 2017, 6:58:40 PM11/2/17
to Lightjams
Just tested taptempo.sawtooth(onbeat( midi.note(1,73), 2)) and taptempo.sawtooth(midi.note(1,73)). It seems to work ok. The minimum BPM is 30. So maybe you're trying to generate something even slower?

Mathieu

unread,
Nov 3, 2017, 10:07:03 AM11/3/17
to Lightjams
After more testing, I think the detection delay can be shortened when tapping a slow beat. 4 beats were needed for the BPM < 60. I'll make it so that only 2 beats are needed.
Reply all
Reply to author
Forward
0 new messages