Changeset b257b60
- Timestamp:
- Aug 12, 2015, 7:21:38 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:
- 60fc05b
- Parents:
- 3a1a5d6 (diff), 7b2d740 (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:
-
- 12 added
- 129 deleted
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r3a1a5d6 rb257b60 24 24 .lock-waf* 25 25 .waf-* 26 waf 27 waflib 26 28 build/ 27 29 -
ChangeLog
r3a1a5d6 rb257b60 1 2015-08-01 Paul Brossier <piem@aubio.org> 2 3 [ Interface ] 4 * src/onset/onset.h: add aubio_onset_get_silence(), fix description of 5 aubio_onset_get/set_delay functions 6 * src/tempo/tempo.h: add aubio_tempo_get_silence and aubio_tempo_get_threshold 7 8 [ Library ] 9 * src/io/audio_unit.c: fix deprecation warning (closes #16) 10 * src/io/sink_apple_audio.c: avoid opening null path 11 * src/io/sink_sndfile.c: improve error messages, set nsamples after write 12 * src/io/sink_wavwrite.c: fail if samplerate is way too large, assume 13 windows is little endian to build with mingw32 14 * src/io/source_apple_audio.c: check out of bounds _seek, set s->path, quiet 15 * src/io/source_avcodec.c: update to libav10, libavcodec 55.34.1 16 * src/io/source_sndfile.c: cast to uint_t for now, clarify some variables 17 names, fix crash, zero-pad output vector when upsampling, improve seek errors and strings 18 * src/io/source_wavread.c: avoid orphan parenthesis , cast size_t to int to 19 avoid warning on win64 , improve seek errors processing , sync error message 20 * src/onset/onset.c: avoid doubled onset at start, check parameters 21 * src/pitch/pitch.c: add Hertz as valid unit string, check parameters 22 * src/pitch/pitchyin.c, src/pitch/pitchyinfft.c: avoid producing NaN on silence (closes #7) 23 * src/pitch/pitchyin.{c,h}: fix typo, developed 24 * src/spectral/phasevoc.c: fix argument checks, improve error messages 25 * src/synth/sampler.c: make sure blocksize > 0 26 * src/tempo/beattracking.c: avoid segfault on silence (closes #24) 27 * src/tempo/tempo.c: add silence detection (closes #23), add old behavior in 28 examples/aubiotrack.c, check parameters 29 * src/*.c: fix some useless float conversion 30 31 [ Python ] 32 * python/ext/aubiomodule.c: improve documentation 33 * python/ext/py-musicutils.c: add silence_detection (closes #21), 34 level_detection, db_spl, level_lin, complete window implementation 35 * python/ext/py-source.c: add channels, add seek (closes #9) 36 * python/demos/demo_a_weighting.py: add simple demo for a_weighting 37 * python/demos/demo_sink_multi.py: add multi channel version 38 * python/demos/, python/demos/: minor improvements, improve syntax (closes #19) 39 * python/setup.py: use setuptools, add numpy to install_requires 40 41 [ Build ] 42 * waf: removed, now automatically downloaded with make, updated to 1.8.12 43 * Makefile: add target to fetch waf and basic instructions 44 * .travis.yml: added template for travis continuous integration 45 * {examples,src,tests}/wscript_build: add external libs and uselib to targets 46 * src/wscript_build: do not hardocode install path 47 * wscript, src/io/*.c: use custom defines instead of __APPLE__ 48 * wscript: make fat build optional, remove iOS sdk versioning 49 50 [ General ] 51 * examples/: use outmsg to print notes (fixes #8) 52 * examples/parse_args.h: improve short documentation (closes #12) 53 * doc/*.cfg: remove html timestamps to make build reproducible (see debian bug #779216) 54 * doc/aubiocut.txt: improve documentation 55 * doc/*.rst: add sphinx documentation basis with Makefile and conf.py 56 * README.md: minor updates 57 * python.old: removed old code 58 * tests/: minor bug fixing 59 1 60 2014-01-31 Paul Brossier <piem@aubio.org> 2 61 -
README.md
r3a1a5d6 rb257b60 46 46 - `aubioquiet` extracts quiet and loud regions 47 47 48 Additional y, the python module comes with the following script:48 Additionally, the python module comes with the following script: 49 49 50 50 - `aubiocut` slices sound files at onset or beat timestamps … … 78 78 page](http://aubio.org/download). 79 79 80 aubio uses [waf](https://code.google.com/p/waf/) to configure, compile, and 81 test the source: 80 aubio uses [waf](https://waf.io/) to configure, compile, and test the source: 82 81 83 82 ./waf configure … … 85 84 sudo ./waf install 86 85 87 aubio compiles on Linux, Mac OS X, Cygwin, and iPhone. 86 If waf is not found in the directory, you can download and install it with: 87 88 make getwaf 89 90 aubio compiles on Linux, Mac OS X, Cygwin, and iOS. 88 91 89 92 Credits and Publications -
VERSION
r3a1a5d6 rb257b60 1 1 AUBIO_MAJOR_VERSION=0 2 2 AUBIO_MINOR_VERSION=4 3 AUBIO_PATCH_VERSION= 23 AUBIO_PATCH_VERSION=3 4 4 AUBIO_VERSION_STATUS='~alpha' 5 5 LIBAUBIO_LT_CUR=4 6 LIBAUBIO_LT_REV= 17 LIBAUBIO_LT_AGE= 16 LIBAUBIO_LT_REV=2 7 LIBAUBIO_LT_AGE=2 -
doc/aubiocut.txt
r3a1a5d6 rb257b60 20 20 21 21 -r, --samplerate rate Fetch the input source, resampled at the given 22 sampling rate. The rate should be specified in Hertz as an integer. If 0,23 t he sampling rate of the original source will be used. Defaults to 0.22 sampling rate. The rate should be specified in Hertz as an integer. If set 23 to 0, the sampling rate of the original source will be used. Defaults to 0. 24 24 25 25 -B, --bufsize win The size of the buffer to analyze, that is the length … … 40 40 41 41 -c, --cut Cut input sound file at detected labels. A new sound files for 42 each slice will be created in the current directory. 42 each slice will be created in the current directory. 43 44 -o, --output directory Specify the directory path where slices of the 45 original source should be created. 46 47 --cut-until-nsamples n How many extra samples should be added at the end of 48 each slice (default 0). 49 50 --cut-until-nslices n How many extra slices should be added at the end of 51 each slice (default 0). 43 52 44 53 -h, --help Print a short help message and exit. -
doc/full.cfg
r3a1a5d6 rb257b60 1109 1109 # This tag requires that the tag GENERATE_HTML is set to YES. 1110 1110 1111 HTML_TIMESTAMP = YES1111 HTML_TIMESTAMP = NO 1112 1112 1113 1113 # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -
doc/web.cfg
r3a1a5d6 rb257b60 1128 1128 # This tag requires that the tag GENERATE_HTML is set to YES. 1129 1129 1130 HTML_TIMESTAMP = YES1130 HTML_TIMESTAMP = NO 1131 1131 1132 1132 # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -
examples/aubiomfcc.c
r3a1a5d6 rb257b60 41 41 void process_print (void) 42 42 { 43 /* output times in seconds and extracted mfccs */ 44 outmsg("%f\t",blocks*hop_size/(float)samplerate); 45 fvec_print(mfcc_out); 43 /* output times in selected format */ 44 print_time (blocks * hop_size); 45 outmsg ("\t"); 46 /* output extracted mfcc */ 47 fvec_print (mfcc_out); 46 48 } 47 49 -
examples/aubioonset.c
r3a1a5d6 rb257b60 50 50 { 51 51 if ( is_onset ) { 52 outmsg ("%f\n", aubio_onset_get_last_s (o) ); 52 print_time(aubio_onset_get_last (o)); 53 outmsg ("\n"); 53 54 } 54 55 } -
examples/aubiopitch.c
r3a1a5d6 rb257b60 47 47 { 48 48 smpl_t pitch_found = fvec_get_sample(pitch, 0); 49 outmsg("%f %f\n",(blocks)50 *hop_size/(float)samplerate, pitch_found);49 print_time(blocks * hop_size); 50 outmsg(" %f\n", pitch_found); 51 51 } 52 52 -
examples/aubioquiet.c
r3a1a5d6 rb257b60 39 39 void process_print (void) { 40 40 int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0; 41 if (issilence == -1) { 42 outmsg("NOISY: %f\n",curblocks*hop_size/(float)samplerate); 43 } else if (issilence == 2) { 44 outmsg("QUIET: %f\n",curblocks*hop_size/(float)samplerate); 41 if (issilence == -1 || issilence == 2) { 42 if (issilence == -1) { 43 outmsg ("NOISY: "); 44 } else { // if (issilence == 2) { 45 outmsg ("QUIET: "); 46 } 47 print_time (curblocks * hop_size); 48 outmsg ("\n"); 45 49 } 46 50 } -
examples/aubiotrack.c
r3a1a5d6 rb257b60 51 51 void process_print (void) { 52 52 if ( is_beat && !is_silence ) { 53 outmsg("%f\n", aubio_tempo_get_last_s(tempo) ); 53 print_time (aubio_tempo_get_last (tempo)); 54 outmsg ("\n"); 54 55 } 55 56 } … … 71 72 tempo_out = new_fvec(2); 72 73 tempo = new_aubio_tempo(tempo_method, buffer_size, hop_size, samplerate); 74 // set silence threshold very low to output beats even during silence 75 // aubio_tempo_set_silence(tempo, -1000.); 73 76 if (onset_threshold != 0.) aubio_tempo_set_threshold (tempo, onset_threshold); 74 77 -
examples/parse_args.h
r3a1a5d6 rb257b60 35 35 extern char_t * pitch_unit; 36 36 extern smpl_t pitch_tolerance; 37 // time stuff 38 extern uint_t time_format; 37 39 // tempo stuff 38 40 extern char_t * tempo_method; … … 69 71 #endif 70 72 " -r --samplerate select samplerate\n" 73 " use 0 to use input source samplerate, or 32000 to force 32kHz\n" 71 74 " -B --bufsize set buffer size\n" 75 " number of frames to run the analysis on\n" 72 76 " -H --hopsize set hopsize\n" 77 " number of frames to read from source before each analysis\n" 73 78 #ifdef PROG_HAS_ONSET 74 79 " -O --onset select onset detection algorithm\n" 80 " <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux>;\n" 81 " default=hfc\n" 75 82 " -t --onset-threshold set onset detection threshold\n" 83 " a value between 0.1 (more detections) and 1 (less); default=0.3\n" 76 84 #endif /* PROG_HAS_ONSET */ 77 85 #ifdef PROG_HAS_PITCH 78 86 " -p --pitch select pitch detection algorithm\n" 87 " <default|yinfft|yin|mcomb|fcomb|schmitt>; default=yinfft\n" 79 88 " -u --pitch-unit select pitch output unit\n" 89 " <default|freq|hertz|Hz|midi|cent|bin>; default=freq\n" 80 90 " -l --pitch-tolerance select pitch tolerance\n" 91 " (yin, yinfft only) a value between 0.1 and 0.7; default=0.3\n" 81 92 #endif /* PROG_HAS_PITCH */ 82 93 " -s --silence select silence threshold\n" 94 " a value in dB, for instance -70, or -100; default=-90\n" 95 " -T --time-format select time values output format\n" 96 " (samples, ms, seconds) default=seconds\n" 83 97 #ifdef PROG_HAS_OUTPUT 84 98 " -m --mix-input mix input signal with output signal\n" 99 " input signal will be added to output synthesis\n" 85 100 " -f --force-overwrite overwrite output file if needed\n" 101 " do not fail if output file already exists\n" 86 102 #endif 87 103 #ifdef PROG_HAS_JACK … … 111 127 "p:u:l:" 112 128 #endif /* PROG_HAS_PITCH */ 129 "T:" 113 130 "s:mf"; 114 131 int next_option; … … 136 153 #endif /* PROG_HAS_PITCH */ 137 154 {"silence", 1, NULL, 's'}, 155 {"time-format", 1, NULL, 'T'}, 138 156 {"mix-input", 0, NULL, 'm'}, 139 157 {"force-overwrite", 0, NULL, 'f'}, … … 189 207 case 'l': 190 208 pitch_tolerance = (smpl_t) atof (optarg); 209 break; 210 case 'T': 211 if (strcmp (optarg, "samples") == 0) { 212 time_format = 2; 213 } else if (strcmp (optarg, "ms") == 0) { 214 time_format = 1; 215 } else if (strcmp (optarg, "seconds") == 0) { 216 time_format = 0; 217 } else { 218 errmsg ("Warning: did not get '%s' time-format string\n", optarg); 219 } 191 220 break; 192 221 case 's': /* silence threshold */ -
examples/utils.c
r3a1a5d6 rb257b60 48 48 char_t * pitch_method = "default"; 49 49 smpl_t pitch_tolerance = 0.0; // will be set if != 0. 50 // time stuff 51 uint_t time_format = 0; // for "seconds", 1 for "ms", 2 for "samples" 50 52 // tempo stuff 51 53 char_t * tempo_method = "default"; … … 197 199 #endif 198 200 if (velo == 0) { 199 outmsg ("%f\n", blocks * hop_size / (float) samplerate); 200 } else { 201 outmsg ("%f\t%f\t", mpitch, blocks * hop_size / (float) samplerate); 202 } 203 } 204 201 print_time (blocks * hop_size); 202 outmsg ("\n"); 203 } else { 204 outmsg ("%f\t", mpitch); 205 print_time (blocks * hop_size); 206 outmsg ("\t"); 207 } 208 } 209 210 void print_time (uint_t time_in_samples) { 211 /* output times in selected format */ 212 if (time_format == 2) { 213 outmsg ("%d", time_in_samples); 214 } else if (time_format == 1) { 215 outmsg ("%f", 1000. * time_in_samples / (float) samplerate); 216 } else { 217 outmsg ("%f", time_in_samples / (float) samplerate); 218 } 219 } -
examples/utils.h
r3a1a5d6 rb257b60 57 57 void process_block (fvec_t *ibuf, fvec_t *obuf); 58 58 void process_print (void); 59 60 void print_time (uint_t samples); -
examples/wscript_build
r3a1a5d6 rb257b60 2 2 3 3 uselib = [] 4 uselib += ['FFTW3', 'FFTW3F'] 5 uselib += ['SAMPLERATE'] 6 uselib += ['SNDFILE'] 7 uselib += ['AVCODEC'] 8 uselib += ['AVFORMAT'] 9 uselib += ['AVRESAMPLE'] 10 uselib += ['AVUTIL'] 4 11 uselib += ['JACK'] 5 12 … … 20 27 lib = 'm', 21 28 use = ['aubio', 'utilsio'], 29 uselib = uselib, 22 30 source = source_file, 23 31 target = str(source_file).split('.')[0] -
python/demos/demo_mfcc.py
r3a1a5d6 rb257b60 7 7 win_s = 512 # fft size 8 8 hop_s = win_s / 4 # hop size 9 n_filters = 40 9 n_filters = 40 # must be 40 for mfcc 10 10 n_coeffs = 13 11 11 samplerate = 44100 -
python/demos/demo_pitch.py
r3a1a5d6 rb257b60 23 23 24 24 pitch_o = pitch("yin", win_s, hop_s, samplerate) 25 pitch_o.set_unit(" freq")25 pitch_o.set_unit("midi") 26 26 pitch_o.set_tolerance(tolerance) 27 27 … … 37 37 confidence = pitch_o.get_confidence() 38 38 #if confidence < 0.8: pitch = 0. 39 print "%f %f %f" % (total_frames / float(samplerate), pitch, confidence)39 #print "%f %f %f" % (total_frames / float(samplerate), pitch, confidence) 40 40 pitches += [pitch] 41 41 confidences += [confidence] … … 81 81 ax2.axis( ymin = 0.9 * true_freqs.min(), ymax = 1.1 * true_freqs.max() ) 82 82 # plot raw pitches 83 ax2.plot(times, pitches, ' --g')83 ax2.plot(times, pitches, '.g') 84 84 # plot cleaned up pitches 85 85 cleaned_pitches = pitches … … 91 91 #ax2.axis( ymin = 55, ymax = 70 ) 92 92 plt.setp(ax2.get_xticklabels(), visible = False) 93 ax2.set_ylabel('f0 ( Hz)')93 ax2.set_ylabel('f0 (midi)') 94 94 95 95 # plot confidence -
python/ext/aubiomodule.c
r3a1a5d6 rb257b60 2 2 #include "aubio-types.h" 3 3 #include "aubio-generated.h" 4 #include "py-musicutils.h" 5 6 static char aubio_module_doc[] = "Python module for the aubio library"; 7 8 static char Py_alpha_norm_doc[] = "" 9 "alpha_norm(fvec, integer) -> float\n" 10 "\n" 11 "Compute alpha normalisation factor on vector, given alpha\n" 12 "\n" 13 "Example\n" 14 "-------\n" 15 "\n" 16 ">>> b = alpha_norm(a, 9)"; 17 18 static char Py_bintomidi_doc[] = "" 19 "bintomidi(float, samplerate = integer, fftsize = integer) -> float\n" 20 "\n" 21 "Convert bin (float) to midi (float), given the sampling rate and the FFT size\n" 22 "\n" 23 "Example\n" 24 "-------\n" 25 "\n" 26 ">>> midi = bintomidi(float, samplerate = 44100, fftsize = 1024)"; 27 28 static char Py_miditobin_doc[] = "" 29 "miditobin(float, samplerate = integer, fftsize = integer) -> float\n" 30 "\n" 31 "Convert midi (float) to bin (float), given the sampling rate and the FFT size\n" 32 "\n" 33 "Example\n" 34 "-------\n" 35 "\n" 36 ">>> bin = miditobin(midi, samplerate = 44100, fftsize = 1024)"; 37 38 static char Py_bintofreq_doc[] = "" 39 "bintofreq(float, samplerate = integer, fftsize = integer) -> float\n" 40 "\n" 41 "Convert bin number (float) in frequency (Hz), given the sampling rate and the FFT size\n" 42 "\n" 43 "Example\n" 44 "-------\n" 45 "\n" 46 ">>> freq = bintofreq(bin, samplerate = 44100, fftsize = 1024)"; 47 48 static char Py_freqtobin_doc[] = "" 49 "freqtobin(float, samplerate = integer, fftsize = integer) -> float\n" 50 "\n" 51 "Convert frequency (Hz) in bin number (float), given the sampling rate and the FFT size\n" 52 "\n" 53 "Example\n" 54 "-------\n" 55 "\n" 56 ">>> bin = freqtobin(freq, samplerate = 44100, fftsize = 1024)"; 57 58 static char Py_zero_crossing_rate_doc[] = "" 59 "zero_crossing_rate(fvec) -> float\n" 60 "\n" 61 "Compute Zero crossing rate of a vector\n" 62 "\n" 63 "Example\n" 64 "-------\n" 65 "\n" 66 ">>> z = zero_crossing_rate(a)"; 67 68 static char Py_min_removal_doc[] = "" 69 "min_removal(fvec) -> float\n" 70 "\n" 71 "Remove the minimum value of a vector, in-place modification\n" 72 "\n" 73 "Example\n" 74 "-------\n" 75 "\n" 76 ">>> min_removal(a)"; 4 77 5 78 extern void add_generated_objects ( PyObject *m ); 6 79 extern void add_ufuncs ( PyObject *m ); 7 80 extern int generated_types_ready(void); 8 9 static char Py_alpha_norm_doc[] = "compute alpha normalisation factor";10 81 11 82 static PyObject * … … 40 111 } 41 112 42 static char Py_bintomidi_doc[] = "convert bin to midi";43 44 113 static PyObject * 45 114 Py_bintomidi (PyObject * self, PyObject * args) … … 57 126 } 58 127 59 static char Py_miditobin_doc[] = "convert midi to bin";60 61 128 static PyObject * 62 129 Py_miditobin (PyObject * self, PyObject * args) … … 74 141 } 75 142 76 static char Py_bintofreq_doc[] = "convert bin to freq";77 78 143 static PyObject * 79 144 Py_bintofreq (PyObject * self, PyObject * args) … … 91 156 } 92 157 93 static char Py_freqtobin_doc[] = "convert freq to bin";94 95 158 static PyObject * 96 159 Py_freqtobin (PyObject * self, PyObject * args) … … 107 170 return (PyObject *)PyFloat_FromDouble (output); 108 171 } 109 110 static char Py_zero_crossing_rate_doc[] = "compute zero crossing rate";111 172 112 173 static PyObject * … … 139 200 return result; 140 201 } 141 142 static char Py_min_removal_doc[] = "compute zero crossing rate";143 202 144 203 static PyObject * … … 182 241 {"zero_crossing_rate", Py_zero_crossing_rate, METH_VARARGS, Py_zero_crossing_rate_doc}, 183 242 {"min_removal", Py_min_removal, METH_VARARGS, Py_min_removal_doc}, 243 {"level_lin", Py_aubio_level_lin, METH_VARARGS, Py_aubio_level_lin_doc}, 244 {"db_spl", Py_aubio_db_spl, METH_VARARGS, Py_aubio_db_spl_doc}, 245 {"silence_detection", Py_aubio_silence_detection, METH_VARARGS, Py_aubio_silence_detection_doc}, 246 {"level_detection", Py_aubio_level_detection, METH_VARARGS, Py_aubio_level_detection_doc}, 247 {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc}, 184 248 {NULL, NULL} /* Sentinel */ 185 249 }; 186 187 static char aubio_module_doc[] = "Python module for the aubio library";188 250 189 251 PyMODINIT_FUNC -
python/ext/py-sink.c
r3a1a5d6 rb257b60 10 10 } Py_sink; 11 11 12 static char Py_sink_doc[] = "sink object"; 12 static char Py_sink_doc[] = "" 13 " __new__(path, samplerate = 44100, channels = 1)\n" 14 "\n" 15 " Create a new sink, opening the given path for writing.\n" 16 "\n" 17 " Examples\n" 18 " --------\n" 19 "\n" 20 " Create a new sink at 44100Hz, mono:\n" 21 "\n" 22 " >>> sink('/tmp/t.wav')\n" 23 "\n" 24 " Create a new sink at 8000Hz, mono:\n" 25 "\n" 26 " >>> sink('/tmp/t.wav', samplerate = 8000)\n" 27 "\n" 28 " Create a new sink at 32000Hz, stereo:\n" 29 "\n" 30 " >>> sink('/tmp/t.wav', samplerate = 32000, channels = 2)\n" 31 "\n" 32 " Create a new sink at 32000Hz, 5 channels:\n" 33 "\n" 34 " >>> sink('/tmp/t.wav', channels = 5, samplerate = 32000)\n" 35 "\n" 36 " __call__(vec, write)\n" 37 " x(vec,write) <==> x.do(vec, write)\n" 38 "\n" 39 " Write vector to sink.\n" 40 "\n" 41 " See also\n" 42 " --------\n" 43 " aubio.sink.do\n" 44 "\n"; 45 46 static char Py_sink_do_doc[] = "" 47 "x.do(vec, write) <==> x(vec, write)\n" 48 "\n" 49 "write monophonic vector to sink"; 50 51 static char Py_sink_do_multi_doc[] = "" 52 "x.do_multi(mat, write)\n" 53 "\n" 54 "write polyphonic vector to sink"; 55 56 static char Py_sink_close_doc[] = "" 57 "x.close()\n" 58 "\n" 59 "close this sink now"; 13 60 14 61 static PyObject * … … 114 161 } 115 162 116 /* function Py_sink_do */163 /* function Py_sink_do_multi */ 117 164 static PyObject * 118 165 Py_sink_do_multi(Py_sink * self, PyObject * args) … … 148 195 149 196 AUBIO_MEMBERS_START(sink) 150 {"uri", T_STRING, offsetof (Py_sink, uri), READONLY, ""}, 151 {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, ""}, 152 {"channels", T_INT, offsetof (Py_sink, channels), READONLY, ""}, 197 {"uri", T_STRING, offsetof (Py_sink, uri), READONLY, 198 "path at which the sink was created"}, 199 {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, 200 "samplerate at which the sink was created"}, 201 {"channels", T_INT, offsetof (Py_sink, channels), READONLY, 202 "number of channels with which the sink was created"}, 153 203 AUBIO_MEMBERS_STOP(sink) 154 204 … … 161 211 162 212 static PyMethodDef Py_sink_methods[] = { 163 {"__call__", (PyCFunction) Py_sink_do, METH_VARARGS, 164 "x.__call__(vec, write)\n" 165 "write monophonic vector to sink" 166 ""}, 167 {"do", (PyCFunction) Py_sink_do, METH_VARARGS, 168 "x.do(vec, write)\n" 169 "write monophonic vector to sink" 170 ""}, 171 {"do_multi", (PyCFunction) Py_sink_do_multi, METH_VARARGS, 172 "x.do_multi(mat, write)\n" 173 "write polyphonic vector to sink"}, 174 {"close", (PyCFunction) Pyaubio_sink_close, METH_NOARGS, 175 "x.close()\n" 176 "close this sink now"}, 213 {"do", (PyCFunction) Py_sink_do, METH_VARARGS, Py_sink_do_doc}, 214 {"do_multi", (PyCFunction) Py_sink_do_multi, METH_VARARGS, Py_sink_do_multi_doc}, 215 {"close", (PyCFunction) Pyaubio_sink_close, METH_NOARGS, Py_sink_close_doc}, 177 216 {NULL} /* sentinel */ 178 217 }; -
python/ext/py-source.c
r3a1a5d6 rb257b60 11 11 } Py_source; 12 12 13 static char Py_source_doc[] = "source object"; 13 static char Py_source_doc[] = "" 14 " __new__(path, samplerate = 0, hop_size = 512, channels = 1)\n" 15 "\n" 16 " Create a new source, opening the given path for reading.\n" 17 "\n" 18 " Examples\n" 19 " --------\n" 20 "\n" 21 " Create a new source, using the original samplerate, with hop_size = 512:\n" 22 "\n" 23 " >>> source('/tmp/t.wav')\n" 24 "\n" 25 " Create a new source, resampling the original to 8000Hz:\n" 26 "\n" 27 " >>> source('/tmp/t.wav', samplerate = 8000)\n" 28 "\n" 29 " Create a new source, resampling it at 32000Hz, hop_size = 32:\n" 30 "\n" 31 " >>> source('/tmp/t.wav', samplerate = 32000, hop_size = 32)\n" 32 "\n" 33 " Create a new source, using its original samplerate:\n" 34 "\n" 35 " >>> source('/tmp/t.wav', samplerate = 0)\n" 36 "\n" 37 " __call__()\n" 38 " vec, read = x() <==> vec, read = x.do()\n" 39 "\n" 40 " Read vector from source.\n" 41 "\n" 42 " See also\n" 43 " --------\n" 44 " aubio.source.do\n" 45 "\n"; 46 47 static char Py_source_get_samplerate_doc[] = "" 48 "x.get_samplerate() -> source samplerate\n" 49 "\n" 50 "Get samplerate of source."; 51 52 static char Py_source_get_channels_doc[] = "" 53 "x.get_channels() -> number of channels\n" 54 "\n" 55 "Get number of channels in source."; 56 57 static char Py_source_do_doc[] = "" 58 "vec, read = x.do() <==> vec, read = x()\n" 59 "\n" 60 "Read monophonic vector from source."; 61 62 static char Py_source_do_multi_doc[] = "" 63 "mat, read = x.do_multi()\n" 64 "\n" 65 "Read polyphonic vector from source."; 66 67 static char Py_source_close_doc[] = "" 68 "x.close()\n" 69 "\n" 70 "Close this source now."; 71 72 static char Py_source_seek_doc[] = "" 73 "x.seek(position)\n" 74 "\n" 75 "Seek to resampled frame position."; 14 76 15 77 static PyObject * … … 20 82 uint_t samplerate = 0; 21 83 uint_t hop_size = 0; 22 static char *kwlist[] = { "uri", "samplerate", "hop_size", NULL }; 23 24 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|sII", kwlist, 25 &uri, &samplerate, &hop_size)) { 84 uint_t channels = 0; 85 static char *kwlist[] = { "uri", "samplerate", "hop_size", "channels", NULL }; 86 87 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|sIII", kwlist, 88 &uri, &samplerate, &hop_size, &channels)) { 26 89 return NULL; 27 90 } … … 56 119 } 57 120 121 self->channels = 1; 122 if ((sint_t)channels >= 0) { 123 self->channels = channels; 124 } else if ((sint_t)channels < 0) { 125 PyErr_SetString (PyExc_ValueError, 126 "can not use negative value for channels"); 127 return NULL; 128 } 129 58 130 return (PyObject *) self; 59 131 } … … 64 136 self->o = new_aubio_source ( self->uri, self->samplerate, self->hop_size ); 65 137 if (self->o == NULL) { 66 PyErr_SetString (PyExc_StandardError, "error creating object"); 138 char_t errstr[30 + strlen(self->uri)]; 139 sprintf(errstr, "error creating source with %s", self->uri); 140 PyErr_SetString (PyExc_StandardError, errstr); 67 141 return -1; 68 142 } 69 143 self->samplerate = aubio_source_get_samplerate ( self->o ); 70 self->channels = aubio_source_get_channels ( self->o ); 144 if (self->channels == 0) { 145 self->channels = aubio_source_get_channels ( self->o ); 146 } 71 147 72 148 return 0; … … 136 212 137 213 AUBIO_MEMBERS_START(source) 138 {"uri", T_STRING, offsetof (Py_source, uri), READONLY, ""}, 139 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, ""}, 140 {"channels", T_INT, offsetof (Py_source, channels), READONLY, ""}, 141 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, ""}, 214 {"uri", T_STRING, offsetof (Py_source, uri), READONLY, 215 "path at which the source was created"}, 216 {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, 217 "samplerate at which the source is viewed"}, 218 {"channels", T_INT, offsetof (Py_source, channels), READONLY, 219 "number of channels found in the source"}, 220 {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, 221 "number of consecutive frames that will be read at each do or do_multi call"}, 142 222 AUBIO_MEMBERS_STOP(source) 143 223 … … 164 244 } 165 245 246 static PyObject * 247 Pyaubio_source_seek (Py_source *self, PyObject *args) 248 { 249 uint_t err = 0; 250 251 uint_t position; 252 if (!PyArg_ParseTuple (args, "I", &position)) { 253 return NULL; 254 } 255 256 err = aubio_source_seek(self->o, position); 257 if (err != 0) { 258 PyErr_SetString (PyExc_ValueError, 259 "error when seeking in source"); 260 return NULL; 261 } 262 Py_RETURN_NONE; 263 } 264 166 265 static PyMethodDef Py_source_methods[] = { 167 266 {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate, 168 METH_NOARGS, ""},267 METH_NOARGS, Py_source_get_samplerate_doc}, 169 268 {"get_channels", (PyCFunction) Pyaubio_source_get_channels, 170 METH_NOARGS, ""}, 269 METH_NOARGS, Py_source_get_channels_doc}, 270 {"do", (PyCFunction) Py_source_do, 271 METH_NOARGS, Py_source_do_doc}, 171 272 {"do_multi", (PyCFunction) Py_source_do_multi, 172 METH_NOARGS, ""},273 METH_NOARGS, Py_source_do_multi_doc}, 173 274 {"close", (PyCFunction) Pyaubio_source_close, 174 METH_NOARGS, ""}, 275 METH_NOARGS, Py_source_close_doc}, 276 {"seek", (PyCFunction) Pyaubio_source_seek, 277 METH_VARARGS, Py_source_seek_doc}, 175 278 {NULL} /* sentinel */ 176 279 }; -
python/setup.py
r3a1a5d6 rb257b60 1 1 #! /usr/bin/env python 2 2 3 from distutils.coreimport setup, Extension3 from setuptools import setup, Extension 4 4 5 5 import sys … … 47 47 "ext/aubioproxy.c", 48 48 "ext/ufuncs.c", 49 "ext/py-musicutils.c", 49 50 "ext/py-cvec.c", 50 51 # example without macro … … 95 96 platforms = 'any', 96 97 classifiers = classifiers, 98 install_requires = ['numpy'], 97 99 ) -
python/tests/test_cvec.py
r3a1a5d6 rb257b60 10 10 def test_vector_created_with_zeroes(self): 11 11 a = cvec(10) 12 a13 12 shape(a.norm) 14 13 shape(a.phas) … … 36 35 spec = cvec(1024) 37 36 spec.norm[40:100] = 100 38 assert_equal 39 assert_equal 40 assert_equal 41 assert_equal 37 assert_equal(spec.norm[0:40], 0) 38 assert_equal(spec.norm[40:100], 100) 39 assert_equal(spec.norm[100:-1], 0) 40 assert_equal(spec.phas, 0) 42 41 43 42 def test_assign_cvec_phas_slice(self): 44 43 spec = cvec(1024) 45 44 spec.phas[39:-1] = -pi 46 assert_equal 47 assert_equal 48 assert_equal 45 assert_equal(spec.phas[0:39], 0) 46 assert_equal(spec.phas[39:-1], -pi) 47 assert_equal(spec.norm, 0) 49 48 50 49 if __name__ == '__main__': -
python/tests/test_mathutils.py
r3a1a5d6 rb257b60 1 1 #! /usr/bin/env python 2 2 3 from numpy.testing import TestCase, run_module_suite 4 from numpy.testing import assert_equal, assert_almost_equal 3 from numpy.testing import TestCase, assert_equal 5 4 from numpy import array, arange, isnan, isinf 6 5 from aubio import bintomidi, miditobin, freqtobin, bintofreq, freqtomidi, miditofreq -
python/tests/test_pitch.py
r3a1a5d6 rb257b60 68 68 errors = errors[2:] 69 69 # check that the mean of all relative errors is less than 10% 70 assert abs (mean(errors) ) < 0.1, pitches71 assert abs (me an(errors) ) < 0.1, "error is bigger than 0.1 (%f)" % mean(errors)70 #assert abs (mean(errors) ) < 0.1, pitches 71 assert abs (median(errors) ) < 0.06, "median of relative errors is bigger than 0.06 (%f)\n found %s\n errors %s" % (mean(errors), pitches, errors) 72 72 #print 'len(pitches), cut:', len(pitches), cut 73 #print 'me an errors: ', mean(errors), 'mean pitches: ', mean(pitches)73 #print 'median errors: ', median(errors), 'median pitches: ', median(pitches) 74 74 75 75 pitch_algorithms = [ "default", "yinfft", "yin", "schmitt", "mcomb", "fcomb" , "specacf" ] 76 pitch_algorithms = [ "default", "yinfft", "yin", "schmitt", "mcomb", "fcomb" ] 76 77 78 #freqs = [ 27.5, 55., 110., 220., 440., 880., 1760., 3520. ] 79 freqs = [ 110., 220., 440., 880., 1760., 3520. ] 80 signal_modes = [] 81 for freq in freqs: 82 signal_modes += [ 83 ( 4096, 2048, 44100, freq ), 84 ( 2048, 512, 44100, freq ), 85 ( 2048, 1024, 44100, freq ), 86 ( 2048, 1024, 32000, freq ), 87 ] 88 89 freqs = [ ] #55., 110., 220., 440., 880., 1760., 3520. ] 90 for freq in freqs: 91 signal_modes += [ 92 ( 2048, 1024, 22050, freq ), 93 ( 1024, 256, 16000, freq ), 94 ( 1024, 256, 8000, freq ), 95 ( 1024, 512+256, 8000, freq ), 96 ] 97 98 """ 77 99 signal_modes = [ 78 100 ( 4096, 512, 44100, 2.*882. ), … … 88 110 ( 1024, 512+256, 8000, 440. ), 89 111 ] 112 """ 90 113 91 114 def create_test (algo, mode): … … 97 120 for mode in signal_modes: 98 121 test_method = create_test (algo, mode) 99 test_method.__name__ = 'test_pitch_%s_%d_%d_%dHz_sin_%. 2f' % ( algo,122 test_method.__name__ = 'test_pitch_%s_%d_%d_%dHz_sin_%.0f' % ( algo, 100 123 mode[0], mode[1], mode[2], mode[3] ) 101 124 setattr (aubio_pitch_Sinusoid, test_method.__name__, test_method) -
python/tests/test_source.py
r3a1a5d6 rb257b60 33 33 class aubio_source_read_test_case(aubio_source_test_case_base): 34 34 35 def read_from_s ink(self, f):35 def read_from_source(self, f): 36 36 total_frames = 0 37 37 while True: … … 43 43 print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")", 44 44 print "from", f.uri 45 return total_frames 45 46 46 47 def test_samplerate_hopsize(self): … … 49 50 f = source(p, samplerate, hop_size) 50 51 assert f.samplerate != 0 51 self.read_from_s ink(f)52 self.read_from_source(f) 52 53 53 54 def test_samplerate_none(self): … … 55 56 f = source(p) 56 57 assert f.samplerate != 0 57 self.read_from_s ink(f)58 self.read_from_source(f) 58 59 59 60 def test_samplerate_0(self): … … 61 62 f = source(p, 0) 62 63 assert f.samplerate != 0 63 self.read_from_s ink(f)64 self.read_from_source(f) 64 65 65 66 def test_wrong_samplerate(self): … … 86 87 assert f.samplerate != 0 87 88 assert f.hop_size != 0 88 self.read_from_sink(f) 89 self.read_from_source(f) 90 91 def test_seek_to_half(self): 92 from random import randint 93 for p in list_of_sounds: 94 f = source(p, 0, 0) 95 assert f.samplerate != 0 96 assert f.hop_size != 0 97 a = self.read_from_source(f) 98 c = randint(0, a) 99 f.seek(c) 100 b = self.read_from_source(f) 101 assert a == b + c 89 102 90 103 class aubio_source_readmulti_test_case(aubio_source_read_test_case): 91 104 92 def read_from_s ink(self, f):105 def read_from_source(self, f): 93 106 total_frames = 0 94 107 while True: … … 101 114 print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")", 102 115 print "from", f.uri 116 return total_frames 103 117 104 118 if __name__ == '__main__': -
src/aubio_priv.h
r3a1a5d6 rb257b60 129 129 #define AUBIO_SPRINTF sprintf 130 130 131 /* Libc shortcuts */ 131 /* pi and 2*pi */ 132 #ifndef M_PI 133 #define PI (3.14159265358979323846) 134 #else 132 135 #define PI (M_PI) 136 #endif 133 137 #define TWO_PI (PI*2.) 134 138 … … 214 218 #define SAFE_LOG(f) LOG(CEIL_DENORMAL(f)) 215 219 220 /** silence unused parameter warning by adding an attribute */ 221 #if defined(__GNUC__) 216 222 #define UNUSED __attribute__((unused)) 223 #else 224 #define UNUSED 225 #endif 217 226 218 227 #endif /* _AUBIO__PRIV_H */ -
src/io/audio_unit.c
r3a1a5d6 rb257b60 234 234 audioFormat.mChannelsPerFrame = 2; 235 235 audioFormat.mFormatID = kAudioFormatLinearPCM; 236 audioFormat.mFormatFlags = kAudioFormatFlag sCanonical;236 audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; 237 237 audioFormat.mFramesPerPacket = 1; 238 audioFormat.mBitsPerChannel = 8 * sizeof( AudioSampleType);238 audioFormat.mBitsPerChannel = 8 * sizeof(SInt16); 239 239 #if 1 // interleaving 240 audioFormat.mBytesPerFrame = 2 * sizeof( AudioSampleType);241 audioFormat.mBytesPerPacket = 2 * sizeof( AudioSampleType);240 audioFormat.mBytesPerFrame = 2 * sizeof(SInt16); 241 audioFormat.mBytesPerPacket = 2 * sizeof(SInt16); 242 242 #else 243 audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame = sizeof( AudioUnitSampleType);243 audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame = sizeof(SInt32); 244 244 audioFormat.mFormatFlags |= kAudioFormatFlagIsNonInterleaved; 245 245 #endif -
src/io/sink_apple_audio.c
r3a1a5d6 rb257b60 61 61 s->max_frames = MAX_SIZE; 62 62 s->async = true; 63 64 if (uri == NULL) { 65 AUBIO_ERROR("sink_apple_audio: Aborted opening null path\n"); 66 goto beach; 67 } 63 68 64 69 s->samplerate = 0; -
src/io/sink_sndfile.c
r3a1a5d6 rb257b60 142 142 void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t write){ 143 143 uint_t i, j, channels = s->channels; 144 int nsamples = channels*write;144 int nsamples = 0; 145 145 smpl_t *pwrite; 146 146 sf_count_t written_frames; 147 147 148 148 if (write > s->max_size) { 149 AUBIO_WRN(" trying to write %d frames, but only %d can be written at a time",149 AUBIO_WRN("sink_sndfile: trying to write %d frames, but only %d can be written at a time\n", 150 150 write, s->max_size); 151 151 write = s->max_size; 152 152 } 153 154 nsamples = channels * write; 153 155 154 156 /* interleaving data */ … … 162 164 written_frames = sf_write_float (s->handle, s->scratch_data, nsamples); 163 165 if (written_frames/channels != write) { 164 AUBIO_WRN("sink_sndfile: trying to write %d frames to %s, but only %d could be written ",166 AUBIO_WRN("sink_sndfile: trying to write %d frames to %s, but only %d could be written\n", 165 167 write, s->path, (uint_t)written_frames); 166 168 } … … 170 172 void aubio_sink_sndfile_do_multi(aubio_sink_sndfile_t *s, fmat_t * write_data, uint_t write){ 171 173 uint_t i, j, channels = s->channels; 172 int nsamples = channels*write;174 int nsamples = 0; 173 175 smpl_t *pwrite; 174 176 sf_count_t written_frames; 175 177 176 178 if (write > s->max_size) { 177 AUBIO_WRN(" trying to write %d frames, but only %d can be written at a time",179 AUBIO_WRN("sink_sndfile: trying to write %d frames, but only %d can be written at a time\n", 178 180 write, s->max_size); 179 181 write = s->max_size; 180 182 } 183 184 nsamples = channels * write; 181 185 182 186 /* interleaving data */ … … 190 194 written_frames = sf_write_float (s->handle, s->scratch_data, nsamples); 191 195 if (written_frames/channels != write) { 192 AUBIO_WRN("sink_sndfile: trying to write %d frames to %s, but only %d could be written ",196 AUBIO_WRN("sink_sndfile: trying to write %d frames to %s, but only %d could be written\n", 193 197 write, s->path, (uint_t)written_frames); 194 198 } -
src/io/sink_wavwrite.c
r3a1a5d6 rb257b60 45 45 #define HTOLES(x) x 46 46 #else 47 #ifdef HAVE_WIN_HACKS 48 #define HTOLES(x) x 49 #else 47 50 #define HTOLES(x) SWAPS(htons(x)) 51 #endif 48 52 #endif 49 53 … … 98 102 // zero samplerate given. do not open yet 99 103 if ((sint_t)samplerate == 0) return s; 104 // samplerate way too large, fail 105 if ((sint_t)samplerate > 192000 * 4) goto beach; 100 106 101 107 s->samplerate = samplerate; -
src/io/source_sndfile.c
r3a1a5d6 rb257b60 152 152 void aubio_source_sndfile_do(aubio_source_sndfile_t * s, fvec_t * read_data, uint_t * read){ 153 153 uint_t i,j, input_channels = s->input_channels; 154 /* do actual reading*/154 /* read from file into scratch_data */ 155 155 sf_count_t read_samples = sf_read_float (s->handle, s->scratch_data, s->scratch_size); 156 156 157 smpl_t *data;158 157 /* where to store de-interleaved data */ 158 smpl_t *ptr_data; 159 159 #ifdef HAVE_SAMPLERATE 160 160 if (s->ratio != 1) { 161 data = s->input_data->data;161 ptr_data = s->input_data->data; 162 162 } else 163 163 #endif /* HAVE_SAMPLERATE */ 164 164 { 165 data = read_data->data;165 ptr_data = read_data->data; 166 166 } 167 167 168 168 /* de-interleaving and down-mixing data */ 169 169 for (j = 0; j < read_samples / input_channels; j++) { 170 data[j] = 0;170 ptr_data[j] = 0; 171 171 for (i = 0; i < input_channels; i++) { 172 data[j] += s->scratch_data[input_channels*j+i];173 } 174 data[j] /= (smpl_t)input_channels;172 ptr_data[j] += s->scratch_data[input_channels*j+i]; 173 } 174 ptr_data[j] /= (smpl_t)input_channels; 175 175 } 176 176 … … 196 196 sf_count_t read_samples = sf_read_float (s->handle, s->scratch_data, s->scratch_size); 197 197 198 smpl_t **data;199 198 /* where to store de-interleaved data */ 199 smpl_t **ptr_data; 200 200 #ifdef HAVE_SAMPLERATE 201 201 if (s->ratio != 1) { 202 AUBIO_ERR("source_sndfile: no multi channel resampling yet ");202 AUBIO_ERR("source_sndfile: no multi channel resampling yet\n"); 203 203 return; 204 // data = s->input_data->data;204 //ptr_data = s->input_data->data; 205 205 } else 206 206 #endif /* HAVE_SAMPLERATE */ 207 207 { 208 data = read_data->data;208 ptr_data = read_data->data; 209 209 } 210 210 … … 214 214 for (j = 0; j < read_samples / input_channels; j++) { 215 215 for (i = 0; i < read_data->height; i++) { 216 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];216 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i]; 217 217 } 218 218 } … … 222 222 for (j = 0; j < read_samples / input_channels; j++) { 223 223 for (i = 0; i < input_channels; i++) { 224 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];224 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i]; 225 225 } 226 226 } … … 232 232 for (j = 0; j < read_samples / input_channels; j++) { 233 233 for (i = input_channels; i < read_data->height; i++) { 234 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)];234 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)]; 235 235 } 236 236 } … … 265 265 uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) { 266 266 uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio); 267 return sf_seek (s->handle, resampled_pos, SEEK_SET); 267 sf_count_t sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET); 268 if (sf_ret == -1) { 269 AUBIO_ERR("source_sndfile: Failed seeking %s at %d: %s\n", s->path, pos, sf_strerror (NULL)); 270 return AUBIO_FAIL; 271 } 272 if (sf_ret != resampled_pos) { 273 AUBIO_ERR("source_sndfile: Tried seeking %s at %d, but got %d: %s\n", 274 s->path, resampled_pos, (uint_t)sf_ret, sf_strerror (NULL)); 275 return AUBIO_FAIL; 276 } 277 return AUBIO_OK; 268 278 } 269 279 … … 273 283 } 274 284 if(sf_close(s->handle)) { 275 AUBIO_ERR("source_sndfile: Error closing file %s: %s ", s->path, sf_strerror (NULL));285 AUBIO_ERR("source_sndfile: Error closing file %s: %s\n", s->path, sf_strerror (NULL)); 276 286 return AUBIO_FAIL; 277 287 } -
src/io/source_wavread.c
r3a1a5d6 rb257b60 93 93 s->fid = fopen((const char *)path, "rb"); 94 94 if (!s->fid) { 95 AUBIO_ERR("source_wavread: could not open %s (%s)\n", s->path, strerror(errno));95 AUBIO_ERR("source_wavread: Failed opening %s (System error: %s)\n", s->path, strerror(errno)); 96 96 goto beach; 97 97 } … … 220 220 #ifndef HAVE_WIN_HACKS 221 221 AUBIO_ERR("source_wavread: short read (%zd instead of %zd) in %s\n", 222 bytes_read, bytes_expected, s->path); 222 223 #else // mingw does not know about %zd... 223 224 AUBIO_ERR("source_wavread: short read (%d instead of %d) in %s\n", 225 (int)bytes_read, (int)bytes_expected, s->path); 224 226 #endif 225 bytes_read, bytes_expected, s->path);226 227 goto beach; 227 228 } … … 356 357 357 358 uint_t aubio_source_wavread_seek (aubio_source_wavread_t * s, uint_t pos) { 358 uint_t ret = fseek(s->fid, s->seek_start + pos * s->blockalign, SEEK_SET); 359 uint_t ret = 0; 360 if ((sint_t)pos < 0) { 361 return AUBIO_FAIL; 362 } 363 ret = fseek(s->fid, s->seek_start + pos * s->blockalign, SEEK_SET); 364 if (ret != 0) { 365 AUBIO_ERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, strerror(errno)); 366 return AUBIO_FAIL; 367 } 368 // reset some values 359 369 s->eof = 0; 360 370 s->read_index = 0; 361 return ret;371 return AUBIO_OK; 362 372 } 363 373 -
src/mathutils.c
r3a1a5d6 rb257b60 141 141 case aubio_win_parzen: 142 142 for (i=0;i<size;i++) 143 w[i] = 1.0 - ABS((2. *i-size)/(size+1.0));143 w[i] = 1.0 - ABS((2.f*i-size)/(size+1.0f)); 144 144 break; 145 145 default: -
src/musicutils.h
r3a1a5d6 rb257b60 113 113 smpl_t aubio_zero_crossing_rate (fvec_t * v); 114 114 115 /** compute sound level on a linear 115 /** compute sound level on a linear scale 116 116 117 117 This gives the average of the square amplitudes. 118 118 119 \param v vector to compute dB SPLfrom119 \param v vector to compute level from 120 120 121 121 \return level of v -
src/onset/onset.c
r3a1a5d6 rb257b60 69 69 } else { 70 70 // we are at the beginning of the file, and we don't find silence 71 if (o->total_frames == 0&& aubio_silence_detection(input, o->silence) == 0) {71 if (o->total_frames <= o->delay && o->last_onset < o ->minioi && aubio_silence_detection(input, o->silence) == 0) { 72 72 //AUBIO_DBG ("beginning of file is not silent, marking as onset\n"); 73 73 isonset = o->delay / o->hop_size; … … 100 100 } 101 101 102 smpl_t aubio_onset_get_silence(aubio_onset_t * o) { 103 return o->silence; 104 } 105 102 106 uint_t aubio_onset_set_threshold(aubio_onset_t * o, smpl_t threshold) { 103 107 aubio_peakpicker_set_threshold(o->pp, threshold); … … 173 177 { 174 178 aubio_onset_t * o = AUBIO_NEW(aubio_onset_t); 179 180 /* check parameters are valid */ 181 if ((sint_t)hop_size < 1) { 182 AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size); 183 goto beach; 184 } else if ((sint_t)buf_size < 1) { 185 AUBIO_ERR("onset: got buffer_size %d, but can not be < 1\n", buf_size); 186 goto beach; 187 } else if (buf_size < hop_size) { 188 AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", buf_size, hop_size); 189 goto beach; 190 } else if ((sint_t)samplerate < 1) { 191 AUBIO_ERR("onset: samplerate (%d) can not be < 1\n", samplerate); 192 goto beach; 193 } 194 175 195 /* store creation parameters */ 176 196 o->samplerate = samplerate; … … 194 214 o->total_frames = 0; 195 215 return o; 216 217 beach: 218 AUBIO_FREE(o); 219 return NULL; 196 220 } 197 221 -
src/onset/onset.h
r3a1a5d6 rb257b60 126 126 uint_t aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence); 127 127 128 /** get onset detection silence threshold 129 130 \param o onset detection object as returned by new_aubio_onset() 131 132 \return current silence threshold 133 134 */ 135 smpl_t aubio_onset_get_silence(aubio_onset_t * o); 136 128 137 /** get onset detection function 129 138 -
src/pitch/pitch.c
r3a1a5d6 rb257b60 130 130 pitch_type = aubio_pitcht_default; 131 131 } 132 133 // check parameters are valid 134 if ((sint_t)hopsize < 1) { 135 AUBIO_ERR("onset: got hopsize %d, but can not be < 1\n", hopsize); 136 goto beach; 137 } else if ((sint_t)bufsize < 1) { 138 AUBIO_ERR("onset: got buffer_size %d, but can not be < 1\n", bufsize); 139 goto beach; 140 } else if (bufsize < hopsize) { 141 AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", bufsize, hopsize); 142 goto beach; 143 } else if ((sint_t)samplerate < 1) { 144 AUBIO_ERR("onset: samplerate (%d) can not be < 1\n", samplerate); 145 goto beach; 146 } 147 132 148 p->samplerate = samplerate; 133 149 p->type = pitch_type; … … 179 195 } 180 196 return p; 197 198 beach: 199 AUBIO_FREE(p); 200 return NULL; 181 201 } 182 202 … … 238 258 pitch_mode = aubio_pitchm_freq; 239 259 else if (strcmp (pitch_unit, "hertz") == 0) 260 pitch_mode = aubio_pitchm_freq; 261 else if (strcmp (pitch_unit, "Hertz") == 0) 240 262 pitch_mode = aubio_pitchm_freq; 241 263 else if (strcmp (pitch_unit, "Hz") == 0) … … 296 318 aubio_pitch_set_silence (aubio_pitch_t * p, smpl_t silence) 297 319 { 298 if (silence < 0 && silence >-200) {320 if (silence <= 0 && silence >= -200) { 299 321 p->silence = silence; 300 322 return AUBIO_OK; 301 323 } else { 302 AUBIO_ERR("pitch: could doset silence to %.2f", silence);324 AUBIO_ERR("pitch: could not set silence to %.2f", silence); 303 325 return AUBIO_FAIL; 304 326 } -
src/pitch/pitchyin.c
r3a1a5d6 rb257b60 146 146 } 147 147 tmp2 += yin->data[tau]; 148 yin->data[tau] *= tau / tmp2; 148 if (tmp2 != 0) { 149 yin->data[tau] *= tau / tmp2; 150 } else { 151 yin->data[tau] = 1.; 152 } 149 153 period = tau - 3; 150 154 if (tau > 4 && (yin->data[period] < tol) && -
src/pitch/pitchyinfft.c
r3a1a5d6 rb257b60 136 136 // and the cumulative mean normalized difference function 137 137 tmp += yin->data[tau]; 138 yin->data[tau] *= tau / tmp; 138 if (tmp != 0) { 139 yin->data[tau] *= tau / tmp; 140 } else { 141 yin->data[tau] = 1.; 142 } 139 143 } 140 144 // find best candidates -
src/spectral/phasevoc.c
r3a1a5d6 rb257b60 78 78 79 79 if ((sint_t)hop_s < 1) { 80 AUBIO_ERR(" got hop_size %d, but can not be < 1\n", hop_s);80 AUBIO_ERR("pvoc: got hop_size %d, but can not be < 1\n", hop_s); 81 81 goto beach; 82 82 } else if ((sint_t)win_s < 1) { 83 AUBIO_ERR(" got buffer_size %d, but can not be < 1\n", win_s);83 AUBIO_ERR("pvoc: got buffer_size %d, but can not be < 1\n", win_s); 84 84 goto beach; 85 85 } else if (win_s < hop_s) { 86 AUBIO_ERR(" hop size (%d) is larger than win size (%d)\n", win_s, hop_s);86 AUBIO_ERR("pvoc: hop size (%d) is larger than win size (%d)\n", win_s, hop_s); 87 87 goto beach; 88 88 } -
src/spectral/specdesc.c
r3a1a5d6 rb257b60 119 119 onset->data[0] += 120 120 SQRT (ABS (SQR (o->oldmag->data[j]) + SQR (fftgrain->norm[j]) 121 - 2 .* o->oldmag->data[j] * fftgrain->norm[j]121 - 2 * o->oldmag->data[j] * fftgrain->norm[j] 122 122 * COS (o->dev1->data[j] - fftgrain->phas[j]))); 123 123 /* swap old phase data (need to remember 2 frames behind)*/ -
src/spectral/specdesc.h
r3a1a5d6 rb257b60 158 158 /** execute spectral description function on a spectral frame 159 159 160 Generic function to compute spectral de tescription.160 Generic function to compute spectral description. 161 161 162 162 \param o spectral description object as returned by new_aubio_specdesc() -
src/synth/sampler.c
r3a1a5d6 rb257b60 40 40 { 41 41 aubio_sampler_t *s = AUBIO_NEW(aubio_sampler_t); 42 if ((sint_t)blocksize < 1) { 43 AUBIO_ERR("sampler: got blocksize %d, but can not be < 1\n", blocksize); 44 goto beach; 45 } 42 46 s->samplerate = samplerate; 43 47 s->blocksize = blocksize; … … 47 51 s->playing = 0; 48 52 return s; 53 beach: 54 AUBIO_FREE(s); 55 return NULL; 49 56 } 50 57 -
src/tempo/beattracking.c
r3a1a5d6 rb257b60 267 267 sint_t k = 0; 268 268 smpl_t three_energy = 0., four_energy = 0.; 269 if (gp < 2) return 4; 269 270 if (acflen > 6 * gp + 2) { 270 271 for (k = -2; k < 2; k++) { … … 331 332 if (counter == 1 && flagstep == 1) { 332 333 //check for consistency between previous beatperiod values 333 if (ABS (2 .* rp - rp1 - rp2) < bt->g_var) {334 if (ABS (2 * rp - rp1 - rp2) < bt->g_var) { 334 335 //if true, can activate context dependent model 335 336 flagconst = 1; -
src/tempo/tempo.c
r3a1a5d6 rb257b60 110 110 tempo->data[0] = o->out->data[i] - FLOOR(o->out->data[i]); /* set tactus */ 111 111 /* test for silence */ 112 /*113 112 if (aubio_silence_detection(input, o->silence)==1) { 114 113 tempo->data[0] = 0; // unset beat if silent 115 114 } 116 */117 115 o->last_beat = o->total_frames + (uint_t)ROUND(tempo->data[0] * o->hop_size); 118 116 } … … 149 147 o->silence = silence; 150 148 return AUBIO_OK; 149 } 150 151 smpl_t aubio_tempo_get_silence(aubio_tempo_t * o) { 152 return o->silence; 151 153 } 152 154 … … 157 159 } 158 160 161 smpl_t aubio_tempo_get_threshold(aubio_tempo_t * o) { 162 return o->threshold; 163 } 164 159 165 /* Allocate memory for an tempo detection */ 160 166 aubio_tempo_t * new_aubio_tempo (char_t * tempo_mode, … … 164 170 char_t specdesc_func[20]; 165 171 o->samplerate = samplerate; 172 // check parameters are valid 173 if ((sint_t)hop_size < 1) { 174 AUBIO_ERR("tempo: got hop size %d, but can not be < 1\n", hop_size); 175 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); 178 goto beach; 179 } else if (buf_size < hop_size) { 180 AUBIO_ERR("tempo: hop size (%d) is larger than window size (%d)\n", buf_size, hop_size); 181 goto beach; 182 } else if ((sint_t)samplerate < 1) { 183 AUBIO_ERR("tempo: samplerate (%d) can not be < 1\n", samplerate); 184 goto beach; 185 } 186 166 187 /* length of observations, worth about 6 seconds */ 167 188 o->winlen = aubio_next_power_of_two(5.8 * samplerate / hop_size); 189 if (o->winlen < 4) o->winlen = 4; 168 190 o->step = o->winlen/4; 169 191 o->blockpos = 0; … … 194 216 }*/ 195 217 return o; 218 219 beach: 220 AUBIO_FREE(o); 221 return NULL; 196 222 } 197 223 -
src/tempo/tempo.h
r3a1a5d6 rb257b60 94 94 uint_t aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence); 95 95 96 /** get tempo detection silence threshold 97 98 \param o tempo detection object as returned by new_aubio_tempo() 99 100 \return current silence threshold 101 102 */ 103 smpl_t aubio_tempo_get_silence(aubio_tempo_t * o); 104 96 105 /** set tempo detection peak picking threshold 97 106 … … 103 112 */ 104 113 uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold); 114 115 /** get tempo peak picking threshold 116 117 \param o tempo detection object as returned by new_aubio_tempo() 118 119 \return current tempo detection threshold 120 121 */ 122 smpl_t aubio_tempo_get_threshold(aubio_tempo_t * o); 105 123 106 124 /** get current tempo -
src/temporal/resampler.c
r3a1a5d6 rb257b60 77 77 struct _aubio_resampler_t 78 78 { 79 void *dummy; 79 80 }; 80 81 -
src/wscript_build
r3a1a5d6 rb257b60 21 21 # build libaubio.so (cshlib) and/or libaubio.a (cstlib) 22 22 if ctx.env['DEST_OS'] in ['ios', 'iosimulator']: 23 build_features = ['cstlib' ]23 build_features = ['cstlib', 'cshlib'] 24 24 elif ctx.env['DEST_OS'] in ['win32', 'win64']: 25 25 build_features = ['cshlib'] … … 30 30 ctx(features = 'c ' + target, 31 31 use = ['lib_objects'], 32 uselib = uselib, 32 33 lib = 'm', 33 34 target = 'aubio', 34 install_path = '${PREFIX}/lib',35 35 vnum = ctx.env['LIB_VERSION']) 36 36 -
tests/src/io/test-source.c
r3a1a5d6 rb257b60 45 45 n_frames / hop_size, source_path); 46 46 47 // close the file (optional) 48 aubio_source_close(s); 49 // test closing the file a second time 50 aubio_source_close(s); 51 47 52 del_fvec (vec); 48 53 del_aubio_source (s); -
tests/src/io/test-source_apple_audio.c
r3a1a5d6 rb257b60 17 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file. wavat 32000Hz\n");19 PRINT_MSG(" - read file.aif at 32000Hz\n"); 20 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file. wavat original samplerate with 4096 blocks\n");22 PRINT_MSG(" %s file. wav0 4096 \n", argv[0]);21 PRINT_MSG(" - read file.mp3 at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.mp3 0 4096 \n", argv[0]); 23 23 return err; 24 24 } -
tests/src/spectral/test-fft.c
r3a1a5d6 rb257b60 3 3 int main (void) 4 4 { 5 uint_t win_s = 8; // window size 5 uint_t i, n_iters = 100; // number of iterations 6 uint_t win_s = 500; // window size 6 7 fvec_t * in = new_fvec (win_s); // input buffer 7 8 cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase … … 19 20 in->data[6] = 5; 20 21 in->data[7] = 6; 21 fvec_print(in);22 //fvec_print(in); 22 23 23 // execute stft 24 aubio_fft_do (fft,in,fftgrain); 25 cvec_print(fftgrain); 24 for (i = 0; i < n_iters; i++) { 25 // execute stft 26 aubio_fft_do (fft,in,fftgrain); 27 cvec_print(fftgrain); 26 28 27 // execute inverse fourier transform 28 aubio_fft_rdo(fft,fftgrain,out); 29 // execute inverse fourier transform 30 aubio_fft_rdo(fft,fftgrain,out); 31 } 29 32 30 33 // cleam up 31 fvec_print(out);34 //fvec_print(out); 32 35 del_aubio_fft(fft); 33 36 del_fvec(in); -
tests/wscript_build
r3a1a5d6 rb257b60 3 3 for target_name in ctx.path.ant_glob('src/**/*.c'): 4 4 uselib = [] 5 uselib += ['FFTW3', 'FFTW3F'] 6 uselib += ['SAMPLERATE'] 7 uselib += ['SNDFILE'] 8 uselib += ['AVCODEC'] 9 uselib += ['AVFORMAT'] 10 uselib += ['AVRESAMPLE'] 11 uselib += ['AVUTIL'] 12 uselib += ['JACK'] 5 13 includes = ['../src', '.'] 6 14 extra_source = [] -
wscript
r3a1a5d6 rb257b60 118 118 if target_platform in [ 'ios', 'iosimulator' ]: 119 119 ctx.define('TARGET_OS_IPHONE', 1) 120 SDKVER="7.1"121 120 MINSDKVER="6.1" 122 121 ctx.env.CFLAGS += ['-std=c99'] … … 124 123 DEVROOT = "/Applications/Xcode.app/Contents" 125 124 DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer" 126 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS %(SDKVER)s.sdk" % locals()127 #ctx.env.CFLAGS += [ '-arch', 'arm64' ]125 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneOS.sdk" % locals() 126 ctx.env.CFLAGS += [ '-arch', 'arm64' ] 128 127 ctx.env.CFLAGS += [ '-arch', 'armv7' ] 129 128 ctx.env.CFLAGS += [ '-arch', 'armv7s' ] 130 #ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]129 ctx.env.LINKFLAGS += [ '-arch', 'arm64' ] 131 130 ctx.env.LINKFLAGS += ['-arch', 'armv7'] 132 131 ctx.env.LINKFLAGS += ['-arch', 'armv7s'] … … 136 135 DEVROOT = "/Applications/Xcode.app/Contents" 137 136 DEVROOT += "/Developer/Platforms/iPhoneSimulator.platform/Developer" 138 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator %(SDKVER)s.sdk" % locals()137 SDKROOT = "%(DEVROOT)s/SDKs/iPhoneSimulator.sdk" % locals() 139 138 ctx.env.CFLAGS += [ '-arch', 'i386' ] 140 139 ctx.env.CFLAGS += [ '-arch', 'x86_64' ] … … 180 179 if (ctx.options.enable_fftw3f != False): 181 180 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', 182 args = '--cflags --libs', mandatory = False) 181 args = '--cflags --libs', 182 mandatory = ctx.options.enable_fftw3f) 183 183 if (ctx.options.enable_double == True): 184 ctx.msg('Warning', 'fftw3f enabled, but compiling in double precision!') 184 ctx.msg('Warning', 185 'fftw3f enabled, but compiling in double precision!') 185 186 else: 186 # fftw3f not enabled, take most sensible one according to enable_double 187 # fftw3f disabled, take most sensible one according to 188 # enable_double 187 189 if (ctx.options.enable_double == True): 188 190 ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', 189 args = '--cflags --libs', mandatory = False) 191 args = '--cflags --libs', mandatory = 192 ctx.options.enable_fftw3) 190 193 else: 191 194 ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', 192 args = '--cflags --libs', mandatory = False) 195 args = '--cflags --libs', 196 mandatory = ctx.options.enable_fftw3) 193 197 ctx.define('HAVE_FFTW3', 1) 194 198 … … 206 210 if (ctx.options.enable_sndfile != False): 207 211 ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', 208 args = '--cflags --libs', mandatory = False) 212 args = '--cflags --libs', 213 mandatory = ctx.options.enable_sndfile) 209 214 210 215 # check for libsamplerate 211 216 if (ctx.options.enable_samplerate != False): 212 217 ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', 213 args = '--cflags --libs', mandatory = False) 218 args = '--cflags --libs', 219 mandatory = ctx.options.enable_samplerate) 214 220 215 221 # check for jack 216 222 if (ctx.options.enable_jack != False): 217 223 ctx.check_cfg(package = 'jack', 218 args = '--cflags --libs', mandatory = False) 224 args = '--cflags --libs', 225 mandatory = ctx.options.enable_jack) 219 226 220 227 # check for libav 221 228 if (ctx.options.enable_avcodec != False): 222 229 ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0', 223 args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = False) 230 args = '--cflags --libs', uselib_store = 'AVCODEC', 231 mandatory = ctx.options.enable_avcodec) 224 232 ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0', 225 args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = False) 233 args = '--cflags --libs', uselib_store = 'AVFORMAT', 234 mandatory = ctx.options.enable_avcodec) 226 235 ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0', 227 args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = False) 236 args = '--cflags --libs', uselib_store = 'AVUTIL', 237 mandatory = ctx.options.enable_avcodec) 228 238 ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1', 229 args = '--cflags --libs', uselib_store = 'AVRESAMPLE', mandatory = False) 239 args = '--cflags --libs', uselib_store = 'AVRESAMPLE', 240 mandatory = ctx.options.enable_avcodec) 230 241 if all ( 'HAVE_' + i in ctx.env.define_key 231 242 for i in ['AVCODEC', 'AVFORMAT', 'AVUTIL', 'AVRESAMPLE'] ): … … 323 334 ctx.excl += ' **/python.old/*' 324 335 ctx.excl += ' **/python/tests/sounds' 336 ctx.excl += ' **/**.asc'
Note: See TracChangeset
for help on using the changeset viewer.