András Murányi | 1 Jun 2012 14:55
Picon

Plugins preferences (Was Re: [PD] Plugins Plugin error)

Hey Guys,

I need some advice here.
I figured that this method won't work - one cannot control which plugins to load *from a plugin* because some plugins may have already loaded at the time. The only method that works without modifications to the pd GUI is the "disabled" folders method.
At the same time, I see that pd_guiprefs.tcl is more prepared for managing the recent files list than for other uses. When trying to add functionality for the plugins list, the best way seemed to be to expand the init_aqua, init_win, init_x11 functions and to create a new write_enabledplugins functions plus a read_enabledplugins in this case. This is because the "domain" has to be defined again for each new use - which seems superfluous to me because it will always be "pd-extended". (The behaviour I expected originally was this: "domain" used for something meaningful like "recentfiles" or "enabledplugins" and "key" identifying really a single key. At the moment, a key holds the content of a whole config file.)

So i'm asking for your kind advice on
A.) how plugin selection could be performed without a modification to the GUI code, or shall the functionality be added to load_startup_plugins (pd-gui.tcl:674)?
B.) should we evolve the way pd_guiprefs.tcl works in any direction?

Thanks,

András


On Fri, Jun 1, 2012 at 2:09 AM, András Murányi <muranyia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:


On Fri, May 18, 2012 at 4:55 PM, João Pais <jmmmpais-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
Thanks for the report!
I've uploaded a quick bugfix to adapt to the new menu structure: there is
no Media->Preferences (or Apple->Preferences) any more, so the plugin will
appear in Media (or Apple).

Please note that this version still uses the deprecated method of disabling
plugins by putting them in subdirectories called "disabled". This means
that new subdirectories called "disabled" will be created where file
permissions are sufficient. It will affect every user on the system.
A new version shall make use of the "::pd_guiprefs" system instead. I'll
try to give it a shot today or in the next days.

so you mean, it pays up to wait for it, then? I'm new to 0.43, and I put the plugins in a folder in my electronic section, away from windows' standard system/user folders.

João

Well i guess it doesn't pay up to wait anymore :)
The pd_guiprefs mechanism is a tiny bit less handy than I expected so this will still take some more time for me.
In the meantime I suggest that you get the oldstyle, but hopefully working version at http://puredata.info/downloads/plugins-plugin/releases/0.1.20120518 (of course if you can live with those extra directories).

András



_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev
Jonathan Wilkes | 1 Jun 2012 17:46
Picon
Favicon

Re: Plugins preferences (Was Re: [PD] Plugins Plugin error)

>________________________________
> From: András Murányi <muranyia@...>
>To: pd-dev <pd-dev@...> 
>Sent: Friday, June 1, 2012 8:55 AM
>Subject: [PD-dev] Plugins preferences (Was Re: [PD] Plugins Plugin error)
> 
>
>Hey Guys,
>
>I need some advice here.
>I figured that this method won't work - one cannot control which plugins to load *from a plugin* because
some plugins may have already loaded at the time. The only method that works without modifications to the
pd GUI is the "disabled" folders method.
>At the same time, I see that pd_guiprefs.tcl is more prepared for managing the recent files list than for
other uses. When trying to add functionality for the plugins list, the best way seemed to be to expand the
init_aqua, init_win, init_x11 functions and to create a new write_enabledplugins functions plus a
read_enabledplugins in this case. This is because the "domain" has to be defined again for each new use -
which seems superfluous to me because it will always be "pd-extended". (The behaviour I expected
originally was this: "domain" used for something meaningful like "recentfiles" or "enabledplugins"
and "key" identifying really a single key. At the moment, a key holds the content of a whole config file.)
>
>So i'm asking for your kind advice on
>A.) how plugin selection could be performed without a modification to the GUI code, or shall the
functionality be added to load_startup_plugins (pd-gui.tcl:674)?

Will the plugin-plugin list itself as a plugin that can be turned on/off?  If so, that's a bad interface,
because an 
accidental user action can completely destroy the convenience of your plugin-- they can't turn it back on
using 
the interface.  (Taken from a different angle, 
the user cannot benefit from the convenience of your plugin in order to install it in the first place.)  If
not, then 
it's not really a plugin but a core gui function and you should put it in the core gui.

>B.) should we evolve the way pd_guiprefs.tcl works in any direction?

What about augmenting/replacing guiprefs.tcl code with your interface?  Then instead of someone like 

Hans having to guess at what kinds of features might be handy to add centrally to core-pd, Pd extended 

can just ship with a bunch of gui-plugins (which the community can test at their leisure before they're 

included), and someone like Hans then only has to guess which checkbuttons to check by default.  The 

benefit is that someone like Hans doesn't have to take on responsibility for these features-- if plugin #12 

has a small bug or is sluggish/confusing, author #12 has the responsibility to fix/improve it or risk it not 

being a default-loaded plugin or-- if it's causing major issues-- not included in the next release.

I haven't looked at the code-- does pd_guiprefs.tcl have an interface for saving/reading gui prefs
data?  If all 

gui-plugins can use the same interface, then adding a plugin for, say, changing default
canvas/object/wire 

colors becomes really easy.

-Jonathan

>
>Thanks,
>
>András
>
>
>
>On Fri, Jun 1, 2012 at 2:09 AM, András Murányi <muranyia@...> wrote:
>
>
>>
>>
>>On Fri, May 18, 2012 at 4:55 PM, João Pais <jmmmpais@...> wrote:
>>
>>Thanks for the report!
>>>>I've uploaded a quick bugfix to adapt to the new menu structure: there is
>>>>no Media->Preferences (or Apple->Preferences) any more, so the plugin will
>>>>appear in Media (or Apple).
>>>>
>>>>Please note that this version still uses the deprecated method of disabling
>>>>plugins by putting them in subdirectories called "disabled". This means
>>>>that new subdirectories called "disabled" will be created where file
>>>>permissions are sufficient. It will affect every user on the system.
>>>>A new version shall make use of the "::pd_guiprefs" system instead. I'll
>>>>try to give it a shot today or in the next days.
>>>>
>>>
so you mean, it pays up to wait for it, then? I'm new to 0.43, and I put the plugins in a folder in my electronic
section, away from windows' standard system/user folders.
>>>
>>>João
>>>
>>Well i guess it doesn't pay up to wait anymore :)
>>The pd_guiprefs mechanism is a tiny bit less handy than I expected so this will still take some more time
for me.
>>In the meantime I suggest that you get the oldstyle, but hopefully working version at
http://puredata.info/downloads/plugins-plugin/releases/0.1.20120518 (of course if you can live
with those extra directories).
>>
>>András
>>
>
>
>
>_______________________________________________
>Pd-dev mailing list
>Pd-dev@...
>http://lists.puredata.info/listinfo/pd-dev
>
>
>
s p | 2 Jun 2012 19:50
Picon
Gravatar

[ pure-data-Feature Requests-3531000 ] Proposal for an alternative file format

So, ... moving the discussion here from sourceforge's tracker :

> <at> Sébastien will you write a .json -> .pd converter too?

Rich, notice the double arrow ".json <-> .pd" ;)

> the proposal is for a new, easier to read / parse, format for existing patches. This facilities writing/reading patches in other languages (such as javascript, C / C++ / Obj-C / Java, etc.), since you wouldn't need to write the text file in a cryptic form.

Yes, exactly ... well said !

Like Rich said also, it would be good to have input from some pd veterans.
For one thing, just to get feedback and comments, but also to know if it has any chances to be implemented one day in pure data. Indeed, right now the file format is THE bridge between pd, libpd, webpd and others ... so if some of the libraries implement this format and not others, it might end up just putting mess and fragmenting the pd world. So ... waiting an answer from pd-devs on whether or not this might be implemented :) ! And what about libpd devs ?

_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev
yvan volochine | 2 Jun 2012 20:01
Picon

Re: [ pure-data-Feature Requests-3531000 ] Proposal for an alternative file format

On 06/02/2012 07:50 PM, s p wrote:
> So, ... moving the discussion here from sourceforge's tracker :
>
>>  <at> Sébastien will you write a .json ->  .pd converter too?
>
> Rich, notice the double arrow ".json<->  .pd" ;)
>
>> the proposal is for a new, easier to read / parse, format for existing
> patches. This facilities writing/reading patches in other languages (such
> as javascript, C / C++ / Obj-C / Java, etc.), since you wouldn't need to
> write the text file in a cryptic form.

I am certainly not a pd-veteran but I think this is a *very good* idea.

y

--

-- 
http://yvanvolochine.com
http://vimeo.com/yv
http://soundcloud.com/yvanvolochine
Rich E | 2 Jun 2012 20:37
Picon
Gravatar

Re: Proposal for an alternative file format (WAS: pure-data-Feature Requests-3531000)


(This was on the sourceforge feature requests, I'm taking the liberty to move it directly to pd-dev)


Initial Comment:
Hi all !

With several people from *libpd* and other *pd* offsprings, we have been thinking that it would be great to have an alternative format for pd files (see: http://noisepages.com/groups/pd-everywhere/forum/topic/javascript-json-apis/).
Problem is that the current format is very tedious to parse ; it is very messy (as seen in the complexity of the documentation) ; and last but not least, it doesn't separate the actual graph data from the GUI data (X, Y, canvases, ...). Overall, this is not good for interoperability between different pd/non-pd systems.

We were thinking that a simple JSON file would save a lot of trouble :
- it has a nested structure, which allows for much clearer, even human-readable format. ex :
[
   {"class": "obj", "id": 0, "type": "osc~", "args": [440]},
   {"class": "obj", "id": 1, "type": "dac~"},
   {"class": "connect", "from": [0, 0], "to": [1, 0]},
   {"class": "connect", "from": [0, 0], "to": [1, 1]}
]

- it allows putting custom attributes (for a GUI for example) :
[
   {"class": "obj", "id": 0, "type": "osc~", "args": [440],
       "myGui": {"x": 123, "y": 78}
   }
]


Strict json has a dictionary as it's outermost object.  Most parsers will accept an array as you have done, but not all (Obj-C's TouchJSON as an example).  An alternative way to organize the patch and adhere to strict json would be to have id's on the outside, such as:

{
"canvas" :
{
"id" : 1,
"name" : "example"
"x" : 95,
"y" : 190,
"width" : 809,
"height" : 538
"elements" :
{
"obj" : {"id" : 0, "type": "osc~", "args": [440]},
"obj" : {"id" : 1, "type": "dac~"},
"connect" : {"from": [0, 0], "to": [1, 0]},
"connect" : {"from": [0, 0], "to": [1, 1]}
}
"canvas" : { ... }
"array" : { ... }
}
}

About the optional GUI, my opinion is that pd is firstly a graphical data flow language existing of canvases and objects with specific location.  To make the dimensions optional means interoperability with pd will be optional, probably not so good.  If you need extra info, I think that's ok, but at a minimum the information in existing pd patches should be represented.

You could also pull the GUI locations into a separate object:

{
"canvas" :
{
"id" : 0,
"name" : "example"
"elements" :
{
"obj" : {"id" : 0, "type": "osc~", "args": [440]},
"obj" : {"id" : 1, "type": "dac~"},
"connect" : {"from": [0, 0], "to": [1, 0]},
"connect" : {"from": [0, 0], "to": [1, 1]}
}
"layout" :
{
"0" : { "pos": [123, 78] },
"1" : { "pos": [123, 100] }
}
}
"layout" :
{
"0" : { "pos": [95, 190], "size" : [809, 538] }
}
}

Don't know if it's better or worse, just throwing it out there.  One side effect is that the id's here are both in string and int format.

 

----------------------------------------------------------------------

Comment By: Andras Muranyi (muranyia)
Date: 2012-06-01 14:00

Message:
<at> reakin: when mentioning two files for one patch i was referring to the
(nice and convenient) idea of separating logic from presentation by
breaking out GUI info into a CSS-like file - which means having two files
per patch (not so convenient and nice). 


Ah, understood.  I also think this would be a bit overcomplicated.  If it's separated, I think the GUI info could just be under a different object in the json of one file.
 
Cheers,
Rich
_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev
Rich E | 2 Jun 2012 20:40
Picon
Gravatar

Re: Proposal for an alternative file format (WAS: pure-data-Feature Requests-3531000)

Arg, this thread should die, was reposted at the same time. :=)  I'll move this message there.

On Sat, Jun 2, 2012 at 2:37 PM, Rich E <reakinator-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

(This was on the sourceforge feature requests, I'm taking the liberty to move it directly to pd-dev)


Initial Comment:
Hi all !

With several people from *libpd* and other *pd* offsprings, we have been thinking that it would be great to have an alternative format for pd files (see: http://noisepages.com/groups/pd-everywhere/forum/topic/javascript-json-apis/).
Problem is that the current format is very tedious to parse ; it is very messy (as seen in the complexity of the documentation) ; and last but not least, it doesn't separate the actual graph data from the GUI data (X, Y, canvases, ...). Overall, this is not good for interoperability between different pd/non-pd systems.

We were thinking that a simple JSON file would save a lot of trouble :
- it has a nested structure, which allows for much clearer, even human-readable format. ex :
[
   {"class": "obj", "id": 0, "type": "osc~", "args": [440]},
   {"class": "obj", "id": 1, "type": "dac~"},
   {"class": "connect", "from": [0, 0], "to": [1, 0]},
   {"class": "connect", "from": [0, 0], "to": [1, 1]}
]

- it allows putting custom attributes (for a GUI for example) :
[
   {"class": "obj", "id": 0, "type": "osc~", "args": [440],
       "myGui": {"x": 123, "y": 78}
   }
]


Strict json has a dictionary as it's outermost object.  Most parsers will accept an array as you have done, but not all (Obj-C's TouchJSON as an example).  An alternative way to organize the patch and adhere to strict json would be to have id's on the outside, such as:

{
"canvas" :
{
"id" : 1,
"name" : "example"
"x" : 95,
"y" : 190,
"width" : 809,
"height" : 538
"elements" :
{
"obj" : {"id" : 0, "type": "osc~", "args": [440]},
"obj" : {"id" : 1, "type": "dac~"},
"connect" : {"from": [0, 0], "to": [1, 0]},
"connect" : {"from": [0, 0], "to": [1, 1]}
}
"canvas" : { ... }
"array" : { ... }
}
}

About the optional GUI, my opinion is that pd is firstly a graphical data flow language existing of canvases and objects with specific location.  To make the dimensions optional means interoperability with pd will be optional, probably not so good.  If you need extra info, I think that's ok, but at a minimum the information in existing pd patches should be represented.

You could also pull the GUI locations into a separate object:

{
"canvas" :
{
"id" : 0,
"name" : "example"
"elements" :
{
"obj" : {"id" : 0, "type": "osc~", "args": [440]},
"obj" : {"id" : 1, "type": "dac~"},
"connect" : {"from": [0, 0], "to": [1, 0]},
"connect" : {"from": [0, 0], "to": [1, 1]}
}
"layout" :
{
"0" : { "pos": [123, 78] },
"1" : { "pos": [123, 100] }
}
}
"layout" :
{
"0" : { "pos": [95, 190], "size" : [809, 538] }
}
}

Don't know if it's better or worse, just throwing it out there.  One side effect is that the id's here are both in string and int format.

 

----------------------------------------------------------------------

Comment By: Andras Muranyi (muranyia)
Date: 2012-06-01 14:00

Message:
<at> reakin: when mentioning two files for one patch i was referring to the
(nice and convenient) idea of separating logic from presentation by
breaking out GUI info into a CSS-like file - which means having two files
per patch (not so convenient and nice). 


Ah, understood.  I also think this would be a bit overcomplicated.  If it's separated, I think the GUI info could just be under a different object in the json of one file.
 
Cheers,
Rich

_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev
Rich E | 2 Jun 2012 20:42
Picon
Gravatar

Re: [ pure-data-Feature Requests-3531000 ] Proposal for an alternative file format

(from Sébastien:) 
We were thinking that a simple JSON file would save a lot of trouble :
- it has a nested structure, which allows for much clearer, even human-readable format. ex :
[
   {"class": "obj", "id": 0, "type": "osc~", "args": [440]},
   {"class": "obj", "id": 1, "type": "dac~"},
   {"class": "connect", "from": [0, 0], "to": [1, 0]},
   {"class": "connect", "from": [0, 0], "to": [1, 1]}
]

- it allows putting custom attributes (for a GUI for example) :
[
   {"class": "obj", "id": 0, "type": "osc~", "args": [440],
       "myGui": {"x": 123, "y": 78}
   }
]


Strict json has a dictionary as it's outermost object.  Most parsers will accept an array as you have done, but not all (Obj-C's TouchJSON as an example).  An alternative way to organize the patch and adhere to strict json would be to have id's on the outside, such as:

{
"canvas" :
{
"id" : 1,
"name" : "example"
"x" : 95,
"y" : 190,
"width" : 809,
"height" : 538
"elements" :
{
"obj" : {"id" : 0, "type": "osc~", "args": [440]},
"obj" : {"id" : 1, "type": "dac~"},
"connect" : {"from": [0, 0], "to": [1, 0]},
"connect" : {"from": [0, 0], "to": [1, 1]}
}
"canvas" : { ... }
"array" : { ... }
}
}

About the optional GUI, my opinion is that pd is firstly a graphical data flow language existing of canvases and objects with specific location.  To make the dimensions optional means interoperability with pd will be optional, probably not so good.  If you need extra info, I think that's ok, but at a minimum the information in existing pd patches should be represented.

You could also pull the GUI locations into a separate object:

{
"canvas" :
{
"id" : 0,
"name" : "example"
"elements" :
{
"obj" : {"id" : 0, "type": "osc~", "args": [440]},
"obj" : {"id" : 1, "type": "dac~"},
"connect" : {"from": [0, 0], "to": [1, 0]},
"connect" : {"from": [0, 0], "to": [1, 1]}
}
"layout" :
{
"0" : { "pos": [123, 78] },
"1" : { "pos": [123, 100] }
}
}
"layout" :
{
"0" : { "pos": [95, 190], "size" : [809, 538] }
}
}

Don't know if it's better or worse, just throwing it out there.  One side effect is that the id's here are both in string and int format.

 

----------------------------------------------------------------------

Comment By: Andras Muranyi (muranyia)
Date: 2012-06-01 14:00

Message:
<at> reakin: when mentioning two files for one patch i was referring to the
(nice and convenient) idea of separating logic from presentation by
breaking out GUI info into a CSS-like file - which means having two files
per patch (not so convenient and nice). 


Ah, understood.  I also think this would be a bit overcomplicated.  If it's separated, I think the GUI info could just be under a different object in the json of one file.
 
Cheers,
Rich

On Sat, Jun 2, 2012 at 2:01 PM, yvan volochine <yvan.pd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On 06/02/2012 07:50 PM, s p wrote:
So, ... moving the discussion here from sourceforge's tracker :

<at> Sébastien will you write a .json ->  .pd converter too?

Rich, notice the double arrow ".json<->  .pd" ;)

the proposal is for a new, easier to read / parse, format for existing
patches. This facilities writing/reading patches in other languages (such
as javascript, C / C++ / Obj-C / Java, etc.), since you wouldn't need to
write the text file in a cryptic form.

I am certainly not a pd-veteran but I think this is a *very good* idea.

y

--
http://yvanvolochine.com
http://vimeo.com/yv
http://soundcloud.com/yvanvolochine

_______________________________________________
Pd-dev mailing list
Pd-dev-3mXD6pJrRzU@public.gmane.org
http://lists.puredata.info/listinfo/pd-dev

_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev
s p | 3 Jun 2012 15:33
Picon
Gravatar

Re: [ pure-data-Feature Requests-3531000 ] Proposal for an alternative file format

> Strict json has a dictionary as it's outermost object.

I don't think this is true. I was not sure so I checked the spec : http://www.ietf.org/rfc/rfc4627.txt?number=4627
and apparently a valid json string is either an array or an object.

> Most parsers will accept an array as you have done, but not all (Obj-C's TouchJSON as an example)

TouchJSON's says (https://github.com/TouchCode/TouchJSON#invalid-json) :
"If you think your JSON is valid but TouchJSON is failing to process it correctly, use the online JSON lint tool to validate your JSON: http://www.jsonlint.com/ "

And it turns out, jsonlint accepts json with an array as outermost element.
Personally, I've always used an array, and many API libraries that I am using for web development return an array as outermost element.

> About the optional GUI, my opinion is that pd is firstly a graphical data flow language existing of canvases and objects with specific location.

Once again (sorry :) I disagree ... True, "pd is firstly a graphical data flow language".
However, times they are a changing, and libpd is becoming more and more important, and will probably continue to grow.
Also, I might be wrong, but I am guessing nobody would disagree that it is a good idea to go towards a better separation between pd core and its GUI.
When you specify something new, it is a good occasion to do things well and clean. Passing over some legacy stuff to a new specification you are writing kind of kills the purpose of making a new specification.

For all those reasons, I think it is a good idea to specify a minimalist file format that doesn't include GUI infos.
Of course, it should include special placeholders for putting extra info (where GUI info can be put).
And as a new parser will have to be written anyways, it is not much extra-work to handle missing attributes that are not mandatory in the spec.

For example, if I take the example I had given before :

[ {"class": "obj", "id": 0, "type": "osc~", "args": [440]}, {"class": "obj", "id": 1, "type": "dac~"}, {"class": "connect", "from": [0, 0], "to": [1, 0]}, {"class": "connect", "from": [0, 0], "to": [1, 1]} ]

// start parsing, in pseudo-code
foreach element in element_list {
if (element.class is "obj") {
obj = create_new_obj_with_type_and_args(element)
if (has_display_infos(element)) {
set_object_display(obj, element)
} else {
set_default_display(obj)
}
}
// ...
}

what I mean is that the core specified should be small : objects, connections, data ; and if a particular program (pd, libpd, ...) using this format wants to add extra-info, it should handle the case where those infos are not available when parsing.
Or at least, that's my opinion :)
_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev
Jonathan Wilkes | 3 Jun 2012 17:57
Picon
Favicon

Re: [ pure-data-Feature Requests-3531000 ] Proposal for an alternative file format

Question: do you care about backwards compatibility, or is it a non-issue?

-Jonathan

From: s p <sebpiq-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pd-dev-3mXD6pJrRzU@public.gmane.org
Sent: Sunday, June 3, 2012 9:33 AM
Subject: Re: [PD-dev] [ pure-data-Feature Requests-3531000 ] Proposal for an alternative file format

> Strict json has a dictionary as it's outermost object.

I don't think this is true. I was not sure so I checked the spec : http://www.ietf.org/rfc/rfc4627.txt?number=4627
and apparently a valid json string is either an array or an object.

> Most parsers will accept an array as you have done, but not all (Obj-C's TouchJSON as an example)

TouchJSON's says (https://github.com/TouchCode/TouchJSON#invalid-json) :
"If you think your JSON is valid but TouchJSON is failing to process it correctly, use the online JSON lint tool to validate your JSON: http://www.jsonlint.com/ "

And it turns out, jsonlint accepts json with an array as outermost element.
Personally, I've always used an array, and many API libraries that I am using for web development return an array as outermost element.

> About the optional GUI, my opinion is that pd is firstly a graphical data flow language existing of canvases and objects with specific location.

Once again (sorry :) I disagree ... True, "pd is firstly a graphical data flow language".
However, times they are a changing, and libpd is becoming more and more important, and will probably continue to grow.
Also, I might be wrong, but I am guessing nobody would disagree that it is a good idea to go towards a better separation between pd core and its GUI.
When you specify something new, it is a good occasion to do things well and clean. Passing over some legacy stuff to a new specification you are writing kind of kills the purpose of making a new specification.

For all those reasons, I think it is a good idea to specify a minimalist file format that doesn't include GUI infos.
Of course, it should include special placeholders for putting extra info (where GUI info can be put).
And as a new parser will have to be written anyways, it is not much extra-work to handle missing attributes that are not mandatory in the spec.

For example, if I take the example I had given before :

[ {"class": "obj", "id": 0, "type": "osc~", "args": [440]}, {"class": "obj", "id": 1, "type": "dac~"}, {"class": "connect", "from": [0, 0], "to": [1, 0]}, {"class": "connect", "from": [0, 0], "to": [1, 1]} ]

// start parsing, in pseudo-code
foreach element in element_list {
if (element.class is "obj") {
obj = create_new_obj_with_type_and_args(element)
if (has_display_infos(element)) {
set_object_display(obj, element)
} else {
set_default_display(obj)
}
}
// ...
}

what I mean is that the core specified should be small : objects, connections, data ; and if a particular program (pd, libpd, ...) using this format wants to add extra-info, it should handle the case where those infos are not available when parsing.
Or at least, that's my opinion :)

_______________________________________________
Pd-dev mailing list
Pd-dev-3mXD6pJrRzU@public.gmane.org
http://lists.puredata.info/listinfo/pd-dev


_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev
Rich E | 3 Jun 2012 18:49
Picon
Gravatar

Re: [ pure-data-Feature Requests-3531000 ] Proposal for an alternative file format



On Sun, Jun 3, 2012 at 9:33 AM, s p <sebpiq-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Strict json has a dictionary as it's outermost object.

I don't think this is true. I was not sure so I checked the spec : http://www.ietf.org/rfc/rfc4627.txt?number=4627
and apparently a valid json string is either an array or an object.


> Most parsers will accept an array as you have done, but not all (Obj-C's TouchJSON as an example)

TouchJSON's says (https://github.com/TouchCode/TouchJSON#invalid-json) :
"If you think your JSON is valid but TouchJSON is failing to process it correctly, use the online JSON lint tool to validate your JSON: http://www.jsonlint.com/ "

And it turns out, jsonlint accepts json with an array as outermost element.
Personally, I've always used an array, and many API libraries that I am using for web development return an array as outermost element.


I stand corrected.  I remember having difficulties using TouchJSON and receiving json with an array as outermost element, but this was a while back and it's clearly supported when I look at it now.  To me, it still seems vague this way: what _is_ the array? Is it a patch? A canvas? A file? When you use a dictionary, the name of the key is helpful in clearing this up.  It can also simplify parsing order.


> About the optional GUI, my opinion is that pd is firstly a graphical data flow language existing of canvases and objects with specific location.

Once again (sorry :) I disagree ... True, "pd is firstly a graphical data flow language".
However, times they are a changing, and libpd is becoming more and more important, and will probably continue to grow.
Also, I might be wrong, but I am guessing nobody would disagree that it is a good idea to go towards a better separation between pd core and its GUI. 
When you specify something new, it is a good occasion to do things well and clean. Passing over some legacy stuff to a new specification you are writing kind of kills the purpose of making a new specification.

For all those reasons, I think it is a good idea to specify a minimalist file format that doesn't include GUI infos.
Of course, it should include special placeholders for putting extra info (where GUI info can be put).
And as a new parser will have to be written anyways, it is not much extra-work to handle missing attributes that are not mandatory in the spec.
I agree with you that graphical representation should be separated out and it should be possible to be auto-generated if not present, but I think it deserves a classification higher than 'extra info'.  A formal extension of the format, so to speak, since the majority of use cases involving a pd patch will require a visual layout.  If you let every app define it's own format for graphical layout, there will be no interchange.  For example, you can define an optional key such as "layout" that contains well known child nodes like "x", "y", "size", etc.  If an element has this, great, if not, an app can generate this data.  But at least the parsing will be well known across the possibly many different graphical interfaces.

Cheers,
Rich
_______________________________________________
Pd-dev mailing list
Pd-dev@...
http://lists.puredata.info/listinfo/pd-dev

Gmane