Expression Help (Using Variable) / Syncing Timing of Modules

Thu May 28, 2020 3:46 am

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: 6
Joined: Thu May 28, 2020 3:24 am

Re: Expression Help (Using Variable)

Thu May 28, 2020 2:32 pm

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.)
iglooooooo
 
Posts: 6
Joined: Thu May 28, 2020 3:24 am

Re: Expression Help (Using Variable)

Thu May 28, 2020 3:09 pm

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)
Eric
Site Admin
 
Posts: 2795
Joined: Wed Apr 09, 2014 9:28 pm

Re: Expression Help (Using Variable)

Thu May 28, 2020 6:35 pm

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: 6
Joined: Thu May 28, 2020 3:24 am

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

Thu May 28, 2020 9:18 pm

OK I was able to solve it following your advice in another thread https://magicmusicvisuals.com/forums/viewtopic.php?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.
iglooooooo
 
Posts: 6
Joined: Thu May 28, 2020 3:24 am

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

Fri May 29, 2020 7:12 pm

No problem.
Eric
Site Admin
 
Posts: 2795
Joined: Wed Apr 09, 2014 9:28 pm

Return to General Discussion

© 2020 Color & Music, LLC • This web site is mobile-friendly