Forums > MaxMSP

Mousestate Question

October 28, 2013 | 8:11 am

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 :)


October 28, 2013 | 9:03 am

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?


October 28, 2013 | 9:50 am

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.


October 28, 2013 | 10:52 am

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>


October 28, 2013 | 11:28 am

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


October 28, 2013 | 11:31 am

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


October 29, 2013 | 8:19 pm

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>


Viewing 7 posts - 1 through 7 (of 7 total)