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);
}
/*-------------------------------------------------------*/