shithub: aubio

Download patch

ref: 189c6ae6ed15ad2875bb0331110f681949fe2868
parent: 4624a568210ffe2b8fc106d5ac5b8f24f76b5322
parent: fb4ab893f8d305b2aa969c766222a4c22f717294
author: Paul Brossier <piem@piem.org>
date: Tue Aug 7 10:05:49 EDT 2018

Merge branch 'master' into dct

--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -42,22 +42,22 @@
   - "%PYTHONDIR%\\python.exe --version"
   - "%PYTHONDIR%\\python.exe -c \"import struct; print(struct.calcsize('P') * 8)\""
 
+  - "%PYTHONDIR%\\python.exe -m pip install --disable-pip-version-check --user --upgrade pip"
+  - "%PYTHONDIR%\\python.exe -m pip install --upgrade setuptools"
+
   # We need wheel installed to build wheels
   - "%PYTHONDIR%\\python.exe -m pip install wheel"
 
   - "SET PATH=%PATH_EXTRAS%;%PYTHONDIR%;%PYTHONDIR%\\Scripts;%PATH%"
 
-  - "pip install --disable-pip-version-check --user --upgrade pip"
-  - "pip install --upgrade setuptools"
-
 before_build:
   - "bash scripts/get_waf.sh"
 
 build_script:
   # build python module without using libaubio
-  - "pip install -r requirements.txt"
+  - "%PYTHONDIR%\\python.exe -m pip install -r requirements.txt"
   - "python setup.py build"
-  - "pip install ."
+  - "%PYTHONDIR%\\python.exe -m pip install ."
   - "python python\\demos\\demo_create_test_sounds.py"
   - "nose2 --verbose"
   # clean up
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,10 +11,6 @@
     - python: 2.7
       os: linux
       compiler: gcc
-    - language: C
-      os: osx
-      osx_image: xcode8
-      compiler: clang
     - python: 3.5
       os: linux
       compiler: gcc
@@ -29,37 +25,21 @@
       env: CFLAGS="`dpkg-buildflags --get CFLAGS`" LDFLAGS="`dpkg-buildflags --get LDFLAGS`"
     - language: C
       os: osx
-      osx_image: xcode8
       compiler: clang
-      env: CFLAGS="-Os" HAVE_AUBIO_DOUBLE=1 WAFOPTS="--disable-accelerate"
     - language: C
       os: osx
-      osx_image: xcode8
       compiler: clang
-      env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile"
+      env: CFLAGS="-Os" HAVE_AUBIO_DOUBLE=1 WAFOPTS="--disable-accelerate"
     - language: C
       os: osx
-      osx_image: xcode8
       compiler: clang
-      env: WAFOPTS="--with-target-platform=ios --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
-    - language: C
-      os: osx
-      osx_image: xcode8
-      compiler: clang
-      env: WAFOPTS="--with-target-platform=iosimulator --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
-    - language: C
-      os: osx
-      osx_image: xcode8.2
-      compiler: clang
       env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile"
     - language: C
       os: osx
-      osx_image: xcode8.2
       compiler: clang
       env: WAFOPTS="--with-target-platform=ios --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
     - language: C
       os: osx
-      osx_image: xcode8.2
       compiler: clang
       env: WAFOPTS="--with-target-platform=iosimulator --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
 
@@ -95,6 +75,10 @@
      fi;
 
 install:
+  - |
+    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
+      alias pip=pip2
+    fi;
   - travis_retry pip install --upgrade pip
   - travis_retry make getwaf expandwaf deps_python
   - which pip
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 [![Travis build status](https://travis-ci.org/aubio/aubio.svg?branch=master)](https://travis-ci.org/aubio/aubio "Travis build status")
 [![Appveyor build status](https://img.shields.io/appveyor/ci/piem/aubio/master.svg)](https://ci.appveyor.com/project/piem/aubio "Appveyor build status")
 [![Landscape code health](https://landscape.io/github/aubio/aubio/master/landscape.svg?style=flat)](https://landscape.io/github/aubio/aubio/master "Landscape code health")
-[![Commits since last release](https://img.shields.io/github/commits-since/aubio/aubio/0.4.6.svg)](https://github.com/aubio/aubio "Commits since last release")
+[![Commits since last release](https://img.shields.io/github/commits-since/aubio/aubio/latest.svg)](https://github.com/aubio/aubio "Commits since last release")
 
 [![Documentation](https://readthedocs.org/projects/aubio/badge/?version=latest)](http://aubio.readthedocs.io/en/latest/?badge=latest "Latest documentation")
 [![DOI](https://zenodo.org/badge/396389.svg)](https://zenodo.org/badge/latestdoi/396389)
--- a/doc/develop.rst
+++ b/doc/develop.rst
@@ -1,7 +1,7 @@
 .. _develop:
 
-Developping with aubio
-======================
+Developing with aubio
+=====================
 
 Here is a brief overview of the C library.
 
--- a/doc/statuslinks.rst
+++ b/doc/statuslinks.rst
@@ -17,7 +17,7 @@
    :target: https://aubio.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation status
 
-.. image:: https://img.shields.io/github/commits-since/aubio/aubio/0.4.6.svg?maxAge=2592000
+.. image:: https://img.shields.io/github/commits-since/aubio/aubio/latest.svg
    :target: https://github.com/aubio/aubio
    :alt: Commits since last release
 
--- a/examples/parse_args.h
+++ b/examples/parse_args.h
@@ -115,13 +115,13 @@
       "       -f      --force-overwrite  overwrite output file if needed\n"
       "                 do not fail if output file already exists\n"
 #endif /* PROG_HAS_OUTPUT */
-#ifdef PROG_HAS_JACK
+#if defined(PROG_HAS_JACK) && defined(HAVE_JACK)
       "       -j      --jack             use Jack\n"
 #if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
       "       -N      --miditap-note     MIDI note; default=69.\n"
       "       -V      --miditap-velo     MIDI velocity; default=65.\n"
 #endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */
-#endif /* PROG_HAS_JACK */
+#endif /* defined(PROG_HAS_JACK) && defined(HAVE_JACK) */
       "       -v      --verbose          be verbose\n"
       "       -h      --help             display this message\n"
       );
@@ -313,7 +313,8 @@
     usejack = 1;
 #else
     errmsg("Error: no arguments given (and no available audio input)\n");
-    usage ( stderr, 1 );
+    errmsg("       consider recompiling with jack support (--enable-jack)\n");
+    exit ( 1 );
 #endif /* HAVE_JACK */
 #else
     errmsg("Error: no arguments given\n");
--- a/python/demos/demo_pitch_sinusoid.py
+++ b/python/demos/demo_pitch_sinusoid.py
@@ -37,7 +37,7 @@
 
 pointer += partition
 pointer += partition
-freqs[ pointer : pointer + partition ] = 400 + 5 * np.random.random(sin_length/8)
+freqs[ pointer : pointer + partition ] = 400 + 5 * np.random.random(sin_length//8)
 
 a = build_sinusoid(sin_length, freqs, samplerate)
 
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -58,7 +58,11 @@
 #include "fmat.h"
 #include "source_avcodec.h"
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56, 56, 0)
 #define AUBIO_AVCODEC_MAX_BUFFER_SIZE FF_MIN_BUFFER_SIZE
+#else
+#define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+#endif
 
 struct _aubio_source_avcodec_t {
   uint_t hop_size;
@@ -271,6 +275,8 @@
   // default to mono output
   aubio_source_avcodec_reset_resampler(s, 0);
 
+  if (s->avr == NULL) goto beach;
+
   s->eof = 0;
   s->multi = 0;
 
@@ -418,6 +424,15 @@
     AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n", s->path);
     goto beach;
   }
+
+#if LIBAVUTIL_VERSION_MAJOR > 52
+  if (avFrame->channels != (sint_t)s->input_channels) {
+    AUBIO_WRN ("source_avcodec: trying to read from %d channel(s),"
+        "but configured for %d; is '%s' corrupt?\n", avFrame->channels,
+        s->input_channels, s->path);
+    goto beach;
+  }
+#endif
 
 #ifdef HAVE_AVRESAMPLE
   in_linesize = 0;
--- a/src/io/source_wavread.c
+++ b/src/io/source_wavread.c
@@ -189,6 +189,26 @@
   // BitsPerSample
   bytes_read += fread(buf, 1, 2, s->fid);
   bitspersample = read_little_endian(buf, 2);
+
+  if ( channels == 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (number of channels can not be 0)\n", s->path);
+    goto beach;
+  }
+
+  if ( (sint_t)sr <= 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (samplerate can not be <= 0)\n", s->path);
+    goto beach;
+  }
+
+  if ( byterate == 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (byterate can not be 0)\n", s->path);
+    goto beach;
+  }
+
+  if ( bitspersample == 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (bitspersample can not be 0)\n", s->path);
+    goto beach;
+  }
 #if 0
   if ( bitspersample != 16 ) {
     AUBIO_ERR("source_wavread: can not process %dbit file %s\n",
--- a/src/notes/notes.c
+++ b/src/notes/notes.c
@@ -83,6 +83,7 @@
   o->onset_output = new_fvec (1);
 
   o->pitch = new_aubio_pitch (pitch_method, o->pitch_buf_size, o->hop_size, o->samplerate);
+  if (o->pitch == NULL) goto fail;
   if (o->pitch_tolerance != 0.) aubio_pitch_set_tolerance (o->pitch, o->pitch_tolerance);
   aubio_pitch_set_unit (o->pitch, "midi");
   o->pitch_output = new_fvec (1);
--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -307,6 +307,8 @@
   } else if (strcmp (onset_mode, "phase") == 0) {
     o->apply_compression = 0;
     aubio_onset_set_awhitening (o, 0);
+  } else if (strcmp (onset_mode, "wphase") == 0) {
+    // use defaults for now
   } else if (strcmp (onset_mode, "mkl") == 0) {
     aubio_onset_set_threshold (o, 0.05);
     aubio_onset_set_awhitening(o, 1);
--- a/src/pitch/pitchyinfft.c
+++ b/src/pitch/pitchyinfft.c
@@ -44,7 +44,7 @@
      0.,    20.,    25.,   31.5,    40.,    50.,    63.,    80.,   100.,   125.,
    160.,   200.,   250.,   315.,   400.,   500.,   630.,   800.,  1000.,  1250.,
   1600.,  2000.,  2500.,  3150.,  4000.,  5000.,  6300.,  8000.,  9000., 10000.,
- 12500., 15000., 20000., 25100
+ 12500., 15000., 20000., 25100., -1.
 };
 
 static const smpl_t weight[] = {
@@ -72,7 +72,10 @@
   p->weight = new_fvec (bufsize / 2 + 1);
   for (i = 0; i < p->weight->length; i++) {
     freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate;
-    while (freq > freqs[j]) {
+    while (freq > freqs[j] && freqs[j] > 0) {
+      //AUBIO_DBG("freq %3.5f > %3.5f \tsamplerate %d (Hz) \t"
+      //    "(weight length %d, bufsize %d) %d %d\n", freq, freqs[j],
+      //    samplerate, p->weight->length, bufsize, i, j);
       j += 1;
     }
     a0 = weight[j - 1];