Changeset 95a64c7


Ignore:
Timestamp:
Sep 12, 2007, 7:23:35 PM (17 years ago)
Author:
Amaury Hazan <mahmoudax@gmail.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
bc4ba75
Parents:
787f1f3
Message:

secondary frequency vectors make a copy of freqs values and are properly freed

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/filterbank.c

    r787f1f3 r95a64c7  
    181181 
    182182  //buffers for computing filter frequencies
    183   fvec_t * freqs=new_fvec( allFilters +2 , 1);
     183  fvec_t * freqs=new_fvec(allFilters+2 , 1);
    184184 
    185185  fvec_t * lower_freqs=new_fvec( allFilters, 1);
    186186  fvec_t * upper_freqs=new_fvec( allFilters, 1);
    187187  fvec_t * center_freqs=new_fvec( allFilters, 1);
    188      
    189   /*fvec_t * lower_freqs=freqs;
    190   fvec_t * upper_freqs=freqs;
    191   fvec_t * center_freqs=freqs*/;
     188
    192189 
    193190  fvec_t * triangle_heights=new_fvec( allFilters, 1);
     
    197194  uint_t filter_cnt, bin_cnt;
    198195 
    199   //first: filling all the linear filter frequencies
     196  //first step: filling all the linear filter frequencies
    200197  for(filter_cnt=0; filter_cnt<linearFilters; filter_cnt++){
    201198    freqs->data[0][filter_cnt]=lowestFrequency+ filter_cnt*linearSpacing;
     
    203200  smpl_t lastlinearCF=freqs->data[0][filter_cnt-1];
    204201 
    205   //second: filling all the log filter frequencies
     202  //second step: filling all the log filter frequencies
    206203  for(filter_cnt=0; filter_cnt<logFilters+2; filter_cnt++){
    207204    freqs->data[0][filter_cnt+linearFilters]=lastlinearCF*(pow(logSpacing,filter_cnt+1));
    208205  }
    209  
    210  
    211   //make fvec->data point directly to freqs arrays
    212   lower_freqs->data=freqs->data;
    213   center_freqs->data[0]=&(freqs->data[0][1]);
    214   upper_freqs->data[0]=&(freqs->data[0][2]);
    215 
    216  
     206
     207  //Option 1. copying interesting values to lower_freqs, center_freqs and upper freqs arrays
     208  //TODO: would be nicer to have a reference to freqs->data, anyway we do not care in this init step
     209   
     210  for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++){
     211    lower_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt];
     212    center_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt+1];
     213    upper_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt+2];
     214  }
     215
     216
    217217  //computing triangle heights so that each triangle has unit area
    218218  for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++){
    219219    triangle_heights->data[0][filter_cnt]=2./(upper_freqs->data[0][filter_cnt]-lower_freqs->data[0][filter_cnt]);
    220220  }
    221 
     221 
     222 
    222223  //AUBIO_DBG
    223224  AUBIO_DBG("filter tables frequencies\n");
     
    300301 
    301302 
     303
    302304  del_fvec(freqs);
    303   //TODO: Check how to do a proper free for the following f_vec
    304 
    305   //del_fvec(lower_freqs);
    306   //del_fvec(upper_freqs);
    307   //del_fvec(center_freqs);
     305  del_fvec(lower_freqs);
     306  del_fvec(upper_freqs);
     307  del_fvec(center_freqs);
     308
    308309  del_fvec(triangle_heights);
    309310  del_fvec(fft_freqs);
    310 
    311  
    312311
    313312  return fb;
  • src/sample.c

    r787f1f3 r95a64c7  
    2020#include "aubio_priv.h"
    2121#include "sample.h"
     22
    2223
    2324fvec_t * new_fvec( uint_t length, uint_t channels) {
Note: See TracChangeset for help on using the changeset viewer.