Forums > Java

Can mxj watch a patcher for arbitrary events?

November 29, 2006 | 1:49 am

Hello all,

I’m trying to write an mxj kinda-alternative to autopattr and company. I want to interface max UI stuff with JMSL (algomusic.com) to record presets and play back my actions.

I REALLY want to do this without wires. I can easily send messages to arbitrary MaxBoxes, but I can’t seem to figure out how to make java respond when I click (for instance) a bangbutton that isn’t wired to the mxj.

Any ideas? I tried implementing MessageReceiver but it seems that it only receives events from AudioBuffer.

best,
Kevin


December 2, 2006 | 6:02 pm

No ideas? Topher (I think you’re the most qualified!)?

-kevin


December 6, 2006 | 8:38 pm

Hi Kevin,

>From within some Java code I can’t think of any way to get at the
message (register a callback, or something like that) that a lonely,
unconnected bang button sends out.

Sorry,
Ben

On 11/28/06, Kevin Cox wrote:
>
> Hello all,
>
> I’m trying to write an mxj kinda-alternative to autopattr and company. I want to interface max UI stuff with JMSL (algomusic.com) to record presets and play back my actions.
>
> I REALLY want to do this without wires. I can easily send messages to arbitrary MaxBoxes, but I can’t seem to figure out how to make java respond when I click (for instance) a bangbutton that isn’t wired to the mxj.
>
> Any ideas? I tried implementing MessageReceiver but it seems that it only receives events from AudioBuffer.
>
> best,
> Kevin
>


January 13, 2007 | 12:26 pm

Quote: Kevin Cox wrote on Wed, 29 November 2006 02:49
—————————————————-
> Hello all,
>
> I’m trying to write an mxj kinda-alternative to autopattr and company. I want to interface max UI stuff with JMSL (algomusic.com) to record presets and play back my actions.
>
> I REALLY want to do this without wires. I can easily send messages to arbitrary MaxBoxes, but I can’t seem to figure out how to make java respond when I click (for instance) a bangbutton that isn’t wired to the mxj.
>
> Any ideas? I tried implementing MessageReceiver but it seems that it only receives events from AudioBuffer.
>
> best,
> Kevin
—————————————————-

I have the same problem in javascript. The way I do this now is to put a pattr outside the js (in your case mxj) object, reserve a special inlet for it, bind it to the pattr where your input enters the patch. You know about the existence of pattrmarker? That one makes this more easy to bind to a remote place.

Oh and make sure you have the latest incremental download of pattr. The default one doesn’t update if its bound counterpart updates.

Hth,
Mattijs


January 13, 2007 | 2:08 pm

(wow, email notification is great! would’ve definitely missed this…)

Thanks for the info, Mattijs! I’m not completely sure of what you mean, and I don’t have time to mess around in Max (on holiday skiing – opened the computer to check the online ski report).

do you mean

[pattr]
|
[mxj or js MyThing]

within a patcher?

Could you maybe paste an example?

thanks VERY much – this was great timing, by the way – I’m about to have a lot more time to Max.


January 13, 2007 | 2:31 pm

Oh.

I thought about this a bit more. The pattr wouldn’t be wired to the mxj/js.

I don’t know about pattrmarker. I feel like I’ve heard of it but I just did a quick search and didn’t turn up anything obvious.

time to suit up!


January 13, 2007 | 4:32 pm

Quote: Kevin Cox wrote on Sat, 13 January 2007 15:08
—————————————————-
> (wow, email notification is great! would’ve definitely missed this…)
>
> Thanks for the info, Mattijs! I’m not completely sure of what you mean, and I don’t have time to mess around in Max (on holiday skiing – opened the computer to check the online ski report).
>
> do you mean
>
> [pattr]
> |
> [mxj or js MyThing]
>
> within a patcher?

That’s right.

>
> Could you maybe paste an example?

Sure. I attached it.

Mattijs


January 16, 2007 | 12:43 am

Is it possible to use either Java or JavaScript to copy a string from
Max to the clipboard (Mac OS X and Windows XP)?

Georg


January 16, 2007 | 1:23 am

Hi Georg,

You can do it with Java:

http://www.javapractices.com/Topic82.cjp


Owen

Georg Hajdu wrote:
> Is it possible to use either Java or JavaScript to copy a string from
> Max to the clipboard (Mac OS X and Windows XP)?
>
> Georg
>


January 16, 2007 | 7:35 am

Hi Owen,

Thank you for the hint.

Georg

On Jan 16, 2007, at 2:23 AM, Owen Green wrote:

> Hi Georg,
>
> You can do it with Java:
> http://www.javapractices.com/Topic82.cjp
>
> —
> Owen
>
> Georg Hajdu wrote:
>> Is it possible to use either Java or JavaScript to copy a string
>> from Max to the clipboard (Mac OS X and Windows XP)?
>> Georg
>


January 16, 2007 | 5:17 pm

Hi Owen,

Do you have an idea how to implement this code in mxj? I failed
miserably, which is probably due to the fact that I’m far from being
a Java, let alone MaxJava expert.

Thank you,

Georg

On Jan 16, 2007, at 2:23 AM, Owen Green wrote:

> Hi Georg,
>
> You can do it with Java:
> http://www.javapractices.com/Topic82.cjp
>
> —
> Owen
>
> Georg Hajdu wrote:
>> Is it possible to use either Java or JavaScript to copy a string
>> from Max to the clipboard (Mac OS X and Windows XP)?
>> Georg
>


January 16, 2007 | 7:46 pm

this should be close if you just want to copy To the system clipboard.
topher

import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.StringSelection;
import java.awt.Toolkit;
import java.io.*;

public class toclipboard extends MaxObject implements ClipboardOwner
{

public void setClipboardContents( String aString ){
StringSelection stringSelection = new StringSelection( aString );
Clipboard clipboard = Toolkit.getDefaultToolkit
().getSystemClipboard();
clipboard.setContents( stringSelection, this );
}

/**
* Empty implementation of the ClipboardOwner interface.
*/
public void lostOwnership( Clipboard aClipboard, Transferable
aContents) {
//do nothing
}
}

On Jan 16, 2007, at 09:17 AM, Georg Hajdu wrote:

> Hi Owen,
>
> Do you have an idea how to implement this code in mxj? I failed
> miserably, which is probably due to the fact that I’m far from
> being a Java, let alone MaxJava expert.
>
> Thank you,
>
> Georg
>
> On Jan 16, 2007, at 2:23 AM, Owen Green wrote:
>
>> Hi Georg,
>>
>> You can do it with Java:
>> http://www.javapractices.com/Topic82.cjp
>>
>> —
>> Owen
>>
>> Georg Hajdu wrote:
>>> Is it possible to use either Java or JavaScript to copy a string
>>> from Max to the clipboard (Mac OS X and Windows XP)?
>>> Georg
>>
>


January 16, 2007 | 8:17 pm

On 16 janv. 07, at 18:17, Georg Hajdu wrote:

> Hi Owen,
>
> Do you have an idea how to implement this code in mxj? I failed
> miserably, which is probably due to the fact that I’m far from
> being a Java, let alone MaxJava expert.

This is quickly made, but should give you enough information to start
with.

Best,
ej


January 16, 2007 | 9:37 pm

Aww, I just made one and in the meantime Topher and Emmanuel beat me to it!

Anyway, just for completeness; put the attached jar file somewhere
useful and hack the source to your heart’s content.

#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P comment 120 133 322 196618 Use paste to spit clipboard contents (if
it’s a string) from outlet;
#P comment 120 102 195 196618 Quote strings with whitespace in them;
#P message 13 71 59 196618 copy hello;
#P window linecount 0;
#P message 13 256 17 196618;
#P window linecount 1;
#P message 13 133 35 196618 paste;
#P newex 13 224 66 196618 prepend set;
#P message 13 102 100 196618 copy "hello world";
#P newex 13 185 162 196618 mxj otg.max.util.ClipboardText;
#P window setfont "Sans Serif" 18.;
#P comment 11 31 209 196626 MXJ Clipboard Example;
#P window setfont "Sans Serif" 10.;
#P comment 120 71 183 196618 Use copy to load text on to clipboard;
#P hidden connect 3 0 2 0;
#P hidden connect 5 0 2 0;
#P hidden connect 7 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 6 0;
#P window clipboard copycount 10;

Georg Hajdu wrote:
> Do you have an idea how to implement this code in mxj? I failed
> miserably, which is probably due to the fact that I’m far from being a
> Java, let alone MaxJava expert.


January 17, 2007 | 12:01 am

Thanks Topher,

Your solution works like a charm! Finally, I get to put my Max chat
stuff on the clipboard.
What about inclusion in Max v5?

Best,

Georg

On Jan 16, 2007, at 8:46 PM, topher lafata wrote:

> this should be close if you just want to copy To the system clipboard.
> topher
>
>
> import java.awt.datatransfer.Clipboard;
> import java.awt.datatransfer.ClipboardOwner;
> import java.awt.datatransfer.Transferable;
> import java.awt.datatransfer.StringSelection;
> import java.awt.Toolkit;
> import java.io.*;
>
> public class toclipboard extends MaxObject implements ClipboardOwner
> {
>
> public void setClipboardContents( String aString ){
> StringSelection stringSelection = new StringSelection( aString );
> Clipboard clipboard = Toolkit.getDefaultToolkit
> ().getSystemClipboard();
> clipboard.setContents( stringSelection, this );
> }
>
> /**
> * Empty implementation of the ClipboardOwner interface.
> */
> public void lostOwnership( Clipboard aClipboard, Transferable
> aContents) {
> //do nothing
> }
> }
>
> On Jan 16, 2007, at 09:17 AM, Georg Hajdu wrote:
>
>> Hi Owen,
>>
>> Do you have an idea how to implement this code in mxj? I failed
>> miserably, which is probably due to the fact that I’m far from
>> being a Java, let alone MaxJava expert.
>>
>> Thank you,
>>
>> Georg
>>
>> On Jan 16, 2007, at 2:23 AM, Owen Green wrote:
>>
>>> Hi Georg,
>>>
>>> You can do it with Java:
>>> http://www.javapractices.com/Topic82.cjp
>>>
>>> —
>>> Owen
>>>
>>> Georg Hajdu wrote:
>>>> Is it possible to use either Java or JavaScript to copy a string
>>>> from Max to the clipboard (Mac OS X and Windows XP)?
>>>> Georg
>>>
>>
>


January 17, 2007 | 6:18 am

Hi Emmanuel

Thank you. For some reason, your solution won’t instantiate on my
computer.

Best,

Georg

On Jan 16, 2007, at 9:17 PM, Emmanuel Jourdan wrote:

> On 16 janv. 07, at 18:17, Georg Hajdu wrote:
>
>> Hi Owen,
>>
>> Do you have an idea how to implement this code in mxj? I failed
>> miserably, which is probably due to the fact that I’m far from
>> being a Java, let alone MaxJava expert.
>
> This is quickly made, but should give you enough information to
> start with.
>
> Best,
> ej
>
>
>


January 17, 2007 | 6:26 am

Thanks to you too! It works.

Regards,

Georg

On Jan 16, 2007, at 10:37 PM, Owen Green wrote:

> #P window setfont "Sans Serif" 10.;
> #P window linecount 1;
> #P comment 120 133 322 196618 Use paste to spit clipboard contents
> (if it’s a string) from outlet;
> #P comment 120 102 195 196618 Quote strings with whitespace in them;
> #P message 13 71 59 196618 copy hello;
> #P window linecount 0;
> #P message 13 256 17 196618;
> #P window linecount 1;
> #P message 13 133 35 196618 paste;
> #P newex 13 224 66 196618 prepend set;
> #P message 13 102 100 196618 copy "hello world";
> #P newex 13 185 162 196618 mxj otg.max.util.ClipboardText;
> #P window setfont "Sans Serif" 18.;
> #P comment 11 31 209 196626 MXJ Clipboard Example;
> #P window setfont "Sans Serif" 10.;
> #P comment 120 71 183 196618 Use copy to load text on to clipboard;
> #P hidden connect 3 0 2 0;
> #P hidden connect 5 0 2 0;
> #P hidden connect 7 0 2 0;
> #P connect 2 0 4 0;
> #P connect 4 0 6 0;
> #P window clipboard copycount 10;


January 17, 2007 | 7:47 am


January 17, 2007 | 5:18 pm


January 17, 2007 | 6:32 pm


March 15, 2012 | 3:24 pm

hello to all.

anybody know where i can get the jar file mentioned here? …seems to have been removed from this decrepit thread.

much thanks.


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