- Timestamp:
- Jun 22, 2016, 1:00:10 PM (9 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:
- 4b9443c4
- Parents:
- 60fc05b (diff), 6769586 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 1 added
- 90 edited
Legend:
- Unmodified
- Added
- Removed
-
src/aubio_priv.h
r60fc05b rf264b17 25 25 */ 26 26 27 #ifndef _AUBIO__PRIV_H28 #define _AUBIO__PRIV_H27 #ifndef AUBIO_PRIV_H 28 #define AUBIO_PRIV_H 29 29 30 30 /********************* … … 36 36 #include "config.h" 37 37 38 #if HAVE_STDLIB_H38 #ifdef HAVE_STDLIB_H 39 39 #include <stdlib.h> 40 40 #endif 41 41 42 #if HAVE_STDIO_H42 #ifdef HAVE_STDIO_H 43 43 #include <stdio.h> 44 44 #endif … … 63 63 #ifdef HAVE_LIMITS_H 64 64 #include <limits.h> // for CHAR_BIT, in C99 standard 65 #endif 66 67 #ifdef HAVE_ACCELERATE 68 #define HAVE_ATLAS 1 69 #include <Accelerate/Accelerate.h> 70 #elif defined(HAVE_ATLAS_CBLAS_H) 71 #define HAVE_ATLAS 1 72 #include <atlas/cblas.h> 73 #else 74 #undef HAVE_ATLAS 75 #endif 76 77 #ifdef HAVE_ACCELERATE 78 #include <Accelerate/Accelerate.h> 79 #ifndef HAVE_AUBIO_DOUBLE 80 #define aubio_vDSP_mmov vDSP_mmov 81 #define aubio_vDSP_vmul vDSP_vmul 82 #define aubio_vDSP_vfill vDSP_vfill 83 #define aubio_vDSP_meanv vDSP_meanv 84 #define aubio_vDSP_sve vDSP_sve 85 #define aubio_vDSP_maxv vDSP_maxv 86 #define aubio_vDSP_maxvi vDSP_maxvi 87 #define aubio_vDSP_minv vDSP_minv 88 #define aubio_vDSP_minvi vDSP_minvi 89 #define aubio_vDSP_dotpr vDSP_dotpr 90 #else /* HAVE_AUBIO_DOUBLE */ 91 #define aubio_vDSP_mmov vDSP_mmovD 92 #define aubio_vDSP_vmul vDSP_vmulD 93 #define aubio_vDSP_vfill vDSP_vfillD 94 #define aubio_vDSP_meanv vDSP_meanvD 95 #define aubio_vDSP_sve vDSP_sveD 96 #define aubio_vDSP_maxv vDSP_maxvD 97 #define aubio_vDSP_maxvi vDSP_maxviD 98 #define aubio_vDSP_minv vDSP_minvD 99 #define aubio_vDSP_minvi vDSP_minviD 100 #define aubio_vDSP_dotpr vDSP_dotprD 101 #endif /* HAVE_AUBIO_DOUBLE */ 102 #endif /* HAVE_ACCELERATE */ 103 104 #ifdef HAVE_ATLAS 105 #ifndef HAVE_AUBIO_DOUBLE 106 #define aubio_catlas_set catlas_sset 107 #define aubio_cblas_copy cblas_scopy 108 #define aubio_cblas_swap cblas_sswap 109 #define aubio_cblas_dot cblas_sdot 110 #else /* HAVE_AUBIO_DOUBLE */ 111 #define aubio_catlas_set catlas_dset 112 #define aubio_cblas_copy cblas_dcopy 113 #define aubio_cblas_swap cblas_dswap 114 #define aubio_cblas_dot cblas_ddot 115 #endif /* HAVE_AUBIO_DOUBLE */ 116 #endif /* HAVE_ATLAS */ 117 118 #if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) 119 #define HAVE_NOOPT 1 120 #else 121 #undef HAVE_NOOPT 65 122 #endif 66 123 … … 136 193 #endif 137 194 #define TWO_PI (PI*2.) 195 196 #ifndef PATH_MAX 197 #define PATH_MAX 1024 198 #endif 138 199 139 200 /* aliases to math.h functions */ … … 194 255 #endif 195 256 257 /* avoid unresolved symbol with msvc 9 */ 258 #if defined(_MSC_VER) && (_MSC_VER < 1900) 259 #define isnan _isnan 260 #endif 261 196 262 /* handy shortcuts */ 197 263 #define DB2LIN(g) (POW(10.0,(g)*0.05f)) … … 229 295 #endif 230 296 231 #endif /* _AUBIO__PRIV_H */ 297 /* are we using gcc -std=c99 ? */ 298 #if defined(__STRICT_ANSI__) 299 #define strnlen(a,b) MIN(strlen(a),b) 300 #if !HAVE_AUBIO_DOUBLE 301 #define floorf floor 302 #endif 303 #endif /* __STRICT_ANSI__ */ 304 305 #endif /* AUBIO_PRIV_H */ -
src/cvec.c
r60fc05b rf264b17 22 22 #include "cvec.h" 23 23 24 cvec_t * new_cvec( 24 cvec_t * new_cvec(uint_t length) { 25 25 cvec_t * s; 26 26 if ((sint_t)length <= 0) { … … 56 56 } 57 57 58 smpl_t * cvec_norm_get_data (c vec_t *s) {58 smpl_t * cvec_norm_get_data (const cvec_t *s) { 59 59 return s->norm; 60 60 } 61 61 62 smpl_t * cvec_phas_get_data (c vec_t *s) {62 smpl_t * cvec_phas_get_data (const cvec_t *s) { 63 63 return s->phas; 64 64 } … … 66 66 /* helper functions */ 67 67 68 void cvec_print(c vec_t *s) {68 void cvec_print(const cvec_t *s) { 69 69 uint_t j; 70 70 AUBIO_MSG("norm: "); … … 80 80 } 81 81 82 void cvec_copy(c vec_t *s, cvec_t *t) {82 void cvec_copy(const cvec_t *s, cvec_t *t) { 83 83 if (s->length != t->length) { 84 84 AUBIO_ERR("trying to copy %d elements to %d elements \n", … … 86 86 return; 87 87 } 88 #if HAVE_MEMCPY_HACKS88 #ifdef HAVE_MEMCPY_HACKS 89 89 memcpy(t->norm, s->norm, t->length * sizeof(smpl_t)); 90 90 memcpy(t->phas, s->phas, t->length * sizeof(smpl_t)); 91 #else 91 #else /* HAVE_MEMCPY_HACKS */ 92 92 uint_t j; 93 93 for (j=0; j< t->length; j++) { … … 95 95 t->phas[j] = s->phas[j]; 96 96 } 97 #endif 97 #endif /* HAVE_MEMCPY_HACKS */ 98 98 } 99 99 … … 106 106 107 107 void cvec_norm_zeros(cvec_t *s) { 108 #if HAVE_MEMCPY_HACKS108 #ifdef HAVE_MEMCPY_HACKS 109 109 memset(s->norm, 0, s->length * sizeof(smpl_t)); 110 #else 110 #else /* HAVE_MEMCPY_HACKS */ 111 111 cvec_norm_set_all (s, 0.); 112 #endif 112 #endif /* HAVE_MEMCPY_HACKS */ 113 113 } 114 114 … … 125 125 126 126 void cvec_phas_zeros(cvec_t *s) { 127 #if HAVE_MEMCPY_HACKS127 #ifdef HAVE_MEMCPY_HACKS 128 128 memset(s->phas, 0, s->length * sizeof(smpl_t)); 129 129 #else -
src/cvec.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO__CVEC_H22 #define _AUBIO__CVEC_H21 #ifndef AUBIO_CVEC_H 22 #define AUBIO_CVEC_H 23 23 24 24 #ifdef __cplusplus … … 151 151 152 152 */ 153 smpl_t * cvec_norm_get_data (c vec_t *s);153 smpl_t * cvec_norm_get_data (const cvec_t *s); 154 154 155 155 /** read phase data from a complex buffer … … 163 163 164 164 */ 165 smpl_t * cvec_phas_get_data (c vec_t *s);165 smpl_t * cvec_phas_get_data (const cvec_t *s); 166 166 167 167 /** print out cvec data … … 170 170 171 171 */ 172 void cvec_print(c vec_t *s);172 void cvec_print(const cvec_t *s); 173 173 174 174 /** make a copy of a vector … … 178 178 179 179 */ 180 void cvec_copy(c vec_t *s, cvec_t *t);180 void cvec_copy(const cvec_t *s, cvec_t *t); 181 181 182 182 /** set all norm elements to a given value … … 235 235 #endif 236 236 237 #endif /* _AUBIO__CVEC_H */237 #endif /* AUBIO_CVEC_H */ -
src/fmat.c
r60fc05b rf264b17 54 54 } 55 55 56 smpl_t fmat_get_sample( fmat_t *s, uint_t channel, uint_t position) {56 smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position) { 57 57 return s->data[channel][position]; 58 58 } 59 59 60 void fmat_get_channel( fmat_t *s, uint_t channel, fvec_t *output) {60 void fmat_get_channel(const fmat_t *s, uint_t channel, fvec_t *output) { 61 61 output->data = s->data[channel]; 62 62 output->length = s->length; … … 64 64 } 65 65 66 smpl_t * fmat_get_channel_data( fmat_t *s, uint_t channel) {66 smpl_t * fmat_get_channel_data(const fmat_t *s, uint_t channel) { 67 67 return s->data[channel]; 68 68 } 69 69 70 smpl_t ** fmat_get_data( fmat_t *s) {70 smpl_t ** fmat_get_data(const fmat_t *s) { 71 71 return s->data; 72 72 } … … 74 74 /* helper functions */ 75 75 76 void fmat_print( fmat_t *s) {76 void fmat_print(const fmat_t *s) { 77 77 uint_t i,j; 78 78 for (i=0; i< s->height; i++) { … … 94 94 95 95 void fmat_zeros(fmat_t *s) { 96 #if HAVE_MEMCPY_HACKS96 #ifdef HAVE_MEMCPY_HACKS 97 97 uint_t i; 98 98 for (i=0; i< s->height; i++) { 99 99 memset(s->data[i], 0, s->length * sizeof(smpl_t)); 100 100 } 101 #else 101 #else /* HAVE_MEMCPY_HACKS */ 102 102 fmat_set(s, 0.); 103 #endif 103 #endif /* HAVE_MEMCPY_HACKS */ 104 104 } 105 105 … … 117 117 } 118 118 119 void fmat_weight(fmat_t *s, fmat_t *weight) {119 void fmat_weight(fmat_t *s, const fmat_t *weight) { 120 120 uint_t i,j; 121 121 uint_t length = MIN(s->length, weight->length); … … 127 127 } 128 128 129 void fmat_copy( fmat_t *s, fmat_t *t) {129 void fmat_copy(const fmat_t *s, fmat_t *t) { 130 130 uint_t i; 131 #if !HAVE_MEMCPY_HACKS131 #ifndef HAVE_MEMCPY_HACKS 132 132 uint_t j; 133 #endif 133 #endif /* HAVE_MEMCPY_HACKS */ 134 134 if (s->height != t->height) { 135 135 AUBIO_ERR("trying to copy %d rows to %d rows \n", … … 142 142 return; 143 143 } 144 #if HAVE_MEMCPY_HACKS144 #ifdef HAVE_MEMCPY_HACKS 145 145 for (i=0; i< s->height; i++) { 146 146 memcpy(t->data[i], s->data[i], t->length * sizeof(smpl_t)); 147 147 } 148 #else 148 #else /* HAVE_MEMCPY_HACKS */ 149 149 for (i=0; i< t->height; i++) { 150 150 for (j=0; j< t->length; j++) { … … 152 152 } 153 153 } 154 #endif /* HAVE_MEMCPY_HACKS */ 155 } 156 157 void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output) { 158 uint_t k; 159 #if 0 160 assert(s->height == output->length); 161 assert(s->length == scale->length); 162 #endif 163 #if !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) 164 uint_t j; 165 fvec_zeros(output); 166 for (j = 0; j < s->length; j++) { 167 for (k = 0; k < s->height; k++) { 168 output->data[k] += scale->data[j] 169 * s->data[k][j]; 170 } 171 } 172 #elif defined(HAVE_ATLAS) 173 for (k = 0; k < s->height; k++) { 174 output->data[k] = aubio_cblas_dot( s->length, scale->data, 1, s->data[k], 1); 175 } 176 #elif defined(HAVE_ACCELERATE) 177 #if 0 178 // seems slower and less precise (and dangerous?) 179 vDSP_mmul (s->data[0], 1, scale->data, 1, output->data, 1, s->height, 1, s->length); 180 #else 181 for (k = 0; k < s->height; k++) { 182 aubio_vDSP_dotpr( scale->data, 1, s->data[k], 1, &(output->data[k]), s->length); 183 } 184 #endif 154 185 #endif 155 186 } 156 -
src/fmat.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO__FMAT_H22 #define _AUBIO__FMAT_H21 #ifndef AUBIO_FMAT_H 22 #define AUBIO_FMAT_H 23 23 24 24 #ifdef __cplusplus … … 66 66 67 67 */ 68 smpl_t fmat_get_sample( fmat_t *s, uint_t channel, uint_t position);68 smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position); 69 69 70 70 /** write sample value in a buffer … … 85 85 86 86 */ 87 void fmat_get_channel ( fmat_t *s, uint_t channel, fvec_t *output);87 void fmat_get_channel (const fmat_t *s, uint_t channel, fvec_t *output); 88 88 89 89 /** get vector buffer from an fmat data … … 93 93 94 94 */ 95 smpl_t * fmat_get_channel_data ( fmat_t *s, uint_t channel);95 smpl_t * fmat_get_channel_data (const fmat_t *s, uint_t channel); 96 96 97 97 /** read data from a buffer … … 100 100 101 101 */ 102 smpl_t ** fmat_get_data( fmat_t *s);102 smpl_t ** fmat_get_data(const fmat_t *s); 103 103 104 104 /** print out fmat data … … 107 107 108 108 */ 109 void fmat_print( fmat_t *s);109 void fmat_print(const fmat_t *s); 110 110 111 111 /** set all elements to a given value … … 147 147 148 148 */ 149 void fmat_weight(fmat_t *s, fmat_t *weight);149 void fmat_weight(fmat_t *s, const fmat_t *weight); 150 150 151 151 /** make a copy of a matrix … … 155 155 156 156 */ 157 void fmat_copy(fmat_t *s, fmat_t *t); 157 void fmat_copy(const fmat_t *s, fmat_t *t); 158 159 /* compute the product of a matrix by a vector 160 161 \param s matrix to compute product with 162 \param scale vector to compute product with 163 \param output vector to store restults in 164 165 */ 166 void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output); 158 167 159 168 #ifdef __cplusplus … … 161 170 #endif 162 171 163 #endif /* _AUBIO__FMAT_H */172 #endif /* AUBIO_FMAT_H */ -
src/fvec.c
r60fc05b rf264b17 22 22 #include "fvec.h" 23 23 24 #ifdef HAVE_ACCELERATE 25 #include <Accelerate/Accelerate.h> 26 #if !HAVE_AUBIO_DOUBLE 27 #define aubio_vDSP_mmov vDSP_mmov 28 #define aubio_vDSP_vmul vDSP_vmul 29 #define aubio_vDSP_vfill vDSP_vfill 30 #else /* HAVE_AUBIO_DOUBLE */ 31 #define aubio_vDSP_mmov vDSP_mmovD 32 #define aubio_vDSP_vmul vDSP_vmulD 33 #define aubio_vDSP_vfill vDSP_vfillD 34 #endif /* HAVE_AUBIO_DOUBLE */ 35 #endif 36 37 fvec_t * new_fvec( uint_t length) { 24 fvec_t * new_fvec(uint_t length) { 38 25 fvec_t * s; 39 26 if ((sint_t)length <= 0) { … … 55 42 } 56 43 57 smpl_t fvec_get_sample( fvec_t *s, uint_t position) {44 smpl_t fvec_get_sample(const fvec_t *s, uint_t position) { 58 45 return s->data[position]; 59 46 } 60 47 61 smpl_t * fvec_get_data( fvec_t *s) {48 smpl_t * fvec_get_data(const fvec_t *s) { 62 49 return s->data; 63 50 } … … 65 52 /* helper functions */ 66 53 67 void fvec_print( fvec_t *s) {54 void fvec_print(const fvec_t *s) { 68 55 uint_t j; 69 56 for (j=0; j< s->length; j++) { … … 74 61 75 62 void fvec_set_all (fvec_t *s, smpl_t val) { 76 #if ndef HAVE_ACCELERATE63 #if !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) 77 64 uint_t j; 78 65 for (j=0; j< s->length; j++) { 79 66 s->data[j] = val; 80 67 } 81 #else 68 #elif defined(HAVE_ATLAS) 69 aubio_catlas_set(s->length, val, s->data, 1); 70 #elif defined(HAVE_ACCELERATE) 82 71 aubio_vDSP_vfill(&val, s->data, 1, s->length); 83 72 #endif … … 107 96 } 108 97 109 void fvec_weight(fvec_t *s, fvec_t *weight) {98 void fvec_weight(fvec_t *s, const fvec_t *weight) { 110 99 #ifndef HAVE_ACCELERATE 111 100 uint_t j; … … 119 108 } 120 109 121 void fvec_copy(fvec_t *s, fvec_t *t) { 110 void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out) { 111 #ifndef HAVE_ACCELERATE 112 uint_t j; 113 uint_t length = MIN(out->length, weight->length); 114 for (j=0; j< length; j++) { 115 out->data[j] = in->data[j] * weight->data[j]; 116 } 117 #else 118 aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, out->length); 119 #endif /* HAVE_ACCELERATE */ 120 } 121 122 void fvec_copy(const fvec_t *s, fvec_t *t) { 122 123 if (s->length != t->length) { 123 124 AUBIO_ERR("trying to copy %d elements to %d elements \n", … … 125 126 return; 126 127 } 127 #if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE)128 #ifdef HAVE_NOOPT 128 129 uint_t j; 129 130 for (j=0; j< t->length; j++) { 130 131 t->data[j] = s->data[j]; 131 132 } 132 #else 133 #if defined(HAVE_MEMCPY_HACKS) 133 #elif defined(HAVE_MEMCPY_HACKS) 134 134 memcpy(t->data, s->data, t->length * sizeof(smpl_t)); 135 #else 135 #elif defined(HAVE_ATLAS) 136 aubio_cblas_copy(s->length, s->data, 1, t->data, 1); 137 #elif defined(HAVE_ACCELERATE) 136 138 aubio_vDSP_mmov(s->data, t->data, 1, s->length, 1, 1); 137 139 #endif 138 #endif139 140 } -
src/fvec.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO__FVEC_H22 #define _AUBIO__FVEC_H21 #ifndef AUBIO_FVEC_H 22 #define AUBIO_FVEC_H 23 23 24 24 #ifdef __cplusplus … … 90 90 91 91 */ 92 smpl_t fvec_get_sample( fvec_t *s, uint_t position);92 smpl_t fvec_get_sample(const fvec_t *s, uint_t position); 93 93 94 94 /** write sample value in a buffer … … 106 106 107 107 */ 108 smpl_t * fvec_get_data( fvec_t *s);108 smpl_t * fvec_get_data(const fvec_t *s); 109 109 110 110 /** print out fvec data … … 113 113 114 114 */ 115 void fvec_print( fvec_t *s);115 void fvec_print(const fvec_t *s); 116 116 117 117 /** set all elements to a given value … … 153 153 154 154 */ 155 void fvec_weight(fvec_t *s, fvec_t *weight);155 void fvec_weight(fvec_t *s, const fvec_t *weight); 156 156 157 157 /** make a copy of a vector … … 161 161 162 162 */ 163 void fvec_copy(fvec_t *s, fvec_t *t); 163 void fvec_copy(const fvec_t *s, fvec_t *t); 164 165 /** make a copy of a vector, applying weights to each element 166 167 \param in input vector 168 \param weight weights vector 169 \param out output vector 170 171 */ 172 void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out); 164 173 165 174 #ifdef __cplusplus … … 167 176 #endif 168 177 169 #endif /* _AUBIO__FVEC_H */178 #endif /* AUBIO_FVEC_H */ -
src/io/audio_unit.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_AUDIO_UNIT_H22 #define _AUBIO_AUDIO_UNIT_H21 #ifndef AUBIO_AUDIO_UNIT_H 22 #define AUBIO_AUDIO_UNIT_H 23 23 24 24 /** \file … … 59 59 #endif 60 60 61 #endif /* _AUBIO_AUDIO_UNIT_H */61 #endif /* AUBIO_AUDIO_UNIT_H */ -
src/io/sink.c
r60fc05b rf264b17 55 55 }; 56 56 57 aubio_sink_t * new_aubio_sink(c har_t * uri, uint_t samplerate) {57 aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) { 58 58 aubio_sink_t * s = AUBIO_NEW(aubio_sink_t); 59 59 #ifdef HAVE_SINK_APPLE_AUDIO … … 71 71 } 72 72 #endif /* HAVE_SINK_APPLE_AUDIO */ 73 #if HAVE_SNDFILE73 #ifdef HAVE_SNDFILE 74 74 s->sink = (void *)new_aubio_sink_sndfile(uri, samplerate); 75 75 if (s->sink) { … … 85 85 } 86 86 #endif /* HAVE_SNDFILE */ 87 #if HAVE_WAVWRITE87 #ifdef HAVE_WAVWRITE 88 88 s->sink = (void *)new_aubio_sink_wavwrite(uri, samplerate); 89 89 if (s->sink) { … … 121 121 } 122 122 123 uint_t aubio_sink_get_samplerate( aubio_sink_t * s) {123 uint_t aubio_sink_get_samplerate(const aubio_sink_t * s) { 124 124 return s->s_get_samplerate((void *)s->sink); 125 125 } 126 126 127 uint_t aubio_sink_get_channels( aubio_sink_t * s) {127 uint_t aubio_sink_get_channels(const aubio_sink_t * s) { 128 128 return s->s_get_channels((void *)s->sink); 129 129 } -
src/io/sink.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SINK_H22 #define _AUBIO_SINK_H21 #ifndef AUBIO_SINK_H 22 #define AUBIO_SINK_H 23 23 24 24 /** \file … … 77 77 78 78 */ 79 aubio_sink_t * new_aubio_sink(c har_t * uri, uint_t samplerate);79 aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate); 80 80 81 81 /** … … 121 121 122 122 */ 123 uint_t aubio_sink_get_samplerate( aubio_sink_t *s);123 uint_t aubio_sink_get_samplerate(const aubio_sink_t *s); 124 124 125 125 /** … … 131 131 132 132 */ 133 uint_t aubio_sink_get_channels( aubio_sink_t *s);133 uint_t aubio_sink_get_channels(const aubio_sink_t *s); 134 134 135 135 /** … … 179 179 #endif 180 180 181 #endif /* _AUBIO_SINK_H */181 #endif /* AUBIO_SINK_H */ -
src/io/sink_apple_audio.c
r60fc05b rf264b17 37 37 extern int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize); 38 38 extern void freeAudioBufferList(AudioBufferList *bufferList); 39 extern CFURLRef getURLFromPath(const char * path);39 extern CFURLRef createURLFromPath(const char * path); 40 40 char_t *getPrintableOSStatusError(char_t *str, OSStatus error); 41 41 … … 43 43 44 44 #define MAX_SIZE 4096 // the maximum number of frames that can be written at a time 45 46 void aubio_sink_apple_audio_write(aubio_sink_apple_audio_t *s, uint_t write); 45 47 46 48 struct _aubio_sink_apple_audio_t { … … 56 58 }; 57 59 58 aubio_sink_apple_audio_t * new_aubio_sink_apple_audio(c har_t * uri, uint_t samplerate) {60 aubio_sink_apple_audio_t * new_aubio_sink_apple_audio(const char_t * uri, uint_t samplerate) { 59 61 aubio_sink_apple_audio_t * s = AUBIO_NEW(aubio_sink_apple_audio_t); 60 s->path = uri;61 62 s->max_frames = MAX_SIZE; 62 s->async = true;63 s->async = false; 63 64 64 65 if (uri == NULL) { … … 66 67 goto beach; 67 68 } 69 if (s->path != NULL) AUBIO_FREE(s->path); 70 s->path = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX) + 1); 71 strncpy(s->path, uri, strnlen(uri, PATH_MAX) + 1); 68 72 69 73 s->samplerate = 0; … … 111 115 } 112 116 113 uint_t aubio_sink_apple_audio_get_samplerate( aubio_sink_apple_audio_t *s)117 uint_t aubio_sink_apple_audio_get_samplerate(const aubio_sink_apple_audio_t *s) 114 118 { 115 119 return s->samplerate; 116 120 } 117 121 118 uint_t aubio_sink_apple_audio_get_channels( aubio_sink_apple_audio_t *s)122 uint_t aubio_sink_apple_audio_get_channels(const aubio_sink_apple_audio_t *s) 119 123 { 120 124 return s->channels; … … 138 142 139 143 AudioFileTypeID fileType = kAudioFileWAVEType; 140 CFURLRef fileURL = getURLFromPath(s->path);144 CFURLRef fileURL = createURLFromPath(s->path); 141 145 bool overwrite = true; 142 146 OSStatus err = noErr; 143 147 err = ExtAudioFileCreateWithURL(fileURL, fileType, &clientFormat, NULL, 144 148 overwrite ? kAudioFileFlags_EraseFile : 0, &s->audioFile); 149 CFRelease(fileURL); 145 150 if (err) { 146 151 char_t errorstr[20]; … … 162 167 163 168 void aubio_sink_apple_audio_do(aubio_sink_apple_audio_t * s, fvec_t * write_data, uint_t write) { 164 OSStatus err = noErr;165 169 UInt32 c, v; 166 170 short *data = (short*)s->bufferList.mBuffers[0].mData; … … 179 183 } 180 184 } 181 if (s->async) { 182 err = ExtAudioFileWriteAsync(s->audioFile, write, &s->bufferList); 183 184 if (err) { 185 char_t errorstr[20]; 186 AUBIO_ERROR("sink_apple_audio: error while writing %s " 187 "in ExtAudioFileWriteAsync (%s), switching to sync\n", s->path, 188 getPrintableOSStatusError(errorstr, err)); 189 s->async = false; 190 } else { 191 return; 192 } 193 194 } else { 195 err = ExtAudioFileWrite(s->audioFile, write, &s->bufferList); 196 197 if (err) { 198 char_t errorstr[20]; 199 AUBIO_ERROR("sink_apple_audio: error while writing %s " 200 "in ExtAudioFileWrite (%s)\n", s->path, 201 getPrintableOSStatusError(errorstr, err)); 202 } 203 } 204 return; 185 aubio_sink_apple_audio_write(s, write); 205 186 } 206 187 207 188 void aubio_sink_apple_audio_do_multi(aubio_sink_apple_audio_t * s, fmat_t * write_data, uint_t write) { 208 OSStatus err = noErr;209 189 UInt32 c, v; 210 190 short *data = (short*)s->bufferList.mBuffers[0].mData; … … 223 203 } 224 204 } 205 aubio_sink_apple_audio_write(s, write); 206 } 207 208 void aubio_sink_apple_audio_write(aubio_sink_apple_audio_t *s, uint_t write) { 209 OSStatus err = noErr; 225 210 if (s->async) { 226 211 err = ExtAudioFileWriteAsync(s->audioFile, write, &s->bufferList); 227 228 212 if (err) { 229 213 char_t errorstr[20]; 214 if (err == kExtAudioFileError_AsyncWriteBufferOverflow) { 215 sprintf(errorstr,"buffer overflow"); 216 } else if (err == kExtAudioFileError_AsyncWriteTooLarge) { 217 sprintf(errorstr,"write too large"); 218 } else { 219 // unknown error 220 getPrintableOSStatusError(errorstr, err); 221 } 230 222 AUBIO_ERROR("sink_apple_audio: error while writing %s " 231 "in ExtAudioFileWriteAsync (%s), switching to sync\n", s->path, 232 getPrintableOSStatusError(errorstr, err)); 233 s->async = false; 234 } else { 235 return; 223 "in ExtAudioFileWriteAsync (%s)\n", s->path, errorstr); 236 224 } 237 238 225 } else { 239 226 err = ExtAudioFileWrite(s->audioFile, write, &s->bufferList); 240 241 227 if (err) { 242 228 char_t errorstr[20]; … … 246 232 } 247 233 } 248 return;249 234 } 250 235 … … 267 252 void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s) { 268 253 if (s->audioFile) aubio_sink_apple_audio_close (s); 254 if (s->path) AUBIO_FREE(s->path); 269 255 freeAudioBufferList(&s->bufferList); 270 256 AUBIO_FREE(s); -
src/io/sink_apple_audio.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SINK_APPLE_AUDIO_H22 #define _AUBIO_SINK_APPLE_AUDIO_H21 #ifndef AUBIO_SINK_APPLE_AUDIO_H 22 #define AUBIO_SINK_APPLE_AUDIO_H 23 23 24 24 /** \file … … 59 59 60 60 */ 61 aubio_sink_apple_audio_t * new_aubio_sink_apple_audio(c har_t * uri, uint_t samplerate);61 aubio_sink_apple_audio_t * new_aubio_sink_apple_audio(const char_t * uri, uint_t samplerate); 62 62 63 63 /** … … 103 103 104 104 */ 105 uint_t aubio_sink_apple_audio_get_samplerate( aubio_sink_apple_audio_t *s);105 uint_t aubio_sink_apple_audio_get_samplerate(const aubio_sink_apple_audio_t *s); 106 106 107 107 /** … … 113 113 114 114 */ 115 uint_t aubio_sink_apple_audio_get_channels( aubio_sink_apple_audio_t *s);115 uint_t aubio_sink_apple_audio_get_channels(const aubio_sink_apple_audio_t *s); 116 116 117 117 /** … … 161 161 #endif 162 162 163 #endif /* _AUBIO_SINK_APPLE_AUDIO_H */163 #endif /* AUBIO_SINK_APPLE_AUDIO_H */ -
src/io/sink_sndfile.c
r60fc05b rf264b17 54 54 uint_t aubio_sink_sndfile_open(aubio_sink_sndfile_t *s); 55 55 56 aubio_sink_sndfile_t * new_aubio_sink_sndfile(c har_t * path, uint_t samplerate) {56 aubio_sink_sndfile_t * new_aubio_sink_sndfile(const char_t * path, uint_t samplerate) { 57 57 aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t); 58 58 s->max_size = MAX_SIZE; 59 s->path = path;60 59 61 60 if (path == NULL) { … … 63 62 return NULL; 64 63 } 64 65 if (s->path) AUBIO_FREE(s->path); 66 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 67 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); 65 68 66 69 s->samplerate = 0; … … 107 110 } 108 111 109 uint_t aubio_sink_sndfile_get_samplerate( aubio_sink_sndfile_t *s)112 uint_t aubio_sink_sndfile_get_samplerate(const aubio_sink_sndfile_t *s) 110 113 { 111 114 return s->samplerate; 112 115 } 113 116 114 uint_t aubio_sink_sndfile_get_channels( aubio_sink_sndfile_t *s)117 uint_t aubio_sink_sndfile_get_channels(const aubio_sink_sndfile_t *s) 115 118 { 116 119 return s->channels; … … 220 223 void del_aubio_sink_sndfile(aubio_sink_sndfile_t * s){ 221 224 if (!s) return; 225 if (s->path) AUBIO_FREE(s->path); 222 226 aubio_sink_sndfile_close(s); 223 227 AUBIO_FREE(s->scratch_data); -
src/io/sink_sndfile.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SINK_SNDFILE_H22 #define _AUBIO_SINK_SNDFILE_H21 #ifndef AUBIO_SINK_SNDFILE_H 22 #define AUBIO_SINK_SNDFILE_H 23 23 24 24 /** \file … … 58 58 59 59 */ 60 aubio_sink_sndfile_t * new_aubio_sink_sndfile(c har_t * uri, uint_t samplerate);60 aubio_sink_sndfile_t * new_aubio_sink_sndfile(const char_t * uri, uint_t samplerate); 61 61 62 62 /** … … 102 102 103 103 */ 104 uint_t aubio_sink_sndfile_get_samplerate( aubio_sink_sndfile_t *s);104 uint_t aubio_sink_sndfile_get_samplerate(const aubio_sink_sndfile_t *s); 105 105 106 106 /** … … 112 112 113 113 */ 114 uint_t aubio_sink_sndfile_get_channels( aubio_sink_sndfile_t *s);114 uint_t aubio_sink_sndfile_get_channels(const aubio_sink_sndfile_t *s); 115 115 116 116 /** … … 160 160 #endif 161 161 162 #endif /* _AUBIO_SINK_SNDFILE_H */162 #endif /* AUBIO_SINK_SNDFILE_H */ -
src/io/sink_wavwrite.c
r60fc05b rf264b17 78 78 } 79 79 80 aubio_sink_wavwrite_t * new_aubio_sink_wavwrite(c har_t * path, uint_t samplerate) {80 aubio_sink_wavwrite_t * new_aubio_sink_wavwrite(const char_t * path, uint_t samplerate) { 81 81 aubio_sink_wavwrite_t * s = AUBIO_NEW(aubio_sink_wavwrite_t); 82 82 … … 90 90 } 91 91 92 s->path = path; 92 if (s->path) AUBIO_FREE(s->path); 93 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 94 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); 95 93 96 s->max_size = MAX_SIZE; 94 97 s->bitspersample = 16; … … 143 146 } 144 147 145 uint_t aubio_sink_wavwrite_get_samplerate( aubio_sink_wavwrite_t *s)148 uint_t aubio_sink_wavwrite_get_samplerate(const aubio_sink_wavwrite_t *s) 146 149 { 147 150 return s->samplerate; 148 151 } 149 152 150 uint_t aubio_sink_wavwrite_get_channels( aubio_sink_wavwrite_t *s)153 uint_t aubio_sink_wavwrite_get_channels(const aubio_sink_wavwrite_t *s) 151 154 { 152 155 return s->channels; … … 288 291 if (!s) return; 289 292 aubio_sink_wavwrite_close(s); 293 if (s->path) AUBIO_FREE(s->path); 290 294 AUBIO_FREE(s->scratch_data); 291 295 AUBIO_FREE(s); -
src/io/sink_wavwrite.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SINK_WAVWRITE_H22 #define _AUBIO_SINK_WAVWRITE_H21 #ifndef AUBIO_SINK_WAVWRITE_H 22 #define AUBIO_SINK_WAVWRITE_H 23 23 24 24 /** \file … … 58 58 59 59 */ 60 aubio_sink_wavwrite_t * new_aubio_sink_wavwrite(c har_t * uri, uint_t samplerate);60 aubio_sink_wavwrite_t * new_aubio_sink_wavwrite(const char_t * uri, uint_t samplerate); 61 61 62 62 /** … … 102 102 103 103 */ 104 uint_t aubio_sink_wavwrite_get_samplerate( aubio_sink_wavwrite_t *s);104 uint_t aubio_sink_wavwrite_get_samplerate(const aubio_sink_wavwrite_t *s); 105 105 106 106 /** … … 112 112 113 113 */ 114 uint_t aubio_sink_wavwrite_get_channels( aubio_sink_wavwrite_t *s);114 uint_t aubio_sink_wavwrite_get_channels(const aubio_sink_wavwrite_t *s); 115 115 116 116 /** … … 160 160 #endif 161 161 162 #endif /* _AUBIO_SINK_WAVWRITE_H */162 #endif /* AUBIO_SINK_WAVWRITE_H */ -
src/io/source.c
r60fc05b rf264b17 41 41 typedef uint_t (*aubio_source_get_samplerate_t)(aubio_source_t * s); 42 42 typedef uint_t (*aubio_source_get_channels_t)(aubio_source_t * s); 43 typedef uint_t (*aubio_source_get_duration_t)(aubio_source_t * s); 43 44 typedef uint_t (*aubio_source_seek_t)(aubio_source_t * s, uint_t seek); 44 45 typedef uint_t (*aubio_source_close_t)(aubio_source_t * s); … … 51 52 aubio_source_get_samplerate_t s_get_samplerate; 52 53 aubio_source_get_channels_t s_get_channels; 54 aubio_source_get_duration_t s_get_duration; 53 55 aubio_source_seek_t s_seek; 54 56 aubio_source_close_t s_close; … … 56 58 }; 57 59 58 aubio_source_t * new_aubio_source(c har_t * uri, uint_t samplerate, uint_t hop_size) {60 aubio_source_t * new_aubio_source(const char_t * uri, uint_t samplerate, uint_t hop_size) { 59 61 aubio_source_t * s = AUBIO_NEW(aubio_source_t); 60 #if HAVE_LIBAV62 #ifdef HAVE_LIBAV 61 63 s->source = (void *)new_aubio_source_avcodec(uri, samplerate, hop_size); 62 64 if (s->source) { … … 65 67 s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_avcodec_get_channels); 66 68 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_avcodec_get_samplerate); 69 s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_avcodec_get_duration); 67 70 s->s_seek = (aubio_source_seek_t)(aubio_source_avcodec_seek); 68 71 s->s_close = (aubio_source_close_t)(aubio_source_avcodec_close); … … 78 81 s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_apple_audio_get_channels); 79 82 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_apple_audio_get_samplerate); 83 s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_apple_audio_get_duration); 80 84 s->s_seek = (aubio_source_seek_t)(aubio_source_apple_audio_seek); 81 85 s->s_close = (aubio_source_close_t)(aubio_source_apple_audio_close); … … 84 88 } 85 89 #endif /* HAVE_SOURCE_APPLE_AUDIO */ 86 #if HAVE_SNDFILE90 #ifdef HAVE_SNDFILE 87 91 s->source = (void *)new_aubio_source_sndfile(uri, samplerate, hop_size); 88 92 if (s->source) { … … 91 95 s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_sndfile_get_channels); 92 96 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_sndfile_get_samplerate); 97 s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_sndfile_get_duration); 93 98 s->s_seek = (aubio_source_seek_t)(aubio_source_sndfile_seek); 94 99 s->s_close = (aubio_source_close_t)(aubio_source_sndfile_close); … … 97 102 } 98 103 #endif /* HAVE_SNDFILE */ 99 #if HAVE_WAVREAD104 #ifdef HAVE_WAVREAD 100 105 s->source = (void *)new_aubio_source_wavread(uri, samplerate, hop_size); 101 106 if (s->source) { … … 104 109 s->s_get_channels = (aubio_source_get_channels_t)(aubio_source_wavread_get_channels); 105 110 s->s_get_samplerate = (aubio_source_get_samplerate_t)(aubio_source_wavread_get_samplerate); 111 s->s_get_duration = (aubio_source_get_duration_t)(aubio_source_wavread_get_duration); 106 112 s->s_seek = (aubio_source_seek_t)(aubio_source_wavread_seek); 107 113 s->s_close = (aubio_source_close_t)(aubio_source_wavread_close); … … 142 148 } 143 149 150 uint_t aubio_source_get_duration(aubio_source_t *s) { 151 return s->s_get_duration((void *)s->source); 152 } 153 144 154 uint_t aubio_source_seek (aubio_source_t * s, uint_t seek ) { 145 155 return s->s_seek((void *)s->source, seek); -
src/io/source.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SOURCE_H22 #define _AUBIO_SOURCE_H21 #ifndef AUBIO_SOURCE_H 22 #define AUBIO_SOURCE_H 23 23 24 24 /** \file … … 86 86 87 87 */ 88 aubio_source_t * new_aubio_source(c har_t * uri, uint_t samplerate, uint_t hop_size);88 aubio_source_t * new_aubio_source(const char_t * uri, uint_t samplerate, uint_t hop_size); 89 89 90 90 /** … … 150 150 /** 151 151 152 get the duration of source object, in frames 153 154 \param s source object, created with ::new_aubio_source 155 \return number of frames in file 156 157 */ 158 uint_t aubio_source_get_duration (aubio_source_t * s); 159 160 /** 161 152 162 close source object 153 163 … … 172 182 #endif 173 183 174 #endif /* _AUBIO_SOURCE_H */184 #endif /* AUBIO_SOURCE_H */ -
src/io/source_apple_audio.c
r60fc05b rf264b17 52 52 extern int createAubioBufferList(AudioBufferList *bufferList, int channels, int max_source_samples); 53 53 extern void freeAudioBufferList(AudioBufferList *bufferList); 54 extern CFURLRef getURLFromPath(const char * path);54 extern CFURLRef createURLFromPath(const char * path); 55 55 char_t *getPrintableOSStatusError(char_t *str, OSStatus error); 56 56 57 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, c har_t * path);58 59 aubio_source_apple_audio_t * new_aubio_source_apple_audio(c har_t * path, uint_t samplerate, uint_t block_size)57 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, const char_t * path); 58 59 aubio_source_apple_audio_t * new_aubio_source_apple_audio(const char_t * path, uint_t samplerate, uint_t block_size) 60 60 { 61 61 aubio_source_apple_audio_t * s = AUBIO_NEW(aubio_source_apple_audio_t); … … 80 80 s->block_size = block_size; 81 81 s->samplerate = samplerate; 82 s->path = path;83 82 84 83 if ( aubio_source_apple_audio_open ( s, path ) ) { … … 92 91 } 93 92 94 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, c har_t * path)93 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, const char_t * path) 95 94 { 96 95 OSStatus err = noErr; 97 96 UInt32 propSize; 98 s->path = path; 97 98 if (s->path) AUBIO_FREE(s->path); 99 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 100 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); 99 101 100 102 // open the resource url 101 CFURLRef fileURL = getURLFromPath(path);103 CFURLRef fileURL = createURLFromPath(s->path); 102 104 err = ExtAudioFileOpenURL(fileURL, &s->audioFile); 105 CFRelease(fileURL); 103 106 if (err == -43) { 104 107 AUBIO_ERR("source_apple_audio: Failed opening %s, " … … 293 296 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){ 294 297 aubio_source_apple_audio_close (s); 298 if (s->path) AUBIO_FREE(s->path); 295 299 freeAudioBufferList(&s->bufferList); 296 300 AUBIO_FREE(s); … … 308 312 } 309 313 // check if we are not seeking out of the file 310 SInt64 fileLengthFrames = 0; 311 UInt32 propSize = sizeof(fileLengthFrames); 312 ExtAudioFileGetProperty(s->audioFile, 313 kExtAudioFileProperty_FileLengthFrames, &propSize, &fileLengthFrames); 314 uint_t fileLengthFrames = aubio_source_apple_audio_get_duration(s); 314 315 // compute position in the source file, before resampling 315 316 smpl_t ratio = s->source_samplerate * 1. / s->samplerate; … … 352 353 } 353 354 354 uint_t aubio_source_apple_audio_get_samplerate( aubio_source_apple_audio_t * s) {355 uint_t aubio_source_apple_audio_get_samplerate(const aubio_source_apple_audio_t * s) { 355 356 return s->samplerate; 356 357 } 357 358 358 uint_t aubio_source_apple_audio_get_channels( aubio_source_apple_audio_t * s) {359 uint_t aubio_source_apple_audio_get_channels(const aubio_source_apple_audio_t * s) { 359 360 return s->channels; 360 361 } 361 362 363 uint_t aubio_source_apple_audio_get_duration(const aubio_source_apple_audio_t * s) { 364 SInt64 fileLengthFrames = 0; 365 UInt32 propSize = sizeof(fileLengthFrames); 366 OSStatus err = ExtAudioFileGetProperty(s->audioFile, 367 kExtAudioFileProperty_FileLengthFrames, &propSize, &fileLengthFrames); 368 if (err) { 369 char_t errorstr[20]; 370 AUBIO_ERROR("source_apple_audio: Failed getting %s duration, " 371 "error in ExtAudioFileGetProperty (%s)\n", s->path, 372 getPrintableOSStatusError(errorstr, err)); 373 return err; 374 } 375 return (uint_t)fileLengthFrames; 376 } 377 362 378 #endif /* HAVE_SOURCE_APPLE_AUDIO */ -
src/io/source_apple_audio.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SOURCE_APPLE_AUDIO_H22 #define _AUBIO_SOURCE_APPLE_AUDIO_H21 #ifndef AUBIO_SOURCE_APPLE_AUDIO_H 22 #define AUBIO_SOURCE_APPLE_AUDIO_H 23 23 24 24 /** \file … … 58 58 59 59 */ 60 aubio_source_apple_audio_t * new_aubio_source_apple_audio(c har_t * uri, uint_t samplerate, uint_t hop_size);60 aubio_source_apple_audio_t * new_aubio_source_apple_audio(const char_t * uri, uint_t samplerate, uint_t hop_size); 61 61 62 62 /** … … 96 96 97 97 */ 98 uint_t aubio_source_apple_audio_get_samplerate( aubio_source_apple_audio_t * s);98 uint_t aubio_source_apple_audio_get_samplerate(const aubio_source_apple_audio_t * s); 99 99 100 100 /** … … 106 106 107 107 */ 108 uint_t aubio_source_apple_audio_get_channels(aubio_source_apple_audio_t * s); 108 uint_t aubio_source_apple_audio_get_channels(const aubio_source_apple_audio_t * s); 109 110 /** 111 112 get the duration of source object, in frames 113 114 \param s source object, created with ::new_aubio_source_apple_audio 115 \return number of frames in file 116 117 */ 118 uint_t aubio_source_apple_audio_get_duration(const aubio_source_apple_audio_t * s); 109 119 110 120 /** … … 144 154 #endif 145 155 146 #endif /* _AUBIO_SOURCE_APPLE_AUDIO_H */156 #endif /* AUBIO_SOURCE_APPLE_AUDIO_H */ -
src/io/source_avcodec.c
r60fc05b rf264b17 24 24 #ifdef HAVE_LIBAV 25 25 26 // determine whether we use libavformat from ffmpe or libav 27 #define FFMPEG_LIBAVFORMAT (LIBAVFORMAT_VERSION_MICRO > 99) 26 // determine whether we use libavformat from ffmpeg or from libav 27 #define FFMPEG_LIBAVFORMAT (LIBAVFORMAT_VERSION_MICRO > 99 ) 28 // max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 through 57.2.100 29 #define FFMPEG_LIBAVFORMAT_MAX_DUR2 FFMPEG_LIBAVFORMAT && ( \ 30 (LIBAVFORMAT_VERSION_MAJOR == 55 && LIBAVFORMAT_VERSION_MINOR >= 43) \ 31 || (LIBAVFORMAT_VERSION_MAJOR == 56) \ 32 || (LIBAVFORMAT_VERSION_MAJOR == 57 && LIBAVFORMAT_VERSION_MINOR < 2) \ 33 ) 28 34 29 35 #include <libavcodec/avcodec.h> … … 67 73 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples); 68 74 69 aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplerate, uint_t hop_size) { 75 uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s); 76 77 uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s) { 78 char proto[20], authorization[256], hostname[128], uripath[256]; 79 int proto_size = 20, authorization_size = 256, hostname_size = 128, 80 *port_ptr = 0, path_size = 256; 81 av_url_split(proto, proto_size, authorization, authorization_size, hostname, 82 hostname_size, port_ptr, uripath, path_size, s->path); 83 if (strlen(proto)) { 84 return 1; 85 } 86 return 0; 87 } 88 89 90 aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t samplerate, uint_t hop_size) { 70 91 aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t); 71 92 int err; … … 85 106 s->hop_size = hop_size; 86 107 s->channels = 1; 87 s->path = path; 108 109 if (s->path) AUBIO_FREE(s->path); 110 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 111 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); 88 112 89 113 // register all formats and codecs 90 114 av_register_all(); 91 115 92 // if path[0] != '/' 93 //avformat_network_init(); 116 if (aubio_source_avcodec_has_network_url(s)) { 117 avformat_network_init(); 118 } 94 119 95 120 // try opening the file and get some info about it … … 104 129 105 130 // try to make sure max_analyze_duration is big enough for most songs 106 #if FFMPEG_LIBAVFORMAT 131 #if FFMPEG_LIBAVFORMAT_MAX_DUR2 107 132 avFormatCtx->max_analyze_duration2 *= 100; 108 133 #else … … 164 189 165 190 if (samplerate == 0) { 166 s amplerate = s->input_samplerate;167 //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate);168 }169 s->samplerate = samplerate;191 s->samplerate = s->input_samplerate; 192 } else { 193 s->samplerate = samplerate; 194 } 170 195 171 196 if (s->samplerate > s->input_samplerate) { … … 300 325 s->output = output; 301 326 302 av_ free_packet(&avPacket);327 av_packet_unref(&avPacket); 303 328 } 304 329 … … 370 395 } 371 396 372 uint_t aubio_source_avcodec_get_samplerate( aubio_source_avcodec_t * s) {397 uint_t aubio_source_avcodec_get_samplerate(const aubio_source_avcodec_t * s) { 373 398 return s->samplerate; 374 399 } 375 400 376 uint_t aubio_source_avcodec_get_channels( aubio_source_avcodec_t * s) {401 uint_t aubio_source_avcodec_get_channels(const aubio_source_avcodec_t * s) { 377 402 return s->input_channels; 378 403 } … … 398 423 } 399 424 425 uint_t aubio_source_avcodec_get_duration (aubio_source_avcodec_t * s) { 426 if (s && &(s->avFormatCtx) != NULL) { 427 int64_t duration = s->avFormatCtx->duration; 428 return s->samplerate * ((uint_t)duration / 1e6 ); 429 } 430 return 0; 431 } 432 400 433 uint_t aubio_source_avcodec_close(aubio_source_avcodec_t * s) { 401 434 if (s->avr != NULL) { … … 425 458 av_frame_free( &(s->avFrame) ); 426 459 } 460 if (s->path) AUBIO_FREE(s->path); 427 461 s->avFrame = NULL; 428 462 AUBIO_FREE(s); -
src/io/source_avcodec.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SOURCE_AVCODEC_H22 #define _AUBIO_SOURCE_AVCODEC_H21 #ifndef AUBIO_SOURCE_AVCODEC_H 22 #define AUBIO_SOURCE_AVCODEC_H 23 23 24 24 /** \file … … 57 57 58 58 */ 59 aubio_source_avcodec_t * new_aubio_source_avcodec(c har_t * uri, uint_t samplerate, uint_t hop_size);59 aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * uri, uint_t samplerate, uint_t hop_size); 60 60 61 61 /** … … 95 95 96 96 */ 97 uint_t aubio_source_avcodec_get_samplerate( aubio_source_avcodec_t * s);97 uint_t aubio_source_avcodec_get_samplerate(const aubio_source_avcodec_t * s); 98 98 99 99 /** … … 105 105 106 106 */ 107 uint_t aubio_source_avcodec_get_channels ( aubio_source_avcodec_t * s);107 uint_t aubio_source_avcodec_get_channels (const aubio_source_avcodec_t * s); 108 108 109 109 /** … … 118 118 */ 119 119 uint_t aubio_source_avcodec_seek (aubio_source_avcodec_t *s, uint_t pos); 120 121 /** 122 123 get the duration of source object, in frames 124 125 \param s source object, created with ::new_aubio_source_avcodec 126 \return number of frames in file 127 128 */ 129 uint_t aubio_source_avcodec_get_duration (aubio_source_avcodec_t * s); 120 130 121 131 /** … … 143 153 #endif 144 154 145 #endif /* _AUBIO_SOURCE_AVCODEC_H */155 #endif /* AUBIO_SOURCE_AVCODEC_H */ -
src/io/source_sndfile.c
r60fc05b rf264b17 36 36 #define MAX_SIZE 4096 37 37 #define MAX_SAMPLES MAX_CHANNELS * MAX_SIZE 38 39 #if !HAVE_AUBIO_DOUBLE 40 #define aubio_sf_read_smpl sf_read_float 41 #else /* HAVE_AUBIO_DOUBLE */ 42 #define aubio_sf_read_smpl sf_read_double 43 #endif /* HAVE_AUBIO_DOUBLE */ 38 44 39 45 struct _aubio_source_sndfile_t { … … 48 54 int input_channels; 49 55 int input_format; 56 int duration; 50 57 51 58 // resampling stuff … … 59 66 // some temporary memory for sndfile to write at 60 67 uint_t scratch_size; 61 float *scratch_data;68 smpl_t *scratch_data; 62 69 }; 63 70 64 aubio_source_sndfile_t * new_aubio_source_sndfile(c har_t * path, uint_t samplerate, uint_t hop_size) {71 aubio_source_sndfile_t * new_aubio_source_sndfile(const char_t * path, uint_t samplerate, uint_t hop_size) { 65 72 aubio_source_sndfile_t * s = AUBIO_NEW(aubio_source_sndfile_t); 66 73 SF_INFO sfinfo; … … 81 88 s->hop_size = hop_size; 82 89 s->channels = 1; 83 s->path = path; 90 91 if (s->path) AUBIO_FREE(s->path); 92 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 93 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); 84 94 85 95 // try opening the file, getting the info in sfinfo … … 97 107 s->input_channels = sfinfo.channels; 98 108 s->input_format = sfinfo.format; 109 s->duration = sfinfo.frames; 99 110 100 111 if (samplerate == 0) { 101 s amplerate = s->input_samplerate;112 s->samplerate = s->input_samplerate; 102 113 //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate); 103 } 104 s->samplerate = samplerate; 114 } else { 115 s->samplerate = samplerate; 116 } 105 117 /* compute input block size required before resampling */ 106 s->ratio = s->samplerate/( float)s->input_samplerate;118 s->ratio = s->samplerate/(smpl_t)s->input_samplerate; 107 119 s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5); 108 120 … … 129 141 s->input_samplerate, s->samplerate); 130 142 } 143 s->duration = (uint_t)FLOOR(s->duration * s->ratio); 131 144 } 132 145 #else … … 139 152 /* allocate data for de/interleaving reallocated when needed. */ 140 153 s->scratch_size = s->input_hop_size * s->input_channels; 141 s->scratch_data = AUBIO_ARRAY( float,s->scratch_size);154 s->scratch_data = AUBIO_ARRAY(smpl_t, s->scratch_size); 142 155 143 156 return s; … … 153 166 uint_t i,j, input_channels = s->input_channels; 154 167 /* read from file into scratch_data */ 155 sf_count_t read_samples = sf_read_float(s->handle, s->scratch_data, s->scratch_size);168 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, s->scratch_size); 156 169 157 170 /* where to store de-interleaved data */ … … 194 207 uint_t i,j, input_channels = s->input_channels; 195 208 /* do actual reading */ 196 sf_count_t read_samples = sf_read_float(s->handle, s->scratch_data, s->scratch_size);209 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, s->scratch_size); 197 210 198 211 /* where to store de-interleaved data */ … … 214 227 for (j = 0; j < read_samples / input_channels; j++) { 215 228 for (i = 0; i < read_data->height; i++) { 216 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];229 ptr_data[i][j] = s->scratch_data[j * input_channels + i]; 217 230 } 218 231 } … … 222 235 for (j = 0; j < read_samples / input_channels; j++) { 223 236 for (i = 0; i < input_channels; i++) { 224 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];237 ptr_data[i][j] = s->scratch_data[j * input_channels + i]; 225 238 } 226 239 } … … 232 245 for (j = 0; j < read_samples / input_channels; j++) { 233 246 for (i = input_channels; i < read_data->height; i++) { 234 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)];247 ptr_data[i][j] = s->scratch_data[j * input_channels + (input_channels - 1)]; 235 248 } 236 249 } … … 261 274 uint_t aubio_source_sndfile_get_channels(aubio_source_sndfile_t * s) { 262 275 return s->input_channels; 276 } 277 278 uint_t aubio_source_sndfile_get_duration (const aubio_source_sndfile_t * s) { 279 if (s && s->duration) { 280 return s->duration; 281 } 282 return 0; 263 283 } 264 284 … … 300 320 } 301 321 #endif /* HAVE_SAMPLERATE */ 322 if (s->path) AUBIO_FREE(s->path); 302 323 AUBIO_FREE(s->scratch_data); 303 324 AUBIO_FREE(s); -
src/io/source_sndfile.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SOURCE_SNDFILE_H22 #define _AUBIO_SOURCE_SNDFILE_H21 #ifndef AUBIO_SOURCE_SNDFILE_H 22 #define AUBIO_SOURCE_SNDFILE_H 23 23 24 24 /** \file … … 57 57 58 58 */ 59 aubio_source_sndfile_t * new_aubio_source_sndfile(c har_t * uri, uint_t samplerate, uint_t hop_size);59 aubio_source_sndfile_t * new_aubio_source_sndfile(const char_t * uri, uint_t samplerate, uint_t hop_size); 60 60 61 61 /** … … 121 121 /** 122 122 123 get the duration of source object, in frames 124 125 \param s source object, created with ::new_aubio_source_sndfile 126 \return number of frames in file 127 128 */ 129 uint_t aubio_source_sndfile_get_duration (const aubio_source_sndfile_t *s); 130 131 /** 132 123 133 close source 124 134 … … 143 153 #endif 144 154 145 #endif /* _AUBIO_SOURCE_SNDFILE_H */155 #endif /* AUBIO_SOURCE_SNDFILE_H */ -
src/io/source_wavread.c
r60fc05b rf264b17 53 53 uint_t eof; 54 54 55 uint_t duration; 56 55 57 size_t seek_start; 56 58 … … 68 70 } 69 71 70 aubio_source_wavread_t * new_aubio_source_wavread(c har_t * path, uint_t samplerate, uint_t hop_size) {72 aubio_source_wavread_t * new_aubio_source_wavread(const char_t * path, uint_t samplerate, uint_t hop_size) { 71 73 aubio_source_wavread_t * s = AUBIO_NEW(aubio_source_wavread_t); 72 74 size_t bytes_read = 0, bytes_expected = 44; 73 75 unsigned char buf[5]; 74 unsigned int format, channels, sr, byterate, blockalign, bitspersample;//, data_size;76 unsigned int format, channels, sr, byterate, blockalign, duration, bitspersample;//, data_size; 75 77 76 78 if (path == NULL) { … … 87 89 } 88 90 89 s->path = path; 91 if (s->path) AUBIO_FREE(s->path); 92 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 93 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); 94 90 95 s->samplerate = samplerate; 91 96 s->hop_size = hop_size; … … 213 218 // Subchunk2Size 214 219 bytes_read += fread(buf, 1, 4, s->fid); 220 duration = read_little_endian(buf, 4) / blockalign; 221 215 222 //data_size = buf[0] + (buf[1] << 8) + (buf[2] << 16) + (buf[3] << 24); 216 223 //AUBIO_MSG("found %d frames in %s\n", 8 * data_size / bitspersample / channels, s->path); … … 232 239 s->blockalign= blockalign; 233 240 s->bitspersample = bitspersample; 241 242 s->duration = duration; 234 243 235 244 s->short_output = (unsigned char *)calloc(s->blockalign, AUBIO_WAVREAD_BUFSIZE); … … 372 381 } 373 382 383 uint_t aubio_source_wavread_get_duration (const aubio_source_wavread_t * s) { 384 if (s && s->duration) { 385 return s->duration; 386 } 387 return 0; 388 } 389 374 390 uint_t aubio_source_wavread_close (aubio_source_wavread_t * s) { 375 391 if (!s->fid) { … … 389 405 if (s->short_output) AUBIO_FREE(s->short_output); 390 406 if (s->output) del_fmat(s->output); 407 if (s->path) AUBIO_FREE(s->path); 391 408 AUBIO_FREE(s); 392 409 } -
src/io/source_wavread.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SOURCE_WAVREAD_H22 #define _AUBIO_SOURCE_WAVREAD_H21 #ifndef AUBIO_SOURCE_WAVREAD_H 22 #define AUBIO_SOURCE_WAVREAD_H 23 23 24 24 /** \file … … 62 62 63 63 */ 64 aubio_source_wavread_t * new_aubio_source_wavread(c har_t * uri, uint_t samplerate, uint_t hop_size);64 aubio_source_wavread_t * new_aubio_source_wavread(const char_t * uri, uint_t samplerate, uint_t hop_size); 65 65 66 66 /** … … 126 126 /** 127 127 128 get the duration of source object, in frames 129 130 \param s source object, created with ::new_aubio_source_sndfile 131 \return number of frames in file 132 133 */ 134 uint_t aubio_source_wavread_get_duration (const aubio_source_wavread_t *s); 135 136 /** 137 128 138 close source 129 139 … … 148 158 #endif 149 159 150 #endif /* _AUBIO_SOURCE_WAVREAD_H */160 #endif /* AUBIO_SOURCE_WAVREAD_H */ -
src/io/utils_apple_audio.c
r60fc05b rf264b17 34 34 } 35 35 36 CFURLRef getURLFromPath(const char * path) {36 CFURLRef createURLFromPath(const char * path) { 37 37 CFStringRef cfTotalPath = CFStringCreateWithCString (kCFAllocatorDefault, 38 38 path, kCFStringEncodingUTF8); 39 39 40 returnCFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfTotalPath,40 CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfTotalPath, 41 41 kCFURLPOSIXPathStyle, false); 42 CFRelease(cfTotalPath); 43 return url; 42 44 } 43 45 -
src/lvec.c
r60fc05b rf264b17 22 22 #include "lvec.h" 23 23 24 lvec_t * new_lvec( 24 lvec_t * new_lvec(uint_t length) { 25 25 lvec_t * s; 26 26 if ((sint_t)length <= 0) { … … 46 46 } 47 47 48 lsmp_t * lvec_get_data( lvec_t *s) {48 lsmp_t * lvec_get_data(const lvec_t *s) { 49 49 return s->data; 50 50 } … … 52 52 /* helper functions */ 53 53 54 void lvec_print( lvec_t *s) {54 void lvec_print(const lvec_t *s) { 55 55 uint_t j; 56 56 for (j=0; j< s->length; j++) { -
src/lvec.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO__LVEC_H22 #define _AUBIO__LVEC_H21 #ifndef AUBIO_LVEC_H 22 #define AUBIO_LVEC_H 23 23 24 24 #ifdef __cplusplus … … 81 81 82 82 */ 83 lsmp_t * lvec_get_data( lvec_t *s);83 lsmp_t * lvec_get_data(const lvec_t *s); 84 84 85 85 /** print out lvec data … … 88 88 89 89 */ 90 void lvec_print( lvec_t *s);90 void lvec_print(const lvec_t *s); 91 91 92 92 /** set all elements to a given value … … 116 116 #endif 117 117 118 #endif /* _AUBIO__LVEC_H */118 #endif /* AUBIO_LVEC_H */ -
src/mathutils.c
r60fc05b rf264b17 26 26 #include "musicutils.h" 27 27 #include "config.h" 28 29 #ifdef HAVE_ACCELERATE30 #include <Accelerate/Accelerate.h>31 #endif32 28 33 29 /** Window types */ … … 167 163 return tmp / (smpl_t) (s->length); 168 164 #else 169 #if !HAVE_AUBIO_DOUBLE 170 vDSP_meanv(s->data, 1, &tmp, s->length); 171 #else /* HAVE_AUBIO_DOUBLE */ 172 vDSP_meanvD(s->data, 1, &tmp, s->length); 173 #endif /* HAVE_AUBIO_DOUBLE */ 165 aubio_vDSP_meanv(s->data, 1, &tmp, s->length); 174 166 return tmp; 175 167 #endif /* HAVE_ACCELERATE */ … … 186 178 } 187 179 #else 188 #if !HAVE_AUBIO_DOUBLE 189 vDSP_sve(s->data, 1, &tmp, s->length); 190 #else /* HAVE_AUBIO_DOUBLE */ 191 vDSP_sveD(s->data, 1, &tmp, s->length); 192 #endif /* HAVE_AUBIO_DOUBLE */ 180 aubio_vDSP_sve(s->data, 1, &tmp, s->length); 193 181 #endif /* HAVE_ACCELERATE */ 194 182 return tmp; … … 206 194 #else 207 195 smpl_t tmp = 0.; 208 #if !HAVE_AUBIO_DOUBLE 209 vDSP_maxv(s->data, 1, &tmp, s->length); 210 #else 211 vDSP_maxvD(s->data, 1, &tmp, s->length); 212 #endif 196 aubio_vDSP_maxv(s->data, 1, &tmp, s->length); 213 197 #endif 214 198 return tmp; … … 226 210 #else 227 211 smpl_t tmp = 0.; 228 #if !HAVE_AUBIO_DOUBLE 229 vDSP_minv(s->data, 1, &tmp, s->length); 230 #else 231 vDSP_minvD(s->data, 1, &tmp, s->length); 232 #endif 212 aubio_vDSP_minv(s->data, 1, &tmp, s->length); 233 213 #endif 234 214 return tmp; … … 248 228 smpl_t tmp = 0.; 249 229 uint_t pos = 0.; 250 #if !HAVE_AUBIO_DOUBLE 251 vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 252 #else 253 vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 254 #endif 230 aubio_vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 255 231 #endif 256 232 return pos; … … 270 246 smpl_t tmp = 0.; 271 247 uint_t pos = 0.; 272 #if !HAVE_AUBIO_DOUBLE 273 vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 274 #else 275 vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 276 #endif 248 aubio_vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 277 249 #endif 278 250 return pos; … … 282 254 fvec_shift (fvec_t * s) 283 255 { 284 uint_t j; 285 for (j = 0; j < s->length / 2; j++) { 286 ELEM_SWAP (s->data[j], s->data[j + s->length / 2]); 287 } 288 } 289 290 smpl_t 291 aubio_level_lin (fvec_t * f) 256 uint_t half = s->length / 2, start = half, j; 257 // if length is odd, middle element is moved to the end 258 if (2 * half < s->length) start ++; 259 #ifndef HAVE_ATLAS 260 for (j = 0; j < half; j++) { 261 ELEM_SWAP (s->data[j], s->data[j + start]); 262 } 263 #else 264 aubio_cblas_swap(half, s->data, 1, s->data + start, 1); 265 #endif 266 if (start != half) { 267 for (j = 0; j < half; j++) { 268 ELEM_SWAP (s->data[j + start - 1], s->data[j + start]); 269 } 270 } 271 } 272 273 void 274 fvec_ishift (fvec_t * s) 275 { 276 uint_t half = s->length / 2, start = half, j; 277 // if length is odd, middle element is moved to the beginning 278 if (2 * half < s->length) start ++; 279 #ifndef HAVE_ATLAS 280 for (j = 0; j < half; j++) { 281 ELEM_SWAP (s->data[j], s->data[j + start]); 282 } 283 #else 284 aubio_cblas_swap(half, s->data, 1, s->data + start, 1); 285 #endif 286 if (start != half) { 287 for (j = 0; j < half; j++) { 288 ELEM_SWAP (s->data[half], s->data[j]); 289 } 290 } 291 } 292 293 smpl_t 294 aubio_level_lin (const fvec_t * f) 292 295 { 293 296 smpl_t energy = 0.; 297 #ifndef HAVE_ATLAS 294 298 uint_t j; 295 299 for (j = 0; j < f->length; j++) { 296 300 energy += SQR (f->data[j]); 297 301 } 302 #else 303 energy = aubio_cblas_dot(f->length, f->data, 1, f->data, 1); 304 #endif 298 305 return energy / f->length; 299 306 } … … 434 441 } 435 442 436 smpl_t fvec_quadratic_peak_pos ( fvec_t * x, uint_t pos) {443 smpl_t fvec_quadratic_peak_pos (const fvec_t * x, uint_t pos) { 437 444 smpl_t s0, s1, s2; uint_t x0, x2; 445 smpl_t half = .5, two = 2.; 438 446 if (pos == 0 || pos == x->length - 1) return pos; 439 447 x0 = (pos < 1) ? pos : pos - 1; … … 444 452 s1 = x->data[pos]; 445 453 s2 = x->data[x2]; 446 return pos + 0.5 * (s0 - s2 ) / (s0 - 2.* s1 + s2);454 return pos + half * (s0 - s2 ) / (s0 - two * s1 + s2); 447 455 } 448 456 … … 458 466 } 459 467 460 uint_t fvec_peakpick( fvec_t * onset, uint_t pos) {468 uint_t fvec_peakpick(const fvec_t * onset, uint_t pos) { 461 469 uint_t tmp=0; 462 470 tmp = (onset->data[pos] > onset->data[pos-1] … … 545 553 546 554 smpl_t 547 aubio_db_spl ( fvec_t * o)555 aubio_db_spl (const fvec_t * o) 548 556 { 549 557 return 10. * LOG10 (aubio_level_lin (o)); … … 551 559 552 560 uint_t 553 aubio_silence_detection ( fvec_t * o, smpl_t threshold)561 aubio_silence_detection (const fvec_t * o, smpl_t threshold) 554 562 { 555 563 return (aubio_db_spl (o) < threshold); … … 591 599 592 600 void 593 aubio_autocorr ( fvec_t * input, fvec_t * output)601 aubio_autocorr (const fvec_t * input, fvec_t * output) 594 602 { 595 603 uint_t i, j, length = input->length; -
src/mathutils.h
r60fc05b rf264b17 28 28 */ 29 29 30 #ifndef _AUBIO_MATHUTILS_H31 #define _AUBIO_MATHUTILS_H30 #ifndef AUBIO_MATHUTILS_H 31 #define AUBIO_MATHUTILS_H 32 32 33 33 #include "fvec.h" … … 99 99 */ 100 100 void fvec_shift (fvec_t * v); 101 102 /** swap the left and right halves of a vector 103 104 This function swaps the left part of the signal with the right part of the 105 signal. Therefore 106 107 \f$ a[0], a[1], ..., a[\frac{N}{2}], a[\frac{N}{2}+1], ..., a[N-1], a[N] \f$ 108 109 becomes 110 111 \f$ a[\frac{N}{2}+1], ..., a[N-1], a[N], a[0], a[1], ..., a[\frac{N}{2}] \f$ 112 113 This operation, known as 'ifftshift' in the Matlab Signal Processing Toolbox, 114 can be used after computing the inverse FFT to simplify the phase relationship 115 of the resulting spectrum. See Amalia de Götzen's paper referred to above. 116 117 */ 118 void fvec_ishift (fvec_t * v); 101 119 102 120 /** compute the sum of all elements of a vector … … 233 251 234 252 */ 235 smpl_t fvec_quadratic_peak_pos ( fvec_t * x, uint_t p);253 smpl_t fvec_quadratic_peak_pos (const fvec_t * x, uint_t p); 236 254 237 255 /** finds magnitude of peak by quadratic interpolation … … 276 294 277 295 */ 278 uint_t fvec_peakpick ( fvec_t * v, uint_t p);296 uint_t fvec_peakpick (const fvec_t * v, uint_t p); 279 297 280 298 /** return 1 if a is a power of 2, 0 otherwise */ … … 290 308 291 309 */ 292 void aubio_autocorr ( fvec_t * input, fvec_t * output);310 void aubio_autocorr (const fvec_t * input, fvec_t * output); 293 311 294 312 #ifdef __cplusplus … … 296 314 #endif 297 315 298 #endif /* _AUBIO_MATHUTILS_H */316 #endif /* AUBIO_MATHUTILS_H */ -
src/musicutils.h
r60fc05b rf264b17 23 23 */ 24 24 25 #ifndef _AUBIO__MUSICUTILS_H26 #define _AUBIO__MUSICUTILS_H25 #ifndef AUBIO_MUSICUTILS_H 26 #define AUBIO_MUSICUTILS_H 27 27 28 28 #ifdef __cplusplus … … 57 57 the International Conference on Digital Audio Effects (DAFx-00), pages 37–44, 58 58 Uni- versity of Verona, Italy, 2000. 59 (<a href="http:// profs.sci.univr.it/%7Edafx/Final-Papers/ps/Bernardini.ps.gz">60 p s.gz</a>)59 (<a href="http://www.cs.princeton.edu/courses/archive/spr09/cos325/Bernardini.pdf"> 60 pdf</a>) 61 61 62 62 */ … … 122 122 123 123 */ 124 smpl_t aubio_level_lin ( fvec_t * v);124 smpl_t aubio_level_lin (const fvec_t * v); 125 125 126 126 /** compute sound pressure level (SPL) in dB … … 135 135 136 136 */ 137 smpl_t aubio_db_spl ( fvec_t * v);137 smpl_t aubio_db_spl (const fvec_t * v); 138 138 139 139 /** check if buffer level in dB SPL is under a given threshold … … 145 145 146 146 */ 147 uint_t aubio_silence_detection ( fvec_t * v, smpl_t threshold);147 uint_t aubio_silence_detection (const fvec_t * v, smpl_t threshold); 148 148 149 149 /** get buffer level if level >= threshold, 1. otherwise … … 161 161 #endif 162 162 163 #endif /* _AUBIO__MUSICUTILS_H */163 #endif /* AUBIO_MUSICUTILS_H */ -
src/onset/onset.c
r60fc05b rf264b17 46 46 47 47 /* execute onset detection function on iput buffer */ 48 void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset)48 void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset) 49 49 { 50 50 smpl_t isonset = 0; … … 85 85 } 86 86 87 uint_t aubio_onset_get_last ( aubio_onset_t *o)87 uint_t aubio_onset_get_last (const aubio_onset_t *o) 88 88 { 89 89 return o->last_onset - o->delay; 90 90 } 91 91 92 smpl_t aubio_onset_get_last_s ( aubio_onset_t *o)92 smpl_t aubio_onset_get_last_s (const aubio_onset_t *o) 93 93 { 94 94 return aubio_onset_get_last (o) / (smpl_t) (o->samplerate); 95 95 } 96 96 97 smpl_t aubio_onset_get_last_ms ( aubio_onset_t *o)97 smpl_t aubio_onset_get_last_ms (const aubio_onset_t *o) 98 98 { 99 99 return aubio_onset_get_last_s (o) * 1000.; … … 105 105 } 106 106 107 smpl_t aubio_onset_get_silence( aubio_onset_t * o) {107 smpl_t aubio_onset_get_silence(const aubio_onset_t * o) { 108 108 return o->silence; 109 109 } … … 114 114 } 115 115 116 smpl_t aubio_onset_get_threshold( aubio_onset_t * o) {116 smpl_t aubio_onset_get_threshold(const aubio_onset_t * o) { 117 117 return aubio_peakpicker_get_threshold(o->pp); 118 118 } … … 123 123 } 124 124 125 uint_t aubio_onset_get_minioi( aubio_onset_t * o) {125 uint_t aubio_onset_get_minioi(const aubio_onset_t * o) { 126 126 return o->minioi; 127 127 } 128 128 129 129 uint_t aubio_onset_set_minioi_s(aubio_onset_t * o, smpl_t minioi) { 130 return aubio_onset_set_minioi (o, minioi * o->samplerate);131 } 132 133 smpl_t aubio_onset_get_minioi_s( aubio_onset_t * o) {130 return aubio_onset_set_minioi (o, (uint_t)ROUND(minioi * o->samplerate)); 131 } 132 133 smpl_t aubio_onset_get_minioi_s(const aubio_onset_t * o) { 134 134 return aubio_onset_get_minioi (o) / (smpl_t) o->samplerate; 135 135 } … … 139 139 } 140 140 141 smpl_t aubio_onset_get_minioi_ms( aubio_onset_t * o) {141 smpl_t aubio_onset_get_minioi_ms(const aubio_onset_t * o) { 142 142 return aubio_onset_get_minioi_s (o) * 1000.; 143 143 } … … 148 148 } 149 149 150 uint_t aubio_onset_get_delay( aubio_onset_t * o) {150 uint_t aubio_onset_get_delay(const aubio_onset_t * o) { 151 151 return o->delay; 152 152 } … … 156 156 } 157 157 158 smpl_t aubio_onset_get_delay_s( aubio_onset_t * o) {158 smpl_t aubio_onset_get_delay_s(const aubio_onset_t * o) { 159 159 return aubio_onset_get_delay (o) / (smpl_t) o->samplerate; 160 160 } … … 164 164 } 165 165 166 smpl_t aubio_onset_get_delay_ms( aubio_onset_t * o) {166 smpl_t aubio_onset_get_delay_ms(const aubio_onset_t * o) { 167 167 return aubio_onset_get_delay_s (o) * 1000.; 168 168 } 169 169 170 smpl_t aubio_onset_get_descriptor( aubio_onset_t * o) {170 smpl_t aubio_onset_get_descriptor(const aubio_onset_t * o) { 171 171 return o->desc->data[0]; 172 172 } 173 173 174 smpl_t aubio_onset_get_thresholded_descriptor( aubio_onset_t * o) {174 smpl_t aubio_onset_get_thresholded_descriptor(const aubio_onset_t * o) { 175 175 fvec_t * thresholded = aubio_peakpicker_get_thresholded_input(o->pp); 176 176 return thresholded->data[0]; … … 178 178 179 179 /* Allocate memory for an onset detection */ 180 aubio_onset_t * new_aubio_onset (c har_t * onset_mode,180 aubio_onset_t * new_aubio_onset (const char_t * onset_mode, 181 181 uint_t buf_size, uint_t hop_size, uint_t samplerate) 182 182 { … … 187 187 AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size); 188 188 goto beach; 189 } else if ((sint_t)buf_size < 1) {190 AUBIO_ERR("onset: got buffer_size %d, but can not be < 1\n", buf_size);189 } else if ((sint_t)buf_size < 2) { 190 AUBIO_ERR("onset: got buffer_size %d, but can not be < 2\n", buf_size); 191 191 goto beach; 192 192 } else if (buf_size < hop_size) { -
src/onset/onset.h
r60fc05b rf264b17 40 40 41 41 42 #ifndef _AUBIO_ONSET_H43 #define _AUBIO_ONSET_H42 #ifndef AUBIO_ONSET_H 43 #define AUBIO_ONSET_H 44 44 45 45 #ifdef __cplusplus … … 60 60 61 61 */ 62 aubio_onset_t * new_aubio_onset (c har_t * method,62 aubio_onset_t * new_aubio_onset (const char_t * method, 63 63 uint_t buf_size, uint_t hop_size, uint_t samplerate); 64 64 … … 89 89 90 90 */ 91 void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset);91 void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset); 92 92 93 93 /** get the time of the latest onset detected, in samples … … 98 98 99 99 */ 100 uint_t aubio_onset_get_last ( aubio_onset_t *o);100 uint_t aubio_onset_get_last (const aubio_onset_t *o); 101 101 102 102 /** get the time of the latest onset detected, in seconds … … 107 107 108 108 */ 109 smpl_t aubio_onset_get_last_s ( aubio_onset_t *o);109 smpl_t aubio_onset_get_last_s (const aubio_onset_t *o); 110 110 111 111 /** get the time of the latest onset detected, in milliseconds … … 116 116 117 117 */ 118 smpl_t aubio_onset_get_last_ms ( aubio_onset_t *o);118 smpl_t aubio_onset_get_last_ms (const aubio_onset_t *o); 119 119 120 120 /** set onset detection silence threshold … … 133 133 134 134 */ 135 smpl_t aubio_onset_get_silence( aubio_onset_t * o);135 smpl_t aubio_onset_get_silence(const aubio_onset_t * o); 136 136 137 137 /** get onset detection function … … 141 141 142 142 */ 143 smpl_t aubio_onset_get_descriptor ( aubio_onset_t *o);143 smpl_t aubio_onset_get_descriptor (const aubio_onset_t *o); 144 144 145 145 /** get thresholded onset detection function … … 149 149 150 150 */ 151 smpl_t aubio_onset_get_thresholded_descriptor ( aubio_onset_t *o);151 smpl_t aubio_onset_get_thresholded_descriptor (const aubio_onset_t *o); 152 152 153 153 /** set onset detection peak picking threshold … … 220 220 221 221 */ 222 uint_t aubio_onset_get_minioi( aubio_onset_t * o);222 uint_t aubio_onset_get_minioi(const aubio_onset_t * o); 223 223 224 224 /** get minimum inter onset interval in seconds … … 229 229 230 230 */ 231 smpl_t aubio_onset_get_minioi_s( aubio_onset_t * o);231 smpl_t aubio_onset_get_minioi_s(const aubio_onset_t * o); 232 232 233 233 /** get minimum inter onset interval in milliseconds … … 238 238 239 239 */ 240 smpl_t aubio_onset_get_minioi_ms( aubio_onset_t * o);240 smpl_t aubio_onset_get_minioi_ms(const aubio_onset_t * o); 241 241 242 242 /** get delay in samples … … 247 247 248 248 */ 249 uint_t aubio_onset_get_delay( aubio_onset_t * o);249 uint_t aubio_onset_get_delay(const aubio_onset_t * o); 250 250 251 251 /** get delay in seconds … … 256 256 257 257 */ 258 smpl_t aubio_onset_get_delay_s( aubio_onset_t * o);258 smpl_t aubio_onset_get_delay_s(const aubio_onset_t * o); 259 259 260 260 /** get delay in milliseconds … … 265 265 266 266 */ 267 smpl_t aubio_onset_get_delay_ms( aubio_onset_t * o);267 smpl_t aubio_onset_get_delay_ms(const aubio_onset_t * o); 268 268 269 269 /** get onset peak picking threshold … … 273 273 274 274 */ 275 smpl_t aubio_onset_get_threshold( aubio_onset_t * o);275 smpl_t aubio_onset_get_threshold(const aubio_onset_t * o); 276 276 277 277 /** delete onset detection object … … 286 286 #endif 287 287 288 #endif /* _AUBIO_ONSET_H */288 #endif /* AUBIO_ONSET_H */ -
src/onset/peakpicker.h
r60fc05b rf264b17 27 27 */ 28 28 29 #ifndef _AUBIO_PEAKPICK_H30 #define _AUBIO_PEAKPICK_H29 #ifndef AUBIO_PEAKPICK_H 30 #define AUBIO_PEAKPICK_H 31 31 32 32 #ifdef __cplusplus … … 55 55 #endif 56 56 57 #endif /* _AUBIO_PEAKPICK_H */57 #endif /* AUBIO_PEAKPICK_H */ -
src/pitch/pitch.c
r60fc05b rf264b17 62 62 63 63 /** callback to get pitch candidate, defined below */ 64 typedef void (*aubio_pitch_detect_t) (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);64 typedef void (*aubio_pitch_detect_t) (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 65 65 66 66 /** callback to convert pitch from one unit to another, defined below */ … … 79 79 void *p_object; /**< pointer to pitch object */ 80 80 aubio_filter_t *filter; /**< filter */ 81 fvec_t *filtered; /**< filtered input */ 81 82 aubio_pvoc_t *pv; /**< phase vocoder for mcomb */ 82 83 cvec_t *fftgrain; /**< spectral frame for mcomb */ … … 89 90 90 91 /* callback functions for pitch detection */ 91 static void aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);92 static void aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);93 static void aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);94 static void aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);95 static void aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);96 static void aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);92 static void aubio_pitch_do_mcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 93 static void aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 94 static void aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 95 static void aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 96 static void aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 97 static void aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf); 97 98 98 99 /* conversion functions for frequency conversions */ … … 102 103 103 104 /* adapter to stack ibuf new samples at the end of buf, and trim `buf` to `bufsize` */ 104 void aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf);105 void aubio_pitch_slideblock (aubio_pitch_t * p, const fvec_t * ibuf); 105 106 106 107 107 108 aubio_pitch_t * 108 new_aubio_pitch (c har_t * pitch_mode,109 new_aubio_pitch (const char_t * pitch_mode, 109 110 uint_t bufsize, uint_t hopsize, uint_t samplerate) 110 111 { … … 133 134 // check parameters are valid 134 135 if ((sint_t)hopsize < 1) { 135 AUBIO_ERR(" onset: got hopsize %d, but can not be < 1\n", hopsize);136 AUBIO_ERR("pitch: got hopsize %d, but can not be < 1\n", hopsize); 136 137 goto beach; 137 138 } else if ((sint_t)bufsize < 1) { 138 AUBIO_ERR(" onset: got buffer_size %d, but can not be < 1\n", bufsize);139 AUBIO_ERR("pitch: got buffer_size %d, but can not be < 1\n", bufsize); 139 140 goto beach; 140 141 } else if (bufsize < hopsize) { 141 AUBIO_ERR(" onset: hop size (%d) is larger than win size (%d)\n", bufsize, hopsize);142 AUBIO_ERR("pitch: hop size (%d) is larger than win size (%d)\n", bufsize, hopsize); 142 143 goto beach; 143 144 } else if ((sint_t)samplerate < 1) { 144 AUBIO_ERR(" onset: samplerate (%d) can not be < 1\n", samplerate);145 AUBIO_ERR("pitch: samplerate (%d) can not be < 1\n", samplerate); 145 146 goto beach; 146 147 } … … 161 162 break; 162 163 case aubio_pitcht_mcomb: 164 p->filtered = new_fvec (hopsize); 163 165 p->pv = new_aubio_pvoc (bufsize, hopsize); 164 166 p->fftgrain = new_cvec (bufsize); … … 210 212 break; 211 213 case aubio_pitcht_mcomb: 214 del_fvec (p->filtered); 212 215 del_aubio_pvoc (p->pv); 213 216 del_cvec (p->fftgrain); … … 238 241 239 242 void 240 aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf) 241 { 242 uint_t j = 0, overlap_size = 0; 243 overlap_size = p->buf->length - ibuf->length; 243 aubio_pitch_slideblock (aubio_pitch_t * p, const fvec_t * ibuf) 244 { 245 uint_t overlap_size = p->buf->length - ibuf->length; 246 #if 1 //!HAVE_MEMCPY_HACKS 247 uint_t j; 244 248 for (j = 0; j < overlap_size; j++) { 245 249 p->buf->data[j] = p->buf->data[j + ibuf->length]; … … 248 252 p->buf->data[j + overlap_size] = ibuf->data[j]; 249 253 } 254 #else 255 smpl_t *data = p->buf->data; 256 smpl_t *newdata = ibuf->data; 257 memmove(data, data + ibuf->length, overlap_size); 258 memcpy(data + overlap_size, newdata, ibuf->length); 259 #endif 250 260 } 251 261 252 262 uint_t 253 aubio_pitch_set_unit (aubio_pitch_t * p, c har_t * pitch_unit)263 aubio_pitch_set_unit (aubio_pitch_t * p, const char_t * pitch_unit) 254 264 { 255 265 uint_t err = AUBIO_OK; … … 336 346 /* do method, calling the detection callback, then the conversion callback */ 337 347 void 338 aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)348 aubio_pitch_do (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 339 349 { 340 350 p->detect_cb (p, ibuf, obuf); … … 347 357 /* do method for each algorithm */ 348 358 void 349 aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)350 { 351 aubio_filter_do (p->filter, ibuf);359 aubio_pitch_do_mcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 360 { 361 aubio_filter_do_outplace (p->filter, ibuf, p->filtered); 352 362 aubio_pvoc_do (p->pv, ibuf, p->fftgrain); 353 363 aubio_pitchmcomb_do (p->p_object, p->fftgrain, obuf); … … 356 366 357 367 void 358 aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)368 aubio_pitch_do_yin (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 359 369 { 360 370 smpl_t pitch = 0.; … … 372 382 373 383 void 374 aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf)384 aubio_pitch_do_yinfft (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * obuf) 375 385 { 376 386 smpl_t pitch = 0.; … … 387 397 388 398 void 389 aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)399 aubio_pitch_do_specacf (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) 390 400 { 391 401 smpl_t pitch = 0., period; … … 403 413 404 414 void 405 aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)415 aubio_pitch_do_fcomb (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) 406 416 { 407 417 aubio_pitch_slideblock (p, ibuf); … … 411 421 412 422 void 413 aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out)423 aubio_pitch_do_schmitt (aubio_pitch_t * p, const fvec_t * ibuf, fvec_t * out) 414 424 { 415 425 smpl_t period, pitch = 0.; -
src/pitch/pitch.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_PITCH_H22 #define _AUBIO_PITCH_H21 #ifndef AUBIO_PITCH_H 22 #define AUBIO_PITCH_H 23 23 24 24 #ifdef __cplusplus … … 108 108 109 109 */ 110 void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, fvec_t * out);110 void aubio_pitch_do (aubio_pitch_t * o, const fvec_t * in, fvec_t * out); 111 111 112 112 /** change yin or yinfft tolerance threshold … … 135 135 136 136 */ 137 aubio_pitch_t *new_aubio_pitch (c har_t * method,137 aubio_pitch_t *new_aubio_pitch (const char_t * method, 138 138 uint_t buf_size, uint_t hop_size, uint_t samplerate); 139 139 … … 146 146 147 147 */ 148 uint_t aubio_pitch_set_unit (aubio_pitch_t * o, c har_t * mode);148 uint_t aubio_pitch_set_unit (aubio_pitch_t * o, const char_t * mode); 149 149 150 150 /** set the silence threshold of the pitch detection object … … 180 180 #endif 181 181 182 #endif /* _AUBIO_PITCH_H */182 #endif /* AUBIO_PITCH_H */ -
src/pitch/pitchfcomb.c
r60fc05b rf264b17 64 64 /* input must be stepsize long */ 65 65 void 66 aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, fvec_t * output)66 aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, const fvec_t * input, fvec_t * output) 67 67 { 68 68 uint_t k, l, maxharm = 0; -
src/pitch/pitchfcomb.h
r60fc05b rf264b17 35 35 */ 36 36 37 #ifndef _AUBIO_PITCHFCOMB_H38 #define _AUBIO_PITCHFCOMB_H37 #ifndef AUBIO_PITCHFCOMB_H 38 #define AUBIO_PITCHFCOMB_H 39 39 40 40 #ifdef __cplusplus … … 52 52 53 53 */ 54 void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input,54 void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, const fvec_t * input, 55 55 fvec_t * output); 56 56 … … 74 74 #endif 75 75 76 #endif /* _AUBIO_PITCHFCOMB_H */76 #endif /* AUBIO_PITCHFCOMB_H */ -
src/pitch/pitchmcomb.c
r60fc05b rf264b17 32 32 uint_t length); 33 33 uint_t aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, 34 fvec_t * X);35 void aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * oldmag);36 void aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag);34 const fvec_t * X); 35 void aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, const fvec_t * oldmag); 36 void aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, const fvec_t * newmag); 37 37 /* not used but useful : sort by amplitudes (or anything else) 38 38 * sort_pitchpeak(peaks, length); … … 43 43 void aubio_pitchmcomb_sort_peak (aubio_spectralpeak_t * peaks, uint_t nbins); 44 44 /** select the best candidates */ 45 uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, c vec_t * fftgrain,45 uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, 46 46 smpl_t * cands); 47 47 … … 102 102 103 103 void 104 aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, c vec_t * fftgrain, fvec_t * output)104 aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, fvec_t * output) 105 105 { 106 106 uint_t j; … … 135 135 136 136 uint_t 137 aubio_pitch_cands (aubio_pitchmcomb_t * p, c vec_t * fftgrain, smpl_t * cands)137 aubio_pitch_cands (aubio_pitchmcomb_t * p, const cvec_t * fftgrain, smpl_t * cands) 138 138 { 139 139 uint_t j; … … 166 166 167 167 void 168 aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag)168 aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, const fvec_t * newmag) 169 169 { 170 170 fvec_t *mag = (fvec_t *) p->scratch; … … 198 198 199 199 void 200 aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag)200 aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, const fvec_t * newmag) 201 201 { 202 202 aubio_spectralpeak_t *peaks = (aubio_spectralpeak_t *) p->peaks; … … 286 286 */ 287 287 uint_t 288 aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, fvec_t * X)288 aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, const fvec_t * X) 289 289 { 290 290 uint_t j, ispeak, count = 0; … … 336 336 uint_t run = 0; 337 337 for (cur = 0; cur < nbins; cur++) { 338 run = cur + 1; 339 for (run = cur; run < nbins; run++) { 338 for (run = cur + 1; run < nbins; run++) { 340 339 if (candidates[run]->ene > candidates[cur]->ene) 341 340 CAND_SWAP (candidates[run], candidates[cur]); … … 352 351 uint_t run = 0; 353 352 for (cur = 0; cur < nbins; cur++) { 354 run = cur + 1; 355 for (run = cur; run < nbins; run++) { 353 for (run = cur + 1; run < nbins; run++) { 356 354 if (candidates[run]->ebin < candidates[cur]->ebin) 357 355 CAND_SWAP (candidates[run], candidates[cur]); … … 367 365 uint_t i, j; 368 366 uint_t spec_size; 369 p->spec_partition = 4;367 p->spec_partition = 2; 370 368 p->ncand = 5; 371 369 p->npartials = 5; … … 379 377 p->phasefreq = bufsize / hopsize / TWO_PI; 380 378 p->phasediff = TWO_PI * hopsize / bufsize; 381 spec_size = bufsize / p->spec_partition ;379 spec_size = bufsize / p->spec_partition + 1; 382 380 //p->pickerfn = quadpick; 383 381 //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348); -
src/pitch/pitchmcomb.h
r60fc05b rf264b17 36 36 */ 37 37 38 #ifndef _AUBIO_PITCHMCOMB_H39 #define _AUBIO_PITCHMCOMB_H38 #ifndef AUBIO_PITCHMCOMB_H 39 #define AUBIO_PITCHMCOMB_H 40 40 41 41 #ifdef __cplusplus … … 53 53 54 54 */ 55 void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, c vec_t * in_fftgrain,55 void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, const cvec_t * in_fftgrain, 56 56 fvec_t * out_cands); 57 57 … … 75 75 #endif 76 76 77 #endif /* _AUBIO_PITCHMCOMB_H */77 #endif /* AUBIO_PITCHMCOMB_H */ -
src/pitch/pitchschmitt.c
r60fc05b rf264b17 48 48 49 49 void 50 aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * input,50 aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, const fvec_t * input, 51 51 fvec_t * output) 52 52 { -
src/pitch/pitchschmitt.h
r60fc05b rf264b17 35 35 */ 36 36 37 #ifndef _AUBIO_PITCHSCHMITT_H38 #define _AUBIO_PITCHSCHMITT_H37 #ifndef AUBIO_PITCHSCHMITT_H 38 #define AUBIO_PITCHSCHMITT_H 39 39 40 40 #ifdef __cplusplus … … 52 52 53 53 */ 54 void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * samples_in,54 void aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, const fvec_t * samples_in, 55 55 fvec_t * cands_out); 56 56 … … 73 73 #endif 74 74 75 #endif /* _AUBIO_PITCHSCHMITT_H */ 76 75 #endif /* AUBIO_PITCHSCHMITT_H */ -
src/pitch/pitchspecacf.c
r60fc05b rf264b17 55 55 56 56 void 57 aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, fvec_t * input, fvec_t * output)57 aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, const fvec_t * input, fvec_t * output) 58 58 { 59 59 uint_t l, tau; … … 92 92 93 93 smpl_t 94 aubio_pitchspecacf_get_confidence ( aubio_pitchspecacf_t * o) {94 aubio_pitchspecacf_get_confidence (const aubio_pitchspecacf_t * o) { 95 95 // no confidence for now 96 96 return o->confidence; … … 105 105 106 106 smpl_t 107 aubio_pitchspecacf_get_tolerance ( aubio_pitchspecacf_t * p)107 aubio_pitchspecacf_get_tolerance (const aubio_pitchspecacf_t * p) 108 108 { 109 109 return p->tol; -
src/pitch/pitchspecacf.h
r60fc05b rf264b17 39 39 */ 40 40 41 #ifndef _AUBIO_PITCHSPECACF_H42 #define _AUBIO_PITCHSPECACF_H41 #ifndef AUBIO_PITCHSPECACF_H 42 #define AUBIO_PITCHSPECACF_H 43 43 44 44 #ifdef __cplusplus … … 56 56 57 57 */ 58 void aubio_pitchspecacf_do (aubio_pitchspecacf_t * o, fvec_t * samples_in, fvec_t * cands_out);58 void aubio_pitchspecacf_do (aubio_pitchspecacf_t * o, const fvec_t * samples_in, fvec_t * cands_out); 59 59 /** creation of the pitch detection object 60 60 … … 77 77 78 78 */ 79 smpl_t aubio_pitchspecacf_get_tolerance ( aubio_pitchspecacf_t * o);79 smpl_t aubio_pitchspecacf_get_tolerance (const aubio_pitchspecacf_t * o); 80 80 81 81 /** set tolerance parameter for `specacf` pitch detection object … … 95 95 96 96 */ 97 smpl_t aubio_pitchspecacf_get_confidence ( aubio_pitchspecacf_t * o);97 smpl_t aubio_pitchspecacf_get_confidence (const aubio_pitchspecacf_t * o); 98 98 99 99 #ifdef __cplusplus … … 101 101 #endif 102 102 103 #endif /* _AUBIO_PITCHSPECACF_H */103 #endif /* AUBIO_PITCHSPECACF_H */ -
src/pitch/pitchyin.c
r60fc05b rf264b17 41 41 42 42 /** compute difference function 43 44 \param input input signal 43 44 \param input input signal 45 45 \param yinbuf output buffer to store difference function (half shorter than input) 46 46 … … 48 48 void aubio_pitchyin_diff (fvec_t * input, fvec_t * yinbuf); 49 49 50 /** in place computation of the YIN cumulative normalised function 51 52 \param yinbuf input signal (a square difference function), also used to store function 50 /** in place computation of the YIN cumulative normalised function 51 52 \param yinbuf input signal (a square difference function), also used to store function 53 53 54 54 */ … … 56 56 57 57 /** detect pitch in a YIN function 58 58 59 59 \param yinbuf input buffer as computed by aubio_pitchyin_getcum 60 60 61 61 */ 62 uint_t aubio_pitchyin_getpitch ( fvec_t * yinbuf);62 uint_t aubio_pitchyin_getpitch (const fvec_t * yinbuf); 63 63 64 64 aubio_pitchyin_t * … … 112 112 113 113 uint_t 114 aubio_pitchyin_getpitch ( fvec_t * yin)114 aubio_pitchyin_getpitch (const fvec_t * yin) 115 115 { 116 116 uint_t tau = 1; … … 131 131 /* all the above in one */ 132 132 void 133 aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * input, fvec_t * out)133 aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out) 134 134 { 135 135 smpl_t tol = o->tol; -
src/pitch/pitchyin.h
r60fc05b rf264b17 36 36 */ 37 37 38 #ifndef _AUBIO_PITCHYIN_H39 #define _AUBIO_PITCHYIN_H38 #ifndef AUBIO_PITCHYIN_H 39 #define AUBIO_PITCHYIN_H 40 40 41 41 #ifdef __cplusplus … … 67 67 68 68 */ 69 void aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * samples_in, fvec_t * cands_out);69 void aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * samples_in, fvec_t * cands_out); 70 70 71 71 … … 98 98 #endif 99 99 100 #endif /* _AUBIO_PITCHYIN_H */100 #endif /* AUBIO_PITCHYIN_H */ -
src/pitch/pitchyinfft.c
r60fc05b rf264b17 99 99 100 100 void 101 aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output)101 aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, const fvec_t * input, fvec_t * output) 102 102 { 103 103 uint_t tau, l; … … 108 108 smpl_t tmp = 0., sum = 0.; 109 109 // window the input 110 for (l = 0; l < input->length; l++) { 111 p->winput->data[l] = p->win->data[l] * input->data[l]; 112 } 110 fvec_weighted_copy(input, p->win, p->winput); 113 111 // get the real / imag parts of its fft 114 112 aubio_fft_do_complex (p->fft, p->winput, fftout); -
src/pitch/pitchyinfft.h
r60fc05b rf264b17 36 36 */ 37 37 38 #ifndef _AUBIO_PITCHYINFFT_H39 #define _AUBIO_PITCHYINFFT_H38 #ifndef AUBIO_PITCHYINFFT_H 39 #define AUBIO_PITCHYINFFT_H 40 40 41 41 #ifdef __cplusplus … … 53 53 54 54 */ 55 void aubio_pitchyinfft_do (aubio_pitchyinfft_t * o, fvec_t * samples_in, fvec_t * cands_out);55 void aubio_pitchyinfft_do (aubio_pitchyinfft_t * o, const fvec_t * samples_in, fvec_t * cands_out); 56 56 /** creation of the pitch detection object 57 57 … … 97 97 #endif 98 98 99 #endif /* _AUBIO_PITCHYINFFT_H */99 #endif /* AUBIO_PITCHYINFFT_H */ -
src/spectral/fft.c
r60fc05b rf264b17 65 65 #ifdef HAVE_FFTW3F 66 66 #if HAVE_AUBIO_DOUBLE 67 # warning"Using aubio in double precision with fftw3 in single precision"67 #error "Using aubio in double precision with fftw3 in single precision" 68 68 #endif /* HAVE_AUBIO_DOUBLE */ 69 69 #define real_t float 70 #el se/* HAVE_FFTW3F */70 #elif defined (HAVE_FFTW3) /* HAVE_FFTW3F */ 71 71 #if !HAVE_AUBIO_DOUBLE 72 # warning"Using aubio in single precision with fftw3 in double precision"72 #error "Using aubio in single precision with fftw3 in double precision" 73 73 #endif /* HAVE_AUBIO_DOUBLE */ 74 74 #define real_t double … … 144 144 aubio_fft_t * new_aubio_fft (uint_t winsize) { 145 145 aubio_fft_t * s = AUBIO_NEW(aubio_fft_t); 146 if ((sint_t)winsize < 1) {147 AUBIO_ERR("fft: got winsize %d, but can not be < 1\n", winsize);146 if ((sint_t)winsize < 2) { 147 AUBIO_ERR("fft: got winsize %d, but can not be < 2\n", winsize); 148 148 goto beach; 149 149 } … … 231 231 } 232 232 233 void aubio_fft_do(aubio_fft_t * s, fvec_t * input, cvec_t * spectrum) {233 void aubio_fft_do(aubio_fft_t * s, const fvec_t * input, cvec_t * spectrum) { 234 234 aubio_fft_do_complex(s, input, s->compspec); 235 235 aubio_fft_get_spectrum(s->compspec, spectrum); 236 236 } 237 237 238 void aubio_fft_rdo(aubio_fft_t * s, c vec_t * spectrum, fvec_t * output) {238 void aubio_fft_rdo(aubio_fft_t * s, const cvec_t * spectrum, fvec_t * output) { 239 239 aubio_fft_get_realimag(spectrum, s->compspec); 240 240 aubio_fft_rdo_complex(s, s->compspec, output); 241 241 } 242 242 243 void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) {243 void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compspec) { 244 244 uint_t i; 245 245 #ifndef HAVE_MEMCPY_HACKS … … 292 292 } 293 293 294 void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) {294 void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * output) { 295 295 uint_t i; 296 296 #ifdef HAVE_FFTW3 … … 347 347 } 348 348 349 void aubio_fft_get_spectrum( fvec_t * compspec, cvec_t * spectrum) {349 void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum) { 350 350 aubio_fft_get_phas(compspec, spectrum); 351 351 aubio_fft_get_norm(compspec, spectrum); 352 352 } 353 353 354 void aubio_fft_get_realimag(c vec_t * spectrum, fvec_t * compspec) {354 void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec) { 355 355 aubio_fft_get_imag(spectrum, compspec); 356 356 aubio_fft_get_real(spectrum, compspec); 357 357 } 358 358 359 void aubio_fft_get_phas( fvec_t * compspec, cvec_t * spectrum) {359 void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum) { 360 360 uint_t i; 361 361 if (compspec->data[0] < 0) { … … 375 375 } 376 376 377 void aubio_fft_get_norm( fvec_t * compspec, cvec_t * spectrum) {377 void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum) { 378 378 uint_t i = 0; 379 379 spectrum->norm[0] = ABS(compspec->data[0]); … … 386 386 } 387 387 388 void aubio_fft_get_imag(c vec_t * spectrum, fvec_t * compspec) {388 void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec) { 389 389 uint_t i; 390 390 for (i = 1; i < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; i++) { … … 394 394 } 395 395 396 void aubio_fft_get_real(c vec_t * spectrum, fvec_t * compspec) {396 void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec) { 397 397 uint_t i; 398 398 for (i = 0; i < compspec->length / 2 + 1; i++) { -
src/spectral/fft.h
r60fc05b rf264b17 32 32 */ 33 33 34 #ifndef _AUBIO_FFT_H35 #define _AUBIO_FFT_H34 #ifndef AUBIO_FFT_H 35 #define AUBIO_FFT_H 36 36 37 37 #ifdef __cplusplus … … 66 66 67 67 */ 68 void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum);68 void aubio_fft_do (aubio_fft_t *s, const fvec_t * input, cvec_t * spectrum); 69 69 /** compute backward (inverse) FFT 70 70 … … 74 74 75 75 */ 76 void aubio_fft_rdo (aubio_fft_t *s, c vec_t * spectrum, fvec_t * output);76 void aubio_fft_rdo (aubio_fft_t *s, const cvec_t * spectrum, fvec_t * output); 77 77 78 78 /** compute forward FFT … … 83 83 84 84 */ 85 void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec);85 void aubio_fft_do_complex (aubio_fft_t *s, const fvec_t * input, fvec_t * compspec); 86 86 /** compute backward (inverse) FFT from real/imag 87 87 … … 91 91 92 92 */ 93 void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output);93 void aubio_fft_rdo_complex (aubio_fft_t *s, const fvec_t * compspec, fvec_t * output); 94 94 95 95 /** convert real/imag spectrum to norm/phas spectrum … … 99 99 100 100 */ 101 void aubio_fft_get_spectrum( fvec_t * compspec, cvec_t * spectrum);101 void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum); 102 102 /** convert real/imag spectrum to norm/phas spectrum 103 103 … … 106 106 107 107 */ 108 void aubio_fft_get_realimag(c vec_t * spectrum, fvec_t * compspec);108 void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec); 109 109 110 110 /** compute phas spectrum from real/imag parts … … 114 114 115 115 */ 116 void aubio_fft_get_phas( fvec_t * compspec, cvec_t * spectrum);116 void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum); 117 117 /** compute imaginary part from the norm/phas cvec 118 118 … … 121 121 122 122 */ 123 void aubio_fft_get_imag(c vec_t * spectrum, fvec_t * compspec);123 void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec); 124 124 125 125 /** compute norm component from real/imag parts … … 129 129 130 130 */ 131 void aubio_fft_get_norm( fvec_t * compspec, cvec_t * spectrum);131 void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum); 132 132 /** compute real part from norm/phas components 133 133 … … 136 136 137 137 */ 138 void aubio_fft_get_real(c vec_t * spectrum, fvec_t * compspec);138 void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec); 139 139 140 140 #ifdef __cplusplus … … 142 142 #endif 143 143 144 #endif /* _AUBIO_FFT_H */144 #endif /* AUBIO_FFT_H */ -
src/spectral/filterbank.c
r60fc05b rf264b17 57 57 58 58 void 59 aubio_filterbank_do (aubio_filterbank_t * f, c vec_t * in, fvec_t * out)59 aubio_filterbank_do (aubio_filterbank_t * f, const cvec_t * in, fvec_t * out) 60 60 { 61 uint_t j, fn; 61 /* apply filter to all input channel, provided out has enough channels */ 62 //uint_t max_filters = MIN (f->n_filters, out->length); 63 //uint_t max_length = MIN (in->length, f->filters->length); 62 64 63 /* apply filter to all input channel, provided out has enough channels */ 64 uint_t max_filters = MIN (f->n_filters, out->length); 65 uint_t max_length = MIN (in->length, f->filters->length); 65 // view cvec->norm as fvec->data 66 fvec_t tmp; 67 tmp.length = in->length; 68 tmp.data = in->norm; 66 69 67 /* reset all values in output vector */ 68 fvec_zeros (out); 69 70 /* for each filter */ 71 for (fn = 0; fn < max_filters; fn++) { 72 /* for each sample */ 73 for (j = 0; j < max_length; j++) { 74 out->data[fn] += in->norm[j] * f->filters->data[fn][j]; 75 } 76 } 70 fmat_vecmul(f->filters, &tmp, out); 77 71 78 72 return; … … 80 74 81 75 fmat_t * 82 aubio_filterbank_get_coeffs ( aubio_filterbank_t * f)76 aubio_filterbank_get_coeffs (const aubio_filterbank_t * f) 83 77 { 84 78 return f->filters; … … 86 80 87 81 uint_t 88 aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filter_coeffs)82 aubio_filterbank_set_coeffs (aubio_filterbank_t * f, const fmat_t * filter_coeffs) 89 83 { 90 84 fmat_copy(filter_coeffs, f->filters); -
src/spectral/filterbank.h
r60fc05b rf264b17 30 30 */ 31 31 32 #ifndef _AUBIO_FILTERBANK_H33 #define _AUBIO_FILTERBANK_H32 #ifndef AUBIO_FILTERBANK_H 33 #define AUBIO_FILTERBANK_H 34 34 35 35 #ifdef __cplusplus … … 67 67 68 68 */ 69 void aubio_filterbank_do (aubio_filterbank_t * f, c vec_t * in, fvec_t * out);69 void aubio_filterbank_do (aubio_filterbank_t * f, const cvec_t * in, fvec_t * out); 70 70 71 71 /** return a pointer to the matrix object containing all filter coefficients … … 74 74 75 75 */ 76 fmat_t *aubio_filterbank_get_coeffs ( aubio_filterbank_t * f);76 fmat_t *aubio_filterbank_get_coeffs (const aubio_filterbank_t * f); 77 77 78 78 /** copy filter coefficients to the filterbank … … 82 82 83 83 */ 84 uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, fmat_t * filters);84 uint_t aubio_filterbank_set_coeffs (aubio_filterbank_t * f, const fmat_t * filters); 85 85 86 86 #ifdef __cplusplus … … 88 88 #endif 89 89 90 #endif /* _AUBIO_FILTERBANK_H */90 #endif /* AUBIO_FILTERBANK_H */ -
src/spectral/filterbank_mel.c
r60fc05b rf264b17 30 30 uint_t 31 31 aubio_filterbank_set_triangle_bands (aubio_filterbank_t * fb, 32 fvec_t * freqs, smpl_t samplerate)32 const fvec_t * freqs, smpl_t samplerate) 33 33 { 34 34 -
src/spectral/filterbank_mel.h
r60fc05b rf264b17 32 32 */ 33 33 34 #ifndef _AUBIO_FILTERBANK_MEL_H35 #define _AUBIO_FILTERBANK_MEL_H34 #ifndef AUBIO_FILTERBANK_MEL_H 35 #define AUBIO_FILTERBANK_MEL_H 36 36 37 37 #ifdef __cplusplus … … 51 51 */ 52 52 uint_t aubio_filterbank_set_triangle_bands (aubio_filterbank_t * fb, 53 fvec_t * freqs, smpl_t samplerate);53 const fvec_t * freqs, smpl_t samplerate); 54 54 55 55 /** filterbank initialization for Mel filters using Slaney's coefficients … … 70 70 #endif 71 71 72 #endif /* _AUBIO_FILTERBANK_MEL_H */72 #endif /* AUBIO_FILTERBANK_MEL_H */ -
src/spectral/mfcc.c
r60fc05b rf264b17 68 68 mfcc->in_dct = new_fvec (n_filters); 69 69 70 mfcc->dct_coeffs = new_fmat (n_ filters, n_coefs);70 mfcc->dct_coeffs = new_fmat (n_coefs, n_filters); 71 71 72 /* compute DCT transform dct_coeffs[ i][j] as72 /* compute DCT transform dct_coeffs[j][i] as 73 73 cos ( j * (i+.5) * PI / n_filters ) */ 74 74 scaling = 1. / SQRT (n_filters / 2.); 75 75 for (i = 0; i < n_filters; i++) { 76 76 for (j = 0; j < n_coefs; j++) { 77 mfcc->dct_coeffs->data[ i][j] =77 mfcc->dct_coeffs->data[j][i] = 78 78 scaling * COS (j * (i + 0.5) * PI / n_filters); 79 79 } 80 mfcc->dct_coeffs->data[ i][0] *= SQRT (2.) / 2.;80 mfcc->dct_coeffs->data[0][i] *= SQRT (2.) / 2.; 81 81 } 82 82 83 83 return mfcc; 84 } ;84 } 85 85 86 86 void … … 101 101 102 102 void 103 aubio_mfcc_do (aubio_mfcc_t * mf, c vec_t * in, fvec_t * out)103 aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out) 104 104 { 105 uint_t j, k;106 107 105 /* compute filterbank */ 108 106 aubio_filterbank_do (mf->fb, in, mf->in_dct); … … 114 112 //fvec_pow (mf->in_dct, 3.); 115 113 116 /* zeros output */ 117 fvec_zeros(out); 118 119 /* compute discrete cosine transform */ 120 for (j = 0; j < mf->n_filters; j++) { 121 for (k = 0; k < mf->n_coefs; k++) { 122 out->data[k] += mf->in_dct->data[j] 123 * mf->dct_coeffs->data[j][k]; 124 } 125 } 114 /* compute mfccs */ 115 fmat_vecmul(mf->dct_coeffs, mf->in_dct, out); 126 116 127 117 return; -
src/spectral/mfcc.h
r60fc05b rf264b17 35 35 */ 36 36 37 #ifndef _AUBIO_MFCC_H38 #define _AUBIO_MFCC_H37 #ifndef AUBIO_MFCC_H 38 #define AUBIO_MFCC_H 39 39 40 40 #ifdef __cplusplus … … 71 71 72 72 */ 73 void aubio_mfcc_do (aubio_mfcc_t * mf, c vec_t * in, fvec_t * out);73 void aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out); 74 74 75 75 #ifdef __cplusplus … … 77 77 #endif 78 78 79 #endif /* _AUBIO_MFCC_H */79 #endif /* AUBIO_MFCC_H */ -
src/spectral/phasevoc.c
r60fc05b rf264b17 45 45 46 46 /** returns data and dataold slided by hop_s */ 47 static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, fvec_t *new);47 static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, const fvec_t *new); 48 48 49 49 /** do additive synthesis from 'old' and 'cur' */ 50 50 static void aubio_pvoc_addsynth(aubio_pvoc_t *pv, fvec_t * synthnew); 51 51 52 void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) {52 void aubio_pvoc_do(aubio_pvoc_t *pv, const fvec_t * datanew, cvec_t *fftgrain) { 53 53 /* slide */ 54 54 aubio_pvoc_swapbuffers(pv, datanew); … … 65 65 aubio_fft_rdo(pv->fft,fftgrain,pv->synth); 66 66 /* unshift */ 67 fvec_shift(pv->synth); 67 fvec_ishift(pv->synth); 68 /* windowing */ 69 // if overlap = 50%, do not apply window (identity) 70 if (pv->hop_s * 2 < pv->win_s) { 71 fvec_weight(pv->synth, pv->w); 72 } 68 73 /* additive synthesis */ 69 74 aubio_pvoc_addsynth(pv, synthnew); … … 80 85 AUBIO_ERR("pvoc: got hop_size %d, but can not be < 1\n", hop_s); 81 86 goto beach; 82 } else if ((sint_t)win_s < 1) {83 AUBIO_ERR("pvoc: got buffer_size %d, but can not be < 1\n", win_s);87 } else if ((sint_t)win_s < 2) { 88 AUBIO_ERR("pvoc: got buffer_size %d, but can not be < 2\n", win_s); 84 89 goto beach; 85 90 } else if (win_s < hop_s) { … … 89 94 90 95 pv->fft = new_aubio_fft (win_s); 96 if (pv->fft == NULL) { 97 goto beach; 98 } 91 99 92 100 /* remember old */ … … 118 126 pv->hop_datasize = pv->hop_s * sizeof(smpl_t); 119 127 120 pv->scale = pv->hop_s * 2. / pv->win_s; 128 // for reconstruction with 75% overlap 129 if (win_s == hop_s * 4) { 130 pv->scale = 2./3.; 131 } else if (win_s == hop_s * 8) { 132 pv->scale = 1./3.; 133 } else if (win_s == hop_s * 2) { 134 pv->scale = 1.; 135 } else { 136 pv->scale = .5; 137 } 121 138 122 139 return pv; … … 137 154 } 138 155 139 static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, fvec_t *new)156 static void aubio_pvoc_swapbuffers(aubio_pvoc_t *pv, const fvec_t *new) 140 157 { 141 158 /* some convenience pointers */ … … 143 160 smpl_t * dataold = pv->dataold->data; 144 161 smpl_t * datanew = new->data; 145 #if !HAVE_MEMCPY_HACKS162 #ifndef HAVE_MEMCPY_HACKS 146 163 uint_t i; 147 164 for (i = 0; i < pv->end; i++) -
src/spectral/phasevoc.h
r60fc05b rf264b17 32 32 */ 33 33 34 #ifndef _AUBIO_PHASEVOC_H35 #define _AUBIO_PHASEVOC_H34 #ifndef AUBIO_PHASEVOC_H 35 #define AUBIO_PHASEVOC_H 36 36 37 37 #ifdef __cplusplus … … 68 68 69 69 */ 70 void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t *in, cvec_t * fftgrain);70 void aubio_pvoc_do(aubio_pvoc_t *pv, const fvec_t *in, cvec_t * fftgrain); 71 71 /** compute signal from spectral frame 72 72 … … 100 100 #endif 101 101 102 #endif /* _AUBIO_PHASEVOC_H */102 #endif /* AUBIO_PHASEVOC_H */ -
src/spectral/specdesc.c
r60fc05b rf264b17 27 27 #include "utils/hist.h" 28 28 29 void aubio_specdesc_energy(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);30 void aubio_specdesc_hfc(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);31 void aubio_specdesc_complex(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);32 void aubio_specdesc_phase(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);33 void aubio_specdesc_specdiff(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);34 void aubio_specdesc_kl(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);35 void aubio_specdesc_mkl(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);36 void aubio_specdesc_specflux(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset);37 38 extern void aubio_specdesc_centroid (aubio_specdesc_t * o, c vec_t * spec,39 fvec_t * desc); 40 extern void aubio_specdesc_spread (aubio_specdesc_t * o, c vec_t * spec,41 fvec_t * desc); 42 extern void aubio_specdesc_skewness (aubio_specdesc_t * o, c vec_t * spec,43 fvec_t * desc); 44 extern void aubio_specdesc_kurtosis (aubio_specdesc_t * o, c vec_t * spec,45 fvec_t * desc); 46 extern void aubio_specdesc_slope (aubio_specdesc_t * o, c vec_t * spec,47 fvec_t * desc); 48 extern void aubio_specdesc_decrease (aubio_specdesc_t * o, c vec_t * spec,49 fvec_t * desc); 50 extern void aubio_specdesc_rolloff (aubio_specdesc_t * o, c vec_t * spec,29 void aubio_specdesc_energy(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 30 void aubio_specdesc_hfc(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 31 void aubio_specdesc_complex(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 32 void aubio_specdesc_phase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 33 void aubio_specdesc_specdiff(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 34 void aubio_specdesc_kl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 35 void aubio_specdesc_mkl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 36 void aubio_specdesc_specflux(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset); 37 38 extern void aubio_specdesc_centroid (aubio_specdesc_t * o, const cvec_t * spec, 39 fvec_t * desc); 40 extern void aubio_specdesc_spread (aubio_specdesc_t * o, const cvec_t * spec, 41 fvec_t * desc); 42 extern void aubio_specdesc_skewness (aubio_specdesc_t * o, const cvec_t * spec, 43 fvec_t * desc); 44 extern void aubio_specdesc_kurtosis (aubio_specdesc_t * o, const cvec_t * spec, 45 fvec_t * desc); 46 extern void aubio_specdesc_slope (aubio_specdesc_t * o, const cvec_t * spec, 47 fvec_t * desc); 48 extern void aubio_specdesc_decrease (aubio_specdesc_t * o, const cvec_t * spec, 49 fvec_t * desc); 50 extern void aubio_specdesc_rolloff (aubio_specdesc_t * o, const cvec_t * spec, 51 51 fvec_t * desc); 52 52 … … 76 76 /** Pointer to aubio_specdesc_<type> function */ 77 77 void (*funcpointer)(aubio_specdesc_t *o, 78 c vec_t * fftgrain, fvec_t * onset);78 const cvec_t * fftgrain, fvec_t * onset); 79 79 smpl_t threshold; /**< minimum norm threshold for phase and specdiff */ 80 80 fvec_t *oldmag; /**< previous norm vector */ … … 88 88 /* Energy based onset detection function */ 89 89 void aubio_specdesc_energy (aubio_specdesc_t *o UNUSED, 90 c vec_t * fftgrain, fvec_t * onset) {90 const cvec_t * fftgrain, fvec_t * onset) { 91 91 uint_t j; 92 92 onset->data[0] = 0.; … … 98 98 /* High Frequency Content onset detection function */ 99 99 void aubio_specdesc_hfc(aubio_specdesc_t *o UNUSED, 100 c vec_t * fftgrain, fvec_t * onset){100 const cvec_t * fftgrain, fvec_t * onset){ 101 101 uint_t j; 102 102 onset->data[0] = 0.; … … 108 108 109 109 /* Complex Domain Method onset detection function */ 110 void aubio_specdesc_complex (aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset) {110 void aubio_specdesc_complex (aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset) { 111 111 uint_t j; 112 112 uint_t nbins = fftgrain->length; … … 132 132 /* Phase Based Method onset detection function */ 133 133 void aubio_specdesc_phase(aubio_specdesc_t *o, 134 c vec_t * fftgrain, fvec_t * onset){134 const cvec_t * fftgrain, fvec_t * onset){ 135 135 uint_t j; 136 136 uint_t nbins = fftgrain->length; … … 162 162 /* Spectral difference method onset detection function */ 163 163 void aubio_specdesc_specdiff(aubio_specdesc_t *o, 164 c vec_t * fftgrain, fvec_t * onset){164 const cvec_t * fftgrain, fvec_t * onset){ 165 165 uint_t j; 166 166 uint_t nbins = fftgrain->length; … … 189 189 * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 190 190 * negative (1.+) and infinite values (+1.e-10) */ 191 void aubio_specdesc_kl(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset){191 void aubio_specdesc_kl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset){ 192 192 uint_t j; 193 193 onset->data[0] = 0.; … … 203 203 * note we use ln(1+Xn/(Xn-1+0.0001)) to avoid 204 204 * negative (1.+) and infinite values (+1.e-10) */ 205 void aubio_specdesc_mkl(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset){205 void aubio_specdesc_mkl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset){ 206 206 uint_t j; 207 207 onset->data[0] = 0.; … … 214 214 215 215 /* Spectral flux */ 216 void aubio_specdesc_specflux(aubio_specdesc_t *o, c vec_t * fftgrain, fvec_t * onset){216 void aubio_specdesc_specflux(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset){ 217 217 uint_t j; 218 218 onset->data[0] = 0.; … … 226 226 /* Generic function pointing to the choosen one */ 227 227 void 228 aubio_specdesc_do (aubio_specdesc_t *o, c vec_t * fftgrain,228 aubio_specdesc_do (aubio_specdesc_t *o, const cvec_t * fftgrain, 229 229 fvec_t * onset) { 230 230 o->funcpointer(o,fftgrain,onset); … … 235 235 */ 236 236 aubio_specdesc_t * 237 new_aubio_specdesc (c har_t * onset_mode, uint_t size){237 new_aubio_specdesc (const char_t * onset_mode, uint_t size){ 238 238 aubio_specdesc_t * o = AUBIO_NEW(aubio_specdesc_t); 239 239 uint_t rsize = size/2+1; -
src/spectral/specdesc.h
r60fc05b rf264b17 146 146 147 147 148 #ifndef _AUBIO_SPECDESC_H149 #define _AUBIO_SPECDESC_H148 #ifndef AUBIO_SPECDESC_H 149 #define AUBIO_SPECDESC_H 150 150 151 151 #ifdef __cplusplus … … 165 165 166 166 */ 167 void aubio_specdesc_do (aubio_specdesc_t * o, c vec_t * fftgrain,167 void aubio_specdesc_do (aubio_specdesc_t * o, const cvec_t * fftgrain, 168 168 fvec_t * desc); 169 169 … … 179 179 180 180 */ 181 aubio_specdesc_t *new_aubio_specdesc (c har_t * method, uint_t buf_size);181 aubio_specdesc_t *new_aubio_specdesc (const char_t * method, uint_t buf_size); 182 182 183 183 /** deletion of a spectral descriptor … … 192 192 #endif 193 193 194 #endif /* _AUBIO_SPECDESC_H */194 #endif /* AUBIO_SPECDESC_H */ -
src/spectral/statistics.c
r60fc05b rf264b17 23 23 #include "spectral/specdesc.h" 24 24 25 void aubio_specdesc_centroid (aubio_specdesc_t * o, c vec_t * spec,26 fvec_t * desc); 27 void aubio_specdesc_spread (aubio_specdesc_t * o, c vec_t * spec,28 fvec_t * desc); 29 void aubio_specdesc_skewness (aubio_specdesc_t * o, c vec_t * spec,30 fvec_t * desc); 31 void aubio_specdesc_kurtosis (aubio_specdesc_t * o, c vec_t * spec,32 fvec_t * desc); 33 void aubio_specdesc_slope (aubio_specdesc_t * o, c vec_t * spec,34 fvec_t * desc); 35 void aubio_specdesc_decrease (aubio_specdesc_t * o, c vec_t * spec,36 fvec_t * desc); 37 void aubio_specdesc_rolloff (aubio_specdesc_t * o, c vec_t * spec,38 fvec_t * desc); 39 40 41 smpl_t cvec_sum (c vec_t * s);42 smpl_t cvec_mean (c vec_t * s);43 smpl_t cvec_centroid (c vec_t * s);44 smpl_t cvec_moment (c vec_t * s, uint_t moment);45 46 smpl_t 47 cvec_sum (c vec_t * s)25 void aubio_specdesc_centroid (aubio_specdesc_t * o, const cvec_t * spec, 26 fvec_t * desc); 27 void aubio_specdesc_spread (aubio_specdesc_t * o, const cvec_t * spec, 28 fvec_t * desc); 29 void aubio_specdesc_skewness (aubio_specdesc_t * o, const cvec_t * spec, 30 fvec_t * desc); 31 void aubio_specdesc_kurtosis (aubio_specdesc_t * o, const cvec_t * spec, 32 fvec_t * desc); 33 void aubio_specdesc_slope (aubio_specdesc_t * o, const cvec_t * spec, 34 fvec_t * desc); 35 void aubio_specdesc_decrease (aubio_specdesc_t * o, const cvec_t * spec, 36 fvec_t * desc); 37 void aubio_specdesc_rolloff (aubio_specdesc_t * o, const cvec_t * spec, 38 fvec_t * desc); 39 40 41 smpl_t cvec_sum (const cvec_t * s); 42 smpl_t cvec_mean (const cvec_t * s); 43 smpl_t cvec_centroid (const cvec_t * s); 44 smpl_t cvec_moment (const cvec_t * s, uint_t moment); 45 46 smpl_t 47 cvec_sum (const cvec_t * s) 48 48 { 49 49 uint_t j; … … 56 56 57 57 smpl_t 58 cvec_mean (c vec_t * s)58 cvec_mean (const cvec_t * s) 59 59 { 60 60 return cvec_sum (s) / (smpl_t) (s->length); … … 62 62 63 63 smpl_t 64 cvec_centroid (c vec_t * spec)64 cvec_centroid (const cvec_t * spec) 65 65 { 66 66 smpl_t sum = 0., sc = 0.; … … 78 78 79 79 smpl_t 80 cvec_moment (c vec_t * spec, uint_t order)80 cvec_moment (const cvec_t * spec, uint_t order) 81 81 { 82 82 smpl_t sum = 0., centroid = 0., sc = 0.; … … 95 95 96 96 void 97 aubio_specdesc_centroid (aubio_specdesc_t * o UNUSED, c vec_t * spec,97 aubio_specdesc_centroid (aubio_specdesc_t * o UNUSED, const cvec_t * spec, 98 98 fvec_t * desc) 99 99 { … … 102 102 103 103 void 104 aubio_specdesc_spread (aubio_specdesc_t * o UNUSED, c vec_t * spec,104 aubio_specdesc_spread (aubio_specdesc_t * o UNUSED, const cvec_t * spec, 105 105 fvec_t * desc) 106 106 { … … 109 109 110 110 void 111 aubio_specdesc_skewness (aubio_specdesc_t * o UNUSED, c vec_t * spec,111 aubio_specdesc_skewness (aubio_specdesc_t * o UNUSED, const cvec_t * spec, 112 112 fvec_t * desc) 113 113 { … … 123 123 124 124 void 125 aubio_specdesc_kurtosis (aubio_specdesc_t * o UNUSED, c vec_t * spec,125 aubio_specdesc_kurtosis (aubio_specdesc_t * o UNUSED, const cvec_t * spec, 126 126 fvec_t * desc) 127 127 { … … 137 137 138 138 void 139 aubio_specdesc_slope (aubio_specdesc_t * o UNUSED, c vec_t * spec,139 aubio_specdesc_slope (aubio_specdesc_t * o UNUSED, const cvec_t * spec, 140 140 fvec_t * desc) 141 141 { … … 165 165 166 166 void 167 aubio_specdesc_decrease (aubio_specdesc_t *o UNUSED, c vec_t * spec,167 aubio_specdesc_decrease (aubio_specdesc_t *o UNUSED, const cvec_t * spec, 168 168 fvec_t * desc) 169 169 { … … 183 183 184 184 void 185 aubio_specdesc_rolloff (aubio_specdesc_t *o UNUSED, c vec_t * spec,185 aubio_specdesc_rolloff (aubio_specdesc_t *o UNUSED, const cvec_t * spec, 186 186 fvec_t *desc) 187 187 { -
src/spectral/tss.c
r60fc05b rf264b17 41 41 }; 42 42 43 void aubio_tss_do(aubio_tss_t *o, c vec_t * input,43 void aubio_tss_do(aubio_tss_t *o, const cvec_t * input, 44 44 cvec_t * trans, cvec_t * stead) 45 45 { -
src/spectral/tss.h
r60fc05b rf264b17 37 37 */ 38 38 39 #ifndef _AUBIO_TSS_H40 #define _AUBIO_TSS_H39 #ifndef AUBIO_TSS_H 40 #define AUBIO_TSS_H 41 41 42 42 #ifdef __cplusplus … … 70 70 71 71 */ 72 void aubio_tss_do (aubio_tss_t * o, c vec_t * input, cvec_t * trans,72 void aubio_tss_do (aubio_tss_t * o, const cvec_t * input, cvec_t * trans, 73 73 cvec_t * stead); 74 74 … … 101 101 #endif 102 102 103 #endif /* _AUBIO_TSS_H */103 #endif /* AUBIO_TSS_H */ -
src/synth/sampler.c
r60fc05b rf264b17 56 56 } 57 57 58 uint_t aubio_sampler_load( aubio_sampler_t * o, c har_t * uri )58 uint_t aubio_sampler_load( aubio_sampler_t * o, const char_t * uri ) 59 59 { 60 60 if (o->source) del_aubio_source(o->source); 61 o->uri = uri; 61 62 if (o->uri) AUBIO_FREE(o->uri); 63 o->uri = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX)); 64 strncpy(o->uri, uri, strnlen(uri, PATH_MAX)); 65 62 66 o->source = new_aubio_source(uri, o->samplerate, o->blocksize); 63 67 if (o->source) return 0; … … 66 70 } 67 71 68 void aubio_sampler_do ( aubio_sampler_t * o, fvec_t * input, fvec_t * output)72 void aubio_sampler_do ( aubio_sampler_t * o, const fvec_t * input, fvec_t * output) 69 73 { 70 74 uint_t read = 0, i; … … 83 87 } 84 88 85 void aubio_sampler_do_multi ( aubio_sampler_t * o, fmat_t * input, fmat_t * output)89 void aubio_sampler_do_multi ( aubio_sampler_t * o, const fmat_t * input, fmat_t * output) 86 90 { 87 91 uint_t read = 0, i, j; … … 104 108 } 105 109 106 uint_t aubio_sampler_get_playing ( aubio_sampler_t * o )110 uint_t aubio_sampler_get_playing ( const aubio_sampler_t * o ) 107 111 { 108 112 return o->playing; … … 131 135 del_aubio_source(o->source); 132 136 } 137 if (o->uri) AUBIO_FREE(o->uri); 133 138 del_fvec(o->source_output); 134 139 del_fmat(o->source_output_multi); -
src/synth/sampler.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_SAMPLER_H22 #define _AUBIO_SAMPLER_H21 #ifndef AUBIO_SAMPLER_H 22 #define AUBIO_SAMPLER_H 23 23 24 24 /** \file … … 60 60 61 61 */ 62 uint_t aubio_sampler_load( aubio_sampler_t * o, c har_t * uri );62 uint_t aubio_sampler_load( aubio_sampler_t * o, const char_t * uri ); 63 63 64 64 /** process sampler function … … 74 74 75 75 */ 76 void aubio_sampler_do ( aubio_sampler_t * o, fvec_t * input, fvec_t * output);76 void aubio_sampler_do ( aubio_sampler_t * o, const fvec_t * input, fvec_t * output); 77 77 78 78 /** process sampler function, multiple channels … … 88 88 89 89 */ 90 void aubio_sampler_do_multi ( aubio_sampler_t * o, fmat_t * input, fmat_t * output);90 void aubio_sampler_do_multi ( aubio_sampler_t * o, const fmat_t * input, fmat_t * output); 91 91 92 92 /** get current playing state … … 97 97 98 98 */ 99 uint_t aubio_sampler_get_playing ( aubio_sampler_t * o );99 uint_t aubio_sampler_get_playing ( const aubio_sampler_t * o ); 100 100 101 101 /** set current playing state … … 138 138 #endif 139 139 140 #endif /* _AUBIO_SAMPLER_H */140 #endif /* AUBIO_SAMPLER_H */ -
src/synth/wavetable.c
r60fc05b rf264b17 69 69 } 70 70 71 static smpl_t interp_2( fvec_t *input, smpl_t pos) {71 static smpl_t interp_2(const fvec_t *input, smpl_t pos) { 72 72 uint_t idx = (uint_t)FLOOR(pos); 73 73 smpl_t frac = pos - (smpl_t)idx; … … 77 77 } 78 78 79 void aubio_wavetable_do ( aubio_wavetable_t * s, fvec_t * input, fvec_t * output)79 void aubio_wavetable_do ( aubio_wavetable_t * s, const fvec_t * input, fvec_t * output) 80 80 { 81 81 uint_t i; … … 108 108 } 109 109 110 void aubio_wavetable_do_multi ( aubio_wavetable_t * s, fmat_t * input, fmat_t * output)110 void aubio_wavetable_do_multi ( aubio_wavetable_t * s, const fmat_t * input, fmat_t * output) 111 111 { 112 112 uint_t i, j; … … 143 143 } 144 144 145 uint_t aubio_wavetable_get_playing ( aubio_wavetable_t * s )145 uint_t aubio_wavetable_get_playing ( const aubio_wavetable_t * s ) 146 146 { 147 147 return s->playing; … … 173 173 } 174 174 175 smpl_t aubio_wavetable_get_freq ( aubio_wavetable_t * s) {175 smpl_t aubio_wavetable_get_freq ( const aubio_wavetable_t * s) { 176 176 return aubio_parameter_get_current_value ( s->freq); 177 177 } … … 182 182 } 183 183 184 smpl_t aubio_wavetable_get_amp ( aubio_wavetable_t * s) {184 smpl_t aubio_wavetable_get_amp ( const aubio_wavetable_t * s) { 185 185 return aubio_parameter_get_current_value ( s->amp ); 186 186 } -
src/synth/wavetable.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_WAVETABLE_H22 #define _AUBIO_WAVETABLE_H21 #ifndef AUBIO_WAVETABLE_H 22 #define AUBIO_WAVETABLE_H 23 23 24 24 /** \file … … 60 60 61 61 */ 62 uint_t aubio_wavetable_load( aubio_wavetable_t * o, c har_t * uri );62 uint_t aubio_wavetable_load( aubio_wavetable_t * o, const char_t * uri ); 63 63 64 64 /** process wavetable function … … 74 74 75 75 */ 76 void aubio_wavetable_do ( aubio_wavetable_t * o, fvec_t * input, fvec_t * output);76 void aubio_wavetable_do ( aubio_wavetable_t * o, const fvec_t * input, fvec_t * output); 77 77 78 78 /** process wavetable function, multiple channels … … 88 88 89 89 */ 90 void aubio_wavetable_do_multi ( aubio_wavetable_t * o, fmat_t * input, fmat_t * output);90 void aubio_wavetable_do_multi ( aubio_wavetable_t * o, const fmat_t * input, fmat_t * output); 91 91 92 92 /** get current playing state … … 97 97 98 98 */ 99 uint_t aubio_wavetable_get_playing ( aubio_wavetable_t * o );99 uint_t aubio_wavetable_get_playing ( const aubio_wavetable_t * o ); 100 100 101 101 /** set current playing state … … 144 144 145 145 */ 146 smpl_t aubio_wavetable_get_freq ( aubio_wavetable_t * o);146 smpl_t aubio_wavetable_get_freq ( const aubio_wavetable_t * o); 147 147 148 148 /** set wavetable amplitude … … 163 163 164 164 */ 165 smpl_t aubio_wavetable_get_amp ( aubio_wavetable_t * o);165 smpl_t aubio_wavetable_get_amp ( const aubio_wavetable_t * o); 166 166 167 167 /** destroy aubio_wavetable_t object … … 176 176 #endif 177 177 178 #endif /* _AUBIO_WAVETABLE_H */178 #endif /* AUBIO_WAVETABLE_H */ -
src/tempo/beattracking.c
r60fc05b rf264b17 124 124 125 125 void 126 aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframe,126 aubio_beattracking_do (aubio_beattracking_t * bt, const fvec_t * dfframe, 127 127 fvec_t * output) 128 128 { … … 410 410 411 411 smpl_t 412 aubio_beattracking_get_bpm (aubio_beattracking_t * bt) 412 aubio_beattracking_get_period (const aubio_beattracking_t * bt) 413 { 414 return bt->hop_size * bt->bp; 415 } 416 417 smpl_t 418 aubio_beattracking_get_period_s (const aubio_beattracking_t * bt) 419 { 420 return aubio_beattracking_get_period(bt) / (smpl_t) bt->samplerate; 421 } 422 423 smpl_t 424 aubio_beattracking_get_bpm (const aubio_beattracking_t * bt) 413 425 { 414 426 if (bt->bp != 0) { 415 return 60. * bt->samplerate/ bt->bp / bt->hop_size;427 return 60. / aubio_beattracking_get_period_s(bt); 416 428 } else { 417 429 return 0.; … … 420 432 421 433 smpl_t 422 aubio_beattracking_get_confidence ( aubio_beattracking_t * bt)434 aubio_beattracking_get_confidence (const aubio_beattracking_t * bt) 423 435 { 424 436 if (bt->gp) { -
src/tempo/beattracking.h
r60fc05b rf264b17 37 37 38 38 */ 39 #ifndef _AUBIO_BEATTRACKING_H40 #define _AUBIO_BEATTRACKING_H39 #ifndef AUBIO_BEATTRACKING_H 40 #define AUBIO_BEATTRACKING_H 41 41 42 42 #ifdef __cplusplus … … 65 65 66 66 */ 67 void aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframes,67 void aubio_beattracking_do (aubio_beattracking_t * bt, const fvec_t * dfframes, 68 68 fvec_t * out); 69 70 /** get current beat period in samples 71 72 \param bt beat tracking object 73 74 Returns the currently observed period, in samples, or 0 if no consistent 75 value is found. 76 77 */ 78 smpl_t aubio_beattracking_get_period (const aubio_beattracking_t * bt); 79 80 /** get current beat period in seconds 81 82 \param bt beat tracking object 83 84 Returns the currently observed period, in seconds, or 0 if no consistent 85 value is found. 86 87 */ 88 smpl_t aubio_beattracking_get_period_s (const aubio_beattracking_t * bt); 69 89 70 90 /** get current tempo in bpm … … 76 96 77 97 */ 78 smpl_t aubio_beattracking_get_bpm( aubio_beattracking_t * bt);98 smpl_t aubio_beattracking_get_bpm(const aubio_beattracking_t * bt); 79 99 80 100 /** get current tempo confidence … … 86 106 87 107 */ 88 smpl_t aubio_beattracking_get_confidence( aubio_beattracking_t * bt);108 smpl_t aubio_beattracking_get_confidence(const aubio_beattracking_t * bt); 89 109 90 110 /** delete beat tracking object … … 99 119 #endif 100 120 101 #endif /* _AUBIO_BEATTRACKING_H */121 #endif /* AUBIO_BEATTRACKING_H */ -
src/tempo/tempo.c
r60fc05b rf264b17 28 28 #include "mathutils.h" 29 29 #include "tempo/tempo.h" 30 31 // TODO implement get/set_delay32 33 /** set current delay34 35 \param o beat tracking object36 37 \return current delay, in samples38 39 */40 uint_t aubio_tempo_get_delay(aubio_tempo_t * o);41 42 /** set current delay43 44 \param o beat tracking object45 \param delay delay to set tempo to, in samples46 47 \return `0` if successful, non-zero otherwise48 49 */50 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay);51 30 52 31 /* structure to store object state */ … … 65 44 sint_t blockpos; /** current position in dfframe */ 66 45 uint_t winlen; /** dfframe bufsize */ 67 uint_t step; /** dfframe hopsize */ 68 uint_t samplerate; /** sampling rate of the signal */ 46 uint_t step; /** dfframe hopsize */ 47 uint_t samplerate; /** sampling rate of the signal */ 69 48 uint_t hop_size; /** get hop_size */ 70 49 uint_t total_frames; /** total frames since beginning */ 71 50 uint_t last_beat; /** time of latest detected beat, in samples */ 72 uint_t delay; /** delay to remove to last beat, in samples */ 51 sint_t delay; /** delay to remove to last beat, in samples */ 52 uint_t last_tatum; /** time of latest detected tatum, in samples */ 53 uint_t tatum_signature; /** number of tatum between each beats */ 73 54 }; 74 55 75 56 /* execute tempo detection function on iput buffer */ 76 void aubio_tempo_do(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo)57 void aubio_tempo_do(aubio_tempo_t *o, const fvec_t * input, fvec_t * tempo) 77 58 { 78 59 uint_t i; … … 91 72 aubio_beattracking_do(o->bt,o->dfframe,o->out); 92 73 /* rotate dfframe */ 93 for (i = 0 ; i < winlen - step; i++ ) 74 for (i = 0 ; i < winlen - step; i++ ) 94 75 o->dfframe->data[i] = o->dfframe->data[i+step]; 95 for (i = winlen - step ; i < winlen; i++ ) 76 for (i = winlen - step ; i < winlen; i++ ) 96 77 o->dfframe->data[i] = 0.; 97 78 o->blockpos = -1; … … 99 80 o->blockpos++; 100 81 aubio_peakpicker_do (o->pp, o->of, o->onset); 101 tempo->data[1] = o->onset->data[0]; 82 // store onset detection function in second sample of vector 83 //tempo->data[1] = o->onset->data[0]; 102 84 thresholded = aubio_peakpicker_get_thresholded_input(o->pp); 103 85 o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0]; 104 86 /* end of second level loop */ 105 87 tempo->data[0] = 0; /* reset tactus */ 106 i=0;88 //i=0; 107 89 for (i = 1; i < o->out->data[0]; i++ ) { 108 90 /* if current frame is a predicted tactus */ … … 114 96 } 115 97 o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size); 98 o->last_tatum = o->last_beat; 116 99 } 117 100 } … … 122 105 uint_t aubio_tempo_get_last (aubio_tempo_t *o) 123 106 { 124 return o->last_beat -o->delay;107 return o->last_beat + o->delay; 125 108 } 126 109 … … 135 118 } 136 119 137 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay) {120 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, sint_t delay) { 138 121 o->delay = delay; 122 return AUBIO_OK; 123 } 124 125 uint_t aubio_tempo_set_delay_s(aubio_tempo_t * o, smpl_t delay) { 126 o->delay = delay * o->samplerate; 127 return AUBIO_OK; 128 } 129 130 uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay) { 131 o->delay = 1000. * delay * o->samplerate; 139 132 return AUBIO_OK; 140 133 } … … 142 135 uint_t aubio_tempo_get_delay(aubio_tempo_t * o) { 143 136 return o->delay; 137 } 138 139 smpl_t aubio_tempo_get_delay_s(aubio_tempo_t * o) { 140 return o->delay / (smpl_t)(o->samplerate); 141 } 142 143 smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o) { 144 return o->delay / (smpl_t)(o->samplerate) / 1000.; 144 145 } 145 146 … … 164 165 165 166 /* Allocate memory for an tempo detection */ 166 aubio_tempo_t * new_aubio_tempo (c har_t * tempo_mode,167 aubio_tempo_t * new_aubio_tempo (const char_t * tempo_mode, 167 168 uint_t buf_size, uint_t hop_size, uint_t samplerate) 168 169 { … … 174 175 AUBIO_ERR("tempo: got hop size %d, but can not be < 1\n", hop_size); 175 176 goto beach; 176 } else if ((sint_t)buf_size < 1) {177 AUBIO_ERR("tempo: got window size %d, but can not be < 1\n", buf_size);177 } else if ((sint_t)buf_size < 2) { 178 AUBIO_ERR("tempo: got window size %d, but can not be < 2\n", buf_size); 178 179 goto beach; 179 180 } else if (buf_size < hop_size) { … … 215 216 onset2 = new_fvec(1); 216 217 }*/ 218 o->last_tatum = 0; 219 o->tatum_signature = 4; 217 220 return o; 218 221 … … 226 229 } 227 230 231 smpl_t aubio_tempo_get_period (aubio_tempo_t *o) 232 { 233 return aubio_beattracking_get_period (o->bt); 234 } 235 236 smpl_t aubio_tempo_get_period_s (aubio_tempo_t *o) 237 { 238 return aubio_beattracking_get_period_s (o->bt); 239 } 240 228 241 smpl_t aubio_tempo_get_confidence(aubio_tempo_t *o) { 229 242 return aubio_beattracking_get_confidence(o->bt); 243 } 244 245 uint_t aubio_tempo_was_tatum (aubio_tempo_t *o) 246 { 247 uint_t last_tatum_distance = o->total_frames - o->last_tatum; 248 smpl_t beat_period = aubio_tempo_get_period(o); 249 smpl_t tatum_period = beat_period / o->tatum_signature; 250 if (last_tatum_distance < o->hop_size) { 251 o->last_tatum = o->last_beat; 252 return 2; 253 } 254 else if (last_tatum_distance > tatum_period) { 255 if ( last_tatum_distance + o->hop_size > beat_period ) { 256 // next beat is too close, pass 257 return 0; 258 } 259 o->last_tatum = o->total_frames; 260 return 1; 261 } 262 return 0; 263 } 264 265 smpl_t aubio_tempo_get_last_tatum (aubio_tempo_t *o) { 266 return (smpl_t)o->last_tatum - o->delay; 267 } 268 269 uint_t aubio_tempo_set_tatum_signature (aubio_tempo_t *o, uint_t signature) { 270 if (signature < 1 || signature > 64) { 271 return AUBIO_FAIL; 272 } else { 273 o->tatum_signature = signature; 274 return AUBIO_OK; 275 } 230 276 } 231 277 -
src/tempo/tempo.h
r60fc05b rf264b17 31 31 */ 32 32 33 #ifndef _AUBIO_TEMPO_H34 #define _AUBIO_TEMPO_H33 #ifndef AUBIO_TEMPO_H 34 #define AUBIO_TEMPO_H 35 35 36 36 #ifdef __cplusplus … … 51 51 52 52 */ 53 aubio_tempo_t * new_aubio_tempo (c har_t * method,53 aubio_tempo_t * new_aubio_tempo (const char_t * method, 54 54 uint_t buf_size, uint_t hop_size, uint_t samplerate); 55 55 … … 61 61 62 62 */ 63 void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);63 void aubio_tempo_do (aubio_tempo_t *o, const fvec_t * input, fvec_t * tempo); 64 64 65 65 /** get the time of the latest beat detected, in samples … … 121 121 */ 122 122 smpl_t aubio_tempo_get_threshold(aubio_tempo_t * o); 123 124 /** get current beat period in samples 125 126 \param bt beat tracking object 127 128 Returns the currently observed period, in samples, or 0 if no consistent 129 value is found. 130 131 */ 132 smpl_t aubio_tempo_get_period (aubio_tempo_t * bt); 133 134 /** get current beat period in seconds 135 136 \param bt beat tracking object 137 138 Returns the currently observed period, in seconds, or 0 if no consistent 139 value is found. 140 141 */ 142 smpl_t aubio_tempo_get_period_s (aubio_tempo_t * bt); 123 143 124 144 /** get current tempo … … 140 160 */ 141 161 smpl_t aubio_tempo_get_confidence(aubio_tempo_t * o); 162 163 /* set number of tatum per beat 164 165 \param o beat tracking object 166 \param signature number of tatum per beat (between 1 and 64) 167 168 */ 169 uint_t aubio_tempo_set_tatum_signature(aubio_tempo_t *o, uint_t signature); 170 171 /* check whether a tatum was detected in the current frame 172 173 \param o beat tracking object 174 175 \return 2 if a beat was detected, 1 if a tatum was detected, 0 otherwise 176 177 */ 178 uint_t aubio_tempo_was_tatum(aubio_tempo_t *o); 179 180 /* get position of last_tatum, in samples 181 182 \param o beat tracking object 183 184 */ 185 smpl_t aubio_tempo_get_last_tatum(aubio_tempo_t *o); 186 187 /** get current delay 188 189 \param o beat tracking object 190 191 \return current delay, in samples 192 193 */ 194 uint_t aubio_tempo_get_delay(aubio_tempo_t * o); 195 196 /** get current delay in seconds 197 198 \param o beat tracking object 199 200 \return current delay, in seconds 201 202 */ 203 smpl_t aubio_tempo_get_delay_s(aubio_tempo_t * o); 204 205 /** get current delay in ms 206 207 \param o beat tracking object 208 209 \return current delay, in milliseconds 210 211 */ 212 smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o); 213 214 /** set current delay 215 216 \param o beat tracking object 217 \param delay delay to set tempo to, in samples 218 219 \return `0` if successful, non-zero otherwise 220 221 */ 222 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, sint_t delay); 223 224 /** set current delay in seconds 225 226 \param o beat tracking object 227 \param delay delay to set tempo to, in seconds 228 229 \return `0` if successful, non-zero otherwise 230 231 */ 232 uint_t aubio_tempo_set_delay_s(aubio_tempo_t * o, smpl_t delay); 233 234 /** set current delay 235 236 \param o beat tracking object 237 \param delay delay to set tempo to, in samples 238 239 \return `0` if successful, non-zero otherwise 240 241 */ 242 uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay); 142 243 143 244 /** delete tempo detection object … … 152 253 #endif 153 254 154 #endif /* _AUBIO_TEMPO_H */255 #endif /* AUBIO_TEMPO_H */ -
src/temporal/a_weighting.c
r60fc05b rf264b17 30 30 { 31 31 uint_t order; lsmp_t *a, *b; lvec_t *as, *bs; 32 33 if ((sint_t)samplerate <= 0) { 34 AUBIO_ERROR("aubio_filter: failed setting A-weighting with samplerate %d\n", samplerate); 35 return AUBIO_FAIL; 36 } 37 if (f == NULL) { 38 AUBIO_ERROR("aubio_filter: failed setting A-weighting with filter NULL\n"); 39 return AUBIO_FAIL; 40 } 41 42 order = aubio_filter_get_order (f); 43 if (order != 7) { 44 AUBIO_ERROR ("aubio_filter: order of A-weighting filter must be 7, not %d\n", order); 45 return 1; 46 } 47 32 48 aubio_filter_set_samplerate (f, samplerate); 33 49 bs = aubio_filter_get_feedforward (f); 34 50 as = aubio_filter_get_feedback (f); 35 51 b = bs->data, a = as->data; 36 order = aubio_filter_get_order (f);37 38 if (order != 7) {39 AUBIO_ERROR ("order of A-weighting filter must be 7, not %d\n", order);40 return 1;41 }42 52 43 53 /* select coefficients according to sampling frequency */ … … 245 255 { 246 256 aubio_filter_t *f = new_aubio_filter (7); 247 aubio_filter_set_a_weighting (f, samplerate); 257 if (aubio_filter_set_a_weighting(f,samplerate) != AUBIO_OK) { 258 del_aubio_filter(f); 259 return NULL; 260 } 248 261 return f; 249 262 } -
src/temporal/a_weighting.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_FILTER_A_DESIGN_H22 #define _AUBIO_FILTER_A_DESIGN_H21 #ifndef AUBIO_FILTER_A_DESIGN_H 22 #define AUBIO_FILTER_A_DESIGN_H 23 23 24 24 /** \file … … 86 86 #endif 87 87 88 #endif /* _AUBIO_FILTER_A_DESIGN_H */88 #endif /* AUBIO_FILTER_A_DESIGN_H */ -
src/temporal/biquad.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_FILTER_BIQUAD_H22 #define _AUBIO_FILTER_BIQUAD_H21 #ifndef AUBIO_FILTER_BIQUAD_H 22 #define AUBIO_FILTER_BIQUAD_H 23 23 24 24 /** \file … … 73 73 #endif 74 74 75 #endif /* _AUBIO_FILTER_BIQUAD_H */75 #endif /* AUBIO_FILTER_BIQUAD_H */ -
src/temporal/c_weighting.c
r60fc05b rf264b17 30 30 { 31 31 uint_t order; lsmp_t *a, *b; lvec_t *as, *bs; 32 33 if ((sint_t)samplerate <= 0) { 34 AUBIO_ERROR("aubio_filter: failed setting C-weighting with samplerate %d\n", samplerate); 35 return AUBIO_FAIL; 36 } 37 if (f == NULL) { 38 AUBIO_ERROR("aubio_filter: failed setting C-weighting with filter NULL\n"); 39 return AUBIO_FAIL; 40 } 41 42 order = aubio_filter_get_order (f); 43 if ( order != 5 ) { 44 AUBIO_ERROR ("aubio_filter: order of C-weighting filter must be 5, not %d\n", order); 45 return 1; 46 } 47 32 48 aubio_filter_set_samplerate (f, samplerate); 33 49 bs = aubio_filter_get_feedforward (f); 34 50 as = aubio_filter_get_feedback (f); 35 51 b = bs->data, a = as->data; 36 order = aubio_filter_get_order (f);37 38 if ( order != 5 ) {39 AUBIO_ERROR ("order of C-weighting filter must be 5, not %d\n", order);40 return 1;41 }42 52 43 53 /* select coefficients according to sampling frequency */ … … 200 210 aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate) { 201 211 aubio_filter_t * f = new_aubio_filter(5); 202 aubio_filter_set_c_weighting (f, samplerate); 212 if (aubio_filter_set_c_weighting(f,samplerate) != AUBIO_OK) { 213 del_aubio_filter(f); 214 return NULL; 215 } 203 216 return f; 204 217 } 205 -
src/temporal/c_weighting.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_FILTER_C_DESIGN_H22 #define _AUBIO_FILTER_C_DESIGN_H21 #ifndef AUBIO_FILTER_C_DESIGN_H 22 #define AUBIO_FILTER_C_DESIGN_H 23 23 24 24 /** \file … … 86 86 #endif 87 87 88 #endif /* _AUBIO_FILTER_C_DESIGN_H */88 #endif /* AUBIO_FILTER_C_DESIGN_H */ -
src/temporal/filter.c
r60fc05b rf264b17 40 40 41 41 void 42 aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out)42 aubio_filter_do_outplace (aubio_filter_t * f, const fvec_t * in, fvec_t * out) 43 43 { 44 44 fvec_copy (in, out); … … 94 94 95 95 lvec_t * 96 aubio_filter_get_feedback ( aubio_filter_t * f)96 aubio_filter_get_feedback (const aubio_filter_t * f) 97 97 { 98 98 return f->a; … … 100 100 101 101 lvec_t * 102 aubio_filter_get_feedforward ( aubio_filter_t * f)102 aubio_filter_get_feedforward (const aubio_filter_t * f) 103 103 { 104 104 return f->b; … … 106 106 107 107 uint_t 108 aubio_filter_get_order ( aubio_filter_t * f)108 aubio_filter_get_order (const aubio_filter_t * f) 109 109 { 110 110 return f->order; … … 112 112 113 113 uint_t 114 aubio_filter_get_samplerate ( aubio_filter_t * f)114 aubio_filter_get_samplerate (const aubio_filter_t * f) 115 115 { 116 116 return f->samplerate; … … 135 135 { 136 136 aubio_filter_t *f = AUBIO_NEW (aubio_filter_t); 137 if ((sint_t)order < 1) { 138 AUBIO_FREE(f); 139 return NULL; 140 } 137 141 f->x = new_lvec (order); 138 142 f->y = new_lvec (order); … … 143 147 f->order = order; 144 148 /* set default to identity */ 145 f->a->data[1] = 1.; 149 f->a->data[0] = 1.; 150 f->b->data[0] = 1.; 146 151 return f; 147 152 } -
src/temporal/filter.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_FILTER_H22 #define _AUBIO_FILTER_H21 #ifndef AUBIO_FILTER_H 22 #define AUBIO_FILTER_H 23 23 24 24 /** \file … … 87 87 88 88 */ 89 void aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out);89 void aubio_filter_do_outplace (aubio_filter_t * f, const fvec_t * in, fvec_t * out); 90 90 91 91 /** filter input vector forward and backward … … 105 105 106 106 */ 107 lvec_t *aubio_filter_get_feedback ( aubio_filter_t * f);107 lvec_t *aubio_filter_get_feedback (const aubio_filter_t * f); 108 108 109 109 /** returns a pointer to feedforward coefficients \f$ b_i \f$ … … 114 114 115 115 */ 116 lvec_t *aubio_filter_get_feedforward ( aubio_filter_t * f);116 lvec_t *aubio_filter_get_feedforward (const aubio_filter_t * f); 117 117 118 118 /** get order of the filter … … 123 123 124 124 */ 125 uint_t aubio_filter_get_order ( aubio_filter_t * f);125 uint_t aubio_filter_get_order (const aubio_filter_t * f); 126 126 127 127 /** get sampling rate of the filter … … 132 132 133 133 */ 134 uint_t aubio_filter_get_samplerate ( aubio_filter_t * f);134 uint_t aubio_filter_get_samplerate (const aubio_filter_t * f); 135 135 136 136 /** get sampling rate of the filter … … 174 174 #endif 175 175 176 #endif /* _AUBIO_FILTER_H */176 #endif /* AUBIO_FILTER_H */ -
src/temporal/resampler.c
r60fc05b rf264b17 25 25 #include "temporal/resampler.h" 26 26 27 #if HAVE_SAMPLERATE27 #ifdef HAVE_SAMPLERATE 28 28 29 29 #include <samplerate.h> /* from libsamplerate */ … … 62 62 63 63 void 64 aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output)64 aubio_resampler_do (aubio_resampler_t * s, const fvec_t * input, fvec_t * output) 65 65 { 66 66 s->proc->input_frames = input->length; … … 93 93 94 94 void 95 aubio_resampler_do (aubio_resampler_t * s UNUSED, fvec_t * input UNUSED, fvec_t * output UNUSED)95 aubio_resampler_do (aubio_resampler_t * s UNUSED, const fvec_t * input UNUSED, fvec_t * output UNUSED) 96 96 { 97 97 } -
src/temporal/resampler.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_RESAMPLER_H22 #define _AUBIO_RESAMPLER_H21 #ifndef AUBIO_RESAMPLER_H 22 #define AUBIO_RESAMPLER_H 23 23 24 24 /** \file … … 56 56 57 57 */ 58 void aubio_resampler_do (aubio_resampler_t * s, fvec_t * input,58 void aubio_resampler_do (aubio_resampler_t * s, const fvec_t * input, 59 59 fvec_t * output); 60 60 … … 63 63 #endif 64 64 65 #endif /* _AUBIO_RESAMPLER_H */65 #endif /* AUBIO_RESAMPLER_H */ -
src/types.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO__TYPES_H22 #define _AUBIO__TYPES_H21 #ifndef AUBIO_TYPES_H 22 #define AUBIO_TYPES_H 23 23 24 24 /** \file … … 68 68 #endif 69 69 70 #endif /* _AUBIO__TYPES_H */70 #endif /* AUBIO_TYPES_H */ -
src/utils/hist.c
r60fc05b rf264b17 138 138 } 139 139 140 smpl_t aubio_hist_mean ( aubio_hist_t *s) {140 smpl_t aubio_hist_mean (const aubio_hist_t *s) { 141 141 uint_t j; 142 142 smpl_t tmp = 0.0; -
src/utils/hist.h
r60fc05b rf264b17 26 26 */ 27 27 28 #ifndef _AUBIO_HIST_H29 #define _AUBIO_HIST_H28 #ifndef AUBIO_HIST_H 29 #define AUBIO_HIST_H 30 30 31 31 #ifdef __cplusplus … … 51 51 void aubio_hist_do_notnull(aubio_hist_t *s, fvec_t * input); 52 52 /** compute the mean of the histogram */ 53 smpl_t aubio_hist_mean( aubio_hist_t *s);53 smpl_t aubio_hist_mean(const aubio_hist_t *s); 54 54 /** weight the histogram */ 55 55 void aubio_hist_weight(aubio_hist_t *s); … … 61 61 #endif 62 62 63 #endif /* _AUBIO_HIST_H */63 #endif /* AUBIO_HIST_H */ -
src/utils/parameter.c
r60fc05b rf264b17 85 85 } 86 86 87 smpl_t aubio_parameter_get_current_value ( aubio_parameter_t * s )87 smpl_t aubio_parameter_get_current_value ( const aubio_parameter_t * s ) 88 88 { 89 89 return s->current_value; … … 110 110 } 111 111 112 uint_t aubio_parameter_get_steps ( aubio_parameter_t * param )112 uint_t aubio_parameter_get_steps ( const aubio_parameter_t * param ) 113 113 { 114 114 return param->steps; … … 121 121 } 122 122 123 smpl_t aubio_parameter_get_min_value ( aubio_parameter_t * param )123 smpl_t aubio_parameter_get_min_value ( const aubio_parameter_t * param ) 124 124 { 125 125 return param->min_value; … … 132 132 } 133 133 134 smpl_t aubio_parameter_get_max_value ( aubio_parameter_t * param )134 smpl_t aubio_parameter_get_max_value ( const aubio_parameter_t * param ) 135 135 { 136 136 return param->max_value; -
src/utils/parameter.h
r60fc05b rf264b17 19 19 */ 20 20 21 #ifndef _AUBIO_PARAMETER_H22 #define _AUBIO_PARAMETER_H21 #ifndef AUBIO_PARAMETER_H 22 #define AUBIO_PARAMETER_H 23 23 24 24 /** \file … … 77 77 78 78 */ 79 smpl_t aubio_parameter_get_current_value ( aubio_parameter_t * param );79 smpl_t aubio_parameter_get_current_value ( const aubio_parameter_t * param ); 80 80 81 81 /** set current parameter value, skipping interpolation … … 106 106 107 107 */ 108 uint_t aubio_parameter_get_steps ( aubio_parameter_t * param);108 uint_t aubio_parameter_get_steps ( const aubio_parameter_t * param); 109 109 110 110 /** set minimum value of this parameter … … 125 125 126 126 */ 127 smpl_t aubio_parameter_get_min_value ( aubio_parameter_t * param );127 smpl_t aubio_parameter_get_min_value ( const aubio_parameter_t * param ); 128 128 129 129 /** set maximum value of this parameter … … 144 144 145 145 */ 146 smpl_t aubio_parameter_get_max_value ( aubio_parameter_t * param );146 smpl_t aubio_parameter_get_max_value ( const aubio_parameter_t * param ); 147 147 148 148 /** destroy ::aubio_parameter_t object … … 157 157 #endif 158 158 159 #endif /* _AUBIO_PARAMETER_H */159 #endif /* AUBIO_PARAMETER_H */ -
src/utils/scale.c
r60fc05b rf264b17 38 38 }; 39 39 40 aubio_scale_t * new_aubio_scale (smpl_t ilow, smpl_t ihig, 40 aubio_scale_t * new_aubio_scale (smpl_t ilow, smpl_t ihig, 41 41 smpl_t olow, smpl_t ohig) { 42 42 aubio_scale_t * s = AUBIO_NEW(aubio_scale_t); -
src/utils/scale.h
r60fc05b rf264b17 29 29 30 30 */ 31 #ifndef _AUBIO_SCALE_H32 #define _AUBIO_SCALE_H31 #ifndef AUBIO_SCALE_H 32 #define AUBIO_SCALE_H 33 33 34 34 #ifdef __cplusplus … … 78 78 #endif 79 79 80 #endif /* _AUBIO_SCALE_H */80 #endif /* AUBIO_SCALE_H */ -
src/vecutils.h
r60fc05b rf264b17 25 25 */ 26 26 27 #ifndef _AUBIO__VECUTILS_H28 #define _AUBIO__VECUTILS_H27 #ifndef AUBIO_VECUTILS_H 28 #define AUBIO_VECUTILS_H 29 29 30 30 #ifdef __cplusplus … … 114 114 #endif 115 115 116 #endif /* _AUBIO__VECUTILS_H */116 #endif /* AUBIO_VECUTILS_H */ -
src/wscript_build
r60fc05b rf264b17 2 2 3 3 uselib = [] 4 uselib += ['M'] 4 5 uselib += ['FFTW3', 'FFTW3F'] 5 6 uselib += ['SAMPLERATE'] … … 9 10 uselib += ['AVRESAMPLE'] 10 11 uselib += ['AVUTIL'] 12 uselib += ['BLAS'] 11 13 12 # build each source files13 14 source = ctx.path.ant_glob('*.c **/*.c') 15 14 16 ctx(features = 'c', 15 17 source = source, 16 18 includes = ['.'], 17 uselib = uselib, 18 lib = 'm', 19 use = uselib, 19 20 target = 'lib_objects') 20 21 … … 23 24 build_features = ['cstlib', 'cshlib'] 24 25 elif ctx.env['DEST_OS'] in ['win32', 'win64']: 25 build_features = ['cshlib'] 26 build_features = ['cstlib', 'cshlib'] 27 elif ctx.env['DEST_OS'] in ['emscripten']: 28 build_features = ['cstlib'] 26 29 else: #linux, darwin, android, mingw, ... 27 build_features = ['cs hlib', 'cstlib']30 build_features = ['cstlib', 'cshlib'] 28 31 29 32 for target in build_features: 30 33 ctx(features = 'c ' + target, 31 use = ['lib_objects'], 32 uselib = uselib, 33 lib = 'm', 34 use = uselib + ['lib_objects'], 34 35 target = 'aubio', 35 36 vnum = ctx.env['LIB_VERSION'])
Note: See TracChangeset
for help on using the changeset viewer.