- Timestamp:
- Apr 1, 2019, 1:30:22 AM (6 years ago)
- Branches:
- feature/cnn, feature/crepe, feature/timestretch, fix/ffmpeg5, master
- Children:
- 65f7886
- Parents:
- 1301f66 (diff), 439ba7b (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:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_wav2midi.py
r1301f66 r7a02ce9 64 64 if new_note[2] > 0: 65 65 track.append(Message('note_off', note=int(new_note[2]), 66 velocity=127, time= 0)66 velocity=127, time=delta) 67 67 ) 68 68 track.append(Message('note_on', -
python/ext/py-filter.c
r1301f66 r7a02ce9 110 110 { 111 111 Py_XDECREF(self->out); 112 del_aubio_filter (self->o); 112 if (self->o) 113 del_aubio_filter (self->o); 113 114 Py_TYPE(self)->tp_free ((PyObject *) self); 114 115 } -
python/ext/py-sink.c
r1301f66 r7a02ce9 151 151 Py_sink_del (Py_sink *self, PyObject *unused) 152 152 { 153 del_aubio_sink(self->o); 154 free(self->mwrite_data.data); 153 if (self->o) { 154 del_aubio_sink(self->o); 155 free(self->mwrite_data.data); 156 } 155 157 if (self->uri) { 156 158 free(self->uri); -
python/ext/py-source.c
r1301f66 r7a02ce9 437 437 aubio_source_do (self->o, &(self->c_read_to), &read); 438 438 439 if (PyErr_Occurred() != NULL) { 440 return NULL; 441 } 442 439 443 outputs = PyTuple_New(2); 440 444 PyTuple_SetItem( outputs, 0, self->read_to ); … … 457 461 /* compute _do function */ 458 462 aubio_source_do_multi (self->o, &(self->c_mread_to), &read); 463 464 if (PyErr_Occurred() != NULL) { 465 return NULL; 466 } 459 467 460 468 outputs = PyTuple_New(2); … … 574 582 } else if (PyLong_AsLong(size) > 0) { 575 583 // short read, return a shorter array 576 PyArrayObject *shortread = (PyArrayObject*)PyTuple_GetItem(done, 0); 584 PyObject *vec = PyTuple_GetItem(done, 0); 585 // take a copy to prevent resizing internal arrays 586 PyArrayObject *shortread = (PyArrayObject*)PyArray_FROM_OTF(vec, 587 NPY_NOTYPE, NPY_ARRAY_ENSURECOPY); 577 588 PyArray_Dims newdims; 578 589 PyObject *reshaped; … … 587 598 reshaped = PyArray_Newshape(shortread, &newdims, NPY_CORDER); 588 599 Py_DECREF(shortread); 600 Py_DECREF(vec); 589 601 return reshaped; 590 602 } else { -
python/lib/moresetuptools.py
r1301f66 r7a02ce9 69 69 for define_macro in ['HAVE_STDLIB_H', 'HAVE_STDIO_H', 70 70 'HAVE_MATH_H', 'HAVE_STRING_H', 71 'HAVE_ C99_VARARGS_MACROS',71 'HAVE_ERRNO_H', 'HAVE_C99_VARARGS_MACROS', 72 72 'HAVE_LIMITS_H', 'HAVE_STDARG_H', 73 73 'HAVE_MEMCPY_HACKS']: -
python/tests/test_sink.py
r1301f66 r7a02ce9 4 4 from aubio import fvec, source, sink 5 5 from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path 6 from _tools import parametrize, skipTest, assert_raises 6 from utils import parse_file_samplerate 7 from _tools import parametrize, skipTest, assert_raises, assert_warns 7 8 8 9 list_of_sounds = list_all_sounds('sounds') … … 61 62 @parametrize('hop_size, samplerate, path', all_params) 62 63 def test_read_and_write(self, hop_size, samplerate, path): 64 orig_samplerate = parse_file_samplerate(soundfile) 63 65 try: 64 f = source(path, samplerate, hop_size) 66 if orig_samplerate is not None and orig_samplerate < samplerate: 67 # upsampling should emit a warning 68 with assert_warns(UserWarning): 69 f = source(soundfile, samplerate, hop_size) 70 else: 71 f = source(soundfile, samplerate, hop_size) 65 72 except RuntimeError as e: 66 73 err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})' … … 79 86 @parametrize('hop_size, samplerate, path', all_params) 80 87 def test_read_and_write_multi(self, hop_size, samplerate, path): 88 orig_samplerate = parse_file_samplerate(soundfile) 81 89 try: 82 f = source(path, samplerate, hop_size) 90 if orig_samplerate is not None and orig_samplerate < samplerate: 91 # upsampling should emit a warning 92 with assert_warns(UserWarning): 93 f = source(soundfile, samplerate, hop_size) 94 else: 95 f = source(soundfile, samplerate, hop_size) 83 96 except RuntimeError as e: 84 97 err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})' -
python/tests/test_source.py
r1301f66 r7a02ce9 4 4 from numpy.testing import TestCase, assert_equal 5 5 from aubio import source 6 from utils import list_all_sounds 6 from utils import list_all_sounds, parse_file_samplerate 7 7 import unittest 8 from _tools import parametrize, assert_raises, assert_equal, skipTest 8 from _tools import assert_raises, assert_equal, assert_warns 9 from _tools import parametrize, skipTest 9 10 10 11 list_of_sounds = list_all_sounds('sounds') … … 24 25 _debug = False 25 26 26 class Test_aubio_source_test_case(object): 27 28 @parametrize('filename', list_of_sounds) 29 def test_close_file(self, filename): 27 28 class Test_aubio_source_test_case(TestCase): 29 30 def setUp(self): 31 if not default_test_sound: 32 skipTest(no_sounds_msg) 33 34 def test_close_file(self): 30 35 samplerate = 0 # use native samplerate 31 36 hop_size = 256 32 f = source(filename, samplerate, hop_size) 33 f.close() 34 35 @parametrize('filename', list_of_sounds) 36 def test_close_file_twice(self, filename): 37 f = source(default_test_sound, samplerate, hop_size) 38 f.close() 39 40 def test_close_file_twice(self): 37 41 samplerate = 0 # use native samplerate 38 42 hop_size = 256 39 f = source(filename, samplerate, hop_size) 40 f.close() 41 f.close() 43 f = source(default_test_sound, samplerate, hop_size) 44 f.close() 45 f.close() 46 47 def test_read_after_close(self): 48 samplerate = 0 # use native samplerate 49 hop_size = 256 50 f = source(default_test_sound, samplerate, hop_size) 51 read, frames = f() 52 f.close() 53 with assert_raises(RuntimeError): 54 read, frames = f() 55 with assert_raises(RuntimeError): 56 read, frames = f.do_multi() 57 42 58 43 59 class Test_aubio_source_read(object): … … 61 77 @parametrize('hop_size, samplerate, soundfile', all_params) 62 78 def test_samplerate_hopsize(self, hop_size, samplerate, soundfile): 79 orig_samplerate = parse_file_samplerate(soundfile) 63 80 try: 64 f = source(soundfile, samplerate, hop_size) 81 if orig_samplerate is not None and orig_samplerate < samplerate: 82 # upsampling should emit a warning 83 with assert_warns(UserWarning): 84 f = source(soundfile, samplerate, hop_size) 85 else: 86 f = source(soundfile, samplerate, hop_size) 65 87 except RuntimeError as e: 66 88 err_msg = 'failed opening with hop_s={:d}, samplerate={:d} ({:s})' -
python/tests/utils.py
r1301f66 r7a02ce9 2 2 3 3 import os 4 import re 4 5 import glob 5 6 import numpy as np … … 78 79 total_files += 1 79 80 return total_files 81 82 def parse_file_samplerate(soundfile): 83 samplerate = None 84 # parse samplerate 85 re_sr = re.compile(r'/([0-9]{4,})Hz_.*') 86 match_samplerate = re_sr.findall(soundfile) 87 if match_samplerate: 88 samplerate = int(match_samplerate[0]) 89 else: 90 import warnings 91 warnings.warn(UserWarning("could not parse samplerate for {:s}" 92 .format(soundfile))) 93 return samplerate
Note: See TracChangeset
for help on using the changeset viewer.