Renamed filterbank to firfilterbank in C-code
This commit is contained in:
parent
195319ab29
commit
9afed2c9a9
@ -17,7 +17,8 @@ add_library(lasp_lib
|
||||
lasp_siggen.c
|
||||
lasp_worker.c
|
||||
lasp_dfifo.c
|
||||
lasp_filterbank.c
|
||||
lasp_firfilterbank.c
|
||||
lasp_sosfilterbank.c
|
||||
# lasp_octave_fir.c
|
||||
lasp_decimation.c
|
||||
lasp_sp_lowpass.c
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Implementation of the decimator
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "lasp_decimation.h"
|
||||
#include "lasp_filterbank.h"
|
||||
#include "lasp_firfilterbank.h"
|
||||
#include "lasp_tracer.h"
|
||||
#include "lasp_alloc.h"
|
||||
#include "lasp_dfifo.h"
|
||||
@ -34,7 +34,7 @@ static __thread DecFilter DecFilters[] = {
|
||||
typedef struct Decimator_s {
|
||||
us nchannels;
|
||||
us dec_fac;
|
||||
FilterBank** fbs;
|
||||
Firfilterbank** fbs;
|
||||
dFifo* output_fifo;
|
||||
} Decimator;
|
||||
|
||||
@ -61,14 +61,14 @@ Decimator* Decimator_create(us nchannels,DEC_FAC df) {
|
||||
|
||||
/* Create the filterbanks */
|
||||
Decimator* dec = a_malloc(sizeof(Decimator));
|
||||
dec->fbs = a_malloc(sizeof(FilterBank*)*nchannels);
|
||||
dec->fbs = a_malloc(sizeof(Firfilterbank*)*nchannels);
|
||||
dec->nchannels = nchannels;
|
||||
dec->dec_fac = filter->dec_fac;
|
||||
|
||||
dmat h = dmat_foreign_data(filter->ntaps,1,filter->h,false);
|
||||
|
||||
for(us channelno=0;channelno<nchannels;channelno++) {
|
||||
dec->fbs[channelno] = FilterBank_create(&h,DEC_FFT_LEN);
|
||||
dec->fbs[channelno] = Firfilterbank_create(&h,DEC_FFT_LEN);
|
||||
}
|
||||
|
||||
dmat_free(&h);
|
||||
@ -128,10 +128,10 @@ dmat Decimator_decimate(Decimator* dec,const dmat* samples) {
|
||||
chan);
|
||||
|
||||
/* Low-pass filter stuff */
|
||||
dmat filtered_res = FilterBank_filter(dec->fbs[chan],
|
||||
dmat filtered_res = Firfilterbank_filter(dec->fbs[chan],
|
||||
&samples_channel);
|
||||
|
||||
dbgassert(filtered_res.n_cols == 1,"Bug in FilterBank");
|
||||
dbgassert(filtered_res.n_cols == 1,"Bug in Firfilterbank");
|
||||
|
||||
vd_free(&samples_channel);
|
||||
|
||||
@ -148,7 +148,7 @@ dmat Decimator_decimate(Decimator* dec,const dmat* samples) {
|
||||
1);
|
||||
|
||||
dbgassert(filtered_res.n_rows == filtered_col.n_rows,
|
||||
"Not all FilterBank's have same output number"
|
||||
"Not all Firfilterbank's have same output number"
|
||||
" of rows!");
|
||||
|
||||
dmat_copy_rows(&filtered_col,
|
||||
@ -209,7 +209,7 @@ void Decimator_free(Decimator* dec) {
|
||||
dFifo_free(dec->output_fifo);
|
||||
|
||||
for(us chan=0;chan<dec->nchannels;chan++) {
|
||||
FilterBank_free(dec->fbs[chan]);
|
||||
Firfilterbank_free(dec->fbs[chan]);
|
||||
}
|
||||
|
||||
a_free(dec->fbs);
|
||||
|
@ -3,17 +3,17 @@
|
||||
// Author: J.A. de Jong -ASCEE
|
||||
//
|
||||
// Description:
|
||||
// FilterBank implementation.
|
||||
// Firfilterbank implementation.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#define TRACERPLUS (-5)
|
||||
#include "lasp_filterbank.h"
|
||||
#include "lasp_firfilterbank.h"
|
||||
#include "lasp_fft.h"
|
||||
#include "lasp_dfifo.h"
|
||||
#include "lasp_tracer.h"
|
||||
#include "lasp_alg.h"
|
||||
#define FIFO_SIZE_MULT 2
|
||||
|
||||
typedef struct FilterBank_s {
|
||||
typedef struct Firfilterbank_s {
|
||||
us nfft;
|
||||
|
||||
us P_m_1; /**< Filter length minus one */
|
||||
@ -25,9 +25,9 @@ typedef struct FilterBank_s {
|
||||
|
||||
Fft* fft; /* Handle to internal FFT-function */
|
||||
|
||||
} FilterBank;
|
||||
} Firfilterbank;
|
||||
|
||||
FilterBank* FilterBank_create(const dmat* h,
|
||||
Firfilterbank* Firfilterbank_create(const dmat* h,
|
||||
const us nfft) {
|
||||
|
||||
fsTRACE(15);
|
||||
@ -46,7 +46,7 @@ FilterBank* FilterBank_create(const dmat* h,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FilterBank* fb = a_malloc(sizeof(FilterBank));
|
||||
Firfilterbank* fb = a_malloc(sizeof(Firfilterbank));
|
||||
|
||||
fb->nfft = nfft;
|
||||
fb->P_m_1 = P-1;
|
||||
@ -77,7 +77,7 @@ FilterBank* FilterBank_create(const dmat* h,
|
||||
feTRACE(15);
|
||||
return fb;
|
||||
}
|
||||
void FilterBank_free(FilterBank* fb) {
|
||||
void Firfilterbank_free(Firfilterbank* fb) {
|
||||
fsTRACE(15);
|
||||
dbgassert(fb,NULLPTRDEREF);
|
||||
cmat_free(&fb->filters);
|
||||
@ -87,7 +87,7 @@ void FilterBank_free(FilterBank* fb) {
|
||||
a_free(fb);
|
||||
feTRACE(15);
|
||||
}
|
||||
dmat FilterBank_filter(FilterBank* fb,
|
||||
dmat Firfilterbank_filter(Firfilterbank* fb,
|
||||
const vd* x) {
|
||||
|
||||
fsTRACE(15);
|
@ -1,8 +1,8 @@
|
||||
// lasp_filterbank.h
|
||||
// lasp_firfilterbank.h
|
||||
//
|
||||
// Author: J.A. de Jong - ASCEE
|
||||
//
|
||||
// Description: Implemententation of a discrete filterbank using fast
|
||||
// Description: Implemententation of a discrete FIR filterbank using fast
|
||||
// convolution and the overlap-save (overlap-scrap method). Multiple
|
||||
// filters can be applied to the same input data (*filterbank*).
|
||||
// Implementation is computationally efficient, as the forward FFT is
|
||||
@ -10,14 +10,14 @@
|
||||
// each filter in the filterbank.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#ifndef LASP_FILTERBANK_H
|
||||
#define LASP_FILTERBANK_H
|
||||
#ifndef LASP_FIRFILTERBANK_H
|
||||
#define LASP_FIRFILTERBANK_H
|
||||
#include "lasp_types.h"
|
||||
#include "lasp_mat.h"
|
||||
typedef struct FilterBank_s FilterBank;
|
||||
typedef struct Firfilterbank_s Firfilterbank;
|
||||
|
||||
/**
|
||||
* Initializes a fast convolution filter bank and returns a FilterBank
|
||||
* Initializes a fast convolution filter bank and returns a Firfilterbank
|
||||
* handle. The nfft will be chosen to be at least four times the
|
||||
* length of the FIR filters.
|
||||
*
|
||||
@ -30,9 +30,9 @@ typedef struct FilterBank_s FilterBank;
|
||||
* times the filter lengths. For the lowest possible latency, it is
|
||||
* better to set nfft at twice the filter length.
|
||||
*
|
||||
* @return FilterBank handle, NULL on error.
|
||||
* @return Firfilterbank handle, NULL on error.
|
||||
*/
|
||||
FilterBank* FilterBank_create(const dmat* h,const us nfft);
|
||||
Firfilterbank* Firfilterbank_create(const dmat* h,const us nfft);
|
||||
|
||||
/**
|
||||
* Filters x using h, returns y
|
||||
@ -44,7 +44,7 @@ FilterBank* FilterBank_create(const dmat* h,const us nfft);
|
||||
* filterbank. The number of output samples is equal to the number of
|
||||
* input samples in x.
|
||||
*/
|
||||
dmat FilterBank_filter(FilterBank* fb,
|
||||
dmat Firfilterbank_filter(Firfilterbank* fb,
|
||||
const vd* x);
|
||||
|
||||
/**
|
||||
@ -52,8 +52,8 @@ dmat FilterBank_filter(FilterBank* fb,
|
||||
*
|
||||
* @param f Filter handle
|
||||
*/
|
||||
void FilterBank_free(FilterBank* f);
|
||||
void Firfilterbank_free(Firfilterbank* f);
|
||||
|
||||
|
||||
#endif // LASP_FILTERBANK_H
|
||||
#endif // LASP_FIRFILTERBANK_H
|
||||
//////////////////////////////////////////////////////////////////////
|
@ -6,6 +6,7 @@
|
||||
// Signal generator implementation
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#define TRACERPLUS (-5)
|
||||
#include "lasp_siggen.h"
|
||||
#include "lasp_alloc.h"
|
||||
#include "lasp_assert.h"
|
||||
#include "lasp_mat.h"
|
||||
@ -19,7 +20,7 @@ typedef enum {
|
||||
|
||||
} SignalType;
|
||||
|
||||
typedef struct {
|
||||
typedef struct Siggen {
|
||||
SignalType signaltype;
|
||||
d fs; // Sampling frequency [Hz]
|
||||
d level_amp;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define LASP_SIGGEN_H
|
||||
#include "lasp_mat.h"
|
||||
|
||||
typedef struct {} Siggen;
|
||||
typedef struct Siggen Siggen;
|
||||
|
||||
/**
|
||||
* Create a sine wave signal generator
|
||||
@ -54,5 +54,5 @@ void Siggen_genSignal(Siggen*,vd* samples);
|
||||
*/
|
||||
void Siggen_free(Siggen*);
|
||||
|
||||
#endif LASP_SIGGEN_H
|
||||
#endif //LASP_SIGGEN_H
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
from .freqweighting_fir import A, C
|
||||
from .bandpass_fir import OctaveBankDesigner, ThirdOctaveBankDesigner
|
||||
from .bandpass_limits import octave_band_limits, third_octave_band_limits
|
||||
|
||||
__all__ = ['A', 'Z']
|
||||
|
@ -349,30 +349,30 @@ cdef class AvPowerSpectra:
|
||||
|
||||
return result
|
||||
|
||||
cdef extern from "lasp_filterbank.h":
|
||||
ctypedef struct c_FilterBank "FilterBank"
|
||||
c_FilterBank* FilterBank_create(const dmat* h,const us nfft) nogil
|
||||
dmat FilterBank_filter(c_FilterBank* fb,const vd* x) nogil
|
||||
void FilterBank_free(c_FilterBank* fb) nogil
|
||||
cdef extern from "lasp_firfilterbank.h":
|
||||
ctypedef struct c_Firfilterbank "Firfilterbank"
|
||||
c_Firfilterbank* Firfilterbank_create(const dmat* h,const us nfft) nogil
|
||||
dmat Firfilterbank_filter(c_Firfilterbank* fb,const vd* x) nogil
|
||||
void Firfilterbank_free(c_Firfilterbank* fb) nogil
|
||||
|
||||
|
||||
cdef class FilterBank:
|
||||
cdef:
|
||||
c_FilterBank* fb
|
||||
c_Firfilterbank* fb
|
||||
def __cinit__(self,d[::1,:] h, us nfft):
|
||||
cdef dmat hmat = dmat_foreign_data(h.shape[0],
|
||||
h.shape[1],
|
||||
&h[0,0],
|
||||
False)
|
||||
|
||||
self.fb = FilterBank_create(&hmat,nfft)
|
||||
self.fb = Firfilterbank_create(&hmat,nfft)
|
||||
dmat_free(&hmat)
|
||||
if not self.fb:
|
||||
raise RuntimeError('Error creating FilberBank')
|
||||
|
||||
def __dealloc__(self):
|
||||
if self.fb:
|
||||
FilterBank_free(self.fb)
|
||||
Firfilterbank_free(self.fb)
|
||||
|
||||
def filter_(self,d[::1, :] input_):
|
||||
assert input_.shape[1] == 1
|
||||
@ -382,7 +382,7 @@ cdef class FilterBank:
|
||||
|
||||
cdef dmat output
|
||||
with nogil:
|
||||
output = FilterBank_filter(self.fb,&input_vd)
|
||||
output = Firfilterbank_filter(self.fb,&input_vd)
|
||||
|
||||
# Steal the pointer from output
|
||||
result = dmat_to_ndarray(&output,True)
|
||||
|
Loading…
Reference in New Issue
Block a user