[Discuss-gnuradio] fft_filter_ccc Output Buffer Size

2017-02-10 Thread Dave NotTelling
I am trying to use the FFT filter in some c++ code and I'm having issues
with seg faulting.  The code below will work, but only because the output
buffer is twice as large as the input buffer.  It doesn't have to be twice
as large, but it does have to be some number larger than the input buffer.
Why is that?  Also, how do I know what the output buffer size should be?

Thank you!!


[code]

#include 
#include 
#include 
#include 

int main(){
// Generate a set of zeroed out taps
std::vector > taps(512, std::complex(0.0f,
0.0f));

// Number of random samples to generate
const int sampleSize = 3;
// Create a vector of 32fc samples.  Don't initialize it to anything,
just let it have
// random data.
gr_complex * input = (gr_complex *)malloc(sizeof(gr_complex) *
sampleSize);

// Place to store the output samples from the FFT
gr_complex * output = (gr_complex *)malloc(sizeof(gr_complex) *
sampleSize);

// Create a filter to run the input samples through
gr::filter::kernel::fft_filter_ccc * filter = new
gr::filter::kernel::fft_filter_ccc(1, taps, 1);

// Filter the input samples
filter->filter(sampleSize, input, output);

// Free up the malloc'd input and output storage
free(input);
free(output);

delete filter;

return 0;
}

[/code]
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] fft_filter_ccc Output Buffer Size

2017-02-10 Thread Dave NotTelling
After some more research it seems that this is an issue of not having an
even multiple of input samples to taps.  For others, here is where I found
the answer: http://www.dspguide.com/ch18/2.htm

On Fri, Feb 10, 2017 at 11:19 AM, Dave NotTelling 
wrote:

> I am trying to use the FFT filter in some c++ code and I'm having issues
> with seg faulting.  The code below will work, but only because the output
> buffer is twice as large as the input buffer.  It doesn't have to be twice
> as large, but it does have to be some number larger than the input buffer.
> Why is that?  Also, how do I know what the output buffer size should be?
>
> Thank you!!
>
>
> [code]
>
> #include 
> #include 
> #include 
> #include 
>
> int main(){
> // Generate a set of zeroed out taps
> std::vector > taps(512, std::complex(0.0f,
> 0.0f));
>
> // Number of random samples to generate
> const int sampleSize = 3;
> // Create a vector of 32fc samples.  Don't initialize it to anything,
> just let it have
> // random data.
> gr_complex * input = (gr_complex *)malloc(sizeof(gr_complex) *
> sampleSize);
>
> // Place to store the output samples from the FFT
> gr_complex * output = (gr_complex *)malloc(sizeof(gr_complex) *
> sampleSize);
>
> // Create a filter to run the input samples through
> gr::filter::kernel::fft_filter_ccc * filter = new
> gr::filter::kernel::fft_filter_ccc(1, taps, 1);
>
> // Filter the input samples
> filter->filter(sampleSize, input, output);
>
> // Free up the malloc'd input and output storage
> free(input);
> free(output);
>
> delete filter;
>
> return 0;
> }
>
> [/code]
>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio