Previous topicNext topic

InputSelector: passing existing input # into an expression

Questions, comments, feedback, etc.
Post Reply
directordash
Posts: 4
Joined: Sun Jul 23, 2017 9:16 pm

InputSelector: passing existing input # into an expression

Post by directordash »

I'm using an expression to take MIDI notes and use them to change the channel on my InputSelector, like so:

Code: Select all

if (roundn(x,3) == 0.236) 1; else if (roundn(x,3) == 0.252) 2; else if (roundn(x,3) == 0.268) 3; else if (roundn(x,3) == 0.283) 4; else if (roundn(x,3) == 0.299) 5; else if (roundn(x,3) == 0.315) 6; else if (roundn(x,3) == 0.331) 7; else if (roundn(x,3) == 0.346) 8; else if (roundn(x,3) == 0.362) 9; else 0;
It all works, however where I've got else 0; I'd really like this to return whatever the current channel is before the expression runs. Is there a variable for the current channel with magic that I can pass through, and return instead? e.g....

Code: Select all

... else if (roundn(x,3) == 0.362) 9; else current_channel_value;
or something to that effect?

The problem I have is that pressing any other MIDI button on my controller (ones that serve different functions elsewhere) they will be picked up by this selector and return zero every time; affecting the selector when i'd rather they didn't interfere. So if anyone knows of another way, that would be great!

D.
artnik
Posts: 268
Joined: Tue Jan 05, 2016 5:33 pm

Re: InputSelector: passing existing input # into an expressi

Post by artnik »

The if control in the expression modifier takes the generic form of:

if (x,y,z),

i.e. "If x is true then return y else return z"

The original x can be used as the z component, so if (x > 1.0, 3.0 , x) would return 3 when the condition is true and the original input x if not.
directordash
Posts: 4
Joined: Sun Jul 23, 2017 9:16 pm

Re: InputSelector: passing existing input # into an expressi

Post by directordash »

artnik wrote:The if control in the expression modifier takes the generic form of:

if (x,y,z),

i.e. "If x is true then return y else return z"

The original x can be used as the z component, so if (x > 1.0, 3.0 , x) would return 3 when the condition is true and the original input x if not.
Which is what I had originally, in 9 separate expressions (one for each MIDI control) – but that still doesn't help me return Z as the existing control value.

The problem is that x is the input value (i.e. the MIDI note) and not the selected value on the InputSelector – so this isn't what I want to pass through.
i.e. MIDI note 0.252 (note 32) in this case activates input channel #2.

I need it so that if none of the 9 MIDI notes above are passed through, the InputSelector is unaffected and retains whatever channel input it had prior to receiving a new MIDI command.

I trust there has to be a way of doing this; otherwise every MIDI controlled parameter in Magic would be affected adversely by every MIDI command received.
artnik
Posts: 268
Joined: Tue Jan 05, 2016 5:33 pm

Re: InputSelector: passing existing input # into an expressi

Post by artnik »

Ah, I see your issue now. Apologies, guess I didn't read carefully enough. I have no answer. :-(

So far, I've been underwhelmed by conditionals in Magic. I ran into similar (but unrelated) issues on an installation project this summer because Global Variables were not exposed to the Expression modifier and I could not set up a conditional statement based on comparing globals.

I think that looking to the future, having some kind of method to expose variables to the EXP Modifier is essential, as well as comparing the state of modifiers. It may be beyond the scope of the software's purpose, but it would open up MMV to being able to create game-like scenarios and conditional branching of scenes.

Having some kind of event-based modifier system would be fantastic. "On Value Change", "On Scene Start", that kind of thing to manipulate the Globals, and make more complicated conditionals, similar to your case, possible.

Another useful thing would be local variables, which operate only within a scene. I found that another use case was tracking scores for comparison between multiple user inputs, but globals kept counting their input from frame 1, as opposed to scene start. As far as I can tell, it's not yet possible to create scenes that are "aware" of their own state, to trigger scene changes. In my case, I was limited to setting static scene lengths in the playlist.

Eric has mentioned that opening up variables to the Expression modifier is on the radar, but no idea where it sits on the to do list.
directordash
Posts: 4
Joined: Sun Jul 23, 2017 9:16 pm

Re: InputSelector: passing existing input # into an expressi

Post by directordash »

artnik wrote:Eric has mentioned that opening up variables to the Expression modifier is on the radar, but no idea where it sits on the to do list.
Hopefully near the top :D

I'd be interested to see how others have used MIDI successfully in Magic; I must be missing something crucial, as the whole idea of passing in MIDI information in is that a scene or modifier only responds to the message(s) that are relevant to it. I'll keep trying!
skarabee
Posts: 130
Joined: Fri Aug 28, 2015 3:11 am

Re: InputSelector: passing existing input # into an expressi

Post by skarabee »

Hi Directordash.
I'm working a lot with midi, live inputs from keyboards and controllers and prepared midifiles. Unfortunately, I'm not sure if this can help you, but I used another way to map notes to input channels. Assuming you have 9 images to show, you could use it:
note selector.jpg
note selector.jpg (11.13 KiB) Viewed 6935 times
I n your case, as I understand it, you want to use a whole tone scale and ignore semitones, so you have to set "scale" to 5, so every 0.5 step will be ignored and the current channel is still displayed.
edit: this only works for ascending scale...:(

@artnik: +1 for event-based triggers. ;)
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: InputSelector: passing existing input # into an expressi

Post by Magic »

I must be missing something crucial, as the whole idea of passing in MIDI information in is that a scene or modifier only responds to the message(s) that are relevant to it. I'll keep trying!
I think it's because you are using the Note Number feature, which responds to all the notes on the channel and uses the most recently received one as the current value. You might want to try using a different method of control, such as an individual Note Velocity or Control Change. It is easy to set these up automatically using the MIDI Learn function: https://magicmusicvisuals.com/downloads ... #MIDILearn
Eric has mentioned that opening up variables to the Expression modifier is on the radar, but no idea where it sits on the to do list.
I can't make any promises, but I'm hoping to have some basic functionality working in v2.11 (the release after the imminently upcoming one). We'll see how it goes, and then decide if there are further directions to be pursued.
perzon
Posts: 17
Joined: Tue Sep 15, 2015 7:38 pm

Re: InputSelector: passing existing input # into an expressi

Post by perzon »

I am not sure if this helps in any way, but I mapped the direction pad on an Xbox controller for changing 2 input selectors. So you have 4 midi buttons that can cycle up and down between the 2 selectors. Here is the glovepie code. I am sure there would be an easy way to do this as an Expression.

Code: Select all

if Pressed(XInput.Up) and var.UpLRS < 101 {
   var.UpLRS = var.UpLRS + 1
   midi4.channel1.Control21 = (var.UpLRS-1)/127
   if var.UpLRS = 101 {
   var.UpLRS = 0

             }
   }
   if Pressed(XInput.Down) and var.UpLRS > -1 {
   var.UpLRS = var.UpLRS - 1
   midi4.channel1.Control21 = (var.UpLRS-1)/127
   if var.UpLRS = -1 {
   var.UpLRS = 100
   midi4.channel1.Control21 = (var.UpRS-1)/127
             }
   }
   if Pressed(XInput.Left) and var.LeftLRS < 101 {
   var.LeftLRS = var.LeftLRS + 1
   midi4.channel1.Control23 = (var.LeftLRS-1)/127
   if var.LeftLRS = 101 {
   var.LeftLRS = 0
   midi4.channel1.Control23 = (var.LeftLRS-1)/127
             }
   }
   if Pressed(XInput.Right) and var.LeftLRS > - 1 {
   var.LeftLRS = var.LeftLRS -1
   midi4.channel1.Control23 = (var.LeftLRS-1)/127
   if var.LeftLRS = -1 {
   var.LeftLRS = 100
   midi4.channel1.Control23 = (var.LeftLRS-1)/127
             }
   }
Attachments
Input Selection.
Input Selection.
magic_inputselect.PNG (15.56 KiB) Viewed 6375 times
Post Reply