Thanks for the help Yves and IOhannes,
I tried your suguestion of 5, as relates to number of parameters, not to count of the sp array, which is what I thought at first. Your suguestion makes more sense.
I still get a segmentation fault though, after I turn on audio processing.
I looked at the page IOhannes pointed me too, and it looks like the only thing I dont do is step through all the samples in the block (while n-- busness). Could this be hats causing my break?
Is the error message I get about fftbin_tilde_dsp really about fftbin_tilde_perform because of this treatment of the sampleblock?
All I want to do is take one value, as specified by my seccond inlet, out of the whole sample block in the first inlet, and spit that out the outlet. I do this as below, in the perform function.
Below is my perform function, the gdb output, and my dsp function.
Thanks for the help again! -thewade
/*-----------fftbin's perform function-------------------*/ t_int *fftbin_tilde_perform(t_int *w) { t_fftbin *ref = (t_fftbin *)(w[1]); //data structure t_sample *in1 = (t_sample *)(w[2]); //fft~ output int in2 = (int)(w[3]); //bin number t_sample *out = (t_float *)(w[4]); //outlet int n = (int)(w[5]); //number of samples in block
int bin = in2; //get bin number if (bin<0) bin = 0; //clip bin to between 0 and n-1 if (bin>=n) bin = n-1; ref->x_bin = bin; //set datstructure ref->x_f = (t_float)*in1+ref->x_bin; //again, set datastructure *out = ref->x_f; //output float value of bin
return (w+6); } /*-------------------------------------------------------*/
/*---------------gdb debug information-------------------*/ Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1073855264 (LWP 1254)] 0x414b197b in fftbin_tilde_dsp () from /home/wade/pd/general/fftbin~.pd_linux (gdb) where #0 0x414b197b in fftbin_tilde_dsp () from /home/wade/pd/general/fftbin~.pd_linux #1 0x082321d0 in ?? () #2 0x082312d8 in ?? () #3 0x08231234 in ?? () #4 0x082321d0 in ?? () #5 0x0809daad in ugen_doit (dc=0x82312d8, u=0xffffffff) at d_ugen.c:750 #6 0x0809ea46 in ugen_done_graph (dc=0x8231eb8) at d_ugen.c:1007 #7 0x08230a20 in ?? () #8 0x08231eb8 in ?? () #9 0x00000001 in ?? () #10 0x00000001 in ?? () #11 0x00000000 in ?? () /*-------------------------------------------------------*/
/*------------------------fftbin dsp function------------*/ void fftbin_tilde_dsp(t_fftbin *ref, t_signal **sp) { dsp_add(fftbin_tilde_perform, 5, ref, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); } /*-------------------------------------------------------*/
Hallo, thewade hat gesagt: // thewade wrote:
Thanks for the help Yves and IOhannes,
I can't help you with your question, but I'd like to point out the pd-dev mailing-list, which actually would be more appropriate for these kinds of topics, so the non-C-users don't get bored. ;)
Frank Barknecht _ ______footils.org__
Zitiere thewade pdman@aproximation.org:
/*-----------fftbin's perform function-------------------*/ t_int *fftbin_tilde_perform(t_int *w) { t_fftbin *ref = (t_fftbin *)(w[1]); //data structure t_sample *in1 = (t_sample *)(w[2]); //fft~ output int in2 = (int)(w[3]); //bin number t_sample *out = (t_float *)(w[4]); //outlet int n = (int)(w[5]); //number of samples in } /*------------------------fftbin dsp function------------*/ void fftbin_tilde_dsp(t_fftbin *ref, t_signal **sp) { dsp_add(fftbin_tilde_perform, 5, ref, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); } /*-------------------------------------------------------*/
i just noticed that there is a discrepancy between passed arguments (dsp_add) and how you interpret them in the perform()-routine: while you are passing the sp[1]-s_vec as the "3rd" argument to the perform routine, it is somehow interpreted as "int n2".
are you sure that you are getting 2 input-signal vectors ? (you have to acquire 2 signal-inputs in the _new()-function).
note: it is required (from you!) that you keep signal-in/out's consistent over the _new(), _dsp() and _perform() routines (at least you have to understand what is going on ;-))
mfg.a.srd IOhannes