Re: [PD] lua scripting for pd objects

2008-04-13 Thread marius schebella
hello frank,
not sure how to compare. the lua code fades the lines out, but the c++ 
object does not. I can create 10 lines in lbuff and still only get 
34% cpu use. with lua and aging 0 I can only have about 17000 lines.
marius.

Frank Barknecht wrote:
> Hallo,
> cyrille henry hat gesagt: // cyrille henry wrote:
> 
>>> luagl is not as fast as C, but it's already much faster than using
>>> lots of separators or double gemheads. 
>>>
>>> Regarding Gem-externals: Does anyone have a simple template project
>>> how to write and compile a custom Gem external? This could be very
>>> useful, but I'm a bit confused how to do this in a simple way.
>>>
>>
>> use a gem object (like cube).
>> search and replace "cube" by the name of your object in both the ccp and h 
>> file.
>> use this makefile (adjust the name of the file / src directory).
>> it should compile.
> 
> Thanks a lot Cyrille. I made a little "benchmark" of a [linebuffer]
> object in luagl vs. a quickly hacked C++ version (warning, very ugly
> code!! Includes bugs I didn't care to fix for now.)
> 
> In this case, Lua does compare quite well with the C++ version on my
> machine.
> 
> Ciao
> 
> 
> 
> 
> ___
> PD-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> http://lists.puredata.info/listinfo/pd-list


___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-13 Thread Frank Barknecht
Hallo,
cyrille henry hat gesagt: // cyrille henry wrote:

> >luagl is not as fast as C, but it's already much faster than using
> >lots of separators or double gemheads. 
> >
> >Regarding Gem-externals: Does anyone have a simple template project
> >how to write and compile a custom Gem external? This could be very
> >useful, but I'm a bit confused how to do this in a simple way.
> >
> 
> 
> use a gem object (like cube).
> search and replace "cube" by the name of your object in both the ccp and h 
> file.
> use this makefile (adjust the name of the file / src directory).
> it should compile.

Thanks a lot Cyrille. I made a little "benchmark" of a [linebuffer]
object in luagl vs. a quickly hacked C++ version (warning, very ugly
code!! Includes bugs I didn't care to fix for now.)

In this case, Lua does compare quite well with the C++ version on my
machine.

Ciao
-- 
 Frank Barknecht _ __footils.org__


lua-c-gemtest.tgz
Description: GNU Unix tar archive
___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-13 Thread cyrille henry

hello,

Frank Barknecht a écrit :

Hallo,
chris clepper hat gesagt: // chris clepper wrote:


C++ - Jamie did a lot of this for his personal use.

I have not used luagl, but I suspect it will not be comparable to C in
speed.


luagl is not as fast as C, but it's already much faster than using
lots of separators or double gemheads. 


Regarding Gem-externals: Does anyone have a simple template project
how to write and compile a custom Gem external? This could be very
useful, but I'm a bit confused how to do this in a simple way.




use a gem object (like cube).
search and replace "cube" by the name of your object in both the ccp and h file.
use this makefile (adjust the name of the file / src directory).
it should compile.

cyrille



Ciao
PD_DIR = /home/nusmuk/pd/pd/src
GEM_DIR = /home/nusmuk/pd/Gem/src

LIBS =  -lm

# build flags

INCLUDE =  -I$(PD_DIR) -I.  -I$(GEM_DIR) -I$(PD_DIR)
CPPFLAGS  = -DPD -O2 -funroll-loops -fomit-frame-pointer  -ffast-math \
-Wall -W -Wno-unused -Wno-parentheses -Wno-switch -g

all:test.pd_linux 
rm -f *.o

.SUFFIXES: .pd_linux

clean:
rm -f *.o
rm -f *.pd_linux

.cpp.o:
g++ $(CPPFLAGS) $(INCLUDE) -o $*.o -c $*.cpp

.cpp.pd_linux:
g++ $(CPPFLAGS) $(INCLUDE) -o $*.o -c $*.cpp
gcc -export_dynamic -shared -o $*.pd_linux $*.o $(LIBS)
rm -f *.o








___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-13 Thread Frank Barknecht
Hallo,
chris clepper hat gesagt: // chris clepper wrote:

> C++ - Jamie did a lot of this for his personal use.
> 
> I have not used luagl, but I suspect it will not be comparable to C in
> speed.

luagl is not as fast as C, but it's already much faster than using
lots of separators or double gemheads. 

Regarding Gem-externals: Does anyone have a simple template project
how to write and compile a custom Gem external? This could be very
useful, but I'm a bit confused how to do this in a simple way.

Ciao
-- 
 Frank Barknecht _ __footils.org__

___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-11 Thread chris clepper
On Fri, Apr 11, 2008 at 11:43 AM, marius schebella <
[EMAIL PROTECTED]> wrote:

>
> I don't know how I could translate the objects correctly without gemheads
> or separators, maybe storing the current XYZlocation and subtracting it from
> the relative position? would that be faster than to use pushmatrix
> popmatrix?
>

For something like a grid this is not difficult to do, but for less uniform
structures it would be a pain.

Pushing and popping the matrix is not expensive done sparingly, but it does
accumulate.  Once the geometry count gets high you will need all the time
you can get.


> the geometry I was using so far was simple, but objects could still be
> faster I guess. are you talking about display lists like VOBs or FBOs? I
> have to read more about that and how gem makes use of it.
>

A display list is the geometry compiled and sent to the card once and then
called from storage on the GPU for drawing.  The model object uses display
lists to help handle large numbers of triangles found in most models.

VBO is a vertex buffer object which can be quite fast if you need to modify
geometry on the CPU side and submit it to the GPU each frame.

FBO is a way to render offscreen to use rasterized geometry as a texture in
another framebuffer (usually the one drawn to screen).  FBOs will probably
not help you here.


> write as write in c++? or write as write in luagl?
>
>
C++ - Jamie did a lot of this for his personal use.

I have not used luagl, but I suspect it will not be comparable to C in
speed.

cgc
___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-11 Thread marius schebella
chris clepper wrote:
> In GEM if you need lots of objects then try to avoid using a gemhead or 
> separator for each.  The setup time for pushing and popping the matrix 
> thousands of times starts to add up. 

I don't know how I could translate the objects correctly without 
gemheads or separators, maybe storing the current XYZlocation and 
subtracting it from the relative position? would that be faster than to 
use pushmatrix popmatrix?


> Also, use a model so rather than compute and upload the geometry in 
> immediate mode each frame a display list is called instead.

the geometry I was using so far was simple, but objects could still be 
faster I guess. are you talking about display lists like VOBs or FBOs? I 
have to read more about that and how gem makes use of it.

> The fastest solution would be to write a custom object that wraps all of 
> the functionality you need.

write as write in c++? or write as write in luagl?

marius.

> On Fri, Apr 11, 2008 at 10:46 AM, marius schebella 
> <[EMAIL PROTECTED] > wrote:
> 
> I tried that too, with a set of new patches and it was quite fast
> (although I think not as fast as luagl), but I already have a lot of old
> interactive object patches that I wanted to use. they have mouseover
> handling and also store textinformation.
> actually it is a question of performance. I want as many as possible
> objects and need to find the fastest solution.
> marius.
> 
> 
> 


___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-11 Thread chris clepper
In GEM if you need lots of objects then try to avoid using a gemhead or
separator for each.  The setup time for pushing and popping the matrix
thousands of times starts to add up.

Also, use a model so rather than compute and upload the geometry in
immediate mode each frame a display list is called instead.

The fastest solution would be to write a custom object that wraps all of the
functionality you need.

On Fri, Apr 11, 2008 at 10:46 AM, marius schebella <
[EMAIL PROTECTED]> wrote:

> I tried that too, with a set of new patches and it was quite fast
> (although I think not as fast as luagl), but I already have a lot of old
> interactive object patches that I wanted to use. they have mouseover
> handling and also store textinformation.
> actually it is a question of performance. I want as many as possible
> objects and need to find the fastest solution.
> marius.
>
>
>
___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-11 Thread marius schebella
I tried that too, with a set of new patches and it was quite fast 
(although I think not as fast as luagl), but I already have a lot of old 
interactive object patches that I wanted to use. they have mouseover 
handling and also store textinformation.
actually it is a question of performance. I want as many as possible 
objects and need to find the fastest solution.
marius.

Roman Haefeli wrote:
> hi marius
> 
> sorry to switch in so late, but let me mention another approach. if you
> only have numeric arguments for your abstractions, you could
> alternatively still use [repeat] and read the different values from
> a/several table/s. that is what i usually do, when i need - let's say -
> 1000 cuboids at different positions with different colours. like this
> you wouldn't need thousands of instances of a certain abstraction, but
> only one, where you send thousands of messages to for each frame. 
> 
> don't know, if this would work for what you want, though...
> 
> roman
> 
> 
> 
> On Thu, 2008-04-10 at 13:47 -0400, marius schebella wrote:
>> thanks for all the answers, I guess I am really looking for something 
>> like actionscript for pd, based on lua or python. I understand that all 
>> of the suggested solutions are working, but all have some minor 
>> downsides, or overheads (of coding) or dynamic restrictions.
>> marius.
>>
>> Thomas Grill wrote:
>>> Hi Marius,
>>> i've used py and dyn~ in combination for such stuff many times.
>>> With that many objects it makes probably sense to put the abstractions 
>>> in subpatches (e.g. 30 subpatches with 100 objects each) as pd has 
>>> problems with many objects in one canvas.
>>> gr~~~
>>>
>>> Am 10.04.2008 um 18:10 schrieb marius schebella:
>>>
 hi,
 i need to create a lot of instances (let's say 3000) of a gem
 abstraction. each instance has to hold it's own variables, so it is
 difficult to work with repeat.
 In the past I always used pd-messages to create these objects, but I
 have the feeling that it would be faster and easier to do in a scripting
 language like lua.
 are there any plans to support scripting of pd objects (in this case gem
 objects) within lua or any other scripting language?
 marius.

 ___
 PD-list@iem.at mailing list
 UNSUBSCRIBE and account-management -> 
 http://lists.puredata.info/listinfo/pd-list
>>>
>>
>> ___
>> PD-list@iem.at mailing list
>> UNSUBSCRIBE and account-management -> 
>> http://lists.puredata.info/listinfo/pd-list
> 
> 
>   
>   
> ___ 
> Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: 
> http://mail.yahoo.de
> 
> 


___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-11 Thread Roman Haefeli
hi marius

sorry to switch in so late, but let me mention another approach. if you
only have numeric arguments for your abstractions, you could
alternatively still use [repeat] and read the different values from
a/several table/s. that is what i usually do, when i need - let's say -
1000 cuboids at different positions with different colours. like this
you wouldn't need thousands of instances of a certain abstraction, but
only one, where you send thousands of messages to for each frame. 

don't know, if this would work for what you want, though...

roman



On Thu, 2008-04-10 at 13:47 -0400, marius schebella wrote:
> thanks for all the answers, I guess I am really looking for something 
> like actionscript for pd, based on lua or python. I understand that all 
> of the suggested solutions are working, but all have some minor 
> downsides, or overheads (of coding) or dynamic restrictions.
> marius.
> 
> Thomas Grill wrote:
> > Hi Marius,
> > i've used py and dyn~ in combination for such stuff many times.
> > With that many objects it makes probably sense to put the abstractions 
> > in subpatches (e.g. 30 subpatches with 100 objects each) as pd has 
> > problems with many objects in one canvas.
> > gr~~~
> > 
> > Am 10.04.2008 um 18:10 schrieb marius schebella:
> > 
> >> hi,
> >> i need to create a lot of instances (let's say 3000) of a gem
> >> abstraction. each instance has to hold it's own variables, so it is
> >> difficult to work with repeat.
> >> In the past I always used pd-messages to create these objects, but I
> >> have the feeling that it would be faster and easier to do in a scripting
> >> language like lua.
> >> are there any plans to support scripting of pd objects (in this case gem
> >> objects) within lua or any other scripting language?
> >> marius.
> >>
> >> ___
> >> PD-list@iem.at mailing list
> >> UNSUBSCRIBE and account-management -> 
> >> http://lists.puredata.info/listinfo/pd-list
> > 
> > 
> 
> 
> ___
> PD-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> http://lists.puredata.info/listinfo/pd-list




___ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: 
http://mail.yahoo.de


___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-10 Thread marius schebella
thanks for all the answers, I guess I am really looking for something 
like actionscript for pd, based on lua or python. I understand that all 
of the suggested solutions are working, but all have some minor 
downsides, or overheads (of coding) or dynamic restrictions.
marius.

Thomas Grill wrote:
> Hi Marius,
> i've used py and dyn~ in combination for such stuff many times.
> With that many objects it makes probably sense to put the abstractions 
> in subpatches (e.g. 30 subpatches with 100 objects each) as pd has 
> problems with many objects in one canvas.
> gr~~~
> 
> Am 10.04.2008 um 18:10 schrieb marius schebella:
> 
>> hi,
>> i need to create a lot of instances (let's say 3000) of a gem
>> abstraction. each instance has to hold it's own variables, so it is
>> difficult to work with repeat.
>> In the past I always used pd-messages to create these objects, but I
>> have the feeling that it would be faster and easier to do in a scripting
>> language like lua.
>> are there any plans to support scripting of pd objects (in this case gem
>> objects) within lua or any other scripting language?
>> marius.
>>
>> ___
>> PD-list@iem.at mailing list
>> UNSUBSCRIBE and account-management -> 
>> http://lists.puredata.info/listinfo/pd-list
> 
> 


___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-10 Thread Thomas Grill
Hi Marius,
i've used py and dyn~ in combination for such stuff many times.
With that many objects it makes probably sense to put the  
abstractions in subpatches (e.g. 30 subpatches with 100 objects each)  
as pd has problems with many objects in one canvas.
gr~~~

Am 10.04.2008 um 18:10 schrieb marius schebella:

> hi,
> i need to create a lot of instances (let's say 3000) of a gem
> abstraction. each instance has to hold it's own variables, so it is
> difficult to work with repeat.
> In the past I always used pd-messages to create these objects, but I
> have the feeling that it would be faster and easier to do in a  
> scripting
> language like lua.
> are there any plans to support scripting of pd objects (in this  
> case gem
> objects) within lua or any other scripting language?
> marius.
>
> ___
> PD-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/ 
> listinfo/pd-list


___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-10 Thread Frank Barknecht
Hallo,
marius schebella hat gesagt: // marius schebella wrote:

> well, nqpoly4 asks for a very special method to write your abstraction, 

That's only because it's a generic helper for dynamic patching. You
could of course also just do your dynamic patching the traditional
way.

> and I wonder if there is an overhead from additional send/receives?

There are no additional sends and receives in nqpoly4: It handles
messaging from the outside through direct connections with in/outlets.
I doubt that it makes much of a differnce anyway. 

An alternative with Lua might be to write "polyphonic" pdlua objects.
A quick example is attached simple [linebuffer] which just draws many
[curve 2]-like lines with optional aging. It can easily handle several
thousands of lines. (Requires luagl, rename suffix for newest pdlua)

Ciao
-- 
 Frank Barknecht _ __footils.org__
require 'luagl' 

local M = pd.Class:new():register("linebuffer")

function M:initialize(name, atoms)
self.inlets = 2
self.outlets = 1
self.buffer = {}
self.aging = 0.01
self.smooth = false
return true
end

function M:in_1_reset()
self.buffer = {}
end

function M:in_2_list(atoms)
for i=1,4 do
assert(type(atoms[i]) == "number", "Error: All 4 coordinates must be 
numbers!")
end
atoms.age = 1
self.buffer[#self.buffer + 1] = atoms
end

function M:in_1_aging(atoms)
self.aging = math.max(0, atoms[1]) or 0.01
end

function M:in_1_smooth(atoms)
if atoms[1] and atoms[1] ~= 0 then
self.smooth = true
else
self.smooth = false
end
if self.smooth then
glEnable(GL_LINE_SMOOTH)
else
glDisable(GL_LINE_SMOOTH)
end
end


function M:render()
for i,l in ipairs(self.buffer) do
c = l.age
glBegin(GL_LINES)
glColor4d(1,1,1,c)
glVertex2d(l[1], l[2])
glVertex2d(l[3], l[4])
glEnd()
l.age = l.age - self.aging 
end
for i,l in ipairs(self.buffer) do
if l.age <= 0 then table.remove(self.buffer, i) end
end

end

function M:in_1_gem_state()
self:render(self)
self:outlet(1, "float", {#self.buffer})
end


linebuffer-help.pd
Description: application/puredata
___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-10 Thread marius schebella
well, nqpoly4 asks for a very special method to write your abstraction, 
and I wonder if there is an overhead from additional send/receives?
besides, I will try it, never used it before, thanks.
marius.

Hans-Christoph Steiner wrote:
> 
> Sounds like a good time for [nqpoly4].  I have used it to manage 1000 
> instances of one abstraction and more than that for multiple 
> abstractions.   Check the included Gem example for nqpoly4.
> 
> .hc
> 
> On Apr 10, 2008, at 12:10 PM, marius schebella wrote:
>> hi,
>> i need to create a lot of instances (let's say 3000) of a gem
>> abstraction. each instance has to hold it's own variables, so it is
>> difficult to work with repeat.
>> In the past I always used pd-messages to create these objects, but I
>> have the feeling that it would be faster and easier to do in a scripting
>> language like lua.
>> are there any plans to support scripting of pd objects (in this case gem
>> objects) within lua or any other scripting language?
>> marius.
>>
>> ___
>> PD-list@iem.at mailing list
>> UNSUBSCRIBE and account-management -> 
>> http://lists.puredata.info/listinfo/pd-list
> 
> 
> 
>  
> 
> 
> Using ReBirth is like trying to play an 808 with a long stick.-David 
> Zicarelli
> 
> 
> 


___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-10 Thread Claude Heiland-Allen
marius schebella wrote:
> are there any plans to support scripting of pd objects (in this case gem 
> objects) within lua or any other scripting language?

Support already exists to the same level that it does in Pd.

You can use pd.send(name, sel, atoms) to send to subpatch's receiver. (I 
think, best check the examples for exact syntax.)

Whether it would be useful to have a library of functions to make it 
easier, I don't know.


Claude
-- 
http://claudiusmaximus.goto10.org

___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] lua scripting for pd objects

2008-04-10 Thread Hans-Christoph Steiner

Sounds like a good time for [nqpoly4].  I have used it to manage 1000  
instances of one abstraction and more than that for multiple  
abstractions.   Check the included Gem example for nqpoly4.

.hc

On Apr 10, 2008, at 12:10 PM, marius schebella wrote:
> hi,
> i need to create a lot of instances (let's say 3000) of a gem
> abstraction. each instance has to hold it's own variables, so it is
> difficult to work with repeat.
> In the past I always used pd-messages to create these objects, but I
> have the feeling that it would be faster and easier to do in a  
> scripting
> language like lua.
> are there any plans to support scripting of pd objects (in this  
> case gem
> objects) within lua or any other scripting language?
> marius.
>
> ___
> PD-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/ 
> listinfo/pd-list



 


Using ReBirth is like trying to play an 808 with a long stick.- 
David Zicarelli



___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list


[PD] lua scripting for pd objects

2008-04-10 Thread marius schebella
hi,
i need to create a lot of instances (let's say 3000) of a gem 
abstraction. each instance has to hold it's own variables, so it is 
difficult to work with repeat.
In the past I always used pd-messages to create these objects, but I 
have the feeling that it would be faster and easier to do in a scripting 
language like lua.
are there any plans to support scripting of pd objects (in this case gem 
objects) within lua or any other scripting language?
marius.

___
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list