here is the code for my convolution project that i'm working on. i
sent an earlier email to the pdlist, but i don't think it'll go through because it's over 2MB which includes a bin file. anyway i found out where i'm getting the seg fault:
for(set=0; set<=255; set++)
{
aleftout[set]=(*in1++); /*brings in 256 samples from input*/
arightout[set]=(*in2++);
}
what i think is happening is that aleftout and arightout are float
arrays, and what i'm trying to pass into them are pointers to floats. everything in my code is happening in the while(n--) part of it, so i think i just need to make some type conversions there. i believe all of the fftr4_ functions take floats, so i need to convert from pointer to float, and then again from float to pointer. thanks in advance to anybody who can help me! i'm just not sure how to do this.
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
---------- Forwarded message ---------- Date: Tue, 20 Aug 2002 14:27:02 -0700 (PDT) From: Jeffrey Hildebrand jscotth@nyquist.cipic.ucdavis.edu To: jscotth@ucdavis.edu
hi,
i think the error is to harcode the size of arrays to 255.
in fact, arrays in1 and in2 are of the size of the n variable passed to the perform routine and this variable is 64 by default ( the default block size ).
for(set=0; set<n; set++)
cheers,
sevy/yves
J. Scott Hildebrand wrote:
here is the code for my convolution project that i'm working on. i
sent an earlier email to the pdlist, but i don't think it'll go through because it's over 2MB which includes a bin file. anyway i found out where i'm getting the seg fault:
for(set=0; set<=255; set++) { aleftout[set]=(*in1++); /*brings in 256 samples from input*/ arightout[set]=(*in2++); }
what i think is happening is that aleftout and arightout are float arrays, and what i'm trying to pass into them are pointers to floats. everything in my code is happening in the while(n--) part of it, so i think i just need to make some type conversions there. i believe all of the fftr4_ functions take floats, so i need to convert from pointer to float, and then again from float to pointer. thanks in advance to anybody who can help me! i'm just not sure how to do this.
scott
Hi, J. Scott Hildebrand hat gesagt: // J. Scott Hildebrand wrote:
here is the code for my convolution project that i'm working on. i
sent an earlier email to the pdlist, but i don't think it'll go through because it's over 2MB which includes a bin file.
I hope it didn't...
anyway i found out where i'm getting the seg fault:
for(set=0; set<=255; set++) { aleftout[set]=(*in1++); /*brings in 256 samples from input*/ arightout[set]=(*in2++);
If *in1 and *in2 are smaller than 256 - they are "n" and thus usually 64 samples long - you're reading past the end of the list into unchartered territory and that results in undefined behaviour == segfault.
what i think is happening is that aleftout and arightout are float
arrays, and what i'm trying to pass into them are pointers to floats.
Pointers to floats and float arrays are practically the same. Instead of your code snippet you could also write: int set = n; while (set--) // "while set not NULL and count it downwards" { (*aleftout++) = (*in1++); // or arightout[set] = in2[set]; }
everything in my code is happening in the while(n--) part of it,
If you just want to copy all elements of *in1 to *aleftout you maybe don't need to do this in the (while n--) loop, because then you would do the copying n-times. But maybe you want excactly this? I'm not quite sure, if your algorithm needs this updating on each sample, because I didn't understand it fully. Maybe you could just copy the pointer...
Frank Barknecht _ ______footils.org__
here's a pd concept i do no understand: first take a look at this
code >>>
t_float lsum = 0.0;
t_float rsum = 0.0;
lsum = *in1++;
rsum = *in2++;
*out1++ = lsum;
*out2++ = rsum;
if i have this in my while(n--) loop inside the perform function, then it takes input audio and just sends it back out. it works. i don't understand how the input and output arrays work though. i thought that in and out were actually arrays with 64 samples in each. right here what i'm doing is taking one sample with lsum and rsum, and then i'm spitting the output out, and then doing the while loop again. right? what exactly is happening? and then what do i need to do to collect 256 samples into an array and then use that in my convolution scheme? thanks!
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
Hi Scott, i'm not quite sure what the problem is, but a few remarks on these things:
different from 64...according to the setting of a block~ object in the patcher 2) the input and output arrays can point to the same locations.. that means that once you have filled the output array, the input data is lost. I think, there is a switch to have separate arrays, though... must be somewhere with class setup. 3) if you want to grab a fixed amount of 256 samples for some fft stuff you will have to reserve some extra space for fft input and transformed data.
You start with empty fft in and transformed data. In every dsp perform function you copy the signal input to the fft in buffer. The transformed data is still zero, hence the signal output will be zero. At some time the fft in buffer is filled. You can then do the transformation and start copying this output data into the signal output. Your fft input is again empty, so you start filling it again.... Once understood, it isn't difficult.
hope that helps, greetings, Thomas
----- Original Message ----- From: "J. Scott Hildebrand" jshildebrand@ucdavis.edu To: "Frank Barknecht" barknech@ph-cip.uni-koeln.de Cc: pd-list@iem.kug.ac.at Sent: Wednesday, August 21, 2002 11:52 PM Subject: Re: [PD] convolution code error
here's a pd concept i do no understand: first take a look at this
code >>>
t_float lsum = 0.0; t_float rsum = 0.0;
lsum = *in1++; rsum = *in2++; *out1++ = lsum; *out2++ = rsum;
if i have this in my while(n--) loop inside the perform function, then it takes input audio and just sends it back out. it works. i don't understand how the input and output arrays work though. i thought that in and out were actually arrays with 64 samples in each. right here what i'm doing is taking one sample with lsum and rsum, and then i'm spitting the output out, and then doing the while loop again. right? what exactly is happening? and then what do i need to do to collect 256 samples into an array and then use that in my convolution scheme? thanks!
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
does the program loop the perform function over and over again, or
just the while(n--) loop? from what i understand the n-- gets a new block of samples right? does that mean that within my while loop i can have more of n-- and get a new block? thanks,
scott
On Thu, 22 Aug 2002, Thomas Grill wrote:
Hi Scott, i'm not quite sure what the problem is, but a few remarks on these things:
- the block size (= the length of the inupt and output vectors) can be
different from 64...according to the setting of a block~ object in the patcher 2) the input and output arrays can point to the same locations.. that means that once you have filled the output array, the input data is lost. I think, there is a switch to have separate arrays, though... must be somewhere with class setup. 3) if you want to grab a fixed amount of 256 samples for some fft stuff you will have to reserve some extra space for fft input and transformed data.
You start with empty fft in and transformed data. In every dsp perform function you copy the signal input to the fft in buffer. The transformed data is still zero, hence the signal output will be zero. At some time the fft in buffer is filled. You can then do the transformation and start copying this output data into the signal output. Your fft input is again empty, so you start filling it again.... Once understood, it isn't difficult.
hope that helps, greetings, Thomas
----- Original Message ----- From: "J. Scott Hildebrand" jshildebrand@ucdavis.edu To: "Frank Barknecht" barknech@ph-cip.uni-koeln.de Cc: pd-list@iem.kug.ac.at Sent: Wednesday, August 21, 2002 11:52 PM Subject: Re: [PD] convolution code error
here's a pd concept i do no understand: first take a look at this
code >>>
t_float lsum = 0.0; t_float rsum = 0.0;
lsum = *in1++; rsum = *in2++; *out1++ = lsum; *out2++ = rsum;
if i have this in my while(n--) loop inside the perform function, then it takes input audio and just sends it back out. it works. i don't understand how the input and output arrays work though. i thought that in and out were actually arrays with 64 samples in each. right here what i'm doing is taking one sample with lsum and rsum, and then i'm spitting the output out, and then doing the while loop again. right? what exactly is happening? and then what do i need to do to collect 256 samples into an array and then use that in my convolution scheme? thanks!
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
"640K ought to be enough for anybody." -- Bill Gates, 1981
does the program loop the perform function over and over again, or
just the while(n--) loop? from what i understand the n-- gets a new block of samples right? does that mean that within my while loop i can have more of n-- and get a new block? thanks,
PD _calls_ the perform function repeatedly, and the data in the input arrays reflects the stream of sample values coming in.
The function gets called, you do your calculation with the data, write the result to the output buffers and _exit_ the perform function. It then gets called again with the next samples of the signal stream.... etc.etc.
Neither does PD interrupt the perform function, nor do several tasks run concurrently.
all the best, Thomas
scott
On Thu, 22 Aug 2002, Thomas Grill wrote:
Hi Scott, i'm not quite sure what the problem is, but a few remarks on these
things:
- the block size (= the length of the inupt and output vectors) can be
different from 64...according to the setting of a block~ object in the patcher 2) the input and output arrays can point to the same locations.. that
means
that once you have filled the output array, the input data is lost. I
think,
there is a switch to have separate arrays, though... must be somewhere
with
class setup. 3) if you want to grab a fixed amount of 256 samples for some fft stuff
you
will have to reserve some extra space for fft input and transformed
data.
You start with empty fft in and transformed data. In every dsp perform function you copy the signal input to the fft in buffer. The transformed data is still zero, hence the signal output will be zero. At some time the fft in buffer is filled. You can then do the
transformation
and start copying this output data into the signal output. Your fft
input is
again empty, so you start filling it again.... Once understood, it isn't difficult.
hope that helps, greetings, Thomas
----- Original Message ----- From: "J. Scott Hildebrand" jshildebrand@ucdavis.edu To: "Frank Barknecht" barknech@ph-cip.uni-koeln.de Cc: pd-list@iem.kug.ac.at Sent: Wednesday, August 21, 2002 11:52 PM Subject: Re: [PD] convolution code error
here's a pd concept i do no understand: first take a look at
this
code >>>
t_float lsum = 0.0; t_float rsum = 0.0;
lsum = *in1++; rsum = *in2++; *out1++ = lsum; *out2++ = rsum;
if i have this in my while(n--) loop inside the perform function,
then
it takes input audio and just sends it back out. it works. i don't understand how the input and output arrays work though. i thought that
in
and out were actually arrays with 64 samples in each. right here what
i'm
doing is taking one sample with lsum and rsum, and then i'm spitting
the
output out, and then doing the while loop again. right? what exactly
is
happening? and then what do i need to do to collect 256 samples into
an
array and then use that in my convolution scheme? thanks!
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
"640K ought to be enough for anybody." -- Bill Gates, 1981
here is what i'm doing. i've tried numerous things, but
nothing has worked. if i can just get 64 samples into my array and then pull them back out, then i'll be able to do the rest. my previous (wrong) logic made me write this code:
int apple = 0;
t_float lsum = 0.0; t_float rsum = 0.0;
while (n--) { aleftout[apple++] = in1[n]; arightout[apple++] = in2[n]; }
apple = 0; while(set--) { lsum = aleftout[apple++]; rsum = arightout[apple++]; *out1++ = lsum; *out2++ = rsum; }
i still get a seg fault!!!! help me!!! please!!! :)
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
Subject: Re: [PD] convolution code error
Date: mer, ago 21, 2002 at 05:49:41 -0700
Quoting J. Scott Hildebrand (jshildebrand@ucdavis.edu):
here is what i'm doing. i've tried numerous things, but
nothing has worked. if i can just get 64 samples into my array and then pull them back out, then i'll be able to do the rest. my previous (wrong) logic made me write this code:
int apple = 0;
t_float lsum = 0.0; t_float rsum = 0.0;
while (n--) { aleftout[apple++] = in1[n]; arightout[apple++] = in2[n]; }
apple = 0; while(set--) { lsum = aleftout[apple++]; rsum = arightout[apple++]; *out1++ = lsum; *out2++ = rsum; }
i still get a seg fault!!!! help me!!! please!!! :)
Here you are increasing apple twice, in both loops. So, for example, instead of
aleftout[apple++] = in1[n]; arightout[apple++] = in2[n];
do
aleftout[apple] = in1[n]; arightout[apple] = in2[n]; apple++;
(change both loops, obviously)
Carlo
in my external i have an in1++ going into an array of samples,
but the weird thing is i get the audio file playing back even though i don't have any out1++ specified in the perform function at all! do i not need an out1++?
scott
"640K ought to be enough for anybody." -- Bill Gates, 1981
Subject: [PD] in my external
Date: gio, ago 22, 2002 at 04:32:58 -0700
Quoting J. Scott Hildebrand (jshildebrand@ucdavis.edu):
in my external i have an in1++ going into an array of samples,
but the weird thing is i get the audio file playing back even though i don't have any out1++ specified in the perform function at all! do i not need an out1++?
Only if you want the outlet of your external to be used as input for other modules. Actually, this is only useful if you modify the signal in any way, so that the modified outlet of your module is the reason for it being there (for example, in the clip~ module).
The audio result is whatever you feed to the appropriate dac~ module(s).
Carlo
if anybody has an IM or ICQ name and wouldn't mind helping people
out (or getting help) from other people on the list, it might speed up productivity. i'm still kinda new at Pd, but i'm learning a lot and fast, so even i could help with some questions.
this list is great but sometimes is a long process to get help on
something simple.
scott
aol IM: klezmer41
"640K ought to be enough for anybody." -- Bill Gates, 1981
On Tue, 20 Aug 2002, J. Scott Hildebrand wrote:
here is the code for my convolution project that i'm working on. i
sent an earlier email to the pdlist, but i don't think it'll go through because it's over 2MB which includes a bin file. anyway i found out where i'm getting the seg fault:
for(set=0; set<=255; set++) { aleftout[set]=(*in1++); /*brings in 256 samples from input*/ arightout[set]=(*in2++); } what i think is happening is that aleftout and arightout are float
arrays, and what i'm trying to pass into them are pointers to floats. everything in my code is happening in the while(n--) part of it, so i think i just need to make some type conversions there. i believe all of the fftr4_ functions take floats, so i need to convert from pointer to float, and then again from float to pointer. thanks in advance to anybody who can help me! i'm just not sure how to do this.
I'm new to this list, and pd, but i know a bit c. Sorry if this is totally unreleated, but is this going to help you?
for(set=0; set<=255; set++)
{
aleftout[set]=*(in1++); /*brings in 256 samples from input*/
arightout[set]=*(in2++);
}
Seems more logical...
On Wed, 21 Aug 2002, Kjetil S. Matheussen wrote:
the fftr4_ functions take floats, so i need to convert from pointer to float, and then again from float to pointer. thanks in advance to anybody who can help me! i'm just not sure how to do this.
I'm new to this list, and pd, but i know a bit c. Sorry if this is totally unreleated, but is this going to help you?
for(set=0; set<=255; set++) { aleftout[set]=*(in1++); /*brings in 256 samples from input*/ arightout[set]=*(in2++); }
Seems more logical...
Ehm. Please ignore that post. ;) I thought of something else.