shithub: aubio

Download patch

ref: 911b175dd18c37bb566d08ac5350f6bbff6c45f3
parent: 1136442dc19347a7330dca1ca0b58b97324872ff
parent: 2a7bcaacd74b38b47b91e6951d1c1481a515f064
author: Paul Brossier <piem@piem.org>
date: Sun Mar 26 09:31:48 EDT 2017

Merge branch 'master' into awhitening

diff: cannot open a/python/scripts//null: file does not exist: 'a/python/scripts//null'
--- a/.gitignore
+++ b/.gitignore
@@ -38,8 +38,11 @@
 python/*.db
 python/*.wav
 
+pip-delete-this-directory.txt
+
 aubio-*.tar.bz2
 aubio-*.zip
+dist/*.tar.gz
 
 # test sounds
 python/tests/sounds
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,6 @@
 include AUTHORS COPYING README.md VERSION ChangeLog
 include python/README.md
+include this_version.py
 include Makefile wscript */wscript_build
 include waf waflib/* waflib/*/*
 exclude waflib/__pycache__/*
--- a/README.md
+++ b/README.md
@@ -1,6 +1,12 @@
-aubio library
-=============
+aubio
+=====
 
+[![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://ci.appveyor.com/api/projects/status/f3lhy3a57rkgn5yi?svg=true)](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")
+[![Documentation Status](https://readthedocs.org/projects/aubio/badge/?version=latest)](http://aubio.readthedocs.io/en/latest/?badge=latest "Documentation status")
+[![Commits since last release](https://img.shields.io/github/commits-since/aubio/aubio/0.4.4.svg?maxAge=2592000)](https://github.com/aubio/aubio "Commits since last release")
+
 aubio is a library to label music and sounds. It listens to audio signals and
 attempts to detect events. For instance, when a drum is hit, at which frequency
 is a note, or at what tempo is a rhythmic melody.
@@ -50,23 +56,6 @@
 
  - `aubiocut` slices sound files at onset or beat timestamps
 
-Implementation and Design Basics
---------------------------------
-
-The library is written in C and is optimised for speed and portability.
-
-The C API is designed in the following way:
-
-    aubio_something_t * new_aubio_something (void * args);
-    audio_something_do (aubio_something_t * t, void * args);
-    smpl_t aubio_something_get_a_parameter (aubio_something_t *t);
-    uint_t aubio_something_set_a_parameter (aubio_something_t *t, smpl_t a_parameter);
-    void del_aubio_something (aubio_something_t * t);
-
-For performance and real-time operation, no memory allocation or freeing take
-place in the `_do` methods. Instead, memory allocation should always take place
-in the `new_` methods, whereas free operations are done in the `del_` methods.
-
 The latest version of the documentation can be found at:
 
   https://aubio.org/documentation
@@ -74,49 +63,19 @@
 Build Instructions
 ------------------
 
-A number of distributions already include aubio. Check your favorite package
-management system, or have a look at the [download
-page](https://aubio.org/download).
-
-aubio uses [waf](https://waf.io/) to configure, compile, and test the source:
-
-    ./waf configure
-    ./waf build
-
-If waf is not found in the directory, you can download and install it with:
-
-    make getwaf
-
 aubio compiles on Linux, Mac OS X, Windows, Cygwin, and iOS.
 
-Installation
-------------
+To compile aubio, you should be able to simply run:
 
-To install aubio library and headers on your system, use:
+    make
 
-    sudo ./waf install
+To compile the python module:
 
-To uninstall:
+    ./setup.py build
 
-    sudo ./waf uninstall
-
-If you don't have root access to install libaubio on your system, you can use
-libaubio without installing libaubio either by setting `LD_LIBRARY_PATH`, or by
-copying it to `~/lib`.
-
-On Linux, you should be able to set `LD_LIBRARY_PATH` with:
-
-    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/build/src
-
-On Mac OS X, a copy or a symlink can be made in `~/lib`:
-
-    $ mkdir -p ~/lib
-    $ ln -sf $PWD/build/src/libaubio*.dylib ~/lib/
-
-Note on Mac OS X systems older than El Capitan (10.11), the `DYLD_LIBRARY_PATH`
-variable can be set as follows:
-
-    $ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$PWD/build/src
+See also the [manual](https://aubio.org/manual/latest/) for more information
+about [compiling](https://aubio.org/manual/latest/building.html) and
+[installing](https://aubio.org/manual/latest/installing.html).
 
 Credits and Publications
 ------------------------
--- a/doc/android.rst
+++ b/doc/android.rst
@@ -1,7 +1,7 @@
 .. _android:
 
-Building aubio for Android
---------------------------
+Android build
+-------------
 
 To compile aubio for android, you will need to get the `Android Native
 Development Toolkit (NDK) <https://developer.android.com/ndk/>`_, prepare a
--- /dev/null
+++ b/doc/aubio.txt
@@ -1,0 +1,135 @@
+NAME
+  aubio - a command line tool to extract information from sound files
+
+SYNOPSIS
+
+  aubio [-h] [-V] <command> ...
+
+COMMANDS
+
+  The general syntax is "aubio <command> <soundfile> [options]". The following
+  commands are available:
+
+  onset        get onset times
+  pitch        extract fundamental frequency
+  beat         get locations of beats
+  tempo        get overall tempo in bpm
+  notes        get midi-like notes
+  mfcc         extract mel-frequency cepstrum coefficients
+  melbands     extract mel-frequency energies per band
+
+  For a list of available commands, use "aubio -h". For more info about each
+  command, use "aubio <command> --help".
+
+GENERAL OPTIONS
+
+  These options can be used before any command has been specified.
+
+  -h, --help  show help message and exit
+
+  -V, --version  show version
+
+COMMON OPTIONS
+
+  The following options can be used with all commands:
+
+  <source_uri>, -i <source_uri>, --input <source_uri>  input sound file to
+  analyse (required)
+
+  -r <freq>, --samplerate <freq>  samplerate at which the file should be
+  represented (default: 0, e.g. samplerate of the input sound)
+
+  -H <size>, --hopsize <size>  overlap size, number of samples between two
+  consecutive analysis (default: 256)
+
+  -B <size>, --bufsize <size>  buffer size, number of samples used for each
+  analysis, (e.g. FFT length, default: 512)
+
+  -h, --help  show help message and exit
+
+  -T format, --time-format format  select time values output format (samples,
+  ms, seconds) (default: seconds)
+
+  -v, --verbose  be verbose (increment verbosity by 1, default: 1)
+
+  -q, --quiet  be quiet (set verbosity to 0)
+
+ONSET
+
+  The following additional options can be used with the "onset" subcommand.
+
+  -m <method>, --method <method>  onset novelty function
+  <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux> (default:
+  default)
+
+  -t <threshold>, --threshold <threshold>  threshold (default: unset)
+
+  -s <value>, --silence <value>  silence threshold, in dB (default: -70)
+
+  -M <value>, --minioi <value>  minimum Inter-Onset Interval (default: 12ms)
+
+PITCH
+
+  The following additional options can be used with the "pitch" subcommand.
+
+  -m <method>, --method <method>  pitch detection method
+  <default|yinfft|yin|mcomb|fcomb|schmitt> (default: default, e.g. yinfft)
+
+  -t <threshold>, --threshold <threshold>  tolerance (default: unset)
+
+  -s <value>, --silence <value>  silence threshold, in dB (default: -70)
+
+  The default buffer size for the beat algorithm is 2048. The default hop size
+  is 256.
+
+BEAT
+
+  The "beat" command accepts all common options and no additional options.
+
+  The default buffer size for the beat algorithm is 1024. The default hop size
+  is 512.
+
+TEMPO
+
+  The "tempo" command accepts all common options and no additional options.
+
+  The default buffer size for the beat algorithm is 1024. The default hop size
+  is 512.
+
+NOTES
+
+  The "note" command accepts all common options and no additional options.
+
+MFCC
+
+  The "mfcc" command accepts all common options and no additional options.
+
+MELBANDS
+
+  The "melbands" command accepts all common options and no additional options.
+
+EXAMPLES
+
+  Extract onsets using a minimum inter-onset interval of 30ms:
+
+    aubio onset /path/to/input_file -M 30ms
+
+  Extract pitch with method "mcomb" and a silence threshold of -90dB:
+
+    aubio pitch /path/to/input_file -m mcomb -s -90.0
+
+  Extract MFCC using the standard Slaney implementation:
+
+    aubio mfcc /path/to/input_file -r 44100
+
+
+SEE ALSO
+
+  aubiocut(1)
+
+AUTHOR
+
+  This manual page was written by Paul Brossier <piem@aubio.org>. Permission is
+  granted to copy, distribute and/or modify this document under the terms of
+  the GNU General Public License as published by the Free Software Foundation,
+  either version 3 of the License, or (at your option) any later version.
--- /dev/null
+++ b/doc/binaries.rst
@@ -1,0 +1,12 @@
+Pre-compiled binaries
+---------------------
+
+`Pre-compiled binaries <https://aubio.org/download>`_
+are available for
+`macOS <https://aubio.org/download#osx>`_,
+`iOS <https://aubio.org/download#ios>`_,
+and
+`windows <https://aubio.org/download#win>`_
+
+To use aubio in a macOS or iOS application, see :ref:`xcode-frameworks-label`.
+
--- a/doc/building.rst
+++ b/doc/building.rst
@@ -20,9 +20,9 @@
 
 The **latest stable release** can be downloaded from https://aubio.org/download::
 
-        $ curl -O http://aubio.org/pub/aubio-0.4.3.tar.bz2
-        $ tar xf aubio-0.4.3.tar.bz2
-        $ cd aubio-0.4.3
+        $ curl -O http://aubio.org/pub/aubio-<version>.tar.bz2
+        $ tar xf aubio-<version>.tar.bz2
+        $ cd aubio-<version>/
 
 Git repository
 --------------
@@ -30,7 +30,7 @@
 The **latest git branch** can be obtained with::
 
         $ git clone git://git.aubio.org/git/aubio
-        $ cd aubio
+        $ cd aubio/
 
 The following command will fetch the correct `waf`_ version (not included in
 aubio's git)::
@@ -73,6 +73,34 @@
 
        $ waf configure build
 
+
+Running as a user
+-----------------
+
+To use aubio without actually installing, for instance if you don't have root
+access to install libaubio on your system,
+
+On Linux or macOS, sourcing the script ``scripts/setenv_local.sh`` should help::
+
+       $ source ./scripts/setenv_local.sh
+
+This script sets ``LD_LIBRARY_PATH``, for libaubio, and ``PYTHONPATH`` for the
+python module.
+
+On Linux, you should be able to set ``LD_LIBRARY_PATH`` with::
+
+        $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/build/src
+
+On Mac OS X, a copy or a symlink can be made in ``~/lib``::
+
+        $ mkdir -p ~/lib
+        $ ln -sf $PWD/build/src/libaubio*.dylib ~/lib/
+
+Note on Mac OS X systems older than El Capitan (10.11), the ``DYLD_LIBRARY_PATH``
+variable can be set as follows::
+
+        $ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$PWD/build/src
+
 Cleaning
 --------
 
@@ -94,5 +122,8 @@
 
 .. _Git Bash: https://git-for-windows.github.io/
 
-.. toctree::
-   :maxdepth: 2
+.. _xcode-frameworks-label:
+
+.. include:: xcode_frameworks.rst
+
+.. include:: android.rst
--- a/doc/cli.rst
+++ b/doc/cli.rst
@@ -3,8 +3,13 @@
 Command line tools
 ==================
 
-A few simple command line tools are included along with the library.
+The python module comes with the following tools:
 
+ - ``aubio`` estimate and extract descriptors from sound files
+ - ``aubiocut`` slices sound files at onset or beat timestamps
+
+More command line tools are included along with the library.
+
  - ``aubioonset`` outputs the time stamp of detected note onsets
  - ``aubiopitch`` attempts to identify a fundamental frequency, or pitch, for
    each frame of the input sound
@@ -13,47 +18,56 @@
  - ``aubionotes`` emits midi-like notes, with an onset, a pitch, and a duration
  - ``aubioquiet`` extracts quiet and loud regions
 
-Additionally, the python module comes with the following script:
 
- - ``aubiocut`` slices sound files at onset or beat timestamps
+``aubio``
+---------
 
+.. literalinclude:: aubio.txt
+   :language: text
 
-.. toctree::
 
-   cli_features
+``aubiocut``
+--------------
 
+.. literalinclude:: aubiocut.txt
+   :language: text
 
+
 ``aubioonset``
 --------------
 
 .. literalinclude:: aubioonset.txt
+   :language: text
 
 ``aubiopitch``
 --------------
 
 .. literalinclude:: aubiopitch.txt
+   :language: text
 
 ``aubiomfcc``
 --------------
 
 .. literalinclude:: aubiomfcc.txt
+   :language: text
 
 ``aubiotrack``
 --------------
 
 .. literalinclude:: aubiotrack.txt
+   :language: text
 
 ``aubionotes``
 --------------
 
 .. literalinclude:: aubionotes.txt
+   :language: text
 
 ``aubioquiet``
 --------------
 
 .. literalinclude:: aubioquiet.txt
+   :language: text
 
-``aubiocut``
---------------
 
-.. literalinclude:: aubiocut.txt
+.. include:: cli_features.rst
--- a/doc/cli_features.rst
+++ b/doc/cli_features.rst
@@ -1,5 +1,5 @@
 Command line features
-=====================
+---------------------
 
 +--------------+-------+-------+------+-------+-------+-------+------+------------------+
 | feat vs. prg | onset | pitch | mfcc | track | notes | quiet | cut1 | short options    |
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -13,6 +13,10 @@
 
 import sys, os
 
+# get version using this_version.py
+sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
+from this_version import get_aubio_version
+
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -48,9 +52,10 @@
 # built documents.
 #
 # The short X.Y version.
-version = '0.4'
+
+version = get_aubio_version()[:3]
 # The full version, including alpha/beta/rc tags.
-release = '0.4.5~alpha'
+release = get_aubio_version()
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -64,7 +69,17 @@
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
-exclude_patterns = ['_build']
+exclude_patterns = ['_build',
+        'statuslinks.rst',
+        'download.rst',
+        'binaries.rst',
+        'debian_packages.rst',
+        'building.rst',
+        'android.rst',
+        'xcode_frameworks.rst',
+        'requirements.rst',
+        'cli_features.rst',
+        ]
 
 # The reST default role (used for this markup: `text`) to use for all documents.
 #default_role = None
--- a/doc/develop.rst
+++ b/doc/develop.rst
@@ -3,47 +3,93 @@
 Developping with aubio
 ======================
 
-Read `Contribute`_ to report issues and request new features.
+Here is a brief overview of the C library.
 
-See `Doxygen documentation`_ for the complete documentation of the C library,
-built using `Doxygen <http://www.doxygen.org/>`_.
+For a more detailed list of available functions, see the `API documentation
+<https://aubio.org/doc/latest/>`_.
 
-Below is a brief `Library overview`_.
+To report issues, ask questions, and request new features, use `Github Issues
+<https://github.com/aubio/aubio/issues>`_
 
-Library overview
-----------------
+Design Basics
+-------------
+
+The library is written in C and is optimised for speed and portability.
 
-Here is a brief overview of the C library. See also the `Doxygen
-documentation`_ for a more detailed list of available functions.
+All memory allocations take place in the `new_` methods. Each successful call
+to `new_` should have a matching call to `del_` to deallocate the object.
 
-Vectors and matrix
-``````````````````
+.. code-block:: C
 
-``fvec_t`` are used to hold vectors of float (``smpl_t``).
+   // new_ to create an object foobar
+   aubio_foobar_t * new_aubio_foobar(void * args);
+   // del_ to delete foobar
+   void del_aubio_foobar (aubio_foobar_t * foobar);
 
-.. literalinclude:: ../tests/src/test-fvec.c
-   :language: C
-   :lines: 7
+The main computations are done in the `_do` methods.
 
+.. code-block:: C
 
+   // _do to process output = foobar(input)
+   audio_foobar_do (aubio_foobar_t * foobar, fvec_t * input, cvec_t * output);
+
+Most parameters can be read and written at any time:
+
 .. code-block:: C
 
-        // set some elements
-        vec->data[511] = 2.;
-        vec->data[vec->length-2] = 1.;
+   // _get_param to get foobar.param
+   smpl_t aubio_foobar_get_a_parameter (aubio_foobar_t * foobar);
+   // _set_param to set foobar.param
+   uint_t aubio_foobar_set_a_parameter (aubio_foobar_t * foobar, smpl_t a_parameter);
 
-Similarly, ``fmat_t`` are used to hold matrix of floats.
+In some case, more functions are available:
 
-.. literalinclude:: ../tests/src/test-fmat.c
-   :language: C
-   :lines: 9-19
+.. code-block:: C
 
+   // non-real time functions
+   uint_t aubio_foobar_reset(aubio_foobar_t * t);
+
+Basic Types
+-----------
+
+.. code-block:: C
+
+    // integers
+    uint_t n = 10;                 // unsigned
+    sint_t delay = -90;            // signed
+
+    // float
+    smpl_t a = -90.;               // simple precision
+    lsmp_t f = 0.024;              // double precision
+
+    // vector of floats (simple precision)
+    fvec_t * vec = new_fvec(n);
+    vec->data[0] = 1;
+    vec->data[vec->length-1] = 1.; // vec->data has n elements
+    fvec_print(vec);
+    del_fvec(vec);
+
+    // complex data
+    cvec_t * fftgrain = new_cvec(n);
+    vec->norm[0] = 1.;             // vec->norm has n/2+1 elements
+    vec->phas[n/2] = 3.1415;       // vec->phas as well
+    del_cvec(fftgrain);
+
+    // matrix
+    fmat_t * mat = new_fmat (height, length);
+    mat->data[height-1][0] = 1;    // mat->data has height rows
+    mat->data[0][length-1] = 10;   // mat->data[0] has length columns
+    del_fmat(mat);
+
+
 Reading a sound file
-````````````````````
-In this example, ``aubio_source`` is used to read a media file.
+--------------------
 
-First, create the objects we need.
+In this example, `aubio_source <https://aubio.org/doc/latest/source_8h.html>`_
+is used to read a media file.
 
+First, define a few variables and allocate some memory.
+
 .. literalinclude:: ../tests/src/io/test-source.c
    :language: C
    :lines: 22-24, 30-32, 34
@@ -58,17 +104,17 @@
    :language: C
    :lines: 40-44
 
-At the end of the processing loop, clean-up and de-allocate memory:
+At the end of the processing loop, memory is deallocated:
 
 .. literalinclude:: ../tests/src/io/test-source.c
    :language: C
-   :lines: 50-56
+   :lines: 55-56
 
 See the complete example: :download:`test-source.c
 <../tests/src/io/test-source.c>`.
 
-Computing the spectrum
-``````````````````````
+Computing a spectrum
+--------------------
 
 Now let's create a phase vocoder:
 
@@ -80,8 +126,14 @@
 
 .. literalinclude:: ../tests/src/spectral/test-phasevoc.c
    :language: C
-   :lines: 21-35
+   :lines: 20-37
 
+Time to clean up the previously allocated memory:
+
+.. literalinclude:: ../tests/src/spectral/test-phasevoc.c
+   :language: C
+   :lines: 39-44
+
 See the complete example: :download:`test-phasevoc.c
 <../tests/src/spectral/test-phasevoc.c>`.
 
@@ -90,9 +142,10 @@
 Doxygen documentation
 ---------------------
 
-The latest version of the doxygen documentation is available at:
+The latest version of the API documentation is built using `Doxygen
+<http://www.doxygen.org/>`_ and is available at:
 
-    https://aubio.org/doc/latest
+    https://aubio.org/doc/latest/
 
 Contribute
 ----------
@@ -99,4 +152,3 @@
 
 Please report any issue and feature request at the `Github issue tracker
 <https://github.com/aubio/aubio/issues>`_. Patches and pull-requests welcome!
-
--- a/doc/download.rst
+++ b/doc/download.rst
@@ -7,14 +7,10 @@
 management system, or have a look at the `aubio download page
 <https://aubio.org/download>`_ for more options.
 
-To use aubio in a macOS or iOS application, see :ref:`xcode-frameworks-label`.
-
 To use aubio in an android project, see :ref:`android`.
 
-.. toctree::
+To compile aubio from source, read :ref:`building`.
 
-  debian_packages
-  xcode_frameworks
-  android
+.. include:: binaries.rst
 
-To compile aubio from source, read :ref:`building`.
+.. include:: debian_packages.rst
--- a/doc/installing.rst
+++ b/doc/installing.rst
@@ -4,16 +4,76 @@
 aubio runs on Linux, Windows, macOS, iOS, Android, and probably a few others
 operating systems.
 
-To download a pre-compiled version of the library, head to :ref:`download`.
+Aubio is available as a C library and as a python module.
 
-To install the python extension, head to :ref:`python`.
+Cheat sheet
+-----------
 
-To compile aubio form source, first check the :ref:`requirements`, then read
-:ref:`building`.
+- :ref:`get aubio latest source code <building>`::
 
-.. toctree::
-   :maxdepth: 2
+    # official repo
+    git clone https://git.aubio.org/aubio/aubio
+    # mirror
+    git clone https://github.com/aubio/aubio
+    # latest release
+    wget https://aubio.org/pub/aubio-<version>.tar.gz
 
-   download
-   building
-   requirements
+
+- :ref:`build aubio from source <building>`::
+
+    # 1. simple
+    cd aubio
+    make
+
+    # 2. step by step
+    ./scripts/get_waf.sh
+    ./waf configure
+    ./waf build
+    sudo ./waf install
+
+- :ref:`install python-aubio from source <python>`::
+
+    # from git
+    pip install git+https://git.aubio.org/aubio/aubio/
+    # mirror
+    pip install git+https://github.com/aubio/aubio/
+    # from latest release
+    pip install https://aubio.org/pub/aubio-latest.tar.bz2
+    # from pypi
+    pip install aubio
+    # from source directory
+    cd aubio
+    pip install -v .
+
+- :ref:`install python-aubio from a pre-compiled binary <python>`::
+
+      # conda [osx, linux, win]
+      conda install -c conda-forge aubio
+      # .deb (debian, ubuntu) [linux]
+      sudo apt-get install python3-aubio python-aubio aubio-tools
+      # brew [osx]
+      brew install aubio --with-python
+
+- :ref:`get a pre-compiled version of libaubio <download>`::
+
+    # .deb (linux) WARNING: old version
+    sudo apt-get install aubio-tools
+
+    # python module
+    ./setup.py install
+    # using pip
+    pip install .
+
+- :ref:`check the list of optional dependencies <requirements>`::
+
+    # debian / ubuntu
+    dpkg -l libavcodec-dev libavutil-dev libavformat-dev \
+            libswresample-dev libavresample-dev \
+            libsamplerate-dev libsndfile-dev \
+            txt2man doxygen
+
+.. include:: download.rst
+
+.. include:: building.rst
+
+.. include:: requirements.rst
--- a/doc/xcode_frameworks.rst
+++ b/doc/xcode_frameworks.rst
@@ -1,8 +1,6 @@
-.. _xcode-frameworks-label:
+Frameworks for Xcode
+--------------------
 
-Using aubio frameworks in Xcode
--------------------------------
-
 `Binary frameworks`_ are available and ready to use in your XCode project, for
 `iOS`_ and `macOS`_.
 
@@ -35,8 +33,13 @@
     import aubio
 
 Using aubio from swift
-......................
+----------------------
 
+Once you have downloaded and installed :ref:`aubio.framework
+<xcode-frameworks-label>`, you sould be able to use aubio from C, Obj-C, and
+Swift source files.
+
+
 Here is a short example showing how to read a sound file in swift:
 
 
@@ -67,4 +70,3 @@
 .. _Binary frameworks: https://aubio.org/download
 .. _iOS: https://aubio.org/download#ios
 .. _macOS: https://aubio.org/download#osx
-.. _Download: https://aubio.org/download
--- /dev/null
+++ b/python/lib/aubio/cmd.py
@@ -1,0 +1,408 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""aubio command line tool
+
+This file was written by Paul Brossier <piem@aubio.org> and is released under
+the GNU/GPL v3.
+
+Note: this script is mostly about parsing command line arguments. For more
+readable code examples, check out the `python/demos` folder."""
+
+import sys
+import argparse
+import aubio
+
+def aubio_parser():
+    epilog = 'use "%(prog)s <command> --help" for more info about each command'
+    parser = argparse.ArgumentParser(epilog=epilog)
+    parser.add_argument('-V', '--version', help="show version",
+            action="store_true", dest="show_version")
+
+    subparsers = parser.add_subparsers(title='commands', dest='command',
+            metavar="")
+
+    # onset subcommand
+    subparser = subparsers.add_parser('onset',
+            help='estimate time of onsets (beginning of sound event)',
+            formatter_class = argparse.ArgumentDefaultsHelpFormatter)
+    parser_add_input(subparser)
+    parser_add_buf_hop_size(subparser)
+    helpstr = "onset novelty function"
+    helpstr += " <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux>"
+    parser_add_method(subparser, helpstr=helpstr)
+    parser_add_threshold(subparser)
+    parser_add_silence(subparser)
+    parser_add_minioi(subparser)
+    parser_add_time_format(subparser)
+    parser_add_verbose_help(subparser)
+    subparser.set_defaults(process=process_onset)
+
+    # pitch subcommand
+    subparser = subparsers.add_parser('pitch',
+            help='estimate fundamental frequency (monophonic)')
+    parser_add_input(subparser)
+    parser_add_buf_hop_size(subparser, buf_size=2048)
+    helpstr = "pitch detection method <default|yinfft|yin|mcomb|fcomb|schmitt>"
+    parser_add_method(subparser, helpstr=helpstr)
+    parser_add_threshold(subparser)
+    parser_add_silence(subparser)
+    parser_add_time_format(subparser)
+    parser_add_verbose_help(subparser)
+    subparser.set_defaults(process=process_pitch)
+
+    # beat subcommand
+    subparser = subparsers.add_parser('beat',
+            help='estimate location of beats')
+    parser_add_input(subparser)
+    parser_add_buf_hop_size(subparser, buf_size=1024, hop_size=512)
+    parser_add_time_format(subparser)
+    parser_add_verbose_help(subparser)
+    subparser.set_defaults(process=process_beat)
+
+    # tempo subcommand
+    subparser = subparsers.add_parser('tempo',
+            help='estimate overall tempo in bpm')
+    parser_add_input(subparser)
+    parser_add_buf_hop_size(subparser, buf_size=1024, hop_size=512)
+    parser_add_time_format(subparser)
+    parser_add_verbose_help(subparser)
+    subparser.set_defaults(process=process_tempo)
+
+    # notes subcommand
+    subparser = subparsers.add_parser('notes',
+            help='estimate midi-like notes (monophonic)')
+    parser_add_input(subparser)
+    parser_add_buf_hop_size(subparser)
+    parser_add_time_format(subparser)
+    parser_add_verbose_help(subparser)
+    subparser.set_defaults(process=process_notes)
+
+    # mfcc subcommand
+    subparser = subparsers.add_parser('mfcc',
+            help='extract Mel-Frequency Cepstrum Coefficients')
+    parser_add_input(subparser)
+    parser_add_buf_hop_size(subparser)
+    parser_add_time_format(subparser)
+    parser_add_verbose_help(subparser)
+    subparser.set_defaults(process=process_mfcc)
+
+    # melbands subcommand
+    subparser = subparsers.add_parser('melbands',
+            help='extract energies in Mel-frequency bands')
+    parser_add_input(subparser)
+    parser_add_buf_hop_size(subparser)
+    parser_add_time_format(subparser)
+    parser_add_verbose_help(subparser)
+    subparser.set_defaults(process=process_melbands)
+
+    return parser
+
+def parser_add_input(parser):
+    parser.add_argument("source_uri", default=None, nargs='?',
+            help="input sound file to analyse", metavar = "<source_uri>")
+    parser.add_argument("-i", "--input", dest = "source_uri2",
+            help="input sound file to analyse", metavar = "<source_uri>")
+    parser.add_argument("-r", "--samplerate",
+            metavar = "<freq>", type=int,
+            action="store", dest="samplerate", default=0,
+            help="samplerate at which the file should be represented")
+
+def parser_add_verbose_help(parser):
+    parser.add_argument("-v","--verbose",
+            action="count", dest="verbose", default=1,
+            help="make lots of noise [default]")
+    parser.add_argument("-q","--quiet",
+            action="store_const", dest="verbose", const=0,
+            help="be quiet")
+
+def parser_add_buf_hop_size(parser, buf_size=512, hop_size=256):
+    parser.add_argument("-B","--bufsize",
+            action="store", dest="buf_size", default=buf_size,
+            metavar = "<size>", type=int,
+            help="buffer size [default=%d]" % buf_size)
+    parser.add_argument("-H","--hopsize",
+            metavar = "<size>", type=int,
+            action="store", dest="hop_size", default=hop_size,
+            help="overlap size [default=%d]" % hop_size)
+
+def parser_add_method(parser, method='default', helpstr='method'):
+    parser.add_argument("-m","--method",
+            metavar = "<method>", type=str,
+            action="store", dest="method", default=method,
+            help="%s [default=%s]" % (helpstr, method))
+
+def parser_add_threshold(parser, default=None):
+    parser.add_argument("-t","--threshold",
+            metavar = "<threshold>", type=float,
+            action="store", dest="threshold", default=default,
+            help="threshold [default=%s]" % default)
+
+def parser_add_silence(parser):
+    parser.add_argument("-s", "--silence",
+            metavar = "<value>", type=float,
+            action="store", dest="silence", default=-70,
+            help="silence threshold")
+
+def parser_add_minioi(parser):
+    parser.add_argument("-M", "--minioi",
+            metavar = "<value>", type=str,
+            action="store", dest="minioi", default="12ms",
+            help="minimum Inter-Onset Interval")
+
+def parser_add_time_format(parser):
+    helpstr = "select time values output format (samples, ms, seconds)"
+    helpstr += " [default=seconds]"
+    parser.add_argument("-T", "--time-format",
+             metavar='format',
+             dest="time_format",
+             default=None,
+             help=helpstr)
+
+# some utilities
+
+def samples2seconds(n_frames, samplerate):
+    return "%f\t" % (n_frames / float(samplerate))
+
+def samples2milliseconds(n_frames, samplerate):
+    return "%f\t" % (1000. * n_frames / float(samplerate))
+
+def samples2samples(n_frames, samplerate):
+    return "%d\t" % n_frames
+
+def timefunc(mode):
+    if mode is None or mode == 'seconds' or mode == 's':
+        return samples2seconds
+    elif mode == 'ms' or mode == 'milliseconds':
+        return samples2milliseconds
+    elif mode == 'samples':
+        return samples2samples
+    else:
+        raise ValueError('invalid time format %s' % mode)
+
+# definition of processing classes
+
+class default_process(object):
+    def __init__(self, args):
+        if 'time_format' in args:
+            self.time2string = timefunc(args.time_format)
+        if args.verbose > 2 and hasattr(self, 'options'):
+            name = type(self).__name__.split('_')[1]
+            optstr = ' '.join(['running', name, 'with options', repr(self.options), '\n'])
+            sys.stderr.write(optstr)
+    def flush(self, n_frames, samplerate):
+        # optionally called at the end of process
+        pass
+
+    def parse_options(self, args, valid_opts):
+        # get any valid options found in a dictionnary of arguments
+        options = {k :v for k,v in vars(args).items() if k in valid_opts}
+        self.options = options
+
+    def remap_pvoc_options(self, options):
+        # FIXME: we need to remap buf_size to win_s, hop_size to hop_s
+        # adjust python/ext/py-phasevoc.c to understand buf_size/hop_size
+        if 'buf_size' in options:
+            options['win_s'] = options['buf_size']
+            del options['buf_size']
+        if 'hop_size' in options:
+            options['hop_s'] = options['hop_size']
+            del options['hop_size']
+        self.options = options
+
+class process_onset(default_process):
+    valid_opts = ['method', 'hop_size', 'buf_size', 'samplerate']
+    def __init__(self, args):
+        self.parse_options(args, self.valid_opts)
+        self.onset = aubio.onset(**self.options)
+        if args.threshold is not None:
+            self.onset.set_threshold(args.threshold)
+        if args.minioi:
+            if args.minioi.endswith('ms'):
+                self.onset.set_minioi_ms(float(args.minioi[:-2]))
+            elif args.minioi.endswith('s'):
+                self.onset.set_minioi_s(float(args.minioi[:-1]))
+            else:
+                self.onset.set_minioi(int(args.minioi))
+        if args.silence:
+            self.onset.set_silence(args.silence)
+        super(process_onset, self).__init__(args)
+    def __call__(self, block):
+        return self.onset(block)
+    def repr_res(self, res, frames_read, samplerate):
+        if res[0] != 0:
+            outstr = self.time2string(self.onset.get_last(), samplerate)
+            sys.stdout.write(outstr + '\n')
+
+class process_pitch(default_process):
+    valid_opts = ['method', 'hop_size', 'buf_size', 'samplerate']
+    def __init__(self, args):
+        self.parse_options(args, self.valid_opts)
+        self.pitch = aubio.pitch(**self.options)
+        if args.threshold is not None:
+            self.pitch.set_tolerance(args.threshold)
+        if args.silence is not None:
+            self.pitch.set_silence(args.silence)
+        super(process_pitch, self).__init__(args)
+    def __call__(self, block):
+        return self.pitch(block)
+    def repr_res(self, res, frames_read, samplerate):
+        fmt_out = self.time2string(frames_read, samplerate)
+        sys.stdout.write(fmt_out + "%.6f\n" % res[0])
+
+class process_beat(default_process):
+    valid_opts = ['method', 'hop_size', 'buf_size', 'samplerate']
+    def __init__(self, args):
+        self.parse_options(args, self.valid_opts)
+        self.tempo = aubio.tempo(**self.options)
+        super(process_beat, self).__init__(args)
+    def __call__(self, block):
+        return self.tempo(block)
+    def repr_res(self, res, frames_read, samplerate):
+        if res[0] != 0:
+            outstr = self.time2string(self.tempo.get_last(), samplerate)
+            sys.stdout.write(outstr + '\n')
+
+class process_tempo(process_beat):
+    def __init__(self, args):
+        super(process_tempo, self).__init__(args)
+        self.beat_locations = []
+    def repr_res(self, res, frames_read, samplerate):
+        if res[0] != 0:
+            self.beat_locations.append(self.tempo.get_last_s())
+    def flush(self, frames_read, samplerate):
+        import numpy as np
+        if len(self.beat_locations) < 2:
+            outstr = "unknown bpm"
+        else:
+            bpms = 60./ np.diff(self.beat_locations)
+            median_bpm = np.mean(bpms)
+            if len(self.beat_locations) < 10:
+                outstr = "%.2f bpm (uncertain)" % median_bpm
+            else:
+                outstr = "%.2f bpm" % median_bpm
+        sys.stdout.write(outstr + '\n')
+
+class process_notes(default_process):
+    valid_opts = ['method', 'hop_size', 'buf_size', 'samplerate']
+    def __init__(self, args):
+        self.parse_options(args, self.valid_opts)
+        self.notes = aubio.notes(**self.options)
+        super(process_notes, self).__init__(args)
+    def __call__(self, block):
+        return self.notes(block)
+    def repr_res(self, res, frames_read, samplerate):
+        if res[2] != 0: # note off
+            fmt_out = self.time2string(frames_read, samplerate)
+            sys.stdout.write(fmt_out + '\n')
+        if res[0] != 0: # note on
+            lastmidi = res[0]
+            fmt_out = "%f\t" % lastmidi
+            fmt_out += self.time2string(frames_read, samplerate)
+            sys.stdout.write(fmt_out) # + '\t')
+    def flush(self, frames_read, samplerate):
+        eof = self.time2string(frames_read, samplerate)
+        sys.stdout.write(eof + '\n')
+
+class process_mfcc(default_process):
+    def __init__(self, args):
+        valid_opts1 = ['hop_size', 'buf_size']
+        self.parse_options(args, valid_opts1)
+        self.remap_pvoc_options(self.options)
+        self.pv = aubio.pvoc(**self.options)
+
+        valid_opts2 = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate']
+        self.parse_options(args, valid_opts2)
+        self.mfcc = aubio.mfcc(**self.options)
+
+        # remember all options
+        self.parse_options(args, list(set(valid_opts1 + valid_opts2)))
+
+        super(process_mfcc, self).__init__(args)
+
+    def __call__(self, block):
+        fftgrain = self.pv(block)
+        return self.mfcc(fftgrain)
+    def repr_res(self, res, frames_read, samplerate):
+        fmt_out = self.time2string(frames_read, samplerate)
+        fmt_out += ' '.join(["% 9.7f" % f for f in res.tolist()])
+        sys.stdout.write(fmt_out + '\n')
+
+class process_melbands(default_process):
+    def __init__(self, args):
+        self.args = args
+        valid_opts = ['hop_size', 'buf_size']
+        self.parse_options(args, valid_opts)
+        self.remap_pvoc_options(self.options)
+        self.pv = aubio.pvoc(**self.options)
+
+        valid_opts = ['buf_size', 'n_filters']
+        self.parse_options(args, valid_opts)
+        self.remap_pvoc_options(self.options)
+        self.filterbank = aubio.filterbank(**self.options)
+        self.filterbank.set_mel_coeffs_slaney(args.samplerate)
+
+        super(process_melbands, self).__init__(args)
+    def __call__(self, block):
+        fftgrain = self.pv(block)
+        return self.filterbank(fftgrain)
+    def repr_res(self, res, frames_read, samplerate):
+        fmt_out = self.time2string(frames_read, samplerate)
+        fmt_out += ' '.join(["% 9.7f" % f for f in res.tolist()])
+        sys.stdout.write(fmt_out + '\n')
+
+def main():
+    parser = aubio_parser()
+    args = parser.parse_args()
+    if 'show_version' in args and args.show_version:
+        sys.stdout.write('aubio version ' + aubio.version + '\n')
+        sys.exit(0)
+    elif 'verbose' in args and args.verbose > 3:
+        sys.stderr.write('aubio version ' + aubio.version + '\n')
+    if 'command' not in args or args.command is None:
+        # no command given, print help and return 1
+        parser.print_help()
+        sys.exit(1)
+    elif not args.source_uri and not args.source_uri2:
+        sys.stderr.write("Error: a source is required\n")
+        parser.print_help()
+        sys.exit(1)
+    elif args.source_uri2 is not None:
+        args.source_uri = args.source_uri2
+    try:
+        # open source_uri
+        with aubio.source(args.source_uri, hop_size=args.hop_size,
+                samplerate=args.samplerate) as a_source:
+            # always update args.samplerate to native samplerate, in case
+            # source was opened with args.samplerate=0
+            args.samplerate = a_source.samplerate
+            # create the processor for this subcommand
+            processor = args.process(args)
+            frames_read = 0
+            while True:
+                # read new block from source
+                block, read = a_source()
+                # execute processor on this block
+                res = processor(block)
+                # print results for this block
+                if args.verbose > 0:
+                    processor.repr_res(res, frames_read, a_source.samplerate)
+                # increment total number of frames read
+                frames_read += read
+                # exit loop at end of file
+                if read < a_source.hop_size: break
+            # flush the processor if needed
+            processor.flush(frames_read, a_source.samplerate)
+            if args.verbose > 1:
+                fmt_string = "read {:.2f}s"
+                fmt_string += " ({:d} samples in {:d} blocks of {:d})"
+                fmt_string += " from {:s} at {:d}Hz\n"
+                sys.stderr.write(fmt_string.format(
+                        frames_read/float(a_source.samplerate),
+                        frames_read,
+                        frames_read // a_source.hop_size + 1,
+                        a_source.hop_size,
+                        a_source.uri,
+                        a_source.samplerate))
+    except KeyboardInterrupt:
+        sys.exit(1)
--- /dev/null
+++ b/python/lib/aubio/cut.py
@@ -1,0 +1,210 @@
+#! /usr/bin/env python
+
+""" this file was written by Paul Brossier
+  it is released under the GNU/GPL license.
+"""
+
+import sys
+
+def parse_args():
+    from optparse import OptionParser
+    usage = "usage: %s [options] -i soundfile" % sys.argv[0]
+    usage += "\n help: %s -h" % sys.argv[0]
+    parser = OptionParser(usage=usage)
+    parser.add_option("-i", "--input", action = "store", dest = "source_file",
+            help="input sound file to analyse", metavar = "<source_file>")
+    parser.add_option("-O","--onset-method",
+            action="store", dest="onset_method", default='default',
+            metavar = "<onset_method>",
+            help="onset detection method [default=default] \
+                    complexdomain|hfc|phase|specdiff|energy|kl|mkl")
+    # cutting methods
+    parser.add_option("-b","--beat",
+            action="store_true", dest="beat", default=False,
+            help="use beat locations")
+    """
+    parser.add_option("-S","--silencecut",
+            action="store_true", dest="silencecut", default=False,
+            help="use silence locations")
+    parser.add_option("-s","--silence",
+            metavar = "<value>",
+            action="store", dest="silence", default=-70,
+            help="silence threshold [default=-70]")
+            """
+    # algorithm parameters
+    parser.add_option("-r", "--samplerate",
+            metavar = "<freq>", type='int',
+            action="store", dest="samplerate", default=0,
+            help="samplerate at which the file should be represented")
+    parser.add_option("-B","--bufsize",
+            action="store", dest="bufsize", default=512,
+            metavar = "<size>", type='int',
+            help="buffer size [default=512]")
+    parser.add_option("-H","--hopsize",
+            metavar = "<size>", type='int',
+            action="store", dest="hopsize", default=256,
+            help="overlap size [default=256]")
+    parser.add_option("-t","--onset-threshold",
+            metavar = "<value>", type="float",
+            action="store", dest="threshold", default=0.3,
+            help="onset peak picking threshold [default=0.3]")
+    parser.add_option("-c","--cut",
+            action="store_true", dest="cut", default=False,
+            help="cut input sound file at detected labels \
+                    best used with option -L")
+
+    # minioi
+    parser.add_option("-M","--minioi",
+            metavar = "<value>", type='string',
+            action="store", dest="minioi", default="12ms",
+            help="minimum inter onset interval [default=12ms]")
+
+    """
+    parser.add_option("-D","--delay",
+            action = "store", dest = "delay", type = "float",
+            metavar = "<seconds>", default=0,
+            help="number of seconds to take back [default=system]\
+                    default system delay is 3*hopsize/samplerate")
+    parser.add_option("-C","--dcthreshold",
+            metavar = "<value>",
+            action="store", dest="dcthreshold", default=1.,
+            help="onset peak picking DC component [default=1.]")
+    parser.add_option("-L","--localmin",
+            action="store_true", dest="localmin", default=False,
+            help="use local minima after peak detection")
+    parser.add_option("-d","--derivate",
+            action="store_true", dest="derivate", default=False,
+            help="derivate onset detection function")
+    parser.add_option("-z","--zerocross",
+            metavar = "<value>",
+            action="store", dest="zerothres", default=0.008,
+            help="zero-crossing threshold for slicing [default=0.00008]")
+            """
+    # plotting functions
+    """
+    parser.add_option("-p","--plot",
+            action="store_true", dest="plot", default=False,
+            help="draw plot")
+    parser.add_option("-x","--xsize",
+            metavar = "<size>",
+            action="store", dest="xsize", default=1.,
+            type='float', help="define xsize for plot")
+    parser.add_option("-y","--ysize",
+            metavar = "<size>",
+            action="store", dest="ysize", default=1.,
+            type='float', help="define ysize for plot")
+    parser.add_option("-f","--function",
+            action="store_true", dest="func", default=False,
+            help="print detection function")
+    parser.add_option("-n","--no-onsets",
+            action="store_true", dest="nplot", default=False,
+            help="do not plot detected onsets")
+    parser.add_option("-O","--outplot",
+            metavar = "<output_image>",
+            action="store", dest="outplot", default=None,
+            help="save plot to output.{ps,png}")
+    parser.add_option("-F","--spectrogram",
+            action="store_true", dest="spectro", default=False,
+            help="add spectrogram to the plot")
+    """
+    parser.add_option("-o","--output", type = str,
+            metavar = "<outputdir>",
+            action="store", dest="output_directory", default=None,
+            help="specify path where slices of the original file should be created")
+    parser.add_option("--cut-until-nsamples", type = int,
+            metavar = "<samples>",
+            action = "store", dest = "cut_until_nsamples", default = None,
+            help="how many extra samples should be added at the end of each slice")
+    parser.add_option("--cut-every-nslices", type = int,
+            metavar = "<samples>",
+            action = "store", dest = "cut_every_nslices", default = None,
+            help="how many slices should be groupped together at each cut")
+    parser.add_option("--cut-until-nslices", type = int,
+            metavar = "<slices>",
+            action = "store", dest = "cut_until_nslices", default = None,
+            help="how many extra slices should be added at the end of each slice")
+
+    parser.add_option("-v","--verbose",
+            action="store_true", dest="verbose", default=True,
+            help="make lots of noise [default]")
+    parser.add_option("-q","--quiet",
+            action="store_false", dest="verbose", default=True,
+            help="be quiet")
+    (options, args) = parser.parse_args()
+    if not options.source_file:
+        if len(args) == 1:
+            options.source_file = args[0]
+        else:
+            print ("no file name given\n" + usage)
+            sys.exit(1)
+    return options, args
+
+def main():
+    options, args = parse_args()
+
+    hopsize = options.hopsize
+    bufsize = options.bufsize
+    samplerate = options.samplerate
+    source_file = options.source_file
+
+    from aubio import onset, tempo, source
+
+    s = source(source_file, samplerate, hopsize)
+    if samplerate == 0: samplerate = s.get_samplerate()
+
+    if options.beat:
+        o = tempo(options.onset_method, bufsize, hopsize)
+    else:
+        o = onset(options.onset_method, bufsize, hopsize)
+        if options.minioi:
+            if options.minioi.endswith('ms'):
+                o.set_minioi_ms(int(options.minioi[:-2]))
+            elif options.minioi.endswith('s'):
+                o.set_minioi_s(int(options.minioi[:-1]))
+            else:
+                o.set_minioi(int(options.minioi))
+    o.set_threshold(options.threshold)
+
+    timestamps = []
+    total_frames = 0
+    # analyze pass
+    while True:
+        samples, read = s()
+        if o(samples):
+            timestamps.append (o.get_last())
+            if options.verbose: print ("%.4f" % o.get_last_s())
+        total_frames += read
+        if read < hopsize: break
+    del s
+    # print some info
+    nstamps = len(timestamps)
+    duration = float (total_frames) / float(samplerate)
+    info = 'found %(nstamps)d timestamps in %(source_file)s' % locals()
+    info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
+    sys.stderr.write(info)
+
+    # cutting pass
+    if options.cut and nstamps > 0:
+        # generate output files
+        from aubio.slicing import slice_source_at_stamps
+        timestamps_end = None
+        if options.cut_every_nslices:
+            timestamps = timestamps[::options.cut_every_nslices]
+            nstamps = len(timestamps)
+        if options.cut_until_nslices and options.cut_until_nsamples:
+            print ("warning: using cut_until_nslices, but cut_until_nsamples is set")
+        if options.cut_until_nsamples:
+            timestamps_end = [t + options.cut_until_nsamples for t in timestamps[1:]]
+            timestamps_end += [ 1e120 ]
+        if options.cut_until_nslices:
+            timestamps_end = [t for t in timestamps[1 + options.cut_until_nslices:]]
+            timestamps_end += [ 1e120 ] * (options.cut_until_nslices + 1)
+        slice_source_at_stamps(source_file, timestamps, timestamps_end = timestamps_end,
+                output_dir = options.output_directory,
+                samplerate = samplerate)
+
+        # print some info
+        duration = float (total_frames) / float(samplerate)
+        info = 'created %(nstamps)d slices from %(source_file)s' % locals()
+        info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
+        sys.stderr.write(info)
--- a/python/lib/moresetuptools.py
+++ b/python/lib/moresetuptools.py
@@ -4,46 +4,8 @@
 import distutils, distutils.command.clean, distutils.dir_util
 from .gen_external import generate_external, header, output_path
 
-def get_aubio_version():
-    # read from VERSION
-    this_file_dir = os.path.dirname(os.path.abspath(__file__))
-    version_file = os.path.join(this_file_dir, '..', '..', 'VERSION')
+from this_version import get_aubio_version
 
-    if not os.path.isfile(version_file):
-        raise SystemError("VERSION file not found.")
-
-    for l in open(version_file).readlines():
-        #exec (l.strip())
-        if l.startswith('AUBIO_MAJOR_VERSION'):
-            AUBIO_MAJOR_VERSION = int(l.split('=')[1])
-        if l.startswith('AUBIO_MINOR_VERSION'):
-            AUBIO_MINOR_VERSION = int(l.split('=')[1])
-        if l.startswith('AUBIO_PATCH_VERSION'):
-            AUBIO_PATCH_VERSION = int(l.split('=')[1])
-        if l.startswith('AUBIO_VERSION_STATUS'):
-            AUBIO_VERSION_STATUS = l.split('=')[1].strip()[1:-1]
-
-    if AUBIO_MAJOR_VERSION is None or AUBIO_MINOR_VERSION is None \
-            or AUBIO_PATCH_VERSION is None:
-        raise SystemError("Failed parsing VERSION file.")
-
-    verstr = '.'.join(map(str, [AUBIO_MAJOR_VERSION,
-                                     AUBIO_MINOR_VERSION,
-                                     AUBIO_PATCH_VERSION]))
-
-    if AUBIO_VERSION_STATUS is not None:
-        verstr += AUBIO_VERSION_STATUS
-    return verstr
-
-def get_aubio_pyversion():
-    # convert to version for python according to pep 440
-    # see https://www.python.org/dev/peps/pep-0440/
-    verstr = get_aubio_version()
-    if '~alpha' in verstr:
-        verstr = verstr.split('~')[0] + 'a1'
-    # TODO: add rc, .dev, and .post suffixes, add numbering
-    return verstr
-
 # inspired from https://gist.github.com/abergmeier/9488990
 def add_packages(packages, ext=None, **kw):
     """ use pkg-config to search which of 'packages' are installed """
@@ -93,7 +55,7 @@
     ext.library_dirs += [os.path.join('build', 'src')]
     ext.libraries += ['aubio']
 
-def add_local_aubio_sources(ext, usedouble = False):
+def add_local_aubio_sources(ext):
     """ build aubio inside python module instead of linking against libaubio """
     print("Info: libaubio was not installed or built locally with waf, adding src/")
     aubio_sources = sorted(glob.glob(os.path.join('src', '**.c')))
@@ -101,6 +63,8 @@
     ext.sources += aubio_sources
 
 def add_local_macros(ext, usedouble = False):
+    if usedouble:
+        ext.define_macros += [('HAVE_AUBIO_DOUBLE', 1)]
     # define macros (waf puts them in build/src/config.h)
     for define_macro in ['HAVE_STDLIB_H', 'HAVE_STDIO_H',
                          'HAVE_MATH_H', 'HAVE_STRING_H',
@@ -193,7 +157,6 @@
 
     def build_extension(self, extension):
         if self.enable_double or 'HAVE_AUBIO_DOUBLE' in os.environ:
-            extension.define_macros += [('HAVE_AUBIO_DOUBLE', 1)]
             enable_double = True
         else:
             enable_double = False
@@ -204,7 +167,7 @@
             # use local src/aubio.h
             if os.path.isfile(os.path.join('src', 'aubio.h')):
                 add_local_aubio_header(extension)
-            add_local_macros(extension)
+            add_local_macros(extension, usedouble=enable_double)
             # look for a local waf build
             if os.path.isfile(os.path.join('build','src', 'fvec.c.1.o')):
                 add_local_aubio_lib(extension)
@@ -212,8 +175,9 @@
                 # check for external dependencies
                 add_external_deps(extension, usedouble=enable_double)
                 # add libaubio sources and look for optional deps with pkg-config
-                add_local_aubio_sources(extension, usedouble=enable_double)
+                add_local_aubio_sources(extension)
         # generate files python/gen/*.c, python/gen/aubio-generated.h
+        extension.include_dirs += [ output_path ]
         extension.sources += generate_external(header, output_path, overwrite = False,
                 usedouble=enable_double)
         return _build_ext.build_extension(self, extension)
--- a/python/scripts/aubiocut
+++ /dev/null
@@ -1,212 +1,0 @@
-#! /usr/bin/env python
-
-""" this file was written by Paul Brossier
-  it is released under the GNU/GPL license.
-"""
-
-import sys
-
-usage = "usage: %s [options] -i soundfile" % sys.argv[0]
-usage += "\n help: %s -h" % sys.argv[0]
-
-def parse_args():
-    from optparse import OptionParser
-    parser = OptionParser(usage=usage)
-    parser.add_option("-i", "--input", action = "store", dest = "source_file",
-            help="input sound file to analyse", metavar = "<source_file>")
-    parser.add_option("-O","--onset-method",
-            action="store", dest="onset_method", default='default',
-            metavar = "<onset_method>",
-            help="onset detection method [default=default] \
-                    complexdomain|hfc|phase|specdiff|energy|kl|mkl")
-    # cutting methods
-    parser.add_option("-b","--beat",
-            action="store_true", dest="beat", default=False,
-            help="use beat locations")
-    """
-    parser.add_option("-S","--silencecut",
-            action="store_true", dest="silencecut", default=False,
-            help="use silence locations")
-    parser.add_option("-s","--silence",
-            metavar = "<value>",
-            action="store", dest="silence", default=-70,
-            help="silence threshold [default=-70]")
-            """
-    # algorithm parameters
-    parser.add_option("-r", "--samplerate",
-            metavar = "<freq>", type='int',
-            action="store", dest="samplerate", default=0,
-            help="samplerate at which the file should be represented")
-    parser.add_option("-B","--bufsize",
-            action="store", dest="bufsize", default=512,
-            metavar = "<size>", type='int',
-            help="buffer size [default=512]")
-    parser.add_option("-H","--hopsize",
-            metavar = "<size>", type='int',
-            action="store", dest="hopsize", default=256,
-            help="overlap size [default=256]")
-    parser.add_option("-t","--onset-threshold",
-            metavar = "<value>", type="float",
-            action="store", dest="threshold", default=0.3,
-            help="onset peak picking threshold [default=0.3]")
-    parser.add_option("-c","--cut",
-            action="store_true", dest="cut", default=False,
-            help="cut input sound file at detected labels \
-                    best used with option -L")
-
-    # minioi
-    parser.add_option("-M","--minioi",
-            metavar = "<value>", type='string',
-            action="store", dest="minioi", default="12ms",
-            help="minimum inter onset interval [default=12ms]")
-
-    """
-    parser.add_option("-D","--delay",
-            action = "store", dest = "delay", type = "float",
-            metavar = "<seconds>", default=0,
-            help="number of seconds to take back [default=system]\
-                    default system delay is 3*hopsize/samplerate")
-    parser.add_option("-C","--dcthreshold",
-            metavar = "<value>",
-            action="store", dest="dcthreshold", default=1.,
-            help="onset peak picking DC component [default=1.]")
-    parser.add_option("-L","--localmin",
-            action="store_true", dest="localmin", default=False,
-            help="use local minima after peak detection")
-    parser.add_option("-d","--derivate",
-            action="store_true", dest="derivate", default=False,
-            help="derivate onset detection function")
-    parser.add_option("-z","--zerocross",
-            metavar = "<value>",
-            action="store", dest="zerothres", default=0.008,
-            help="zero-crossing threshold for slicing [default=0.00008]")
-            """
-    # plotting functions
-    """
-    parser.add_option("-p","--plot",
-            action="store_true", dest="plot", default=False,
-            help="draw plot")
-    parser.add_option("-x","--xsize",
-            metavar = "<size>",
-            action="store", dest="xsize", default=1.,
-            type='float', help="define xsize for plot")
-    parser.add_option("-y","--ysize",
-            metavar = "<size>",
-            action="store", dest="ysize", default=1.,
-            type='float', help="define ysize for plot")
-    parser.add_option("-f","--function",
-            action="store_true", dest="func", default=False,
-            help="print detection function")
-    parser.add_option("-n","--no-onsets",
-            action="store_true", dest="nplot", default=False,
-            help="do not plot detected onsets")
-    parser.add_option("-O","--outplot",
-            metavar = "<output_image>",
-            action="store", dest="outplot", default=None,
-            help="save plot to output.{ps,png}")
-    parser.add_option("-F","--spectrogram",
-            action="store_true", dest="spectro", default=False,
-            help="add spectrogram to the plot")
-    """
-    parser.add_option("-o","--output", type = str,
-            metavar = "<outputdir>",
-            action="store", dest="output_directory", default=None,
-            help="specify path where slices of the original file should be created")
-    parser.add_option("--cut-until-nsamples", type = int,
-            metavar = "<samples>",
-            action = "store", dest = "cut_until_nsamples", default = None,
-            help="how many extra samples should be added at the end of each slice")
-    parser.add_option("--cut-every-nslices", type = int,
-            metavar = "<samples>",
-            action = "store", dest = "cut_every_nslices", default = None,
-            help="how many slices should be groupped together at each cut")
-    parser.add_option("--cut-until-nslices", type = int,
-            metavar = "<slices>",
-            action = "store", dest = "cut_until_nslices", default = None,
-            help="how many extra slices should be added at the end of each slice")
-
-    parser.add_option("-v","--verbose",
-            action="store_true", dest="verbose", default=True,
-            help="make lots of noise [default]")
-    parser.add_option("-q","--quiet",
-            action="store_false", dest="verbose", default=True,
-            help="be quiet")
-    (options, args) = parser.parse_args()
-    if not options.source_file:
-        import os.path
-        if len(args) == 1:
-            options.source_file = args[0]
-        else:
-            print ("no file name given\n" + usage)
-            sys.exit(1)
-    return options, args
-
-if __name__ == '__main__':
-    options, args = parse_args()
-
-    hopsize = options.hopsize
-    bufsize = options.bufsize
-    samplerate = options.samplerate
-    source_file = options.source_file
-
-    from aubio import onset, tempo, source, sink
-
-    s = source(source_file, samplerate, hopsize)
-    if samplerate == 0: samplerate = s.get_samplerate()
-
-    if options.beat:
-        o = tempo(options.onset_method, bufsize, hopsize)
-    else:
-        o = onset(options.onset_method, bufsize, hopsize)
-        if options.minioi:
-            if options.minioi.endswith('ms'):
-                o.set_minioi_ms(int(options.minioi[:-2]))
-            elif options.minioi.endswith('s'):
-                o.set_minioi_s(int(options.minioi[:-1]))
-            else:
-                o.set_minioi(int(options.minioi))
-    o.set_threshold(options.threshold)
-
-    timestamps = []
-    total_frames = 0
-    # analyze pass
-    while True:
-        samples, read = s()
-        if o(samples):
-            timestamps.append (o.get_last())
-            if options.verbose: print ("%.4f" % o.get_last_s())
-        total_frames += read
-        if read < hopsize: break
-    del s
-    # print some info
-    nstamps = len(timestamps)
-    duration = float (total_frames) / float(samplerate)
-    info = 'found %(nstamps)d timestamps in %(source_file)s' % locals()
-    info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
-    sys.stderr.write(info)
-
-    # cutting pass
-    if options.cut and nstamps > 0:
-        # generate output files
-        from aubio.slicing import slice_source_at_stamps
-        timestamps_end = None
-        if options.cut_every_nslices:
-            timestamps = timestamps[::options.cut_every_nslices]
-            nstamps = len(timestamps)
-        if options.cut_until_nslices and options.cut_until_nsamples:
-            print ("warning: using cut_until_nslices, but cut_until_nsamples is set")
-        if options.cut_until_nsamples:
-            timestamps_end = [t + options.cut_until_nsamples for t in timestamps[1:]]
-            timestamps_end += [ 1e120 ]
-        if options.cut_until_nslices:
-            timestamps_end = [t for t in timestamps[1 + options.cut_until_nslices:]]
-            timestamps_end += [ 1e120 ] * (options.cut_until_nslices + 1)
-        slice_source_at_stamps(source_file, timestamps, timestamps_end = timestamps_end,
-                output_dir = options.output_directory,
-                samplerate = samplerate)
-
-        # print some info
-        duration = float (total_frames) / float(samplerate)
-        info = 'created %(nstamps)d slices from %(source_file)s' % locals()
-        info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
-        sys.stderr.write(info)
--- a/python/tests/test_sink.py
+++ b/python/tests/test_sink.py
@@ -117,10 +117,11 @@
         del_tmp_sink_path(sink_path)
 
     def test_read_with(self):
-        sink_path =get_tmp_sink_path()
+        samplerate = 44100
+        sink_path = get_tmp_sink_path()
         vec = fvec(128)
         with sink(sink_path, samplerate) as g:
-            for i in range(10):
+            for _ in range(10):
                 g(vec, 128)
 
 if __name__ == '__main__':
--- a/python/tests/test_source.py
+++ b/python/tests/test_source.py
@@ -5,7 +5,6 @@
 from numpy.testing import TestCase, assert_equal
 from aubio import source
 from .utils import list_all_sounds
-import numpy as np
 
 import warnings
 warnings.filterwarnings('ignore', category=UserWarning, append=True)
--- a/setup.py
+++ b/setup.py
@@ -2,19 +2,19 @@
 
 import sys, os.path, glob
 from setuptools import setup, Extension
-from python.lib.moresetuptools import *
+from python.lib.moresetuptools import build_ext, CleanGenerated
 # function to generate gen/*.{c,h}
-from python.lib.gen_external import generate_external, header, output_path
+from this_version import get_aubio_version, get_aubio_pyversion
 
 __version__ = get_aubio_pyversion()
+__aubio_version__ = get_aubio_version()
 
 include_dirs = []
 library_dirs = []
-define_macros = [('AUBIO_VERSION', '%s' % __version__)]
+define_macros = [('AUBIO_VERSION', '%s' % __aubio_version__)]
 extra_link_args = []
 
 include_dirs += [ 'python/ext' ]
-include_dirs += [ output_path ] # aubio-generated.h
 try:
     import numpy
     include_dirs += [ numpy.get_include() ]
@@ -57,7 +57,6 @@
     version = __version__,
     packages = ['aubio'],
     package_dir = {'aubio':'python/lib/aubio'},
-    scripts = ['python/scripts/aubiocut'],
     ext_modules = [aubio_extension],
     description = 'a collection of tools for music analysis',
     long_description = 'a collection of tools for music analysis',
@@ -75,6 +74,12 @@
         'clean': CleanGenerated,
         'build_ext': build_ext,
         },
+    entry_points = {
+        'console_scripts': [
+            'aubio = aubio.cmd:main',
+            'aubiocut = aubio.cut:main',
+        ],
+    },
     test_suite = 'nose2.collector.collector',
     extras_require = {
         'tests': ['numpy'],
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -356,6 +356,7 @@
       char errorstr[256];
       av_strerror (err, errorstr, sizeof(errorstr));
       AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", s->path, errorstr);
+      s->eof = 1;
       goto beach;
     }
   } while (avPacket.stream_index != s->selected_stream);
@@ -373,7 +374,8 @@
   }
   if (ret < 0) {
     if (ret == AVERROR(EAGAIN)) {
-      AUBIO_WRN("source_avcodec: output is not available right now - user must try to send new input\n");
+      //AUBIO_WRN("source_avcodec: output is not available right now - user must try to send new input\n");
+      goto beach;
     } else if (ret == AVERROR_EOF) {
       AUBIO_WRN("source_avcodec: the decoder has been fully flushed, and there will be no more output frames\n");
     } else {
@@ -563,7 +565,11 @@
   }
   s->avr = NULL;
   if (s->avCodecCtx != NULL) {
+#ifndef HAVE_AUBIO_LIBAVCODEC_DEPRECATED
+    avcodec_free_context( &s->avCodecCtx );
+#else
     avcodec_close ( s->avCodecCtx );
+#endif
   }
   s->avCodecCtx = NULL;
   if (s->avFormatCtx != NULL) {
--- /dev/null
+++ b/this_version.py
@@ -1,0 +1,101 @@
+#! python
+import os
+
+__version_info = {} # keep a reference to parse VERSION once
+
+def get_version_info():
+    # read from VERSION
+    # return dictionary filled with content of version
+    if not __version_info:
+        this_file_dir = os.path.dirname(os.path.abspath(__file__))
+        version_file = os.path.join(this_file_dir, 'VERSION')
+
+        if not os.path.isfile(version_file):
+            raise SystemError("VERSION file not found.")
+
+        for l in open(version_file).readlines():
+            if l.startswith('AUBIO_MAJOR_VERSION'):
+                __version_info['AUBIO_MAJOR_VERSION'] = int(l.split('=')[1])
+            if l.startswith('AUBIO_MINOR_VERSION'):
+                __version_info['AUBIO_MINOR_VERSION'] = int(l.split('=')[1])
+            if l.startswith('AUBIO_PATCH_VERSION'):
+                __version_info['AUBIO_PATCH_VERSION'] = int(l.split('=')[1])
+            if l.startswith('AUBIO_VERSION_STATUS'):
+                __version_info['AUBIO_VERSION_STATUS'] = \
+                    l.split('=')[1].strip()[1:-1]
+
+            if l.startswith('LIBAUBIO_LT_CUR'):
+                __version_info['LIBAUBIO_LT_CUR'] = int(l.split('=')[1])
+            if l.startswith('LIBAUBIO_LT_REV'):
+                __version_info['LIBAUBIO_LT_REV'] = int(l.split('=')[1])
+            if l.startswith('LIBAUBIO_LT_AGE'):
+                __version_info['LIBAUBIO_LT_AGE'] = int(l.split('=')[1])
+
+        if len(__version_info) < 6:
+            raise SystemError("Failed parsing VERSION file.")
+
+        # switch version status with commit sha in alpha releases
+        if __version_info['AUBIO_VERSION_STATUS'] and \
+                '~alpha' in __version_info['AUBIO_VERSION_STATUS']:
+            AUBIO_GIT_SHA = get_git_revision_hash()
+            if AUBIO_GIT_SHA:
+                __version_info['AUBIO_VERSION_STATUS'] = '~git+' + AUBIO_GIT_SHA
+
+    return __version_info
+
+def get_libaubio_version():
+    verfmt = '%(LIBAUBIO_LT_CUR)s.%(LIBAUBIO_LT_REV)s.%(LIBAUBIO_LT_AGE)s'
+    return str(verfmt % get_version_info())
+
+def get_aubio_version():
+    verfmt = '%(AUBIO_MAJOR_VERSION)s.%(AUBIO_MINOR_VERSION)s.%(AUBIO_PATCH_VERSION)s%(AUBIO_VERSION_STATUS)s'
+    return str(verfmt % get_version_info())
+
+def get_aubio_pyversion():
+    # convert to version for python according to pep 440
+    # see https://www.python.org/dev/peps/pep-0440/
+    # outputs MAJ.MIN.PATCH[a0[+git.<sha>[.mods]]]
+    aubio_version = get_aubio_version()
+    if '~git+' in aubio_version:
+        pep440str = aubio_version.replace('+', '.')
+        verstr = pep440str.replace('~git.', 'a0+')
+    elif '~alpha' in aubio_version:
+        verstr = aubio_version.replace('~alpha', 'a0')
+    else:
+        verstr = aubio_version
+    return verstr
+
+def get_git_revision_hash(short=True):
+    # get commit id, with +mods if local tree is not clean
+    if not os.path.isdir('.git'):
+        # print('Version : not in git repository : can\'t get sha')
+        return None
+    import subprocess
+    aubio_dir = os.path.dirname(os.path.abspath(__file__))
+    if not os.path.exists(aubio_dir):
+        raise SystemError("git / root folder not found")
+    gitcmd = ['git', '-C', aubio_dir, 'rev-parse']
+    if short:
+        gitcmd.append('--short')
+    gitcmd.append('HEAD')
+    try:
+        gitsha = subprocess.check_output(gitcmd).strip().decode('utf8')
+    except Exception as e:
+        print('git command error :%s' % e)
+        return None
+    # check if we have a clean tree
+    gitcmd = ['git', '-C', aubio_dir, 'status', '--porcelain']
+    try:
+        output = subprocess.check_output(gitcmd).decode('utf8')
+        if len(output):
+            print('Info: current tree is not clean\n')
+            print(output)
+            gitsha += '+mods'
+    except subprocess.CalledProcessError as e:
+        print (e)
+        pass
+    return gitsha
+
+if __name__ == '__main__':
+    print ('%30s'% 'aubio version:', get_aubio_version())
+    print ('%30s'% 'python-aubio version:', get_aubio_pyversion())
--- a/wscript
+++ b/wscript
@@ -14,20 +14,11 @@
 
 APPNAME = 'aubio'
 
-# source VERSION
-for l in open('VERSION').readlines(): exec (l.strip())
+from this_version import *
 
-VERSION = '.'.join ([str(x) for x in [
-    AUBIO_MAJOR_VERSION,
-    AUBIO_MINOR_VERSION,
-    AUBIO_PATCH_VERSION
-    ]]) + AUBIO_VERSION_STATUS
+VERSION = get_aubio_version()
+LIB_VERSION = get_libaubio_version()
 
-LIB_VERSION = '.'.join ([str(x) for x in [
-    LIBAUBIO_LT_CUR,
-    LIBAUBIO_LT_REV,
-    LIBAUBIO_LT_AGE]])
-
 top = '.'
 out = 'build'
 
@@ -259,8 +250,8 @@
     if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
         # one of fftwf or fftw3f
         if (ctx.options.enable_fftw3f != False):
-            ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
-                    args = '--cflags --libs',
+            ctx.check_cfg(package = 'fftw3f',
+                    args = '--cflags --libs fftw3f >= 3.0.0',
                     mandatory = ctx.options.enable_fftw3f)
             if (ctx.options.enable_double == True):
                 ctx.msg('Warning',
@@ -269,12 +260,12 @@
             # fftw3f disabled, take most sensible one according to
             # enable_double
             if (ctx.options.enable_double == True):
-                ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
-                        args = '--cflags --libs', mandatory =
-                        ctx.options.enable_fftw3)
+                ctx.check_cfg(package = 'fftw3',
+                        args = '--cflags --libs fftw3 >= 3.0.0.',
+                        mandatory = ctx.options.enable_fftw3)
             else:
-                ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
-                        args = '--cflags --libs',
+                ctx.check_cfg(package = 'fftw3f',
+                        args = '--cflags --libs fftw3f >= 3.0.0',
                         mandatory = ctx.options.enable_fftw3)
         ctx.define('HAVE_FFTW3', 1)
 
@@ -290,8 +281,8 @@
 
     # check for libsndfile
     if (ctx.options.enable_sndfile != False):
-        ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
-                args = '--cflags --libs',
+        ctx.check_cfg(package = 'sndfile',
+                args = '--cflags --libs sndfile >= 1.0.4',
                 mandatory = ctx.options.enable_sndfile)
 
     # check for libsamplerate
@@ -303,8 +294,8 @@
             ctx.msg('Checking if using samplerate', 'no (disabled in double precision mode)',
                     color = 'YELLOW')
     if (ctx.options.enable_samplerate != False):
-        ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
-                args = '--cflags --libs',
+        ctx.check_cfg(package = 'samplerate',
+                args = '--cflags --libs samplerate >= 0.0.15',
                 mandatory = ctx.options.enable_samplerate)
 
     # check for jack
@@ -315,21 +306,26 @@
 
     # check for libav
     if (ctx.options.enable_avcodec != False):
-        ctx.check_cfg(package = 'libavcodec', atleast_version = '54.35.0',
-                args = '--cflags --libs', uselib_store = 'AVCODEC',
+        ctx.check_cfg(package = 'libavcodec',
+                args = '--cflags --libs libavcodec >= 54.35.0',
+                uselib_store = 'AVCODEC',
                 mandatory = ctx.options.enable_avcodec)
-        ctx.check_cfg(package = 'libavformat', atleast_version = '52.3.0',
-                args = '--cflags --libs', uselib_store = 'AVFORMAT',
+        ctx.check_cfg(package = 'libavformat',
+                args = '--cflags --libs libavformat >= 52.3.0',
+                uselib_store = 'AVFORMAT',
                 mandatory = ctx.options.enable_avcodec)
-        ctx.check_cfg(package = 'libavutil', atleast_version = '52.3.0',
-                args = '--cflags --libs', uselib_store = 'AVUTIL',
+        ctx.check_cfg(package = 'libavutil',
+                args = '--cflags --libs libavutil >= 52.3.0',
+                uselib_store = 'AVUTIL',
                 mandatory = ctx.options.enable_avcodec)
-        ctx.check_cfg(package = 'libswresample', atleast_version = '2.3.0',
-                args = '--cflags --libs', uselib_store = 'SWRESAMPLE',
+        ctx.check_cfg(package = 'libswresample',
+                args = '--cflags --libs libswresample >= 2.3.0',
+                uselib_store = 'SWRESAMPLE',
                 mandatory = False)
         if 'HAVE_SWRESAMPLE' not in ctx.env:
-            ctx.check_cfg(package = 'libavresample', atleast_version = '1.0.1',
-                    args = '--cflags --libs', uselib_store = 'AVRESAMPLE',
+            ctx.check_cfg(package = 'libavresample',
+                    args = '--cflags --libs libavresample >= 1.0.1',
+                    uselib_store = 'AVRESAMPLE',
                     mandatory = False)
 
         msg_check = 'Checking for all libav libraries'