Mousestate Question

Oct 28, 2013 at 8:11am

Mousestate Question

Hey,

I’m messing about with a patch using the mousestate object and I am trying to figure out the best way to do this. What I want to do is be able to basically split the screen in 2, so when my mouse scrolls left and right past the halfway mark, it sends a bang. This bang will be sent to a gswitch2 so that when the mouse is in the left half of the screen the left outlet is being used and when it is on the right, it is the opposite. I have tried using ‘select’ with the values out of mousestate, but the values don’t update fast enough if i run my mouse across the screen at a fast pace only when i do it gently. I have the metro object set to 1 connected to mousestate so it is updating at 1 ms but this is not fast enough.

So basically what I am asking is, if anybody knows the best way to get ’1′ bang when the mouse moves left and ’1′ bang when mouse moves right of the half way mark. Preferably when the mouse is moved at fast and slow speeds.

Thanks for your help :)

#269347
Oct 28, 2013 at 9:03am

you can send [mousestate] the message “poll” instead of banging it through [metro].
And instead of using [select] and trying to obtain an exact number, why don’t you use [>], detecting when the mouse x value goes above a certain number?

#269351
Oct 28, 2013 at 9:50am

Thanks,

Will give that a go now :) have only been using max for a short while really, just doing a few things in Uni so still trying to get my head around it.

#269356
Oct 28, 2013 at 10:52am

Some other objects you’ll want to investigate are [screensize], [unpack], and [change].

(Spoiler alert: Don’t look at the following example till you’ve tried solving it yourself.)
<code>

– Pasted Max Patch, click to expand. –

</code>

#269367
Oct 28, 2013 at 11:28am

Thanks Chrostopher,

haven’t looked at your patch yet, but i used [screensize] and [unpack] so that when the patch is opened on any system, the max and min values will be set straight away so that my patch will work on whichever size screen. Instead of using the mid point of the screen as the crossover point, i instead used the extreme left and right values to send a bang to the [gswitch2]. Until i figure out a better way myself, this work around will do :)

Thanks again guys

#269370
Oct 28, 2013 at 11:31am

Just after looking at your patch and seeing you already have the mid point method done ha.

I think i will use a combination of the 2 in my project.

Thanks

#269372
Oct 29, 2013 at 8:19pm

Just curious…but what is the necessity of the [change] object? It seems to work perfectly well without it. What do you mean by “suppress repetitions”?

Also, it seems to work perfectly well without the [!] and [+] objects too!

<code>

– Pasted Max Patch, click to expand. –

</code>

#269541

You must be logged in to reply to this topic.