Re: [PD-dev] Multiple Instance of pdlib

2014-02-25 Thread Peter Brinkmann
Good point. I wasn't involved when Peter first started the project and I'm
 sure, back then, multiple PD instances seemed waaay off into the future.


That's not actually what I was thinking when I was putting together the API
of libpd. My goal was simply to create the thinnest possible wrapper in C
that would make Pd embeddable, and then to add the thinnest possible Java
bindings that would make the C API available to Android devices. The
latter, with all the static methods in PdBase.java, drew some criticism
from some Java people, but I still believe that minimality is the way to go
for a library like this.

I also figured that support for multiple instances, if it ever happened,
would be an excellent excuse to start over and create a new API that would
be informed by the mistakes of the original API. I have little faith in
up-front design that tries to imagine what might happen in the future, but
I do believe in Brooks's admonition that you need to be prepared to throw
the initial version away.

As it happens, the original API has held up rather nicely, and I would
change relatively little if I were to start over right now. One minor
regret is that the libpd API has a few function names that don't include
verbs, a vestige of the initial rush to get stuff to work. A bigger concern
is that in virtually all use cases, it's good to have lock-free ring
buffers between the messaging functions and the audio processing callback,
for both input and output. We've been retrofitting ring buffers as needed
and that worked out okay, but it probably would have been cleaner to have
them in the core library.
Cheers,
 Peter
___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2014-02-24 Thread IOhannes m zmoelnig
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 2014-02-23 20:46, Dan Wilcox wrote:
 Any further updates on this front? If a consensus is made, we could
 outline a roadmap and move to the task of implementation. At this
 point, I think breaking externals would be less of an issue if said
 breakage would be manageable via about find/replace. I'd be willing
 to handle that, at the least.

i was going to ask something along these lines as well, but more libpd
specific:
when i (last) looked into the libpd API, i noticed that libpd works on
a global namespace as well...what i mean is, that the API (at least
the C-API, i haven't checked the others) does not allow to specify an
instance of pd.

the current API looks like:

snip
void libpd_init(void);
int libpd_process_float(int ticks, const float *in, float *out);
// ...
/snip

obviously with this API it will *never* be possible to initialize
multiple instances of libpd.
so i would have expected something along:
snip
typedef struct libpd_ libpd_t;
libpd_t*libpd_init(void);
int libpd_process_float(libpd_t*instance, int ticks, ...);
// ...
libpd_deinit(libpd_t*instance);
/snip

now obviously we *currently* cannot have multiple instances of pd
(afaiu, that's what dan's question is about).
but i fail to see why libpd doesn't provide the API for this, even if
the instance pointer would not be used (until Pd does support
multiple instances).

e.g. the application programmer would have to check that libpd_init()
returns non-NULL anyhow, and in the current implementation it would
always return NULL but the first time being called.

this would have allowed for a transition to multiple instances without
having to change the API...


ghsdft
IOhannes
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCAAGBQJTCwfjAAoJELZQGcR/ejb4uDsQAIrdZNgHX4zFytnGCjeG/PkB
UVbyXLy6EJwLNd15sFcO1u9VG6LWWC3LB7pSmw5DDoGhpnVcr4vCtNtRNX1hLFqy
n8WAI8IKyzioQlno1ed29Cjb9T0n2IKHZryHqPTobukURKmAWh4ZwQxGe7yM8AbM
6e+KyZb3JZHb7IVbf6DqqnPlb9hlLz7TP7f5SgDzY0TJGAbmSsfLha1SVoblZjY5
VzEQ3jl3rhblmWVmEFmHDR+LIBCJkKwGmPG0r3N8dbhvMFMFWVFtZCEKujbStvzz
cKvzjtgwtEL6n3kcw2eRHttCpZOnGsd/RW59r/68Pa+a2UvOhKdff0MELUSqm2Iu
rOjwl58mBtkXdtrqlgNPu2ZmdSNmwaw8OJizz2ttlX+r1CiBQPhEAzmRDYdtMN4V
QTDad5wKCW4l/eaSTX4+z/Dn3qZJ9X6CmQjc+fX2OgrTnWPe1P1Q0FpZ4ZuVHbGB
DYdFD5dJp/DU2OygQg6MO4h25VfalQ++MAujC5EPUxKkXZjOAsS8Nt29EFgC7mCc
QLeB/zlGbRNI7iRfrHI6zWANuPIvLuomHmhnc1UhkLZNPxFJ+GVkEfK+nyWq+rEG
n7751NYxGOdI5D8X3CZHuVOmmlRAqBceaEkH0gtJumr/o2k/GvN8kWjKQFSCncuc
/phnie1+8fSV7MlZ1rVr
=wrR6
-END PGP SIGNATURE-

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-12 Thread IOhannes m zmoelnig
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 2013-12-11 20:38, Rob Bairos wrote:
 
 Sorry, Im pretty new to this code, whats an extern in pdlib?

the same as in proper Pd: an external aka plugin that is, a
pre-compiled object loaded on-demand at runtime.

 
 Does it make more sense for the instance structure to be a set of 
 structures?

if we go that route, i'd suggest to use a structure of pointers to
structures (so the separate structures can be more easily extended
without breaking binary incompatibility).

fgmasdr
IOhannes
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.15 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCAAGBQJSqXiCAAoJELZQGcR/ejb4LBgP/1wayhKsCdBOX8in1tklqISK
gNR8ChKtsJX5Zju2oqBI7BL5VfIg1NdciWO1hAUhM4HLWG4Wd1/8oICFez+Nggu9
zmYa/lxxIk6XDuKtVCCRfCPYu3WTKbujwd1c7GVcnM2RSNInwwRuHn5wXhsi5HuC
60GtX086gPDwMtLNB3D8YjJxhhgnydP4SV4OUfxVW7USOpwsxQIPzPGInX7ukEE5
Tet+LCYKv27ojbZshJ5jYOp+zaK1vl7gx1Tu7NSGZbpo0pk1tQrXWy+KUlrvgRGL
zA/YUe280NWhf8JPBh9VMDCSXpRfU2LJkrrXIWStl/dphX0jj88nSjPu4qpuzFtJ
fAY13Noatjy357IvTh5i8YxZhX/Ryp5iuem0O/dzJJelD6KQQ97qYNXTTitcSWd8
bq3nyFoswi8KLt1svil/Ukd9/BAF1jNuNxGGKbpnMfkist+S616kvLd4Luo1exvd
NLo86trvie3SMsnTH9itGFOBP9DwKCp3FvNwo/50kS8ubZSbXjmwPjnAGSoD9fNA
scZElHJxlXISUA/ah4XTv+0RtPNjjyJhvsMjm18fzdjinziyizYw7n0SLlelCy1U
sqsbWlXQYKVS4HG2H5qM6QFZgb9ov+B/z5NVkcyn85C5LXIgL6BrTVk/anWQrbeD
P4d0RlArbWhCqWDrOLnn
=UyCi
-END PGP SIGNATURE-

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-12 Thread Rich E
+1 to localizing the symbol table and dsp chain, that would be a huge step
forward towards being able to use pd as a 'plugin''.

What other things would be global other than search path?  Audio and midi
settings?

cheers,
Rich


On Thu, Dec 12, 2013 at 3:49 AM, IOhannes m zmoelnig zmoel...@iem.atwrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256

 On 2013-12-11 20:38, Rob Bairos wrote:
 
  Sorry, Im pretty new to this code, whats an extern in pdlib?

 the same as in proper Pd: an external aka plugin that is, a
 pre-compiled object loaded on-demand at runtime.

 
  Does it make more sense for the instance structure to be a set of
  structures?

 if we go that route, i'd suggest to use a structure of pointers to
 structures (so the separate structures can be more easily extended
 without breaking binary incompatibility).

 fgmasdr
 IOhannes
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.15 (GNU/Linux)
 Comment: Using GnuPG with Icedove - http://www.enigmail.net/

 iQIcBAEBCAAGBQJSqXiCAAoJELZQGcR/ejb4LBgP/1wayhKsCdBOX8in1tklqISK
 gNR8ChKtsJX5Zju2oqBI7BL5VfIg1NdciWO1hAUhM4HLWG4Wd1/8oICFez+Nggu9
 zmYa/lxxIk6XDuKtVCCRfCPYu3WTKbujwd1c7GVcnM2RSNInwwRuHn5wXhsi5HuC
 60GtX086gPDwMtLNB3D8YjJxhhgnydP4SV4OUfxVW7USOpwsxQIPzPGInX7ukEE5
 Tet+LCYKv27ojbZshJ5jYOp+zaK1vl7gx1Tu7NSGZbpo0pk1tQrXWy+KUlrvgRGL
 zA/YUe280NWhf8JPBh9VMDCSXpRfU2LJkrrXIWStl/dphX0jj88nSjPu4qpuzFtJ
 fAY13Noatjy357IvTh5i8YxZhX/Ryp5iuem0O/dzJJelD6KQQ97qYNXTTitcSWd8
 bq3nyFoswi8KLt1svil/Ukd9/BAF1jNuNxGGKbpnMfkist+S616kvLd4Luo1exvd
 NLo86trvie3SMsnTH9itGFOBP9DwKCp3FvNwo/50kS8ubZSbXjmwPjnAGSoD9fNA
 scZElHJxlXISUA/ah4XTv+0RtPNjjyJhvsMjm18fzdjinziyizYw7n0SLlelCy1U
 sqsbWlXQYKVS4HG2H5qM6QFZgb9ov+B/z5NVkcyn85C5LXIgL6BrTVk/anWQrbeD
 P4d0RlArbWhCqWDrOLnn
 =UyCi
 -END PGP SIGNATURE-

 ___
 Pd-dev mailing list
 Pd-dev@iem.at
 http://lists.puredata.info/listinfo/pd-dev

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-12 Thread Rob Bairos
why would you make audio settings global?
in our particular setup each 'plugin / node' etc has an arbitrary number of
inputs/outputs/sample rate.


On Thu, Dec 12, 2013 at 12:31 PM, Rich E reakina...@gmail.com wrote:

 +1 to localizing the symbol table and dsp chain, that would be a huge step
 forward towards being able to use pd as a 'plugin''.

 What other things would be global other than search path?  Audio and midi
 settings?

 cheers,
 Rich


 On Thu, Dec 12, 2013 at 3:49 AM, IOhannes m zmoelnig zmoel...@iem.atwrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256

 On 2013-12-11 20:38, Rob Bairos wrote:
 
  Sorry, Im pretty new to this code, whats an extern in pdlib?

 the same as in proper Pd: an external aka plugin that is, a
 pre-compiled object loaded on-demand at runtime.

 
  Does it make more sense for the instance structure to be a set of
  structures?

 if we go that route, i'd suggest to use a structure of pointers to
 structures (so the separate structures can be more easily extended
 without breaking binary incompatibility).

 fgmasdr
 IOhannes
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.15 (GNU/Linux)
 Comment: Using GnuPG with Icedove - http://www.enigmail.net/

 iQIcBAEBCAAGBQJSqXiCAAoJELZQGcR/ejb4LBgP/1wayhKsCdBOX8in1tklqISK
 gNR8ChKtsJX5Zju2oqBI7BL5VfIg1NdciWO1hAUhM4HLWG4Wd1/8oICFez+Nggu9
 zmYa/lxxIk6XDuKtVCCRfCPYu3WTKbujwd1c7GVcnM2RSNInwwRuHn5wXhsi5HuC
 60GtX086gPDwMtLNB3D8YjJxhhgnydP4SV4OUfxVW7USOpwsxQIPzPGInX7ukEE5
 Tet+LCYKv27ojbZshJ5jYOp+zaK1vl7gx1Tu7NSGZbpo0pk1tQrXWy+KUlrvgRGL
 zA/YUe280NWhf8JPBh9VMDCSXpRfU2LJkrrXIWStl/dphX0jj88nSjPu4qpuzFtJ
 fAY13Noatjy357IvTh5i8YxZhX/Ryp5iuem0O/dzJJelD6KQQ97qYNXTTitcSWd8
 bq3nyFoswi8KLt1svil/Ukd9/BAF1jNuNxGGKbpnMfkist+S616kvLd4Luo1exvd
 NLo86trvie3SMsnTH9itGFOBP9DwKCp3FvNwo/50kS8ubZSbXjmwPjnAGSoD9fNA
 scZElHJxlXISUA/ah4XTv+0RtPNjjyJhvsMjm18fzdjinziyizYw7n0SLlelCy1U
 sqsbWlXQYKVS4HG2H5qM6QFZgb9ov+B/z5NVkcyn85C5LXIgL6BrTVk/anWQrbeD
 P4d0RlArbWhCqWDrOLnn
 =UyCi
 -END PGP SIGNATURE-

 ___
 Pd-dev mailing list
 Pd-dev@iem.at
 http://lists.puredata.info/listinfo/pd-dev



 ___
 Pd-dev mailing list
 Pd-dev@iem.at
 http://lists.puredata.info/listinfo/pd-dev


___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-12 Thread Rich E
On Thu, Dec 12, 2013 at 1:16 PM, Rob Bairos r...@derivative.ca wrote:

 why would you make audio settings global?
 in our particular setup each 'plugin / node' etc has an arbitrary number
 of inputs/outputs/sample rate.


I wouldn't, but I think they might already be.  I was asking what other
vars would remain global in Miller's proposed solution, giving audio
setttings as an example of something that you'd probably want to also be
local.  I don't know if there are others.
___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-11 Thread Rob Bairos
Oh, but for sending messages between instances, you would have to queue
the messages, and then it starts to get complicated..
I think sticking to independent instances with no shared arrays/etc would
be a great first step.

The idea of throwing all statis/externs into a data structure wouldn't
extend to externs, which would be ugly since it would mean the API for
internal objects would have to be different than for externs (which would
have to make their own data structures, per-Pd-instance, and would have to
have some way to look those up from the Pd instance.

Sorry, Im pretty new to this code, whats an extern in pdlib?

Also, the idea of
having a data structure that you have to change to add anthing static to
anything at all inside Pd sounds quite heavy to me.

Well if the engine requires a static variable, it should be treated
properly,
whether thats implementing it as a global instance structure or some other
mechanism,
different than simply declaring it static.

I'm liking the idea of simply localizing symbols and the DSP chain more
and more as I think about it... it's nice and self-contained and I think it
would help things a lot from what I'm hearing.

Well the first pass would definitely involve avoiding the need for a
variable to be static in the first place.
My brief skimming indicated that fit quite a few of them.


Does it make more sense for the instance structure to be a set of
structures?





On Wed, Dec 11, 2013 at 2:56 AM, Kjetil Matheussen k.s.matheus...@gmail.com
 wrote:

 On Wed, Dec 11, 2013 at 8:52 AM, Kjetil Matheussen
 k.s.matheus...@gmail.com wrote:
  On Wed, Dec 11, 2013 at 3:55 AM, Miller Puckette m...@ucsd.edu wrote:
 
  I'm liking the idea of simply localizing symbols and the DSP chain
 more
  and more as I think about it... it's nice and self-contained and I
 think it
  would help things a lot from what I'm hearing.
 
 
  Perhaps I misunderstand what you talk about, but for Radium,
  I think a shared symbol table could be better.
  Then you can share arrays and other things between instances.
  (And patch specific symbol names should be injected with $0 anyway.)

 Oh, but for sending messages between instances, you would have to queue
 the messages, and then it starts to get complicated...

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-10 Thread Rob Bairos
Sorry for the delay.
#1 I agree. Seems like a workaround. Ultimately it should be clear in the
source code when a static is meant to be shared across threads or not.
 Seems like something that could be properly implemented in the future?

#2  Sounds good, but Im not familiar with which variables are symbol table
related, DSP chain related, etc.
  Im of the mind, Id just like to put them *all* into one structure, to
get a stable release, and then individual variables can be pulled back out
in future as the need arises.
 Id be inclined to throw everything into one structure, and name things
according to which file they originated in:

example,  firstnet in d_fftroutine.c would live as an entry

struct PDinstance {
...
FFT_NET *d_fftroutine_firstnet;
...
}

This would allow one to at least see where the variable is used.

 #3  Peter mentions that in order to support legacy code, all API calls
would need to be mirrored, with and without the pd-instance variable.
I don't think C allows for overloading, so would this require a separate
name for all the functions?
Would supporting two parallel APIs be wanted though, or just lead to
confusion?
Is this in order to support previously compiled objects (Dlls)?

-Rob





On Mon, Dec 9, 2013 at 5:30 AM, Kjetil Matheussen
k.s.matheus...@gmail.comwrote:

 Hi Miller,

 Idea #1 sounds quite good, except that it sounds hacky
 and that performance might go down notifiable because
 of thread switching. The extra amount of code necessary
 to switch threads doesn't sound like too much work.

 So I like idea #2 much better. The limitation of only one
 DSP chain was the only good reason for implementing
 multiple pd instances for Radium. If you implement #2,
 that's probably good enough for Radium, and most likely
 good enough for most others too. At least, it's a very
 good start.


 On Sun, Dec 8, 2013 at 6:53 PM, Miller Puckette m...@ucsd.edu wrote:
  Hi all -
 
  two idea, neither of them as general but perhaps much easier to pull off:
 
  1.  make macros like:
  #define STATIC static __thread
 
  and rely on gcc's per-thread static storage mechanism.  This would
 involve
  some global search-and-replace action but wouldn't clutter the code too
 badly.
  The downside is it would require that each instance of libpd would have
 to
  run in its own thread - As Peter pointed out to me, in many situations
 the
  programmer can't even determine at compile time whether this would be
 true
  or not.
 
  I'm not sure but I think other C compilers besides gcc might support
 __thread
  these days.
 
  2.  Just make the symbol table and DSP chain per-instance,  and leave
 the rest
  alone.  This only solves a subset of the problem (things like the search
 path
  would remain global) but my intuition has it that fixing these two would
 be
  enough so that people could practically make patches that don't interfere
  with each other.  (Making the symbol table per-instance would keep things
  like arrays, send/receives, etc., from cross-talking.)
 
  The result wouldn't be thread-safe; however, combining this with the
  __thread idea from above would probably work, and then you'd have
 something
  that would at least work (although perhaps slightly differently) in
  same-thread and multi-thread contexts.
 
  These are just ideas - if there's enough interest I can pull (2) off
 quite
  easily; (1) would be a global search-and-replace mess that would likely
  conflict with every source-code patch out there (e.g., all the patches
 that
  are applied for Pd extended) so I'd need a real good reason to inflict
 that
  one on the world.
 
  cheers
  Miller
 
  On Sun, Dec 08, 2013 at 10:12:03AM +0100, Kjetil Matheussen wrote:
  Excellent plan.
 
  In my branch of libpd on Github, I've solved the Pd multiple
  instances problem by letting the linker take care of separating
  the global variables. However, using the linker causing various
  problems, such as making it very difficult to load externals,
  and it should probably also be considered a hack.
  Your plan (the plan I didn't bother doing in my branch) is quite
  undoubtedly the proper way to do it, and hopefully I would have time to
  help. At least I would be helping to debug it afterwards,
  because I would start using this system (in the Radium music editor),
  instead of my own, to embed Pd instances.
 
  And an advantage to Pd itself might be that the source could be clearer
 when
  variables that belongs to the instance, actually are denoted as such
  in the text.
 
  There is also quite microscopic concern, which is that the added
  amount of text could make the source more difficult to read,
  here and there. Maybe a very short variable name for the pd instance,
  such as p, pi', would be a good idea. (i.e. not
 pure_data_instance).
 
 
 
  On Sat, Dec 7, 2013 at 10:20 PM, Rob Bairos r...@derivative.ca wrote:
   Sorry, most of my original post got cut off.
   Here's the rest (minus the list of symbols) in case 

Re: [PD-dev] Multiple Instance of pdlib

2013-12-10 Thread Miller Puckette
Well, I think #1 (making statics per-thread) is only necessary on the
assumtion that you want Pd running simultaneously in multiple threads;
otherwise it would accomplish nothing.  I'm not sure but I guess the overhead
would be the same as the one-structure solution (which is essentially how,
I think, the per-thread thing would have to work internally anyhow.)

The idea of throwing all statis/externs into a data structure wouldn't
extend to externs, which would be ugly since it would mean the API for
internal objects would have to be different than for externs (which would
have to make their own data structures, per-Pd-instance, and would have to
have some way to look those up from the Pd instance.  Also, the idea of
having a data structure that you have to change to add anthing static to
anything at all inside Pd sounds quite heavy to me.

I'm liking the idea of simply localizing symbols and the DSP chain more
and more as I think about it... it's nice and self-contained and I think it
would help things a lot from what I'm hearing.

cheers
Miller

On Tue, Dec 10, 2013 at 01:07:08PM -0500, Rob Bairos wrote:
 Sorry for the delay.
 #1 I agree. Seems like a workaround. Ultimately it should be clear in the
 source code when a static is meant to be shared across threads or not.
  Seems like something that could be properly implemented in the future?
 
 #2  Sounds good, but Im not familiar with which variables are symbol table
 related, DSP chain related, etc.
   Im of the mind, Id just like to put them *all* into one structure, to
 get a stable release, and then individual variables can be pulled back out
 in future as the need arises.
  Id be inclined to throw everything into one structure, and name things
 according to which file they originated in:
 
 example,  firstnet in d_fftroutine.c would live as an entry
 
 struct PDinstance {
 ...
 FFT_NET *d_fftroutine_firstnet;
 ...
 }
 
 This would allow one to at least see where the variable is used.
 
  #3  Peter mentions that in order to support legacy code, all API calls
 would need to be mirrored, with and without the pd-instance variable.
 I don't think C allows for overloading, so would this require a separate
 name for all the functions?
 Would supporting two parallel APIs be wanted though, or just lead to
 confusion?
 Is this in order to support previously compiled objects (Dlls)?
 
 -Rob
 
 
 
 
 
 On Mon, Dec 9, 2013 at 5:30 AM, Kjetil Matheussen
 k.s.matheus...@gmail.comwrote:
 
  Hi Miller,
 
  Idea #1 sounds quite good, except that it sounds hacky
  and that performance might go down notifiable because
  of thread switching. The extra amount of code necessary
  to switch threads doesn't sound like too much work.
 
  So I like idea #2 much better. The limitation of only one
  DSP chain was the only good reason for implementing
  multiple pd instances for Radium. If you implement #2,
  that's probably good enough for Radium, and most likely
  good enough for most others too. At least, it's a very
  good start.
 
 
  On Sun, Dec 8, 2013 at 6:53 PM, Miller Puckette m...@ucsd.edu wrote:
   Hi all -
  
   two idea, neither of them as general but perhaps much easier to pull off:
  
   1.  make macros like:
   #define STATIC static __thread
  
   and rely on gcc's per-thread static storage mechanism.  This would
  involve
   some global search-and-replace action but wouldn't clutter the code too
  badly.
   The downside is it would require that each instance of libpd would have
  to
   run in its own thread - As Peter pointed out to me, in many situations
  the
   programmer can't even determine at compile time whether this would be
  true
   or not.
  
   I'm not sure but I think other C compilers besides gcc might support
  __thread
   these days.
  
   2.  Just make the symbol table and DSP chain per-instance,  and leave
  the rest
   alone.  This only solves a subset of the problem (things like the search
  path
   would remain global) but my intuition has it that fixing these two would
  be
   enough so that people could practically make patches that don't interfere
   with each other.  (Making the symbol table per-instance would keep things
   like arrays, send/receives, etc., from cross-talking.)
  
   The result wouldn't be thread-safe; however, combining this with the
   __thread idea from above would probably work, and then you'd have
  something
   that would at least work (although perhaps slightly differently) in
   same-thread and multi-thread contexts.
  
   These are just ideas - if there's enough interest I can pull (2) off
  quite
   easily; (1) would be a global search-and-replace mess that would likely
   conflict with every source-code patch out there (e.g., all the patches
  that
   are applied for Pd extended) so I'd need a real good reason to inflict
  that
   one on the world.
  
   cheers
   Miller
  
   On Sun, Dec 08, 2013 at 10:12:03AM +0100, Kjetil Matheussen wrote:
   Excellent plan.
  
   In my branch of 

Re: [PD-dev] Multiple Instance of pdlib

2013-12-10 Thread Kjetil Matheussen
On Wed, Dec 11, 2013 at 3:55 AM, Miller Puckette m...@ucsd.edu wrote:

 I'm liking the idea of simply localizing symbols and the DSP chain more
 and more as I think about it... it's nice and self-contained and I think it
 would help things a lot from what I'm hearing.


Perhaps I misunderstand what you talk about, but for Radium,
I think a shared symbol table could be better.
Then you can share arrays and other things between instances.
(And patch specific symbol names should be injected with $0 anyway.)

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-10 Thread Kjetil Matheussen
On Wed, Dec 11, 2013 at 8:52 AM, Kjetil Matheussen
k.s.matheus...@gmail.com wrote:
 On Wed, Dec 11, 2013 at 3:55 AM, Miller Puckette m...@ucsd.edu wrote:

 I'm liking the idea of simply localizing symbols and the DSP chain more
 and more as I think about it... it's nice and self-contained and I think it
 would help things a lot from what I'm hearing.


 Perhaps I misunderstand what you talk about, but for Radium,
 I think a shared symbol table could be better.
 Then you can share arrays and other things between instances.
 (And patch specific symbol names should be injected with $0 anyway.)

Oh, but for sending messages between instances, you would have to queue
the messages, and then it starts to get complicated...

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Multiple Instance of pdlib

2013-12-09 Thread Kjetil Matheussen
Hi Miller,

Idea #1 sounds quite good, except that it sounds hacky
and that performance might go down notifiable because
of thread switching. The extra amount of code necessary
to switch threads doesn't sound like too much work.

So I like idea #2 much better. The limitation of only one
DSP chain was the only good reason for implementing
multiple pd instances for Radium. If you implement #2,
that's probably good enough for Radium, and most likely
good enough for most others too. At least, it's a very
good start.


On Sun, Dec 8, 2013 at 6:53 PM, Miller Puckette m...@ucsd.edu wrote:
 Hi all -

 two idea, neither of them as general but perhaps much easier to pull off:

 1.  make macros like:
 #define STATIC static __thread

 and rely on gcc's per-thread static storage mechanism.  This would involve
 some global search-and-replace action but wouldn't clutter the code too badly.
 The downside is it would require that each instance of libpd would have to
 run in its own thread - As Peter pointed out to me, in many situations the
 programmer can't even determine at compile time whether this would be true
 or not.

 I'm not sure but I think other C compilers besides gcc might support __thread
 these days.

 2.  Just make the symbol table and DSP chain per-instance,  and leave the rest
 alone.  This only solves a subset of the problem (things like the search path
 would remain global) but my intuition has it that fixing these two would be
 enough so that people could practically make patches that don't interfere
 with each other.  (Making the symbol table per-instance would keep things
 like arrays, send/receives, etc., from cross-talking.)

 The result wouldn't be thread-safe; however, combining this with the
 __thread idea from above would probably work, and then you'd have something
 that would at least work (although perhaps slightly differently) in
 same-thread and multi-thread contexts.

 These are just ideas - if there's enough interest I can pull (2) off quite
 easily; (1) would be a global search-and-replace mess that would likely
 conflict with every source-code patch out there (e.g., all the patches that
 are applied for Pd extended) so I'd need a real good reason to inflict that
 one on the world.

 cheers
 Miller

 On Sun, Dec 08, 2013 at 10:12:03AM +0100, Kjetil Matheussen wrote:
 Excellent plan.

 In my branch of libpd on Github, I've solved the Pd multiple
 instances problem by letting the linker take care of separating
 the global variables. However, using the linker causing various
 problems, such as making it very difficult to load externals,
 and it should probably also be considered a hack.
 Your plan (the plan I didn't bother doing in my branch) is quite
 undoubtedly the proper way to do it, and hopefully I would have time to
 help. At least I would be helping to debug it afterwards,
 because I would start using this system (in the Radium music editor),
 instead of my own, to embed Pd instances.

 And an advantage to Pd itself might be that the source could be clearer when
 variables that belongs to the instance, actually are denoted as such
 in the text.

 There is also quite microscopic concern, which is that the added
 amount of text could make the source more difficult to read,
 here and there. Maybe a very short variable name for the pd instance,
 such as p, pi', would be a good idea. (i.e. not pure_data_instance).



 On Sat, Dec 7, 2013 at 10:20 PM, Rob Bairos r...@derivative.ca wrote:
  Sorry, most of my original post got cut off.
  Here's the rest (minus the list of symbols) in case its causing a problem:
 
 
  From my understanding, the current proposed solution is to take all statics
  and globals,
  encapsulate them in one object, and pass that object to all api calls.
  Peter further suggested legacy api is maintained by having them call the 
  new
  api with a default instance object.
 
  I did a little bit of hunting, using objdump on the current dll, to get a
  rough list of all the globals and statics currently involved.
 
  Im thinking the *_class and *_sym static pointers are in fact constant, and
  need only one shared instance.  That would leave about 320 variables
  remaining.
  Many of these variables are constant arrays, strings, etc.
  And many seem to be used only as a shortcut for passing data between two
  functions, possibly bringing down the number further.
 
  Im toying with the idea of taking on this task if anyone's interested.
  I may require some tips and help from the forum, in terms of creating a
  branch, explanation of some statics etc.
 
  So how feasible is this? Am I on the right track?
  Thanks very much,
  Rob Bairos.
 
  ___
  Pd-dev mailing list
  Pd-dev@iem.at
  http://lists.puredata.info/listinfo/pd-dev
 

 ___
 Pd-dev mailing list
 Pd-dev@iem.at
 http://lists.puredata.info/listinfo/pd-dev

___
Pd-dev mailing list

Re: [PD-dev] Multiple Instance of pdlib

2013-12-08 Thread Kjetil Matheussen
Excellent plan.

In my branch of libpd on Github, I've solved the Pd multiple
instances problem by letting the linker take care of separating
the global variables. However, using the linker causing various
problems, such as making it very difficult to load externals,
and it should probably also be considered a hack.
Your plan (the plan I didn't bother doing in my branch) is quite
undoubtedly the proper way to do it, and hopefully I would have time to
help. At least I would be helping to debug it afterwards,
because I would start using this system (in the Radium music editor),
instead of my own, to embed Pd instances.

And an advantage to Pd itself might be that the source could be clearer when
variables that belongs to the instance, actually are denoted as such
in the text.

There is also quite microscopic concern, which is that the added
amount of text could make the source more difficult to read,
here and there. Maybe a very short variable name for the pd instance,
such as p, pi', would be a good idea. (i.e. not pure_data_instance).



On Sat, Dec 7, 2013 at 10:20 PM, Rob Bairos r...@derivative.ca wrote:
 Sorry, most of my original post got cut off.
 Here's the rest (minus the list of symbols) in case its causing a problem:


 From my understanding, the current proposed solution is to take all statics
 and globals,
 encapsulate them in one object, and pass that object to all api calls.
 Peter further suggested legacy api is maintained by having them call the new
 api with a default instance object.

 I did a little bit of hunting, using objdump on the current dll, to get a
 rough list of all the globals and statics currently involved.

 Im thinking the *_class and *_sym static pointers are in fact constant, and
 need only one shared instance.  That would leave about 320 variables
 remaining.
 Many of these variables are constant arrays, strings, etc.
 And many seem to be used only as a shortcut for passing data between two
 functions, possibly bringing down the number further.

 Im toying with the idea of taking on this task if anyone's interested.
 I may require some tips and help from the forum, in terms of creating a
 branch, explanation of some statics etc.

 So how feasible is this? Am I on the right track?
 Thanks very much,
 Rob Bairos.

 ___
 Pd-dev mailing list
 Pd-dev@iem.at
 http://lists.puredata.info/listinfo/pd-dev


___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev