[PD-dev] Making externals work by sending post("",);

Ed Kelly morph_2016 at yahoo.co.uk
Fri Sep 12 13:25:35 CEST 2014


Hmm, that sorta figures.
I've got lots of t_atom * arrays and I'm getting some values from four separate arrays, setting them in another array and outputting the final array as a list. When I put the post() message in after the outlet_list() message it works, but when I don't it just outputs a list of 0's, regardless of the values I got.

I'll try to run it with gdb and a simple test patch later on - I'm curious to know what the cause is as it's happened to me a few times.

Cheers,
Ed

(simplified) code extract, if you're curious:
#define ELEMENTS 4

njsequence_float(t_njsequence *x, t_floatarg fin) {

int inPos = (int)fin;

x->offset_1 = atom_getfloatarg(inPos, MAXENTRIES, x->x_tracks.offset_1);
x->offset_2 = atom_getfloatarg(inPos, MAXENTRIES, x->x_tracks.offset_2);
x->offset_3 = atom_getfloatarg(inPos, MAXENTRIES, x->x_tracks.offset_3);
x->offset_4 = atom_getfloatarg(inPos, MAXENTRIES, x->x_tracks.offset_4);

SETFLOAT(&x->x_tracks.offsetList[0],x->offset_1);
SETFLOAT(&x->x_tracks.offsetList[1],x->offset_2);
SETFLOAT(&x->x_tracks.offsetList[2],x->offset_3);
SETFLOAT(&x->x_tracks.offsetList[3],x->offset_4);

outlet_list(x->offsets, gensym("list"), ELEMENTS, x->x_tracks.offsetList);
post("normal! OFFSETS:::: %d, %d, %d, %d",(int)x->offset_1,(int)x->offset_2,(int)x->offset_3,(int)x->offset_4);
}


I could post the whole thing, but you probably have better things to do than sift through >1300 lines of code
 
Ninja Jamm - a revolutionary new music remix app from Ninja Tune and Seeper, for iPhone and iPad
http://www.ninjajamm.com/


Gemnotes-0.2: Live music notation for Pure Data, now with dynamics!
http://sharktracks.co.uk/ 


On Friday, 12 September 2014, 2:46, Miller Puckette <msp at ucsd.edu> wrote:
 

>
>
>This has happened to me occasionally in the past.  I think it's usually
>that some routine that is getting called after post() is accessing an
>automatic variable (on the stack) without having set it earlier.  The
>post() call is simply changing the behavior by using the stack
>itself.
>
>If you can't catch it with gdb (which might allow you to avoid adding printout)
>another strategy is to try moving the post() line further down in the code -
>if by moving it below some other line you make it fail again, some function
>call in that line might be doing the bad access.
>
>cheers
>M
>
>
>On Fri, Sep 12, 2014 at 01:27:53AM +0100, Ed Kelly wrote:
>> Hi devs,
>> 
>> I've recently, and a number of times in the past had a problem with writing externals which is this:
>> An external is supposed to output something (such as a list) from an internally stored array, and it does not work.
>> When I add a 
>> post("This is this %d",x->theValue);
>> It starts working.
>> This has happened to my code more than once, both in Pd under Linux and in libPd in iOS. It's happened not just recently, but over a number of years.
>> I wonder if there is a relationship between Pd and the use of internal arrays that has to be cemented in some way before it can work, and if there is some problem in the Pd code (or I might be stupid about something).
>> I'll try to find a simple way of demonstrating this - the current extern is about 1800 lines of C, but maybe I can cook up a test if I have time.
>> 
>> Has anyone else had this problem?
>> Ed 
>>  
>> Ninja Jamm - a revolutionary new music remix app from Ninja Tune and Seeper, for iPhone and iPad
>> http://www.ninjajamm.com/
>> 
>> 
>> Gemnotes-0.2: Live music notation for Pure Data, now with dynamics!
>> http://sharktracks.co.uk/ 
>
>> _______________________________________________
>> Pd-dev mailing list
>> Pd-dev at lists.iem.at
>> http://lists.puredata.info/listinfo/pd-dev
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20140912/7952be20/attachment.html>


More information about the Pd-dev mailing list