Toggle/If statement/switch activation

Michael Mich's icon

Hello,
I have 2 output sources as you can see on the patch. I am using Kinect so I can control the outputs with values I receive once I am connected with the Kinect.
What I am trying to do is to have activated only one of them each time and when a specific value found to switch to the other sound source. I am not sure how I could to this as I am new with Max. I have added an if Statement within a toggle object but what I tried didn't work. So in the if statement I added $i1 ==3 as that value will be a position coming from the Kinect, so when that value is triggered I want the other output source to be activated so the user can switch sound 'environments' when does a specific moment. I am not sure whether I need to use toggles, if statement, a selector or anything else to make it work. Any help would be appreciated!!

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

Michael Mich's icon

Any ideas??

yaniki's icon

I'm not sure, what you want to create... Is it something wrong with the selector~?

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

Michael Mich's icon

Hello,

So far I have this. Each value of the selector activates a different source.
What I want to do is the value of the selector to be changed when a specific value is found.
I will be tracking a user using the kinect and for instance when a value is equal to 3 I want the selector to switch to the next value(source) automatically.
Thanks

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

yaniki's icon

Something like this?

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

Michael Mich's icon

Yeah!!
thank you

Michael Mich's icon

Can I put a range instead of a specific value?

Michael Mich's icon

I mean instead of the number 3, to change when a value between 3-6 if found?

yaniki's icon

Change [select 3] to [select 3 4 5 6] and connect all outlets - except the rightmost - to the radiogroup.

Michael Mich's icon
Michael Mich's icon

Hello again, I would like to ask you something more in case you could help me.
So I am using the Selector to switch between two output sources(similar to the example you sent me) when a specific value if found.
I am using Kinect and sending the values to Max but unfortunately event if I send the corresponding values the selector doesn't work properly. What I believe is that there are so many incoming values per second and the selector can't handle them. (If you try to change the numbers that we are sending to the selector really quick it won't respond). I tried different things with the Kinect but none work. For example I calculate the Y position of the head and when I jump the value increases from 130 to 150. So I tried the selector with the value 150 but even if it is found(rarely) it happens really quick that the selector would change but immediately return back to the other value. I was wondering whether there is another way to do that (maybe if I could add the threshold values into a range..idk)? Any idea would be really helpful.

Roman Thilenius's icon

>> Can I put a range instead of a specific value?

[split 3 7]

or

[if ($i1 >=3) && ($i1<=7) then $i1]

Michael Mich's icon

Thanks, it doesn't work though, it's like having several selector values so it behaves the same.

Source Audio's icon

What do You actually want ?
to react to specific incoming range and ignore fast jumps ?
Than use peak.
Or something else ?

yaniki's icon

If you are parsing data stream from kinect it is probably a list whose first element is the user index - that is your entry point.

If you want the change in this index to trigger the switching of the audio environment learn how to deal with lists in Max and how to detect changes in the data stream. This (+ some info about the basic logic and data flow inside Max itself) is absolute generic "homework" if you want to understand the basics of Max.

Read the documentation regarding to the "lists" and try to learn how to use objects such as [zl.change], [change], [pack], [unpack], [trigger].

Michael Mich's icon

@Source Audio, More or less yes, at first I just want to react to a specific value or range (peak would be an option but not sure if would be ideal as I want to switch the audio sources several times and a peak would make that difficult as the space(environment values) is limited (e.g if you jump you would then need to jump higher(right?)), I tried a simple example using the x-position of the user which is a range between 100-300 so I have added the value 200 as the selector value to make the switch happen when is found but it still doesn't work. As I explained and above it seems that it gets so many values per second so it can't handle them or somthng.

@Yaniki, Ok I will go through the lists, hope there is a way to make it work.

Thanks

Source Audio's icon

I don't see why that should be difficult.
Select will not work as stream is too fast, but as Roman suggested,
if You use range for example from 100 - 300 to switch number 1,
and range from 301 - 400 to switch number 2, than just
use split object or if statement to trigger number 1 or 2 , just use change object
at the output.
Or do I still missunderstand the switching ?

Luke Woodbury's icon

Does [past] do it? Hard to know what you want exactly, maybe post an annotated patch showing problem.

Michael Mich's icon

@Source, what you are suggesting might works, I have to give a try again as I just tried the selector(split). For now I did this which quite works (at least) (and bit similar to what you suggested I think). Thanks

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

@Luke What do you mean?
Thats pretty much the idea

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

I don' have time now to explain a lot, ill come back later but in order to work you need to activate the metro(550) and you will realise the difference when the value that is going to the selector is over 40, so in my case when a value over 40 is found ( a temporal movement like a jump or velocity(moving fast) will generate the selector.