Changeset bafe71d for src/temporal/resampler.c
- Timestamp:
- Nov 3, 2009, 4:22:39 PM (14 years ago)
- 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:
- 31907fd
- Parents:
- fddfa64
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/temporal/resampler.c
rfddfa64 rbafe71d 23 23 #if HAVE_SAMPLERATE 24 24 25 #include <samplerate.h> /* from libsamplerate */25 #include <samplerate.h> /* from libsamplerate */ 26 26 27 27 #include "aubio_priv.h" … … 29 29 #include "temporal/resampler.h" 30 30 31 struct _aubio_resampler_t { 32 SRC_DATA *proc; 33 SRC_STATE *stat; 34 smpl_t ratio; 35 uint_t type; 31 struct _aubio_resampler_t 32 { 33 SRC_DATA *proc; 34 SRC_STATE *stat; 35 smpl_t ratio; 36 uint_t type; 36 37 }; 37 38 38 aubio_resampler_t * new_aubio_resampler(smpl_t ratio, uint_t type) { 39 aubio_resampler_t * s = AUBIO_NEW(aubio_resampler_t); 40 int error = 0; 41 s->stat = src_new (type, 1, &error) ; /* only one channel */ 42 s->proc = AUBIO_NEW(SRC_DATA); 43 if (error) AUBIO_ERR("%s\n",src_strerror(error)); 44 s->ratio = ratio; 45 return s; 39 aubio_resampler_t * 40 new_aubio_resampler (smpl_t ratio, uint_t type) 41 { 42 aubio_resampler_t *s = AUBIO_NEW (aubio_resampler_t); 43 int error = 0; 44 s->stat = src_new (type, 1, &error); /* only one channel */ 45 s->proc = AUBIO_NEW (SRC_DATA); 46 if (error) 47 AUBIO_ERR ("%s\n", src_strerror (error)); 48 s->ratio = ratio; 49 return s; 46 50 } 47 51 48 void del_aubio_resampler(aubio_resampler_t *s) { 49 src_delete(s->stat); 50 AUBIO_FREE(s->proc); 51 AUBIO_FREE(s); 52 void 53 del_aubio_resampler (aubio_resampler_t * s) 54 { 55 src_delete (s->stat); 56 AUBIO_FREE (s->proc); 57 AUBIO_FREE (s); 52 58 } 53 59 54 void aubio_resampler_do (aubio_resampler_t *s,55 fvec_t * input, fvec_t * output) { 56 uint_t i ; 57 s->proc->input_frames = input->length;58 s->proc->output_frames = output->length;59 s->proc->src_ratio = (double)s->ratio;60 for (i = 0 ; i< input->channels; i++) 61 62 63 s->proc->data_in = (float *)input->data[i];64 s->proc->data_out= (float *)output->data[i];65 66 src_process (s->stat, s->proc);67 68 } 60 void 61 aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output) 62 { 63 uint_t i; 64 s->proc->input_frames = input->length; 65 s->proc->output_frames = output->length; 66 s->proc->src_ratio = (double) s->ratio; 67 for (i = 0; i < input->channels; i++) { 68 /* make SRC_PROC data point to input outputs */ 69 s->proc->data_in = (float *) input->data[i]; 70 s->proc->data_out = (float *) output->data[i]; 71 /* do resampling */ 72 src_process (s->stat, s->proc); 73 } 74 } 69 75 70 76 #endif /* HAVE_SAMPLERATE */
Note: See TracChangeset
for help on using the changeset viewer.