Logical comparator in Reason

Have an urge to learn, or a calling to teach? Want to share some useful Youtube videos? Do it here!
Post Reply
User avatar
ljekio
Posts: 962
Joined: 21 Jan 2015

18 Sep 2018

Anybody help me with create simply logic equation IF A = B THEN 1 ELSE 0 in Reason (stock or RE)?
DVC-1 haven't "equal", TRUTH works with equation ">0" or raise value.

User avatar
rcbuse
RE Developer
Posts: 1175
Joined: 16 Jan 2015
Location: SR388
Contact:

18 Sep 2018

What are you trying to accomplish? CV A == CV B can be difficult because you might consider two CV values equal but the precision of the math doesn't. i.e 0.77171 != 0.77172

User avatar
ljekio
Posts: 962
Joined: 21 Jan 2015

18 Sep 2018

Note CV do not require deep precision, I think.
I need compare two note CV values and return 1 if equal it.

User avatar
rcbuse
RE Developer
Posts: 1175
Joined: 16 Jan 2015
Location: SR388
Contact:

18 Sep 2018

ljekio wrote:
18 Sep 2018
Note CV do not require deep precision, I think.
I need compare two note CV values and return 1 if equal it.
Reason devices take CV and quantize it to 128 steps to get a MIDI note value. For instance the entire range from 0.0 to 0.0078125 would be 'equal' to C-2. I can't think of an easy way, even with my own devices, to trigger on two CVs being in the same note range.

User avatar
Timmy Crowne
Competition Winner
Posts: 357
Joined: 06 Apr 2017
Location: California, United States

18 Sep 2018

For an equal value check, you could:

Route CV(a) and CV(b) into a Thor’s CV inputs 1 and 2.

Hold a MIDI note for the Thor so that its gate is held open. (You can sequence the note and play the song for this to trigger.)

Use the mod matrix to send CV input 1(a) to Filter 1 Audio Input with an amount of 100, and CV input 2(b) to the same destination with an amount of -100 to essentially subtract (b) from (a).

Set the Shaper module to rectify, with full drive. This will ensure that if there is any difference between (a) and (b), the Shaper will return a positive value.

Use the mod matrix to route the shaper output to Global Env Gate Trig and Set Global Env Sustain level to maximum.

Turn Rotary 1 to 127 and route it to CV Out1. Also route Global Env to CV Out1, with an amount of -100. This means that your function will default to false unless (a) and (b) are equal.

***MAKE SURE THE THOR’S AUDIO OUTPUTS ARE DISCONNECTED! Sending DC signal to your audio outputs is something I don’t think you want. :)***


Sent from my iPhone using Tapatalk

User avatar
ljekio
Posts: 962
Joined: 21 Jan 2015

18 Sep 2018

Thank you, Timmy, but I can't take comparator with that patch (I can have error somewhere).

User avatar
selig
RE Developer
Posts: 11685
Joined: 15 Jan 2015
Location: The NorthWoods, CT, USA

18 Sep 2018

Timmy Crowne wrote:
18 Sep 2018
For an equal value check, you could:

Route CV(a) and CV(b) into a Thor’s CV inputs 1 and 2.

Hold a MIDI note for the Thor so that its gate is held open. (You can sequence the note and play the song for this to trigger.)

Use the mod matrix to send CV input 1(a) to Filter 1 Audio Input with an amount of 100, and CV input 2(b) to the same destination with an amount of -100 to essentially subtract (b) from (a).

Set the Shaper module to rectify, with full drive. This will ensure that if there is any difference between (a) and (b), the Shaper will return a positive value.

Use the mod matrix to route the shaper output to Global Env Gate Trig and Set Global Env Sustain level to maximum.

Turn Rotary 1 to 127 and route it to CV Out1. Also route Global Env to CV Out1, with an amount of -100. This means that your function will default to false unless (a) and (b) are equal.
Super clever solution - Thor to the rescue once again!
Don't forget to turn the "Gate Trig" on the Global Env OFF, or the note you use to trigger the voice section will also trigger the Global Env, defeating the purpose. Also, set Global Env release to zero.
:)
Selig Audio, LLC

User avatar
Timmy Crowne
Competition Winner
Posts: 357
Joined: 06 Apr 2017
Location: California, United States

18 Sep 2018

ljekio wrote:
18 Sep 2018
Thank you, Timmy, but I can't take comparator with that patch (I can have error somewhere).
Maybe my explanation was unclear. I've attached a test file here:

Equal Value Checker.reason.zip
(73.78 KiB) Downloaded 49 times

You'll see that when Synth A and Synth B both play the same note (G3), the Equal Value Checker returns true, and triggers a cymbal sample on the Kong. Hope this is what you're looking for!

What @rcbuse says is true though, if the MIDI note values are even slightly off, this won't work.
selig wrote:
18 Sep 2018
Super clever solution - Thor to the rescue once again!
Don't forget to turn the "Gate Trig" on the Global Env OFF, or the note you use to trigger the voice section will also trigger the Global Env, defeating the purpose. Also, set Global Env release to zero.
:)
EDIT: Good catch, Selig. I forgot that I always start with a completely zeroed-out Thor!

User avatar
rcbuse
RE Developer
Posts: 1175
Joined: 16 Jan 2015
Location: SR388
Contact:

18 Sep 2018

Timmy Crowne wrote:
18 Sep 2018

What @rcbuse says is true though, if the MIDI note values are even slightly off, this won't work.
You should be fine if you are driving it with a sequencer like matrix or RPG. But say if you wanted to test note equality for two free running LFOs, you are going to have some issues.

User avatar
selig
RE Developer
Posts: 11685
Joined: 15 Jan 2015
Location: The NorthWoods, CT, USA

18 Sep 2018

Timmy Crowne wrote:
18 Sep 2018
What @rcbuse says is true though, if the MIDI note values are even slightly off, this won't work.
Just to be clear, what cases will a Note CV device generate a non integer Note CV value?
I can't think of any, so I'm curious what I might be missing.

Of course, if you're talking about generic CV values, they are floating point, not integer.
Selig Audio, LLC

User avatar
rcbuse
RE Developer
Posts: 1175
Joined: 16 Jan 2015
Location: SR388
Contact:

18 Sep 2018

selig wrote:
18 Sep 2018
Timmy Crowne wrote:
18 Sep 2018
What @rcbuse says is true though, if the MIDI note values are even slightly off, this won't work.
Just to be clear, what cases will a Note CV device generate a non integer Note CV value?
I can't think of any, so I'm curious what I might be missing.

Of course, if you're talking about generic CV values, they are floating point, not integer.
Well, there isn't any such thing as an integer CV value, CV is always floating point, typically -1.0 to +1.0 (but can be larger)
It only becomes a MIDI value when a device multiplies incoming CV by 127 and converts to an integer.
Something like the matrix would take an integer note value and divide to by 127 to get the CV value.
Like C-3 = MIDI 60 = 60.0/127.0 = 0.4724409449 CV
Like C#-3 = MIDI 61 = 61.0/127.0 = 0.4803149606 CV

But all the values inbetween 0.4724409449 and 0.4803149606 would also be valid once converted back

A synth would also take 0.48000000 * 127.0 = 60.96 = 60 = C-3

User avatar
Timmy Crowne
Competition Winner
Posts: 357
Joined: 06 Apr 2017
Location: California, United States

18 Sep 2018

I’ve never programmed an RE, but I would imagine it’s possible a developer could code a device’s tuning with round-off such that note values are functionally accurate, but not precise to the floating point. Theoretically, the device would behave as expected in Reason’s environment, but its Note CV output wouldn’t necessarily match other devices perfectly for the same pitch class. Perhaps there are safeguards in the API that prevent this.


Sent from my iPhone using Tapatalk

User avatar
rcbuse
RE Developer
Posts: 1175
Joined: 16 Jan 2015
Location: SR388
Contact:

18 Sep 2018

Timmy Crowne wrote:
18 Sep 2018
I’ve never programmed an RE, but I would imagine it’s possible a developer could code a device’s tuning with round-off such that note values are functionally accurate, but not precise to the floating point. Theoretically, the device would behave as expected in Reason’s environment, but its Note CV output wouldn’t necessarily match other devices perfectly for the same pitch class. Perhaps there are safeguards in the API that prevent this.


Sent from my iPhone using Tapatalk
Well, there is a standard formula that all devices conform to for MIDI > CV > MIDI conversions. However, if you are in the realm of CV, you can do things like, say, with Janitor, you could add 0.0315 CV to a signal and transpose all notes up 4 semitones, but if you compare those values to other values, they will be the same "notes" according to the conversions, but not the same value.

User avatar
Timmy Crowne
Competition Winner
Posts: 357
Joined: 06 Apr 2017
Location: California, United States

18 Sep 2018

Ah I see. So a CV signal could be given a slight offset but still convert to the “proper” MIDI note. Perhaps a Neptune could be placed inline to quantize both CV signals prior to checking for equivalency.


Sent from my iPhone using Tapatalk

User avatar
selig
RE Developer
Posts: 11685
Joined: 15 Jan 2015
Location: The NorthWoods, CT, USA

18 Sep 2018

rcbuse wrote:
18 Sep 2018
selig wrote:
18 Sep 2018


Just to be clear, what cases will a Note CV device generate a non integer Note CV value?
I can't think of any, so I'm curious what I might be missing.

Of course, if you're talking about generic CV values, they are floating point, not integer.
Well, there isn't any such thing as an integer CV value, CV is always floating point, typically -1.0 to +1.0 (but can be larger)
It only becomes a MIDI value when a device multiplies incoming CV by 127 and converts to an integer.
Something like the matrix would take an integer note value and divide to by 127 to get the CV value.
Like C-3 = MIDI 60 = 60.0/127.0 = 0.4724409449 CV
Like C#-3 = MIDI 61 = 61.0/127.0 = 0.4803149606 CV

But all the values inbetween 0.4724409449 and 0.4803149606 would also be valid once converted back

A synth would also take 0.48000000 * 127.0 = 60.96 = 60 = C-3
In what case would a value of 0.48 be output from a CV device to represent C3? Isn't every CV Note value for C3 the same float value? Or are you suggesting some devices don't use the same formula to derive the Note CV value?

And if the above is true, how can a comparator fail to see two "C3" values as being equal, whether integer or float?

I thought that was the question here, whether a comparator can distinguish between two C3 values and see them as being the same. My question was based on that line of reasoning, so maybe I should rephrase: in what case would two C3 CV Note values NOT be seen as the same by a "compare" function?
Selig Audio, LLC

User avatar
rcbuse
RE Developer
Posts: 1175
Joined: 16 Jan 2015
Location: SR388
Contact:

18 Sep 2018

selig wrote:
18 Sep 2018
in what case would two C3 CV Note values NOT be seen as the same by a "compare" function?
Well, say you are getting freaky with CV and using a LFO to drive note values. Or if you are using PSQ which doesn't use note values it just outputs 0.0 to 100.0. Or you are using something like Janitor to add a little CV to transpose notes from a matrix or RPG.

User avatar
selig
RE Developer
Posts: 11685
Joined: 15 Jan 2015
Location: The NorthWoods, CT, USA

18 Sep 2018

rcbuse wrote:
18 Sep 2018
selig wrote:
18 Sep 2018
in what case would two C3 CV Note values NOT be seen as the same by a "compare" function?
Well, say you are getting freaky with CV and using a LFO to drive note values. Or if you are using PSQ which doesn't use note values it just outputs 0.0 to 100.0. Or you are using something like Janitor to add a little CV to transpose notes from a matrix or RPG.
Got it!
:)
Selig Audio, LLC

User avatar
ljekio
Posts: 962
Joined: 21 Jan 2015

19 Sep 2018

Timmy Crowne wrote:
18 Sep 2018

You'll see that when Synth A and Synth B both play the same note (G3), the Equal Value Checker returns true, and triggers a cymbal sample on the Kong. Hope this is what you're looking for!
Great and unexpected solution, Timmy!
Lot of thanks!

User avatar
ljekio
Posts: 962
Joined: 21 Jan 2015

19 Sep 2018

But... Im so dumb for fix one problem.
After key (equal) note that device trigger any next note before off.
Attachments
drumroll (under construction)_v2.zip
(10.08 KiB) Downloaded 40 times

User avatar
Timmy Crowne
Competition Winner
Posts: 357
Joined: 06 Apr 2017
Location: California, United States

19 Sep 2018

ljekio wrote:
19 Sep 2018
But... Im so dumb for fix one problem.
After key (equal) note that device trigger any next note before off.
This is an ingenious patch! Wow. I think I see the issues you're having with it:

The most recently "rolled" note is being triggered on any next different note’s onset.
(Substitute Seq Gate for Global Env in Thor 1 Mod 13; Set Global Env's delay to 0.1ms and full sustain, zero out other env parameters.)

In SELECTED mode, the currently rolled note is undesirably held over when a different note is played legato.
(Activate MIDI Trigger Button in Comparathor to ensure current values are being passed into the Shaper.)

A note's "rolled" sequence begins simultaneously with its manual drum trigger, resulting in build up of multiple samples and phasing.
(Add two Note Echo's to Thor 1 and Comparathor as a variable timing lookaheads, creating a natural flam effect when the roll starts.)

Here's the version with the changes I made:
drumroll (under construction)_v2.1.cmb.zip
(11.39 KiB) Downloaded 41 times


Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests