Changeset 82c588a
- Timestamp:
- Oct 30, 2007, 3:33:19 AM (17 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:
- 36fa6cb, ef7df76
- Parents:
- 647a2d8 (diff), 6d4ec49 (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. - Files:
-
- 2 added
- 5 edited
- 38 moved
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
r647a2d8 r82c588a 25 25 dnl Check for programs 26 26 AC_PROG_CC 27 AM_PROG_CC_C_O dnl compiling with per-target flag 27 28 if test "$ac_cv_prog_cc" = "no" ; then 28 29 AC_MSG_ERROR([*** No C compiler found !]) … … 240 241 ext/Makefile 241 242 examples/Makefile 242 examples/tests/Makefile 243 tests/Makefile 244 tests/src/Makefile 243 245 sounds/Makefile 244 246 swig/Makefile -
examples/Makefile.am
r647a2d8 r82c588a 1 if COMPILE_TESTS2 SUBDIRS = tests3 endif4 5 1 # global flags 6 2 AM_CFLAGS = -DAUBIO_PREFIX=\"$(prefix)\" -I$(top_srcdir)/src -I$(top_srcdir)/ext @AUBIO_CFLAGS@ @LASH_CFLAGS@ @FFTWLIB_CFLAGS@ -
src/aubio.h
r647a2d8 r82c588a 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier <piem@altern.org> 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 15 16 17 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 18 18 */ 19 19 … … 22 22 * \section whatis Introduction 23 23 * 24 * 25 * 24 * Aubio is a library for audio labelling: it provides functions for pitch 25 * estimation, onset detection, beat tracking, and other annotation tasks. 26 26 * 27 27 * \verbinclude README … … 29 29 * \section bugs bugs and todo 30 30 * 31 * 32 * 31 * This software is under development. It needs debugging and 32 * optimisations. 33 33 * 34 34 * See <a href='bug.html'>bugs</a> and <a href='todo.html'>todo</a> lists. -
src/pitchdetection.c
r647a2d8 r82c588a 15 15 along with this program; if not, write to the Free Software 16 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */17 */ 18 18 19 19 #include "aubio_priv.h" … … 29 29 #include "pitchdetection.h" 30 30 31 typedef smpl_t (*aubio_pitchdetection_func_t)(aubio_pitchdetection_t *p, 32 fvec_t * ibuf); 33 typedef smpl_t (*aubio_pitchdetection_conv_t)(smpl_t value,uint_t srate,uint_t bufsize); 31 typedef smpl_t (*aubio_pitchdetection_func_t) 32 (aubio_pitchdetection_t *p, fvec_t * ibuf); 33 typedef smpl_t (*aubio_pitchdetection_conv_t) 34 (smpl_t value, uint_t srate, uint_t bufsize); 35 34 36 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf); 35 37 36 smpl_t aubio_pitchdetection_mcomb (aubio_pitchdetection_t *p, fvec_t *ibuf);37 smpl_t aubio_pitchdetection_yin (aubio_pitchdetection_t *p, fvec_t *ibuf);38 smpl_t aubio_pitchdetection_schmitt (aubio_pitchdetection_t *p, fvec_t *ibuf);39 smpl_t aubio_pitchdetection_fcomb (aubio_pitchdetection_t *p, fvec_t *ibuf);40 smpl_t aubio_pitchdetection_yinfft (aubio_pitchdetection_t *p, fvec_t *ibuf);38 smpl_t aubio_pitchdetection_mcomb (aubio_pitchdetection_t *p, fvec_t *ibuf); 39 smpl_t aubio_pitchdetection_yin (aubio_pitchdetection_t *p, fvec_t *ibuf); 40 smpl_t aubio_pitchdetection_schmitt (aubio_pitchdetection_t *p, fvec_t *ibuf); 41 smpl_t aubio_pitchdetection_fcomb (aubio_pitchdetection_t *p, fvec_t *ibuf); 42 smpl_t aubio_pitchdetection_yinfft (aubio_pitchdetection_t *p, fvec_t *ibuf); 41 43 42 44 /** generic pitch detection structure */ … … 64 66 smpl_t freqconvbin(smpl_t f,uint_t srate,uint_t bufsize); 65 67 smpl_t freqconvbin(smpl_t f,uint_t srate,uint_t bufsize){ 66 68 return aubio_freqtobin(f,srate,bufsize); 67 69 } 68 70 69 71 smpl_t freqconvmidi(smpl_t f,uint_t srate,uint_t bufsize); 70 72 smpl_t freqconvmidi(smpl_t f,uint_t srate UNUSED,uint_t bufsize UNUSED){ 71 73 return aubio_freqtomidi(f); 72 74 } 73 75 74 76 smpl_t freqconvpass(smpl_t f,uint_t srate,uint_t bufsize); 75 77 smpl_t freqconvpass(smpl_t f,uint_t srate UNUSED,uint_t bufsize UNUSED){ 76 78 return f; 77 79 } 78 80 79 81 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 80 81 82 83 84 82 uint_t hopsize, 83 uint_t channels, 84 uint_t samplerate, 85 aubio_pitchdetection_type type, 86 aubio_pitchdetection_mode mode) 85 87 { 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 88 aubio_pitchdetection_t *p = AUBIO_NEW(aubio_pitchdetection_t); 89 p->srate = samplerate; 90 p->type = type; 91 p->mode = mode; 92 p->bufsize = bufsize; 93 switch(p->type) { 94 case aubio_pitch_yin: 95 p->buf = new_fvec(bufsize,channels); 96 p->yin = new_fvec(bufsize/2,channels); 97 p->callback = aubio_pitchdetection_yin; 98 p->yinthres = 0.15; 99 break; 100 case aubio_pitch_mcomb: 101 p->pv = new_aubio_pvoc(bufsize, hopsize, channels); 102 p->fftgrain = new_cvec(bufsize, channels); 103 p->mcomb = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate); 104 p->filter = new_aubio_cdsgn_filter(samplerate); 105 p->callback = aubio_pitchdetection_mcomb; 106 break; 107 case aubio_pitch_fcomb: 108 p->buf = new_fvec(bufsize,channels); 109 p->fcomb = new_aubio_pitchfcomb(bufsize,hopsize,samplerate); 110 p->callback = aubio_pitchdetection_fcomb; 111 break; 112 case aubio_pitch_schmitt: 113 p->buf = new_fvec(bufsize,channels); 114 p->schmitt = new_aubio_pitchschmitt(bufsize,samplerate); 115 p->callback = aubio_pitchdetection_schmitt; 116 break; 117 case aubio_pitch_yinfft: 118 p->buf = new_fvec(bufsize,channels); 119 p->yinfft = new_aubio_pitchyinfft(bufsize); 120 p->callback = aubio_pitchdetection_yinfft; 121 p->yinthres = 0.85; 122 break; 123 default: 124 break; 125 } 126 switch(p->mode) { 127 case aubio_pitchm_freq: 128 p->freqconv = freqconvpass; 129 break; 130 case aubio_pitchm_midi: 131 p->freqconv = freqconvmidi; 132 break; 133 case aubio_pitchm_cent: 134 /* bug: not implemented */ 135 p->freqconv = freqconvmidi; 136 break; 137 case aubio_pitchm_bin: 138 p->freqconv = freqconvbin; 139 break; 140 default: 141 break; 142 } 143 return p; 142 144 } 143 145 144 146 void del_aubio_pitchdetection(aubio_pitchdetection_t * p) { 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 147 switch(p->type) { 148 case aubio_pitch_yin: 149 del_fvec(p->yin); 150 del_fvec(p->buf); 151 break; 152 case aubio_pitch_mcomb: 153 del_aubio_pvoc(p->pv); 154 del_cvec(p->fftgrain); 155 del_aubio_pitchmcomb(p->mcomb); 156 break; 157 case aubio_pitch_schmitt: 158 del_fvec(p->buf); 159 del_aubio_pitchschmitt(p->schmitt); 160 break; 161 case aubio_pitch_fcomb: 162 del_fvec(p->buf); 163 del_aubio_pitchfcomb(p->fcomb); 164 break; 165 case aubio_pitch_yinfft: 166 del_fvec(p->buf); 167 del_aubio_pitchyinfft(p->yinfft); 168 break; 169 default: 170 break; 171 } 172 AUBIO_FREE(p); 171 173 } 172 174 173 175 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf){ 174 uint_t i,j = 0, overlap_size = 0; 175 overlap_size = p->buf->length-ibuf->length; 176 for (i=0;i<p->buf->channels;i++){ 177 for (j=0;j<overlap_size;j++){ 178 p->buf->data[i][j] = 179 p->buf->data[i][j+ibuf->length]; 180 } 181 } 182 for (i=0;i<ibuf->channels;i++){ 183 for (j=0;j<ibuf->length;j++){ 184 p->buf->data[i][j+overlap_size] = 185 ibuf->data[i][j]; 186 } 187 } 176 uint_t i,j = 0, overlap_size = 0; 177 overlap_size = p->buf->length-ibuf->length; 178 for (i=0;i<p->buf->channels;i++){ 179 for (j=0;j<overlap_size;j++){ 180 p->buf->data[i][j] = p->buf->data[i][j+ibuf->length]; 181 } 182 } 183 for (i=0;i<ibuf->channels;i++){ 184 for (j=0;j<ibuf->length;j++){ 185 p->buf->data[i][j+overlap_size] = ibuf->data[i][j]; 186 } 187 } 188 188 } 189 189 190 190 void aubio_pitchdetection_set_yinthresh(aubio_pitchdetection_t *p, smpl_t thres) { 191 191 p->yinthres = thres; 192 192 } 193 193 194 194 smpl_t aubio_pitchdetection(aubio_pitchdetection_t *p, fvec_t * ibuf) { 195 195 return p->freqconv(p->callback(p,ibuf),p->srate,p->bufsize); 196 196 } 197 197 198 198 smpl_t aubio_pitchdetection_mcomb(aubio_pitchdetection_t *p, fvec_t *ibuf) { 199 200 201 202 203 204 205 206 207 208 209 199 smpl_t pitch = 0.; 200 aubio_filter_do(p->filter,ibuf); 201 aubio_pvoc_do(p->pv,ibuf,p->fftgrain); 202 pitch = aubio_pitchmcomb_detect(p->mcomb,p->fftgrain); 203 /** \bug should move the >0 check within aubio_bintofreq */ 204 if (pitch>0.) { 205 pitch = aubio_bintofreq(pitch,p->srate,p->bufsize); 206 } else { 207 pitch = 0.; 208 } 209 return pitch; 210 210 } 211 211 212 212 smpl_t aubio_pitchdetection_yin(aubio_pitchdetection_t *p, fvec_t *ibuf) { 213 214 215 216 217 218 219 220 221 213 smpl_t pitch = 0.; 214 aubio_pitchdetection_slideblock(p,ibuf); 215 pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, p->yinthres); 216 if (pitch>0) { 217 pitch = p->srate/(pitch+0.); 218 } else { 219 pitch = 0.; 220 } 221 return pitch; 222 222 } 223 223 224 224 225 225 smpl_t aubio_pitchdetection_yinfft(aubio_pitchdetection_t *p, fvec_t *ibuf){ 226 227 228 229 230 231 232 233 234 226 smpl_t pitch = 0.; 227 aubio_pitchdetection_slideblock(p,ibuf); 228 pitch = aubio_pitchyinfft_detect(p->yinfft,p->buf,p->yinthres); 229 if (pitch>0) { 230 pitch = p->srate/(pitch+0.); 231 } else { 232 pitch = 0.; 233 } 234 return pitch; 235 235 } 236 236 237 237 smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf){ 238 239 238 aubio_pitchdetection_slideblock(p,ibuf); 239 return aubio_pitchfcomb_detect(p->fcomb,p->buf); 240 240 } 241 241 242 242 smpl_t aubio_pitchdetection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf){ 243 244 245 } 243 aubio_pitchdetection_slideblock(p,ibuf); 244 return aubio_pitchschmitt_detect(p->schmitt,p->buf); 245 } -
src/pitchdetection.h
r647a2d8 r82c588a 15 15 along with this program; if not, write to the Free Software 16 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */17 */ 18 18 19 19 #ifndef PITCHAUTOTCORR_H … … 26 26 /** \file 27 27 28 Generic method for pitch detection 28 Generic method for pitch detection 29 29 30 30 This file creates the objects required for the computation of the selected … … 35 35 /** pitch detection algorithm */ 36 36 typedef enum { 37 38 39 40 41 37 aubio_pitch_yin, /**< YIN algorithm */ 38 aubio_pitch_mcomb, /**< Multi-comb filter */ 39 aubio_pitch_schmitt, /**< Schmitt trigger */ 40 aubio_pitch_fcomb, /**< Fast comb filter */ 41 aubio_pitch_yinfft /**< Spectral YIN */ 42 42 } aubio_pitchdetection_type; 43 43 44 44 /** pitch detection output mode */ 45 45 typedef enum { 46 47 48 49 46 aubio_pitchm_freq, /**< Frequency (Hz) */ 47 aubio_pitchm_midi, /**< MIDI note (0.,127) */ 48 aubio_pitchm_cent, /**< Cent */ 49 aubio_pitchm_bin /**< Frequency bin (0,bufsize) */ 50 50 } aubio_pitchdetection_mode; 51 51 … … 54 54 55 55 /** execute pitch detection on an input signal frame 56 56 57 57 \param p pitch detection object as returned by new_aubio_pitchdetection 58 \param ibuf input signal of length hopsize 59 58 \param ibuf input signal of length hopsize 59 60 60 */ 61 61 smpl_t aubio_pitchdetection(aubio_pitchdetection_t * p, fvec_t * ibuf); 62 62 63 63 /** change yin or yinfft tolerance threshold 64 64 65 65 default is 0.15 for yin and 0.85 for yinfft 66 66 67 67 */ 68 68 void aubio_pitchdetection_set_yinthresh(aubio_pitchdetection_t *p, smpl_t thres); 69 69 70 70 /** deletion of the pitch detection object 71 71 72 72 \param p pitch detection object as returned by new_aubio_pitchdetection 73 73 74 74 */ 75 75 void del_aubio_pitchdetection(aubio_pitchdetection_t * p); 76 76 77 77 /** creation of the pitch detection object 78 79 \param bufsize size of the input buffer to analyse 80 \param hopsize step size between two consecutive analysis instant 78 79 \param bufsize size of the input buffer to analyse 80 \param hopsize step size between two consecutive analysis instant 81 81 \param channels number of channels to analyse 82 \param samplerate sampling rate of the signal 82 \param samplerate sampling rate of the signal 83 83 \param type set pitch detection algorithm 84 84 \param mode set pitch units for output 85 85 86 86 */ 87 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 88 uint_t hopsize,89 90 91 92 87 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 88 uint_t hopsize, 89 uint_t channels, 90 uint_t samplerate, 91 aubio_pitchdetection_type type, 92 aubio_pitchdetection_mode mode); 93 93 94 94 #ifdef __cplusplus … … 96 96 #endif 97 97 98 #endif /*PITCHDETECTION_H*/ 98 #endif /*PITCHDETECTION_H*/ -
tests/python/run_all_tests
r647a2d8 r82c588a 4 4 # so the script is runnable from a compiled source tree. 5 5 import sys, os 6 sys.path.append('..') 7 sys.path.append(os.path.join('..','aubio','.libs')) 6 7 cur_dir = os.path.dirname(sys.argv[0]) 8 sys.path.append(os.path.join(cur_dir,'..','..','python')) 9 sys.path.append(os.path.join(cur_dir,'..','..','python','aubio','.libs')) 8 10 9 11 import unittest
Note: See TracChangeset
for help on using the changeset viewer.