- Timestamp:
- Sep 23, 2016, 6:57:20 AM (9 years ago)
- Branches:
- feature/cnn, feature/crepe, feature/pitchshift, feature/timestretch, fix/applefworks, fix/ffmpeg5, master, pitchshift, sampler, timestretch
- Children:
- 7d01fdf
- Parents:
- 3ffedf22 (diff), bd8a92d (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:
- python
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_mfcc.py
r3ffedf22 rad65346 3 3 import sys 4 4 from aubio import source, pvoc, mfcc 5 from numpy import vstack, zeros 5 from numpy import vstack, zeros, diff 6 6 7 win_s = 512 # fft size8 hop_s = win_s // 4 # hop size9 7 n_filters = 40 # must be 40 for mfcc 10 8 n_coeffs = 13 11 samplerate = 4410012 9 13 10 if len(sys.argv) < 2: 14 print("Usage: %s <source_filename>" % sys.argv[0]) 11 print("Usage: %s <source_filename> [samplerate] [win_s] [hop_s] [mode]" % sys.argv[0]) 12 print(" where [mode] can be 'delta' or 'ddelta' for first and second derivatives") 15 13 sys.exit(1) 16 14 17 15 source_filename = sys.argv[1] 16 17 if len(sys.argv) > 2: samplerate = int(sys.argv[2]) 18 else: samplerate = 0 19 if len(sys.argv) > 3: win_s = int(sys.argv[3]) 20 else: win_s = 512 21 if len(sys.argv) > 4: hop_s = int(sys.argv[4]) 22 else: hop_s = win_s // 4 23 if len(sys.argv) > 5: mode = sys.argv[5] 24 else: mode = "default" 18 25 19 26 samplerate = 0 … … 49 56 wave.yaxis.set_visible(False) 50 57 58 # compute first and second derivatives 59 if mode in ["delta", "ddelta"]: 60 mfccs = diff(mfccs, axis = 0) 61 if mode == "ddelta": 62 mfccs = diff(mfccs, axis = 0) 63 51 64 all_times = arange(mfccs.shape[0]) * hop_s 52 65 n_coeffs = mfccs.shape[1] … … 54 67 ax = plt.axes ( [0.1, 0.75 - ((i+1) * 0.65 / n_coeffs), 0.8, 0.65 / n_coeffs], sharex = wave ) 55 68 ax.xaxis.set_visible(False) 56 ax.yaxis.set_visible(False) 69 ax.set_yticks([]) 70 ax.set_ylabel('%d' % i) 57 71 ax.plot(all_times, mfccs.T[i]) 58 72 59 73 # add time to the last axis 60 set_xlabels_sample2time( ax, frames_read, samplerate) 74 set_xlabels_sample2time( ax, frames_read, samplerate) 61 75 62 76 #plt.ylabel('spectral descriptor value') 63 77 ax.xaxis.set_visible(True) 64 wave.set_title('MFCC for %s' % source_filename) 78 title = 'MFCC for %s' % source_filename 79 if mode == "delta": title = mode + " " + title 80 elif mode == "ddelta": title = "double-delta" + " " + title 81 wave.set_title(title) 65 82 plt.show() -
python/ext/aubiomodule.c
r3ffedf22 rad65346 257 257 #endif 258 258 259 void 260 aubio_log_function(int level, const char *message, void *data) 261 { 262 // remove trailing \n 263 char *pos; 264 if ((pos=strchr(message, '\n')) != NULL) { 265 *pos = '\0'; 266 } 267 // warning or error 268 if (level == AUBIO_LOG_ERR) { 269 PyErr_Format(PyExc_RuntimeError, "%s", message); 270 } else { 271 PyErr_WarnEx(PyExc_UserWarning, message, 1); 272 } 273 } 274 259 275 static PyObject * 260 276 initaubio (void) … … 316 332 add_ufuncs(m); 317 333 334 aubio_log_set_level_function(AUBIO_LOG_ERR, aubio_log_function, NULL); 335 aubio_log_set_level_function(AUBIO_LOG_WRN, aubio_log_function, NULL); 318 336 return m; 319 337 } -
python/ext/py-fft.c
r3ffedf22 rad65346 52 52 self->o = new_aubio_fft (self->win_s); 53 53 if (self->o == NULL) { 54 PyErr_Format(PyExc_RuntimeError, 55 "error creating fft with win_s=%d " 56 "(should be a power of 2 greater than 1; " 57 "try recompiling aubio with --enable-fftw3)", 58 self->win_s); 54 // PyErr_Format(PyExc_RuntimeError, ...) was set above by new_ which called 55 // AUBIO_ERR when failing 59 56 return -1; 60 57 } -
python/ext/py-phasevoc.c
r3ffedf22 rad65346 67 67 self->o = new_aubio_pvoc ( self->win_s, self->hop_s); 68 68 if (self->o == NULL) { 69 PyErr_Format(PyExc_RuntimeError, 70 "failed creating pvoc with win_s=%d, hop_s=%d", 71 self->win_s, self->hop_s); 69 // PyErr_Format(PyExc_RuntimeError, ...) was set above by new_ which called 70 // AUBIO_ERR when failing 72 71 return -1; 73 72 } -
python/ext/py-source.c
r3ffedf22 rad65346 141 141 self->o = new_aubio_source ( self->uri, self->samplerate, self->hop_size ); 142 142 if (self->o == NULL) { 143 PyErr_Format (PyExc_RuntimeError, "error creating source with \"%s\"",144 self->uri);143 // PyErr_Format(PyExc_RuntimeError, ...) was set above by new_ which called 144 // AUBIO_ERR when failing 145 145 return -1; 146 146 } -
python/lib/moresetuptools.py
r3ffedf22 rad65346 66 66 'HAVE_MATH_H', 'HAVE_STRING_H', 67 67 'HAVE_C99_VARARGS_MACROS', 68 'HAVE_LIMITS_H', 'HAVE_MEMCPY_HACKS']: 68 'HAVE_LIMITS_H', 'HAVE_STDARG_H', 69 'HAVE_MEMCPY_HACKS']: 69 70 ext.define_macros += [(define_macro, 1)] 70 71 -
python/tests/test_fvec.py
r3ffedf22 rad65346 99 99 alpha = np.random.rand() * 5. 100 100 x_alpha_norm = (np.sum(np.abs(x)**alpha)/len(x))**(1/alpha) 101 assert_almost_equal(alpha_norm(x, alpha), x_alpha_norm, decimal = 5)101 assert_almost_equal(alpha_norm(x, alpha), x_alpha_norm, decimal = 4) 102 102 103 103 class aubio_zero_crossing_rate_test(TestCase): -
python/tests/test_source.py
r3ffedf22 rad65346 6 6 from aubio import source 7 7 from utils import list_all_sounds 8 9 import warnings 10 warnings.filterwarnings('ignore', category=UserWarning, append=True) 8 11 9 12 list_of_sounds = list_all_sounds('sounds') … … 23 26 24 27 def setUp(self): 25 if not len(list_of_sounds): self.skipTest('add some sound files in \'python/tests/sounds\'') 28 if not len(list_of_sounds): 29 self.skipTest('add some sound files in \'python/tests/sounds\'') 26 30 self.default_test_sound = list_of_sounds[0] 27 31 -
python/tests/test_specdesc.py
r3ffedf22 rad65346 226 226 227 227 def test_unknown(self): 228 # FIXME should fail? 229 with self.assertRaises(ValueError): 228 with self.assertRaises(RuntimeError): 230 229 specdesc("unknown", 512) 231 self.skipTest('todo: new_specdesc should fail on wrong method')232 230 233 231 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.