save float to sysex/restore float from sysex
@oid Thanks! I think I'm gonna go with [makefilename %.7e] to reduce the word count to 13 per float and probably just use fudiparse to convert back to float. It would've taken me a while to figure out that I had to strip the leading "symbol " selector, so thanks for saving me that effort.
pack s s s , pak s s s
@gentleclockdivider of course, you can look at the code.
static void pack_anything(t_pack *x, t_symbol *s, int ac, t_atom *av)
{
t_atom *av2 = (t_atom *)alloca((ac + 1) * sizeof(t_atom));
int i;
for (i = 0; i < ac; i++)
av2[i + 1] = av[i];
SETSYMBOL(av2, s);
obj_list(&x->x_obj, 0, ac + 1, av2);
}
you have to get into a few functions, but basically the argument 's' is the 'selector' (in this case '-' or 'X'), 'ac' is the count of items in the list (after the selector) and *av is the pointer to the atoms that make it up.
first, it allocates a new list of atoms of length of the input elements (elements after the selector, in this case 0) + 1 = 1
then it shifts all the input elements up by 1, and inserts the selector as a symbol in the first element
Then obj_list will distribute all the elements of that list to the inlets of pack, from right to left which will set the atoms that pack is storing for those inlets
when obj_list lastly reaches/distributes to the leftmost it will call pack_symbol, which will call pack_bang which triggers the atoms pack has stored to be output as another new list
binding pack_anything to anythings coming into the first inlet is done by calling class_addanything in pack_setup method
pack s s s , pak s s s
@seb-harmonik.ar
That's exactly what thought
Is there any way how to actually see how pack works internally , or any other object for that matter . ?
@ oid , interesting
How did you find out that pack works like that ,( not that I doubt your expertise at all ) ?
Max has this wonderfull object in the pack family called join ( not zl - join ) it accepts everything no matter the selector .
You just give it the nr of input arguments and the hot inlet port ( all if needed )
Really wish pd has someting like that
pack s s s , pak s s s
@gentleclockdivider Yeah, will fix that error. The first inlet in the case of [pack] is always a list, a float or symbol is just a list of one element list. Internally [pack] works like this:
So left inlet will always add the appropriate selector even if it is a single element.
pack s s s , pak s s s
@gentleclockdivider First inlet of [pack] and many objects treats everything on the first inlet as a list which it unpacks and fans out to the other inlets in order, a symbol or float is just a list of one element in this case.
This is standard behavior for vanilla objects. [pak] is not vanilla and many external objects go against vanillas standard behavior.
pack s s s , pak s s s
Firstof all , I 'd like to say that is the second forum I am posting this on because it is doing my head in .
If I have a pak object (PAK ) with s s s as arguments , it accepts and outputs a list , but I can not conclude if these are considered symbols or not ( see next )
Like this
If I use a pack ( PACK ) with s s s , the messages 'x ' and '-' in the second and third inlet , need to be converted to symbols in order for the pack object to work , the first inlet does not need it
Like this
Now have a look at pack without the symbol boxes ,
When pressing the second and third toggle , the console says : expected symbol but got "x" or "-" ( there is no symbol box involved ) .
When pressing the first toggle , the "- "or "x" is send and received , does the pack see this as a symbol ? ( if so how can we examine this )
Furthermore , why doesn't it see the second and third as a symbol ?
This is were it's so cumbersome to actually see what's going on under the hood ..
Now I change the first argument of pack to integer , so pack = i s s , then the console says : Pack_symbol wrong type
From this I can conclude that the first message is indeed interpreted as a symbol (and rejected because it expected an integer ) , so why do the next and third inlet need an explicit symbol box , and why doesn't PAK need any at all ?
Just when I got the hang of lists and it's selectors , I bump into new issues
Symbols explicit
@porres said:
so I wonder what is not clear about all this.
It is a tricky thing to explain when your audience includes everything from complete layman to accomplished programmers. I can see now that it is all there and have been studying it and a few other sections trying to figure out what tripped me up and I think it is just a minor structural and terminology issues. What a selector is and does should be covered in the first paragraph instead of being split out between the first and fourth. This is the main thing the user needs to understand in this section and it should be laid out up front so anytime they refer back to this section it gets beaten into our heads. Maybe something like this?
Messages contain a selector followed by any number of arguments. The receiver of a message uses the selector to 'select' how it should proceed and handle any arguments. Selectors can be any valid symbol and arguments are anything that follows the selector and may be symbols or numbers (aka atoms). For instance "list a b c" has a "list" selector, which tells the receiver to process the arguments "a b c" as a list data type. This message is only composed of symbols but a list message can combine two or more symbols and/or floats.
You are right about keeping methods out of this section, the detailed explanation including methods should be in 2.7.3 which is almost there, just needs a few things like methods added in and probably simple definitions of things like object, class and method in context of pd. Maybe a reference to 2.7.3 in 2.4.1, "this will be covered in more depth in 2.7.3" or the like? The rest seems good to me.
I really hate doing documentation.
Symbols explicit
@oid said:
any object which accepts the float selector also has a corresponding float method?
yup, which is the function that deals with it, and float, symbol, bang, list and pointer are special methods, with predefined macros to add them, others have to be specified manually. Check the source code of any object, it'll be clear.
it never tells us what a method is and how selectors relate to methods
that section does not, and the manual doesn't say much about it other than one mere usage of the term. I agree we could have some more and I could add that... it's nice to better explain what the "no method" error is... but hey, this is not being "overly technical", on the contrary, mentioning about "method" here could be arguably an unnecessary technicality in that subsection.
Symbols explicit
@porres said:
The "set" IS the selector. What you refer as a "method" is if the object understands that message selector. So it means it has a function (or "method") to deal with it. If it does not, it will say "no method for set", but it can also say "no method for symbol/float/bang", so it's the same for the special selectors as is with any other general selector.
And that is what I was missing, the old terse documentation which I learned from made it seem like selectors were essentially types and methods had nothing to do with selectors but the reality is that any valid selector has a corresponding method, that any object which accepts the float selector also has a corresponding float method? To put it into pd terms, a [f ] is essentially this on the inside:
If I understand this correctly, what a selector actually selects is the method for its arguments? If so I think this is why section 2.4.1 comes off as overly technical to me, it never tells us what a method is and how selectors relate to methods but it and pd's help files and pd's errors assume we will just understand this relation; for many of the seasoned programmers coming to pd this is probably a safe assumption but pd attracts a wide range right down to those who have no programming experience and for them it is quite abstract.
Symbols explicit
@oid said:
No, it is just a message, to be a symbol it would need the symbol selector.
Torres says:
Yes, it is a symbol, hence, it is the selector of the message, so "c3 d3 e3" is a message whose selector is "c3" and the actual message is "d3 e3".
I wrote :
The message c3 f3 a3 , the first selector is c3 and thus this message is an implicit symbol , correct ?
So It's not implicit but c3 is a symbol .
@toress
Why would I bring this up , because this is the topic for it , no ?
And because I am writng my note notation/ rests like this : c3---f#4---g3--- ,
edit : can't (yet ) get the multiquote to work .