[PD-dev] pyext users?

B. Bogart ben at ekran.org
Sun Jul 31 16:08:34 CEST 2005


Hi Thomas,

I hope vacation did treat you well.

So I've cvs updated to flex 0.5.1 in CVS and the newest py (as of today) .

It is certainly behaving differently, but I am also still getting the
same crash just at a different time.

I've attached a "gem.pd" and a "simple.pd" only with the gem example
will you actually be able to see anything, but the simple example will
not depend on anything. of course my py script is also attached.

So now rather than crashing on the creation arguments PD now crashes on
the "change" message. Actually it also crashes on "reload." to reload
the script. So loading the script the first time does not crash (when
opening the patch) but it does crash when reloading the script. "bang"
and "reset" messages do not crash pd.

Note the below traces were taken from the simple test patch.

I've also changed my classname "array" to curve3d_array to avoid the
possible numarray conflict. Again I've had no crashes on OSX.

Sorry for the pasting of the patches/scripts I'm using X forwarding and
the patches are not on my email machine!

B.

Trace caused by "reload." message to pyext:
------------------------------------------

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 1076259328 (LWP 5285)]
0x421d9ef0 in pybase::MakePyArgs () from /usr/lib/pd/extra/py.pd_linux
(gdb) where
#0  0x421d9ef0 in pybase::MakePyArgs () from /usr/lib/pd/extra/py.pd_linux
#1  0x421d65cb in pyext::DoInit () from /usr/lib/pd/extra/py.pd_linux
#2  0x421d67e8 in pyext::InitInOut () from /usr/lib/pd/extra/py.pd_linux
#3  0x421d6aa2 in pyext::Load () from /usr/lib/pd/extra/py.pd_linux
#4  0x421de3b8 in pybase::Reload () from /usr/lib/pd/extra/py.pd_linux
#5  0x421d78e5 in pyext::flext_c_m_reload () from
/usr/lib/pd/extra/py.pd_linux
#6  0x421ec158 in flext_base_multi::TryMethTag () from
/usr/lib/pd/extra/py.pd_linux
#7  0x421ec417 in flext_base_multi::FindMeth () from
/usr/lib/pd/extra/py.pd_linux
#8  0x421ec66b in flext_base_multi::CbMethodHandler () from
/usr/lib/pd/extra/py.pd_linux
#9  0x421eca4f in flext_base_multi::cb_px_anything () from
/usr/lib/pd/extra/py.pd_linux
#10 0x0809b696 in pd_typedmess ()


Trace caused by "generate" & "change" message to script:
--------------------------------------------------------

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 1076259328 (LWP 5018)]
0x421d9ef0 in pybase::MakePyArgs () from /usr/lib/pd/extra/py.pd_linux
(gdb) where
#0  0x421d9ef0 in pybase::MakePyArgs () from /usr/lib/pd/extra/py.pd_linux
#1  0x421d711e in pyext::call () from /usr/lib/pd/extra/py.pd_linux
#2  0x421d7247 in pyext::work () from /usr/lib/pd/extra/py.pd_linux
#3  0x421d6ef3 in pyext::CbMethodResort () from
/usr/lib/pd/extra/py.pd_linux
#4  0x421ec705 in flext_base_multi::CbMethodHandler () from
/usr/lib/pd/extra/py.pd_linux
#5  0x421eca17 in flext_base_multi::px_object::px_method () from
/usr/lib/pd/extra/py.pd_linux
#6  0x0809b696 in pd_typedmess ()

simple.pd
---------
#N canvas 194 259 487 533 10;
#X obj 382 346 r cmd;
#X obj 58 349 r py-cmd;
#X msg 77 80 \; py-cmd reload.;
#X msg 78 129 \; cmd reset;
#X msg 79 174 \; cmd bang;
#X obj 58 380 pyext curve3d curve3d_array 10 10 -6 6 -4.5 4.5;
#X text 79 26 Py stuff;
#X msg 79 218 \; cmd change 0 0 0.5 0.5 0.03;
#X obj 58 473 print;
#X obj 58 440 spigot;
#X obj 95 417 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X text 193 85 Crashes;
#X text 157 137 No crash;
#X text 148 180 No crash;
#X msg 79 265 \; cmd generate 10 10 -6 6 -4.5 4.5;
#X text 289 226 Crashes;
#X text 320 274 Crashes;
#X connect 0 0 5 1;
#X connect 1 0 5 0;
#X connect 5 0 9 0;
#X connect 9 0 8 0;
#X connect 10 0 9 1;

curve3d.py
----------
import pyext
import sys
from numarray import *

class curve3d_array(pyext._class):

   # number of inlets and outlets
   _inlets=1
   _outlets=1

   # Vars
   width = 0
   height = 0
   points = array()
   w_lower = -5.333
   w_upper = 5.333
   h_lower = -4
   h_upper = 4
   direction = "down"

   print "curve3d scripts init"

   # Definitions

   # Constructor

   def __init__(self,*args):
     if len(args) == 6:
       self.width = args[0]
       self.height = args[1]
       self.w_lower = args[2]
       self.w_upper = args[3]
       self.h_lower = args[4]
       self.h_upper = args[5]
       self.generate_array(*args)
     else:
       print "External requires 6 arguments: <width> <height> <width
lower> <width upper> <height lower> <height upper>"
       print "Try using the 'generate' message with the same 6 arguments."

   def send_array(self):

     for i in xrange(self.width):
       for j in xrange(self.height):
         self._outlet(1,"set",(i,j)+tuple(self.points[i,j]))

   # Generates Array of Control points
   def generate_array(self,w,h,w_lower,w_upper,h_lower,h_upper):

     # Set values

     self.width = w
     self.height = h
     self.w_lower = w_lower
     self.w_upper = w_upper
     self.h_lower = h_lower
     self.h_upper = h_upper

     # Create Array
     self.points=zeros((w,h,3),Float32)

     # Calculate Size
     w_range = w_upper-w_lower
     h_range = h_upper-h_lower

     z=0

     for i in xrange(w):
       for j in xrange(h):
         x=i*(w_range/(w-1.0))+w_lower
         y=j*(h_range/(h-1.0))+h_lower
         self.points[i,j] = [x,y,z]

   # if the point matches then subtract 0.1
   def change_1(self,*args):
     if len(args) == 5:
       x = args[0]
       y = args[1]
       test_width = args[2]
       test_height = args[3]
       z = args[4]

       for i in xrange(self.width):
         for j in xrange(self.height):
           #if (self.w_lower < x < self.w_upper) and (self.h_lower > y >
self.h_upper):
           if (self.points[i,j,0]-test_width < x <
self.points[i,j,0]+test_width) and (self.points[i,j,1]-test_height < y <
self.points[i,j,1]+test_height):
             # Round makes sure that 1.000000156 == 1.0
             current = float(around(self.points[i,j,2],1))
             if self.direction == "up":
               incr = z*-1
             if self.direction == "down":
               incr = z

             if current >= 2:
               self.direction = "up"
             if current <= -2:
               self.direction = "down"

             self.points[i,j,2] = self.points[i,j,2] + incr
             self.send_array()
             #print current, self.points[i,j,2]
     else:
       print "Change requires 5 arguments: 'change <X> <Y> <test-width>
<test-height> <z>'"

   # methods for first inlet
   def generate_1(self,*args):
     if len(args) == 6:

       self.generate_array(*args)
       self.send_array()

     else:
       print "generate_array requires 6 arguments: <width> <height>
<width lower> <width upper> <height lower> <height upper>"

   # Send out array (if generated using creation arguments)
   def bang_(self,n):
     self.send_array()

   # Reset array to zeros
   def reset_(self,n):

self.generate_array(self.width,self.height,self.w_lower,self.w_upper,self.h_lower,self.h_upper)
     self.send_array()



gem.pd
------
#N canvas 465 174 779 592 10;
#X obj 18 446 gemwin 80;
#X msg 59 396 0 \, destroy;
#X msg 10 341 lighting \$1;
#X obj 15 314 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X msg 57 420 create \, 1;
#X obj 534 235 pack f f;
#X obj 517 174 gemmouse 10.666 8;
#X obj 507 197 - 5.33;
#X obj 556 197 expr ($f1*-1)+4;
#X msg 550 324 generate 4 4 -4 0 0 4;
#X obj 668 345 r cmd;
#X obj 437 346 r py-cmd;
#X msg 481 75 \; py-cmd reload.;
#X msg 592 75 \; cmd reset;
#X msg 670 75 \; cmd bang;
#N canvas 799 326 532 447 curve 0;
#X msg 80 284 set 0 0 -5.333 -4 \$1;
#X floatatom 81 265 5 0 0 0 - - -;
#X floatatom 44 87 5 0 0 0 - - -;
#X floatatom 88 86 5 0 0 0 - - -;
#X msg 76 334 res 10 10;
#X obj 20 338 r curve;
#X obj 70 134 inlet;
#X obj 8 302 inlet;
#X obj 32 370 curve3d 10 10;
#X floatatom 142 93 5 0 0 0 - - -;
#X floatatom 182 90 5 0 0 0 - - -;
#X obj 32 108 translateXYZ 0 -1.02 0;
#X obj 47 234 alpha;
#X obj 182 208 colorRGB 0 1 1 0.9;
#X obj 42 208 colorRGB 1 1 1 1;
#X obj 32 53 separator;
#X obj 29 32 r group;
#X obj 30 159 rotateXYZ 90 0 0;
#X connect 0 0 8 0;
#X connect 1 0 0 0;
#X connect 2 0 11 1;
#X connect 3 0 11 2;
#X connect 4 0 8 0;
#X connect 5 0 8 0;
#X connect 6 0 17 2;
#X connect 7 0 8 0;
#X connect 9 0 17 1;
#X connect 10 0 17 2;
#X connect 11 0 17 0;
#X connect 12 0 8 0;
#X connect 14 0 12 0;
#X connect 15 0 11 0;
#X connect 16 0 15 0;
#X connect 17 0 14 0;
#X restore 444 507 pd curve bottom;
#N canvas 550 324 536 451 curve 0;
#X obj 32 158 rotateXYZ;
#X msg 80 284 set 0 0 -5.333 -4 \$1;
#X floatatom 81 265 5 0 0 0 - - -;
#X obj 32 108 translateXYZ;
#X floatatom 44 87 5 0 0 0 - - -;
#X floatatom 88 86 5 0 0 0 - - -;
#X msg 76 334 res 10 10;
#X obj 20 338 r curve;
#X obj 70 134 inlet;
#X obj 8 302 inlet;
#X obj 32 370 curve3d 10 10;
#X floatatom 142 93 5 0 0 0 - - -;
#X floatatom 182 90 5 0 0 0 - - -;
#X obj 32 53 separator;
#X obj 31 31 r group;
#X connect 0 0 10 0;
#X connect 1 0 10 0;
#X connect 2 0 1 0;
#X connect 3 0 0 0;
#X connect 4 0 3 1;
#X connect 5 0 3 2;
#X connect 6 0 10 0;
#X connect 7 0 10 0;
#X connect 8 0 0 2;
#X connect 9 0 10 0;
#X connect 11 0 0 1;
#X connect 12 0 0 2;
#X connect 13 0 3 0;
#X connect 14 0 13 0;
#X restore 453 426 pd curve back;
#N canvas 766 310 548 463 curve 0;
#X msg 80 284 set 0 0 -5.333 -4 \$1;
#X floatatom 81 265 5 0 0 0 - - -;
#X floatatom 44 87 5 0 0 0 - - -;
#X floatatom 88 86 5 0 0 0 - - -;
#X msg 76 334 res 10 10;
#X obj 20 338 r curve;
#X obj 70 134 inlet;
#X obj 8 302 inlet;
#X obj 32 370 curve3d 10 10;
#X floatatom 142 93 5 0 0 0 - - -;
#X floatatom 182 90 5 0 0 0 - - -;
#X obj 32 108 translateXYZ 0 2.44 0;
#X obj 22 228 alpha;
#X obj 177 200 colorRGB 0 0.5 1 0.75;
#X obj 17 200 colorRGB 1 1 1 1;
#X obj 32 53 separator;
#X obj 29 32 r group;
#X obj 32 158 rotateXYZ 275 0 0;
#X connect 0 0 8 0;
#X connect 1 0 0 0;
#X connect 2 0 11 1;
#X connect 3 0 11 2;
#X connect 4 0 8 0;
#X connect 5 0 8 0;
#X connect 6 0 17 2;
#X connect 7 0 8 0;
#X connect 9 0 17 1;
#X connect 10 0 17 2;
#X connect 11 0 17 0;
#X connect 12 0 8 0;
#X connect 14 0 12 0;
#X connect 15 0 11 0;
#X connect 16 0 15 0;
#X connect 17 0 14 0;
#X restore 469 471 pd curve top;
#X msg 13 564 dimen 640 480 \, border 0 \, cursor 1 \, offset 0 -20
\, FSAA 6;
#X obj 17 30 gemhead;
#X floatatom 42 78 5 0 0 0 - - -;
#X floatatom 84 77 5 0 0 0 - - -;
#X floatatom 129 78 5 0 0 0 - - -;
#X obj 20 119 light;
#X floatatom 562 404 5 0 0 0 - - -;
#X msg 560 422 draw control_line2 \, width \$1;
#N canvas 550 324 540 455 curve 0;
#X msg 80 284 set 0 0 -5.333 -4 \$1;
#X floatatom 81 265 5 0 0 0 - - -;
#X floatatom 44 87 5 0 0 0 - - -;
#X floatatom 88 86 5 0 0 0 - - -;
#X msg 76 334 res 10 10;
#X obj 20 338 r curve;
#X obj 70 134 inlet;
#X obj 8 302 inlet;
#X obj 32 370 curve3d 10 10;
#X floatatom 142 93 5 0 0 0 - - -;
#X floatatom 182 90 5 0 0 0 - - -;
#X obj 32 108 translateXYZ 2.2 0 0;
#X obj 32 53 separator;
#X obj 29 32 r group;
#X obj 32 158 rotateXYZ 0 109 0;
#X connect 0 0 8 0;
#X connect 1 0 0 0;
#X connect 2 0 11 1;
#X connect 3 0 11 2;
#X connect 4 0 8 0;
#X connect 5 0 8 0;
#X connect 6 0 14 2;
#X connect 7 0 8 0;
#X connect 9 0 14 1;
#X connect 10 0 14 2;
#X connect 11 0 14 0;
#X connect 12 0 11 0;
#X connect 13 0 12 0;
#X connect 14 0 8 0;
#X restore 604 494 pd curve right;
#X obj 21 98 translateXYZ -4.5 0.8 2.4;
#X obj 179 282 counter 0 35900;
#X obj 186 240 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
10;
#X msg 249 256 reset;
#X obj 157 327 rotateXYZ;
#X obj 158 354 s group;
#X obj 160 212 gemhead;
#X obj 186 260 metro 25;
#X obj 178 300 / 50;
#X msg 534 258 \; cmd change \$1 \$2 0.5 0.5 0.03;
#X floatatom 218 236 5 0 0 0 - - -;
#X obj 439 377 pyext curve3d curve3d_array 10 10 -6 6 -4.5 4.5;
#X obj 92 131 loadbang;
#X msg 92 154 \; curve draw control_fill;
#X obj 374 40 cnv 4 4 500 empty empty empty 20 12 0 14 -90881 -66577
0;
#X text 115 28 Gem stuff;
#X text 430 24 Py stuff;
#X obj 29 531 loadbang;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 2 0;
#X connect 4 0 0 0;
#X connect 5 0 36 0;
#X connect 6 0 7 0;
#X connect 6 1 8 0;
#X connect 7 0 5 0;
#X connect 8 0 5 1;
#X connect 9 0 38 1;
#X connect 10 0 38 1;
#X connect 11 0 38 0;
#X connect 18 0 0 0;
#X connect 19 0 27 0;
#X connect 20 0 27 1;
#X connect 21 0 27 2;
#X connect 22 0 27 3;
#X connect 24 0 25 0;
#X connect 25 0 16 0;
#X connect 27 0 23 0;
#X connect 28 0 35 0;
#X connect 29 0 34 0;
#X connect 30 0 28 0;
#X connect 31 0 32 0;
#X connect 33 0 31 0;
#X connect 34 0 28 0;
#X connect 35 0 31 2;
#X connect 37 0 34 1;
#X connect 38 0 16 0;
#X connect 38 0 15 0;
#X connect 38 0 17 0;
#X connect 38 0 26 0;
#X connect 39 0 40 0;
#X connect 44 0 18 0;



Thomas Grill wrote:
> Hi Ben,
> could you send me an associated test patch?
> Also, calling your class array might not be a good idea, as you also
> imported numarray.array as array.
>
> best,
> Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20050731/d0139a3a/attachment.pgp>


More information about the Pd-dev mailing list