[PD-dev] Object crashes when trying to write to its outlet

Christof Ressi info at christofressi.com
Tue Oct 10 15:54:58 CEST 2023


Yes. the perform routine needs to access the signal vectors.

If the object has a fixed number of inlets and outlets, you simply pass 
the signal vectors directly to `dsp_add`.

If the number of inlets and outlets is variable, you have to store the 
signal vector pointers somewhere in the object.

Note that in the latter case, you could also use `dsp_addv`, where the 
`t_int` arguments are passed as an array. This is left as an exercise to 
the reader :)

Christof

On 10.10.2023 12:27, Alexandros Drymonitis wrote:
> Getting back here after a while, just to confirm that Christof was 
> right. I would like to clarify if the following chunk is necessary to 
> be placed in the dsp routine:
>
> ```
> t_sample **dummy = x->in;
> for (i = 0; i < x->inchnls; i++)
>     *dummy++ = sp[i]->s_vec;
> dummy = x->out;
> for (i = x->inchnls; i < x->inchnls+x->outchnls; i++)
>     *dummy++ = sp[i]->s_vec;
> ```
>
> Without this the object crashes. From what I understand, the sp 
> pointer contains the input and output samples, together with the block 
> size, right? So, it's necessary to write the input and output to the 
> pointer of pointers for the inlets and outlets.
>
> Anyway, thanks for the help.
>
> Alexandros
>
> On 9/23/23 11:39, Christof Ressi wrote:
>>
>>> So you're saying that I only need to do the initial allocation, like 
>>> this:
>>>
>>> `x->x_in = (t_sample **)getbytes(ninlets * sizeof(t_sample *));`
>>>
>>> and not try to allocate `t_sample *` bytes in the for loop? I did 
>>> try this, but again the object is crushing.
>>
>> Yes, because "x_in" and "x_out" are supposed to hold the signal 
>> vectors ("s_vecf") of the inlets and outlets, which you would assign 
>> in the "dsp" method.
>>
>> Christof
>>
>>
>>
>>
>> _______________________________________________
>> Pd-dev mailing list
>> Pd-dev at lists.iem.at
>> https://lists.puredata.info/listinfo/pd-dev
>
>
>
> _______________________________________________
> Pd-dev mailing list
> Pd-dev at lists.iem.at
> https://lists.puredata.info/listinfo/pd-dev





More information about the Pd-dev mailing list