From 95a64c7e8aaaacb64ed5a0c81e8bdd7a0454ce1e Mon Sep 17 00:00:00 2001 From: Amaury Hazan Date: Wed, 12 Sep 2007 19:23:35 +0200 Subject: [PATCH] secondary frequency vectors make a copy of freqs values and are properly freed --- src/filterbank.c | 41 ++++++++++++++++++++--------------------- src/sample.c | 1 + 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/filterbank.c b/src/filterbank.c index a0aa50ed..fdc549ed 100644 --- a/src/filterbank.c +++ b/src/filterbank.c @@ -180,15 +180,12 @@ aubio_filterbank_t * new_aubio_filterbank_mfcc2(uint_t n_filters, uint_t win_s, uint_t allFilters = linearFilters + logFilters; //buffers for computing filter frequencies - fvec_t * freqs=new_fvec( allFilters +2 , 1); + fvec_t * freqs=new_fvec(allFilters+2 , 1); fvec_t * lower_freqs=new_fvec( allFilters, 1); fvec_t * upper_freqs=new_fvec( allFilters, 1); fvec_t * center_freqs=new_fvec( allFilters, 1); - - /*fvec_t * lower_freqs=freqs; - fvec_t * upper_freqs=freqs; - fvec_t * center_freqs=freqs*/; + fvec_t * triangle_heights=new_fvec( allFilters, 1); //lookup table of each bin frequency in hz @@ -196,29 +193,33 @@ aubio_filterbank_t * new_aubio_filterbank_mfcc2(uint_t n_filters, uint_t win_s, uint_t filter_cnt, bin_cnt; - //first: filling all the linear filter frequencies + //first step: filling all the linear filter frequencies for(filter_cnt=0; filter_cntdata[0][filter_cnt]=lowestFrequency+ filter_cnt*linearSpacing; } smpl_t lastlinearCF=freqs->data[0][filter_cnt-1]; - //second: filling all the log filter frequencies + //second step: filling all the log filter frequencies for(filter_cnt=0; filter_cntdata[0][filter_cnt+linearFilters]=lastlinearCF*(pow(logSpacing,filter_cnt+1)); } - - - //make fvec->data point directly to freqs arrays - lower_freqs->data=freqs->data; - center_freqs->data[0]=&(freqs->data[0][1]); - upper_freqs->data[0]=&(freqs->data[0][2]); - + //Option 1. copying interesting values to lower_freqs, center_freqs and upper freqs arrays + //TODO: would be nicer to have a reference to freqs->data, anyway we do not care in this init step + + for(filter_cnt=0; filter_cntdata[0][filter_cnt]=freqs->data[0][filter_cnt]; + center_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt+1]; + upper_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt+2]; + } + + //computing triangle heights so that each triangle has unit area for(filter_cnt=0; filter_cntdata[0][filter_cnt]=2./(upper_freqs->data[0][filter_cnt]-lower_freqs->data[0][filter_cnt]); } - + + //AUBIO_DBG AUBIO_DBG("filter tables frequencies\n"); for(filter_cnt=0; filter_cnt