Forums > Dev

t_symbol size limit

February 16, 2006 | 5:36 pm

Hi list,
I’m programming an external that would allow to save an XML interface
for a Lemur inside the containing patcher. I implemented the save
method for the object, but I’m now in front of an issue : it seems
it’s impossible to generate a symbol larger than 2000 bytes. That
means that if I use gensym on a file larger than 2k, I get a
truncated XML file in my saved patcher.

Any ideas ?

Thanks in advance…


Axel Balley
JazzMutant


February 16, 2006 | 9:15 pm

I would recommend you serialize the xml file into multiple symbols,
or write the raw bytes as a sequence of integer atoms as does comment
in "two-byte compatibility mode". A little more work, but shouldn’t
be that tough to implement.

-Joshua


February 16, 2006 | 10:32 pm

Hi Axel,
are you sure you can’t solve this by using a list of symbols?
Don’t forget that large unique symbols fill up memory since they never
go away as long as Max is running.

best greetings,
Thomas


February 16, 2006 | 10:56 pm

Thanks for your answers, Thomas and Joshua
I’ll try going in those directions, though I’m still a newbie at this
(I coded my first Max external about 4 days ago)


Axel Balley
JazzMutant


February 17, 2006 | 9:31 am

On around Feb 16, 2006, at 23:56, Axel Balley said something like:
> I’ll try going in those directions, though I’m still a newbie at this
> (I coded my first Max external about 4 days ago)

In that case, may I add the following, some stuff I learnt from writing
my I Ching objects, which also had many kB of text…

The SDK docs leave the impression that lists cannot begin with a
symbol. This is not strictly true. It is perfectly possible to write
something like

Atom textlist[3];

SETSYM(textlist, gensym("foo")); // Handy macro, cf. ext_mess.h
SETSYM(textlist+1, gensym("baz"));
SETSYM(textlist+2, gensym("bark"));

outlet_list(myOutlet, NIL, 3, textlist);

(2nd param to outlet_list() can also be gensym("list"), but NIL will do
fine; the example can be extended to more items).

But note:

1) Most Max objects will convert your list [foo baz bark] into a foo
message with the parameters baz and bark. These are two different
animals. For this reason, you might be better off to follow the model
of the textedit object, which sends out "text" messages with the text
followed by a stream of symbol parameters. The code would be identical
to above, just the outlet_list() call would be an outlet_anything()
call:

outlet_anything(myOutlet, gensym("text"), 3, textlist);

Stash the value of gensym("text") in a static variable if you’re going
to use it a lot (which seems likely).

2) Most Max objects will either croak or truncate your argument list if
it contains more than 255 elements. You will probably need to subdivide
your XML file into multiple messages rather then send the entire file
out as a single message.

Hope this helps,
Peter

————– http://www.bek.no/~pcastine/Litter/ ————–
Peter Castine | ^
| Litter Power & Litter Bundle for Jitter
pcastine@gmx.net |
pcastine@bek.no | iCE: Sequencing, Recording, and Interface Building
4-15@kagi.com | for Max/MSP
| Extremely cool
| http://www.dspaudio.com
| http://www.dspaudio.com/software/software.html


February 17, 2006 | 11:07 am

On around Feb 17, 2006, at 10:31, Peter Castine said something like:
> better off to follow the model of the textedit object, which sends out
> "text" messages with the text followed by a stream of symbol
> parameters.

That was unclear, sorry. Please read:

…the model of the textedit object, which sends out "text" messages,
each followed by a stream of symbol parameters representing the actual
text. So for an XML file containing the fragment "fourscore and seven
years ago our fathers brought forth upon this continent" you might
generate the messages

text fourscore and seven years ago our fathers
text brought forth upon this continent a new nation
text conceived in liberty and dedicated to the proposition

etc…

Hope that’s clearer (even if "conceived in liberty" sounds like the
title of a movie about someone born out of wedlock),
P.

————– http://www.bek.no/~pcastine/Litter/ ————–
Peter Castine | ^
| Litter Power & Litter Bundle for Jitter
pcastine@gmx.net |
pcastine@bek.no | iCE: Sequencing, Recording, and Interface Building
4-15@kagi.com | for Max/MSP
| Extremely cool
| http://www.dspaudio.com
| http://www.dspaudio.com/software/software.html


February 17, 2006 | 1:12 pm

Thanks for your help, the symbols stream thing is exactly what I was
after.
I’ll let you know if things work out !

Axel


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