Previous topicNext topic

Expression Help (Using Variable) / Syncing Timing of Modules

Questions, comments, feedback, etc.
Post Reply
iglooooooo
Posts: 15
Joined: Thu May 28, 2020 3:24 am

Expression Help (Using Variable) / Syncing Timing of Modules

Post by iglooooooo »

I am having trouble writing the correct expression and would appreciate any guidance.

Context:
I need Event1 and Event2 to happen at the same exact time (each on a separate module). To achieve this, I am using a Sine Osc modifier on both, making the timing in sync.

Goal:
Each time the sine osc hits 1, I want the output value to increase by 2.

Osc hits 1 first time, output is 2. Output remains at 2 until Osc hits 1 again, then output is 4. And so on. That output number steadily keeps increasing by 2, in rhythm with the Osc.

Current Strategy:
I am trying to use a variable "y" to achieve this. The following is what I have written out now, but I am new to creating expressions like this and am obviously messing something up because it's not working.

Code: Select all

var y:= if(x=1, +2,+0)
x=y
My thought is "y" is increasing by 2 each time the [input] x is 1. And so the [output] x just has to match whatever y is. But again, my logic is clearly faulty because this is not working.

Anyone able to offer any suggestions / point out my stupid flaws?
iglooooooo
Posts: 15
Joined: Thu May 28, 2020 3:24 am

Re: Expression Help (Using Variable)

Post by iglooooooo »

If it helps to have some visual context, this is the module and the expression modifier I'm trying to find the right expression for: https://imgur.com/WZOEOF8
(The step modifier is there because the "x=1" condition was never being met without it.)
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: Expression Help (Using Variable)

Post by Magic »

I think you are making things way too complicated for yourself.

First of all, if you want two or more modules to be synced, use a Global. Very simple.

Second, if you want a value to increase by 2 every so often, just do:
Increase(whatever speed you want)
Step(2)
iglooooooo
Posts: 15
Joined: Thu May 28, 2020 3:24 am

Re: Expression Help (Using Variable)

Post by iglooooooo »

Eric, very grateful for your feedback. Thank you. I had omitted some context in an attempt to make my question clearer, but am seeing now that I should explain a bit more.

See screenshot: https://imgur.com/a/YXESSWn

The MultiMix module is using the Sine Oscillator to oscillate between the two inputs.
-When MultiMix's Index is 1 (Input1 cannot be seen), I want Input1 to update.
-When MultiMix's Index is 0 (Input2 cannot be seen), I want Input2 to update.

Since the MultiMix module is utilizing the Sine Oscillator, I need the two input modules to somehow be in sync with that oscillator (as described above). It's very likely that I'm still making this way too complicated for myself, as you pointed out. And I probably should be using globals.

Backing it up further
The overall idea I have here is to constantly display an ever-changing visual by using the Replicate Random module and repeatedly changing its RandomSeed parameter. My problem is that there's a sudden "jump" in the visual when Replicate Random updates RandomSeed so I'm oscillating between two of them to hide when that "jump" occurs.
iglooooooo
Posts: 15
Joined: Thu May 28, 2020 3:24 am

Re: Expression Help (Using Variable) / Syncing Timing of Mod

Post by iglooooooo »

OK I was able to solve it following your advice in another thread https://magicmusicvisuals.com/forums/vi ... f=2&t=2143

Just made a couple tweaks to fit my desired result. This is my set up:
https://imgur.com/a/Ht99w2M

Thanks again for all the great support you offer.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: Expression Help (Using Variable) / Syncing Timing of Mod

Post by Magic »

No problem.
Post Reply