How to make a [bang] at [cycle~220] + [cycle~222] resulting sinus beat?

Master Beatit's icon

Max Patch
Copy patch and select New From Clipboard in Max.

Master Beatit's icon

Is there no answer because the question is unclear?

So let me rephrase: I have two [cycle~] objects, one at 220 the other at 222, both combined going directly into the [dac~]. The audible result is a pulse (the dictionary says "sinus beat", but I am not sure about this) whose volume goes up and down every second or so.

I like to make a [bang] at every maximum or minimum of that "volume curve". How would you achieve that?

Roman Thilenius's icon


what you are going to do with it? and will the frequencies be modulated?

i ask because if you want it sample exact you could sychronize the beginning using phasors and make the system aware of the phase of the cycles - then you can calculate these min and max points in the "beating envelope" in advance and dont need to measure anything at all.

for example currently in your patch the maximum appears at the first sample / 0.0 ms, then the minimum appear at ((abs(220 - 222)) / 2 * 1000) milliseconds.

the alternative would be measuring power over time, which 1. doesnt really work good when the material is a cosine and 2. introduces a delay.

bertrandfraysse's icon

something like that ?

Max Patch
Copy patch and select New From Clipboard in Max.

Peter Ostry's icon

You need an envelope follower that delivers your "overall" waveform. The attached patch uses a [meter~] for envelope following and bangs once when the signal level begins to go down, which means immediately after the maximum. Close enough, I think.

1. This method is not sensitive to signal level or waveform, but since your "overall" wave is sliced, it is time-dependent. By default the meter's refresh interval is 50 ms. At fast pulse rates it loses accuracy. If you make the refresh interval too short you may get double triggers at low pulse rates. I assume that you want this for some rhythmical triggers and have set the refresh interval to 20 ms, which should work if you want something like LFO rates.

2. The cycle objects are not synced. Playing with frequencies and then setting both to the same value most likely produces random triggers because the signals are randomly mixed. Therefore the control signal is gated, there is no output if the two frequencies are equal.

Max Patch
Copy patch and select New From Clipboard in Max.

Master Beatit's icon

Thank you all.

I'll go with Peters suggestion; it's close enough and I understand what's happening. I'm sure Roman is more exact but also above my crown and it's way too hot to open that beginners math book.

Peter Ostry's icon

The difference to Roman’s scientific approach is, that mine is a quick hack that works well within a certain range. It is not bound to a general timing and when you change frequencies and don’t restart the audio engine it drifts to somewhere. By testing frequency ranges you may get the length of the slices under control and adjust the meter’s refresh interval better. Otherwise there is not much room for improvement. However, it proves that the [meter~] is a pretty good and simple envelope follower for low frequencies.

Roman Thilenius's icon


that´s why didnt post a patch... after i noticed that this phasor/sah based domain changing stuff will cause more confusion than help. but maybe i will later. :)

meter/peakamp are a great all-in-one solution... unless the frequencies go higher than they currently are...