Calling/placing abstractions in my Patcher via JAVA give error ….

May 28, 2012 at 4:28pm

Calling/placing abstractions in my Patcher via JAVA give error ….


import com.cycling74.max.MaxObject;

[...]
ArrayList myObjectsList = new ArrayList();

[...]
myObjectsList.add( new MaxObject("myAbstraction") );

This is basic but I have an error because I’m missing something for sure.

The error is :
com.cycling74.max.MaxObject is abstract; cannot be instantiated
myObjectsList.add( new MaxObject(“myAbstraction”) );
^

anyone to unstick me ??

#56822
May 28, 2012 at 4:32pm

okay.
Nick answered here: http://cycling74.com/forums/topic.php?id=23901 (2 years ago)

So How can I place an abstraction via JAVA … ?
It is okay with JS but I’d need stuff via JAVA unavailable with JS (afaik) (related to http://cycling74.com/forums/topic.php?id=40213)

#203650
May 28, 2012 at 4:32pm

okay.
Nick answered here: http://cycling74.com/forums/topic.php?id=23901 (2 years ago)

So How can I place an abstraction via JAVA … ?
It is okay with JS but I’d need stuff via JAVA unavailable with JS (afaik) (related to http://cycling74.com/forums/topic.php?id=40213)

#203709
May 28, 2012 at 5:49pm

You create a class which extends MaxObject, as you would with any abstract class.

public class Foo extends MaxObject
{

}

This class is the class you call via the mxj object in your patcher.

#203651
May 28, 2012 at 5:49pm

You create a class which extends MaxObject, as you would with any abstract class.

public class Foo extends MaxObject
{

}

This class is the class you call via the mxj object in your patcher.

#203710
May 28, 2012 at 5:56pm

It means I would have to create one class/mxj per abstraction created ?
this is insane in my case (and it probably means I missed smthg :/)

#203653
May 28, 2012 at 5:56pm

It means I would have to create one class/mxj per abstraction created ?
this is insane in my case (and it probably means I missed smthg :/)

#203711
May 28, 2012 at 6:30pm

No, this would be your top-level object. Your abstractions would be contained within this object.

#203655
May 28, 2012 at 6:30pm

No, this would be your top-level object. Your abstractions would be contained within this object.

#203712
May 28, 2012 at 6:39pm

yep I got it.

I would extend MaxObject as you proposed (and as I’m doing) for each abstractions or type of abstractions ?

I mean.
(considering this is not the best solution, probably..)
One abstraction = One type of object = One visuals & sounds object
I need to create sometimes a lot of objects.

How would I apply this to my case?

#203657
May 28, 2012 at 6:39pm

yep I got it.

I would extend MaxObject as you proposed (and as I’m doing) for each abstractions or type of abstractions ?

I mean.
(considering this is not the best solution, probably..)
One abstraction = One type of object = One visuals & sounds object
I need to create sometimes a lot of objects.

How would I apply this to my case?

#203713
May 28, 2012 at 7:20pm

I don’t think you would need to extend MaxObject for each of your abstractions. The class that extends MaxObject can contain any number of Java objects, even ones that wrap around JitterObjects.

The only class that needs to extend MaxObject would be the one that you use to initialize your entire system, via mxj. This object would also be responsible for messaging all of its child object, so you could create a messaging structure with inlets/outlets and functions to do so – this exposes the child objects to messages from the patcher environment.

#203658
May 28, 2012 at 7:20pm

I don’t think you would need to extend MaxObject for each of your abstractions. The class that extends MaxObject can contain any number of Java objects, even ones that wrap around JitterObjects.

The only class that needs to extend MaxObject would be the one that you use to initialize your entire system, via mxj. This object would also be responsible for messaging all of its child object, so you could create a messaging structure with inlets/outlets and functions to do so – this exposes the child objects to messages from the patcher environment.

#203714
May 28, 2012 at 7:31pm

I got it.
But basically, how to initialize and call my abstractions from JAVA without creating a new MaxObject ?

#203659
May 28, 2012 at 7:31pm

I got it.
But basically, how to initialize and call my abstractions from JAVA without creating a new MaxObject ?

#203715
May 28, 2012 at 7:53pm

Just construct them within the constructor of your top-level MaxObject, or in response to a function call via a Max message.

#203660
May 28, 2012 at 7:53pm

Just construct them within the constructor of your top-level MaxObject, or in response to a function call via a Max message.

#203716
May 28, 2012 at 8:07pm

Jesse, I don’t know another way to “construct” them than to use :

new MaxObject("myAbstraction")

and this is particularly that one that doesn’t work :-/

I got the concept, I guess
But I cannot do that because of the error :-/

#203661
May 28, 2012 at 8:07pm

Jesse, I don’t know another way to “construct” them than to use :

new MaxObject("myAbstraction")

and this is particularly that one that doesn’t work :-/

I got the concept, I guess
But I cannot do that because of the error :-/

#203717
May 28, 2012 at 10:13pm

Yes, I can see that you’re still confused.

MaxObject and MSPObject are an abstract classes that one extends to create Java objects that can live at the level of the patcher, instantiated through MXJ.

The issue appears to be the “abstraction” which still has not been clearly defined. If I understand what you’re wanting to do, this abstraction is a Java class that wraps Jitter objects and sound related data.

If this is right you should take a look at the JitterObject class, which could be contained inside your abstractions. JitterObject allows you to instantiate Jitter objects that reside inside your Java code, and not in the patcher.

#203662
May 28, 2012 at 10:13pm

Yes, I can see that you’re still confused.

MaxObject and MSPObject are an abstract classes that one extends to create Java objects that can live at the level of the patcher, instantiated through MXJ.

The issue appears to be the “abstraction” which still has not been clearly defined. If I understand what you’re wanting to do, this abstraction is a Java class that wraps Jitter objects and sound related data.

If this is right you should take a look at the JitterObject class, which could be contained inside your abstractions. JitterObject allows you to instantiate Jitter objects that reside inside your Java code, and not in the patcher.

#203718
May 29, 2012 at 7:48am

Hi Jesse.
an abstraction in my case here, wouldn’t be JAVA stuff, but a “basic” abstraction as defined in Max patchers (I mean, that one : http://cycling74.com/docs/max6/dynamic/c74_docs.html#abstractions

The idea would be to create abstractions on a side and to call them (I mean, to create them in a patcher) via JAVA.
I have that working with JS but because I’d need to have a powerful communication system between my core (here JS, wanting JAVA) and all the abstractions, I thought about JAVA compiled stuff would be more fast

#203664
May 29, 2012 at 7:48am

Hi Jesse.
an abstraction in my case here, wouldn’t be JAVA stuff, but a “basic” abstraction as defined in Max patchers (I mean, that one : http://cycling74.com/docs/max6/dynamic/c74_docs.html#abstractions

The idea would be to create abstractions on a side and to call them (I mean, to create them in a patcher) via JAVA.
I have that working with JS but because I’d need to have a powerful communication system between my core (here JS, wanting JAVA) and all the abstractions, I thought about JAVA compiled stuff would be more fast

#203719
May 29, 2012 at 4:35pm

In that case you want to use the MaxPatcher and MaxBox objects within Java.

#203665
May 29, 2012 at 4:35pm

In that case you want to use the MaxPatcher and MaxBox objects within Java.

#203720
May 29, 2012 at 4:50pm

just before your answer (I swear I swear)
I did that and indeed, as you wrote, it works fine:


import com.cycling74.max.*;
public class testAbstractionLoad extends MaxObject {

private MaxPatcher _p = null;

testAbstractionLoad() {
_p = this.getParentPatcher();

}

public void buildAbstraction()
{

MaxBox b11 = _p.newDefault(20,20,"myAbstraction",null);

}
}

It means I can begin to build the core that would “dispatch” my abstraction on the go
I’ll keep references of all abstractions in nice Java data structures better than array for what I want to do
Indeed, I’ll need to add/remove abstraction without to have to make an array with empty slot :p

(maxi thanks Jesse to have taken time to explain me things a lot)

#203666
May 29, 2012 at 4:50pm

just before your answer (I swear I swear)
I did that and indeed, as you wrote, it works fine:


import com.cycling74.max.*;
public class testAbstractionLoad extends MaxObject {

private MaxPatcher _p = null;

testAbstractionLoad() {
_p = this.getParentPatcher();

}

public void buildAbstraction()
{

MaxBox b11 = _p.newDefault(20,20,"myAbstraction",null);

}
}

It means I can begin to build the core that would “dispatch” my abstraction on the go
I’ll keep references of all abstractions in nice Java data structures better than array for what I want to do
Indeed, I’ll need to add/remove abstraction without to have to make an array with empty slot :p

(maxi thanks Jesse to have taken time to explain me things a lot)

#203721

You must be logged in to reply to this topic.