Changeset 41b985f


Ignore:
Timestamp:
Mar 12, 2017, 11:26:24 AM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
sampler
Children:
bde49c4a
Parents:
71f2e5f (diff), 67b6618 (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.
Message:

Merge 'origin/master' into sampler

Conflicts:

.travis.yml
Makefile
examples/aubionotes.c
examples/parse_args.h
python/demos/demo_timestretch_online.py
python/lib/moresetuptools.py
python/tests/test_source.py
setup.py
src/io/source.c

Files:
12 added
97 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r71f2e5f r41b985f  
    3131doc/web/
    3232doc/full/
     33doc/_build/
    3334
    3435python/gen
  • .travis.yml

    r71f2e5f r41b985f  
    33matrix:
    44  include:
     5    - python: 3.5
     6      os: linux
     7      compiler: gcc
     8    - python: 3.4
     9      os: linux
     10      compiler: gcc
    511    - python: 2.7
    612      os: linux
    713      compiler: gcc
    8       env: ARCH=x86_64
     14    - language: C
     15      os: osx
     16      osx_image: xcode8
     17      compiler: clang
     18    - python: 3.5
     19      os: linux
     20      compiler: gcc
     21      env: CFLAGS="-Os" WAFOPTS="--disable-samplerate --disable-sndfile"
     22    - python: 3.4
     23      os: linux
     24      compiler: gcc
     25      env: HAVE_AUBIO_DOUBLE=1 CFLAGS="-O3" WAFOPTS="--enable-fftw3"
    926    - python: 2.7
    1027      os: linux
    1128      compiler: gcc
    12       env: ARCH=i386
    13     - python: 3.4
    14       os: linux
    15       compiler: gcc
    16       env: ARCH=x86_64
    17     - python: 3.4
    18       os: linux
    19       compiler: gcc
    20       env: ARCH=i386 WAFOPTS=--enable-fftw3f
     29      env: CFLAGS="`dpkg-buildflags --get CFLAGS`" LDFLAGS="`dpkg-buildflags --get LDFLAGS`"
    2130    - language: C
    2231      os: osx
     32      osx_image: xcode8
    2333      compiler: clang
    24       env: ARCH=x86_64
     34      env: CFLAGS="-Os" HAVE_AUBIO_DOUBLE=1 WAFOPTS="--disable-accelerate"
    2535    - language: C
    2636      os: osx
     37      osx_image: xcode8
    2738      compiler: clang
    28       env: ARCH=i386
    29     - python: 2.7
    30       os: linux
    31       compiler: gcc
    32       env: ARCH=x86_64 HAVE_DOUBLE=1 WAFOPTS=--enable-fftw3
    33     - python: 2.7
    34       os: linux
    35       compiler: gcc
    36       env: ARCH=i386 HAVE_DOUBLE=1
    37     - python: 3.4
    38       os: linux
    39       compiler: gcc
    40       env: ARCH=x86_64 HAVE_DOUBLE=1
    41     - python: 3.4
    42       os: linux
    43       compiler: gcc
    44       env: ARCH=i386 HAVE_DOUBLE=1
     39      env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile"
    4540    - language: C
    4641      os: osx
     42      osx_image: xcode8
    4743      compiler: clang
    48       env: ARCH=x86_64 HAVE_DOUBLE=1
     44      env: WAFOPTS="--with-target-platform=ios --disable-avcodec --disable-sndfile --disable-samplerate --disable-rubberband" AUBIO_NOTESTS=1
    4945    - language: C
    5046      os: osx
     47      osx_image: xcode8
    5148      compiler: clang
    52       env: ARCH=i386 HAVE_DOUBLE=1
     49      env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile --disable-samplerate --disable-rubberband" AUBIO_NOTESTS=1
    5350    - language: C
    5451      os: osx
     52      osx_image: xcode8.2
    5553      compiler: clang
    56       env: ARCH=x86_64 WAFOPTS="--enable-fat --disable-sndfile --disable-samplerate --disable-rubberband"
     54      env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile"
    5755    - language: C
    5856      os: osx
     57      osx_image: xcode8.2
    5958      compiler: clang
    60       env: ARCH=i386 WAFOPTS="--enable-fat --disable-sndfile --disable-samplerate --disable-rubberband"
     59      env: WAFOPTS="--with-target-platform=ios --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
     60    - language: C
     61      os: osx
     62      osx_image: xcode8.2
     63      compiler: clang
     64      env: WAFOPTS="--with-target-platform=iosimulator --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
     65
     66# use trusty
     67dist: trusty
     68sudo: required
    6169
    6270addons:
     
    6472    packages:
    6573    - bzip2
     74    - libavcodec-dev
     75    - libavformat-dev
     76    - libavresample-dev
     77    - libavutil-dev
    6678    - libsndfile1-dev
    6779    - libsamplerate-dev
     
    7688     if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
    7789       brew update
    78        brew install sox libsamplerate libsndfile rubberband
     90       brew install sox
     91       brew install ffmpeg
     92       brew install libsndfile
     93       brew install libsamplerate
     94       brew install rubberband
    7995       export PATH="$HOME/Library/Python/2.7/bin/:$PATH"
    8096     fi;
    8197
    82 
    8398install:
    84   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_retry pip install nose2; fi
    85   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then travis_retry pip install --user nose2; fi
     99  - travis_retry pip install --upgrade pip
     100  - travis_retry make getwaf expandwaf deps_python
     101  - which pip
     102  - pip --version
    86103
    87104script:
    88105  - make create_test_sounds
    89   - make build
    90   - make build_python
    91   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make test_python; fi
    92   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make test_python_osx; fi
    93   - make clean_python
    94   - make clean
    95   - make distcheck
    96   - make test_pure_python
     106  - |
     107    if [[ -z "$AUBIO_NOTESTS" ]]; then
     108      make test_lib_python_clean
     109      make test_python_only_clean
     110    else
     111      make test_lib_only_clean
     112    fi;
    97113
    98114notifications:
     
    101117            - "irc.freenode.org#aubio"
    102118        use_notice: true
     119    webhooks:
     120        urls:
     121            - https://webhooks.gitter.im/e/81e7733a5b1d977854b4
     122        on_success: change  # options: [always|never|change] default: always
     123        on_failure: always  # options: [always|never|change] default: always
     124        on_start: never     # options: [always|never|change] default: always
  • ChangeLog

    r71f2e5f r41b985f  
     12017-01-08 Paul Brossier <piem@aubio.org>
     2
     3        [ Overview ]
     4
     5        * VERSION: bump to 0.4.4
     6        * src/utils/log.h: new function to redirect log, error, and warnings
     7        * python/: AUBIO_ERR raises python exception, AUBIO_WRN to emit py warning
     8        * doc/: add some documentation, fix errors in manpages
     9        * wscript: new rules to build 'manpages', 'doxygen', and 'sphinx', new
     10        --build-type=<release|debug> option (thanks to Eduard Mueller)
     11        * src/notes/notes.h: add minioi and silence methods
     12        * examples/: add --minioi (minimum inter-onset interval) option
     13        * src/pitch/pitchyin.c: improve msvc compiler optimisations (thanks to
     14        Eduard Mueller)
     15        * python/, src/: improve error messages, fix minor memory leaks
     16        * src/io/source_avcodec.c: improve compatibility with latest ffmpeg and with
     17        older libav/ffmpeg versions
     18        * python/demos/: new demos to capture microphone in real time
     19
     20        [ Interface]
     21
     22        * src/aubio.h: include utils/log.h
     23        * src/utils/log.h: add new aubio_log_set_function to redirect log messages
     24        * src/notes/notes.h: add aubio_notes_{get,set}_minioi_ms, add
     25        _{get,set}_silence methods
     26
     27        [ Library ]
     28
     29        * src/aubio_priv.h: add AUBIO_INF to print to stdout with header, use new
     30        logging function, add ATAN alias, add stdarg.h, move #include "config.h"
     31        * src/{fmat,fvec}.c: avoid integer division
     32        * src/pitch/pitchyin.c: [msvc] help compiler to optimize aubio_pitchyin_do
     33        by giving it addresses for all arrays which are referenced in inner loops,
     34        thanks to Eduard Mueller.
     35        * src/pitch/pitch.c: declare internal functions as static, fail on wrong
     36        method, warn on wrong unit, improve error messages, fix error string
     37        * src/spectral/specdesc.c: return NULL if wrong mode asked, remove trailing
     38        spaces
     39        * src/onset/onset.c: return null and clean-up if new_aubio_specdesc failed,
     40        fix error message
     41        * src/notes/notes.c: use midi note to store pitch candidate, round to
     42        nearest note, add a variable to define precision, fix out-of-bound write,
     43        fix unset silence_threshold, fix error message
     44        * src/spectral/ooura_fft8g.c: add cast to avoid conversion warnings, prefix
     45        public function with aubio_ooura_ to avoid with other apps using ooura (e.g.
     46        puredata), make internal functions static,
     47        * src/spectral/fft.c: add message about fftw3 being able to do non-power of
     48        two sizes, make calls to fftw_destroy_plan thread-safe, use prefixed
     49        aubio_ooura_rdft
     50        * src/spectral/phasevoc.c: fix error string
     51        * src/temporal/resampler.c: throw an error when using libsamplerate with doubles
     52        * src/io/ioutils.h: add functions to check samplerate and channels, use in sink_*.c
     53        * src/io/source.c: add error message when aubio was compiled with no source,
     54        only show error message from last child source_
     55        * src/io/source_avcodec.c: call avformat_free_context after
     56        avformat_close_input, keep a reference to packet to remove it when closing
     57        file, avoid deprecation warnings with ffmpeg 3.2, add backward compatibility
     58        for libavcodec55, fix for old libavcodec54, use AV_SAMPLE_FMT_DBL when
     59        compiling with HAVE_AUBIO_DOUBLE, fix missing samples in eof block, avoid
     60        function calls before declarations, improve error messages, replace with new
     61        context before closing old one, make sure s->path is set to null
     62        * src/io/{source_wavread,sink_wavwrite}.c: declare internal functions as static
     63        * src/io/source_wavread.c: fix bytes_read for JUNK headers, improve error
     64        messages, initialize buffer, skip chunks until data is found, or abort, skip
     65        junk chunk
     66        * src/io/source_sndfile.c: add support for multi-channel resampling, set
     67        handle to null after sucessful close, add missing floor in ratio comparison,
     68        improve formatting
     69        * src/io/sink.c: only show error message from last child sink_
     70        * src/io/sink_apple_audio.c: avoid crash on empty file name
     71        * src/io/sink_sndfile.c: improve error message
     72        * src/io/sink_{sndfile,wavwrite}.c: use AUBIO_MAX_CHANNELS, fix error message
     73
     74        [ Documentation ]
     75
     76        * README.md: update copyright dates, use https
     77        * src/aubio.h: add some links to examples, use https
     78        * src/pitch/pitch.h: add aubio_pitch_get_tolerance, add basic description of
     79        unit modes
     80        * src/notes/notes.h: add doxygen header
     81        * src/spectral/fft.h: strip example path
     82        * doc/*.rst: improve sphinx documentation
     83        * doc/android.rst: add reference to it scripts/build_android
     84        * doc/debian_packages.rst: added page on debian packages
     85        * doc/python_module.rst: add demo_source_simple.py, add note on pip, add
     86        `print(aubio.version)`
     87        * doc/cli.rst: include command line manpages
     88        * doc/cli_features.rst: add matrix of command line features
     89        * doc/requirements.rst: add a note about --notests (closes #77), document
     90        --msvc options, improve description of options
     91        * doc/download.rst: added page on download
     92        * doc/installing.rst: update
     93        * doc/xcode_frameworks.rst: added page on xcode frameworks
     94        * doc/**: use https://aubio.org
     95        * doc/conf.py: use pyramid theme, update copyright, remove hardcoded path
     96        * doc/web.cfg: exclude ioutils from doc
     97        * doc/aubionotes.txt: document -M option (see #18),
     98        * doc/aubioonset.txt: add documentation for -M, --minioi, improve threshold
     99        description (thanks to Peter Parker), fix typo (onset, not pitch)
     100        * doc/aubio*.txt: document -T/--timeformat option
     101
     102        [ Build ]
     103
     104        * Makefile: add a brief intro, avoid offline operations, add html and dist
     105        targets, add rules for documentation, simplify listing, avoid offline
     106        operations, bump waf to 1.9.6, check for waf before clean, chmod go-w
     107        waflib, improve clean, use pip to install, factorise pip options, generate
     108        more test sounds, improve test_python and test_pure_python, pass build_ext
     109        in test_pure_python{,_wheel}, quieten uninstall_python if already
     110        uninstalled, improve test targets, use bdist_wheel in test_pure_python,
     111        build_ext only for --enable-double, verbose waf rules, add cleanwaf
     112        * wscript: added debug/release build type configurations release (default)
     113        enables optimizations, debug symbols are enabled in both configurations,
     114        thanks to Eduard Mueller.
     115        * wscript: add options to disable source_wavread/sink_wavwrite, add check
     116        for stdarg.h, new rules 'manpages', 'sphinx', and 'doxygen' to build
     117        documentation, add version to sphinx and manpages, disable libsamplerate
     118        if double precision enabled (libsamplerate only supports float), fix typos,
     119        remove trailing spaces, improve tarball creation (./waf dist), remove
     120        full.cfg from tarball, prepend to CFLAGS to honor user cflags
     121        * wscript, src/wscript_build: improve install locations using DATAROOTDIR,
     122        MANDIR, INCLUDEDIR
     123        * wscript: default to no atlas for now
     124        * src/wscript_build: always build static library
     125        * scripts/build_android: add an example script to build aubio on android,
     126
     127        [ Tools ]
     128
     129        * examples/aubionotes.c: use new notes, set minioi, send last note off when
     130        needed, add warning for missing options
     131        * examples/aubioonset.c: add minioi option, in seconds
     132        * examples/: only send a last note off when using jack
     133        * examples/: return 1 if object creation failed
     134        * examples/: use PROG_HAS_OUTPUT, add PROG_HAS_SILENCE
     135
     136        [ Tests ]
     137
     138        * tests/src/spectral/test-fft.c: fix default size
     139        * tests/src/spectral/test-phasevoc.c: fix typos
     140        * tests/src/utils/test-log.c: add AUBIO_INF, add example for
     141        aubio_log_set_function, improve messages
     142
     143        [ Python ]
     144
     145        * python/ext/aubiomodule.c: add aubio._aubio.__version__ and import it as
     146        aubio.version, use custom logging function for errors and warnings, remove
     147        duplicated add_generated_objects, use <> for non local aubio
     148        * python/ext/py-cvec.c: use NPY_INTP_FMT
     149        * python/ext/py-fft.c: use error string set in src/spectral/fft.c
     150        * python/ext/py-phasevoc.c: use error string set in src/spectral/phasevoc.c
     151        * python/ext/py-sink.c: always set samplerate and channels in init
     152        * python/ext/py-source.c: use error string set in src/io/source.c
     153        * python/lib/aubio/midiconv.py: add unicode double sharp and double flat,
     154        improve unicode handling, skip UnicodeEncodeError on python 2.x
     155
     156        [ Python build ]
     157
     158        * MANIFEST.in: add src/**.c, exclude full.cfg, include waflib, remove
     159        python/ext/config.h
     160        * setup.py: define AUBIO_VERSION use sorted glob.glob to improve
     161        reproducibility, remove extra quotes, remove status from version string,
     162        update description, use custom build_ext instead of 'generate' command,
     163        define HAVE_AUBIO_DOUBLE to 1 if needed
     164        * python/lib/gen_code.py: add support for multiple _do outputs, fix number
     165        of output, improve del_ function, safer DECREF, fix indentation, emit RuntimeError
     166        * python/lib/gen_external.py: clean-up, enable tss, remove duplicate,
     167        sort generated files
     168        * python/lib/moresetuptools.py: add HAVE_STDARG_H, also check for
     169        HAVE_AUBIO_DOUBLE, cleaner clean, look first for system library, then for
     170        local build, then local sources, mo nore fake config.h here, use
     171        samplerate in single precision only
     172        * python/README.md: add a note about nose2 for python tests (closes #74)
     173        * scripts/setenv_local.sh: python3 compat
     174
     175        [ Python demos ]
     176
     177        * python/demos/demo_alsa.py: add example using alsaaudio (closes #72)
     178        * python/demos/demo_mfcc.py: add options to plot first and second
     179        derivatives, and set samplerate/win_s/hop_s, thanks to @jhoelzl (closes #68)
     180        * python/demos/demo_notes.py: add simple notes demos
     181        * python/demos/demo_pyaudio.py: added simple demo for pyaudio, see #6,
     182        closes #78, thanks to @jhoelzl and @notalentgeek, add some comments, avoid
     183        overwriting aubio.pitch
     184        * python/demos/demo_source_simple.py: fix indentation, make executable
     185        * python/demos/demo_timestretch{,_online}.py: fix usage string, remove
     186        unused import, use // to yield an integer (closes #71)
     187        * python/demos/demo_timestretch_online.py: use 512, fix block counter
     188        * python/demos/demo_tss.py: improve default parameters, exit before plotting
     189
     190        [ Python tests ]
     191
     192        * python/tests/: use local import, add __init__.py
     193        * python/tests/test_cvec.py: simplify
     194        * python/tests/test_fft.py: skip test fft(zeros).phas == 0 if needed, expected powerpc
     195        * python/tests/test_fvec.py: reduce alpha norm precision to 10.-4
     196        * python/tests/test_{midi2note,note2midi}.py: use nose2.params, add unicode tests
     197        * python/tests/test_notes.py: add basic tests
     198        * python/tests/test_notes.py: test results are correct for 44100Hz_44100f_sine441.wav
     199        * python/tests/test_sink.py: add more tests, quiet warnings
     200        * python/tests/test_source.py: break long line, check the tail of the file
     201        is non-zero on non silent test files, filter user warnings to avoid spamming
     202        the console, only check if last frames are non silent on brownnoise (weak),
     203        remove fragile brownnoise test, check duration on short files, use nose2
     204        params to process one sound file per test
     205        * python/tests/test_specdesc.py: RuntimeError is now raised on wrong mode
     206        * python/tests/utils.py: by default, use 5 seconds brownoise
     207
     208        [ Only in git ]
     209
     210        * .travis.yml: add debian dpkg-buildflags config, switch from precise to
     211        trusty, sudo required, add ffmpeg on osx, add targets ios, iosimulator,
     212        and osx noopt configs, bump to xcode8, add xcode8.2 config, mimick
     213        build_apple_frameworks options, alway upgrade pip, add pip --version and
     214        which pip after upgrading, remove --user, use expandwaf in install, remove
     215        unused ARCH, shuffle order, remove duplicate, add missing opening quote,
     216        use AUBIO_NOTESTS to build only lib on ios, add gitter webhook
     217        * .appveyor.yml: fix path for windows+python 3.5, fix typo in path, make
     218        nose2 tests verbose
     219
    12202016-08-16 Paul Brossier <piem@aubio.org>
    2221
  • MANIFEST.in

    r71f2e5f r41b985f  
    22include python/README.md
    33include Makefile wscript */wscript_build
    4 include waf
     4include waf waflib/* waflib/*/*
     5exclude waflib/__pycache__/*
    56include aubio.pc.in
    67include nose2.cfg
     
    1819include python/tests/run_all_tests
    1920include python/tests/*.py
     21include python/tests/eval_pitch
    2022include python/demos/*.py
    2123include python/tests/*.expected
    2224include doc/*.txt doc/*.rst doc/*.cfg doc/Makefile doc/make.bat doc/conf.py
     25exclude doc/full.cfg
    2326include scripts/* scripts/apple/Info.plist scripts/apple/Modules/module.modulemap
    2427exclude python/gen/*
    25 exclude python/ext/config.h
  • Makefile

    r71f2e5f r41b985f  
     1#!/usr/bin/make -f
     2# -*- makefile -*-
     3#
     4# This makefile contains simple rules to prepare, compile, test, and install
     5# aubio. Try one of the following rules:
     6#
     7# $ make configure
     8# $ make build
     9# $ make install
     10# $ make test_python
     11
    112WAFCMD=python waf
    2 WAFURL=https://waf.io/waf-1.8.22
     13WAFURL=https://waf.io/waf-1.9.6
     14
     15#WAFOPTS:=
     16# turn on verbose mode
     17WAFOPTS += --verbose
     18# build wafopts
     19WAFOPTS += --destdir $(DESTDIR)
     20# multiple jobs
     21WAFOPTS += --jobs 4
     22# if HAVE_AUBIO_DOUBLE is defined, pass --enable-double to waf
     23# python/lib/moresetuptools.py also checks for HAVE_AUBIO_DOUBLE
     24WAFOPTS += $(shell [ -z $(HAVE_AUBIO_DOUBLE) ] || echo --enable-double )
     25
     26PIPOPTS += --verbose
     27
     28DESTDIR:=$(PWD)/build/dist
     29PYDESTDIR:=$(PWD)/build/pydist
     30
     31# default install locations
     32PREFIX?=/usr/local
     33EXEC_PREFIX?=$(PREFIX)
     34LIBDIR?=$(PREFIX)/lib
     35INCLUDEDIR?=$(PREFIX)/include
     36DATAROOTDIR?=$(PREFIX)/share
     37MANDIR?=$(DATAROOTDIR)/man
    338
    439SOX=sox
    540
    6 ENABLE_DOUBLE := $(shell [ -z $(HAVE_DOUBLE) ] || echo --enable-double )
    741TESTSOUNDS := python/tests/sounds
    842
     
    1347
    1448getwaf:
    15         @./scripts/get_waf.sh
    16 
    17 expandwaf:
    18         @[ -d wafilb ] || rm -fr waflib
    19         @$(WAFCMD) --help > /dev/null
    20         @mv .waf*/waflib . && rm -fr .waf*
    21         @sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
    22         @chmod +x waf
     49        ./scripts/get_waf.sh
     50
     51expandwaf: getwaf
     52        [ -d wafilb ] || rm -fr waflib
     53        $(WAFCMD) --help > /dev/null
     54        mv .waf*/waflib . && rm -fr .waf*
     55        sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
     56        chmod +x waf && chmod -R go-w waflib
     57
     58cleanwaf:
     59        rm -rf waf waflib .waf*
    2360
    2461configure: checkwaf
    25         $(WAFCMD) configure $(WAFOPTS) $(ENABLE_DOUBLE)
     62        $(WAFCMD) configure $(WAFOPTS)
    2663
    2764build: configure
    2865        $(WAFCMD) build $(WAFOPTS)
    2966
     67install:
     68        # install
     69        $(WAFCMD) install $(WAFOPTS)
     70
     71list_installed:
     72        find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|'
     73
     74list_installed_python:
     75        pip show -f aubio
     76
     77list_all_installed: list_installed list_installed_python
     78
     79uninstall:
     80        # uninstall
     81        $(WAFCMD) uninstall $(WAFOPTS)
     82
     83delete_install:
     84        rm -rf $(PWD)/dist/test
     85
    3086build_python:
    31         python ./setup.py build_ext $(ENABLE_DOUBLE)
    32 
    33 test_python: export LD_LIBRARY_PATH=$(PWD)/build/src
    34 test_python:
    35         pip install -v -r requirements.txt
    36         pip install -v .
    37         nose2 --verbose
    38         pip uninstall -y -v aubio
    39 
    40 test_python_osx:
     87        # build python-aubio, using locally built libaubio if found
     88        python ./setup.py build
     89
     90build_python_extlib:
     91        # build python-aubio using (locally) installed libaubio
     92        [ -f $(DESTDIR)/$(INCLUDEDIR)/aubio/aubio.h ]
     93        [ -d $(DESTDIR)/$(LIBDIR) ]
     94        [ -f $(DESTDIR)/$(LIBDIR)/pkgconfig/aubio.pc ]
     95        PKG_CONFIG_PATH=$(DESTDIR)/$(LIBDIR)/pkgconfig \
     96        CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \
     97        LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \
     98                make build_python
     99
     100deps_python:
     101        # install or upgrade python requirements
     102        pip install $(PIPOPTS) --requirement requirements.txt
     103
     104# use pip or distutils?
     105install_python: install_python_with_pip
     106uninstall_python: uninstall_python_with_pip
     107#install_python: install_python_with_distutils
     108#uninstall_python: uninstall_python_with_distutils
     109
     110install_python_with_pip:
     111        # install package
     112        pip install $(PIPOPTS) .
     113
     114uninstall_python_with_pip:
     115        # uninstall package
     116        ( pip show aubio | grep -l aubio > /dev/null ) && \
     117        pip uninstall -y -v aubio || echo "info: aubio package is not installed"
     118
     119install_python_with_distutils:
     120        ./setup.py install $(PIPOPTS) $(DISTUTILSOPTS)
     121
     122uninstall_python_with_distutils:
     123        #./setup.py uninstall
     124        [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true
     125
     126force_uninstall_python:
     127        # ignore failure if not installed
     128        -make uninstall_python
     129
     130local_dylib:
     131        # DYLD_LIBRARY_PATH is no more on mac os
    41132        # create links from ~/lib/lib* to build/src/lib*
    42         [ -f build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
    43         # then run the tests
    44         pip install --user -v -r requirements.txt
    45         pip install --user -v .
    46         nose2 --verbose
    47         pip uninstall -y -v aubio
     133        [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
     134
     135test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR)
     136test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR)
     137test_python: local_dylib
     138        # run test with installed package
     139        ./python/tests/run_all_tests --verbose
     140        # also run with nose, multiple processes
     141        nose2 -N 4
    48142
    49143clean_python:
    50144        ./setup.py clean
    51145
    52 test_pure_python:
    53         -pip uninstall -v -y aubio
    54         -rm -rf build/ python/gen/
    55         -rm -f dist/*.egg
    56         -pip install -v -r requirements.txt
    57         CFLAGS=-Os python setup.py build_ext $(ENABLE_DOUBLE) bdist_wheel
    58         pip install dist/aubio-*.whl
    59         nose2 -N 4
    60         pip uninstall -v -y aubio
    61 
    62 test_pure_python_wheel:
    63         -pip uninstall -v -y aubio
    64         -rm -rf build/ python/gen/
    65         -rm -f dist/*.whl
    66         -pip install -v -r requirements.txt
    67         -pip install -v wheel
    68         CFLAGS=-Os python setup.py build_ext $(ENABLE_DOUBLE) bdist_wheel --universal
    69         wheel install dist/*.whl
    70         nose2 -N 4
    71         pip uninstall -v -y aubio
    72 
    73 build_python3:
    74         python3 ./setup.py build_ext $(ENABLE_DOUBLE)
    75 
    76 clean_python3:
    77         python3 ./setup.py clean
    78 
    79 clean:
     146check_clean_python:
     147        # check cleaning a second time works
     148        make clean_python
     149        make clean_python
     150
     151clean: checkwaf
     152        # optionnaly clean before build
     153        -$(WAFCMD) clean
     154        # remove possible left overs
     155        -rm -rf doc/_build
     156
     157check_clean:
     158        # check cleaning after build works
     159        $(WAFCMD) clean
     160        # check cleaning a second time works
    80161        $(WAFCMD) clean
    81162
    82163distclean:
    83164        $(WAFCMD) distclean
     165        -rm -rf doc/_build/
     166        -rm -rf doc/web/
     167
     168check_distclean:
     169        make distclean
    84170
    85171distcheck: checkwaf
    86         $(WAFCMD) distcheck $(WAFOPTS) $(ENABLE_DOUBLE)
     172        $(WAFCMD) distcheck $(WAFOPTS)
    87173
    88174help:
     
    92178        -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
    93179        -mkdir -p $(TESTSOUNDS)
    94         -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"      synth 1s   silence 0
     180        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"      trim 0 1s
    95181        -$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav"   synth 5    brownnoise      vol 0.9
    96182        -$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav"    synth 127s sine 440        vol 0.9
    97         -$(SOX) -r  8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav"      synth 30   silence 0       vol 0.9
     183        -$(SOX) -r  8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav"      trim 0 30
    98184        -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav"       synth 60   sine 100-20000  vol 0.9
     185        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_44100f_sine441.wav"  synth 44100s   sine 441   vol 0.9
     186        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav"    synth 100s sine 441       vol 0.9
     187
     188# build only libaubio, no python-aubio
     189test_lib_only: clean distclean configure build install list_installed
     190# additionally, clean after a fresh build
     191test_lib_only_clean: test_lib_only uninstall check_clean check_distclean
     192
     193# build libaubio, build and test python-aubio against it
     194test_lib_python: force_uninstall_python deps_python \
     195        clean_python clean distclean \
     196        configure build build_python \
     197        install install_python \
     198        test_python \
     199        list_all_installed
     200
     201test_lib_python_clean: test_lib_python \
     202        uninstall_python uninstall \
     203        check_clean_python \
     204        check_clean \
     205        check_distclean
     206
     207# build libaubio, install it, build python-aubio against it
     208test_lib_install_python: force_uninstall_python deps_python \
     209        clean_python distclean \
     210        configure build \
     211        install \
     212        build_python_extlib \
     213        install_python \
     214        test_python \
     215        list_all_installed
     216
     217test_lib_install_python_clean: test_lib_install_python \
     218        uninstall_python \
     219        delete_install \
     220        check_clean_python \
     221        check_distclean
     222
     223# build a python-aubio that includes libaubio
     224test_python_only: force_uninstall_python deps_python \
     225        clean_python clean distclean \
     226        build_python \
     227        install_python \
     228        test_python \
     229        list_installed_python
     230
     231test_python_only_clean: test_python_only \
     232        uninstall_python \
     233        check_clean_python
     234
     235sphinx: configure
     236        $(WAFCMD) sphinx $(WAFOPTS)
     237
     238doxygen: configure
     239        $(WAFCMD) doxygen $(WAFOPTS)
     240
     241manpages: configure
     242        $(WAFCMD) manpages $(WAFOPTS)
     243
     244html: doxygen sphinx
     245
     246docs: html manpages
     247
     248dist: distclean expandwaf
     249        $(WAFCMD) dist
  • README.md

    r71f2e5f r41b985f  
    8888    make getwaf
    8989
    90 aubio compiles on Linux, Mac OS X, Cygwin, and iOS.
     90aubio compiles on Linux, Mac OS X, Windows, Cygwin, and iOS.
    9191
    9292Installation
     
    163163
    164164To subscribe to the list, use the mailman form:
    165 http://lists.aubio.org/listinfo/aubio-user/
     165https://lists.aubio.org/listinfo/aubio-user/
    166166
    167167Alternatively, feel free to contact directly the author.
     
    171171---------------------------------
    172172
    173 Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org>
     173Copyright (C) 2003-2016 Paul Brossier <piem@aubio.org>
    174174
    175175aubio is free software: you can redistribute it and/or modify it under the
  • VERSION

    r71f2e5f r41b985f  
    11AUBIO_MAJOR_VERSION=0
    22AUBIO_MINOR_VERSION=4
    3 AUBIO_PATCH_VERSION=4
     3AUBIO_PATCH_VERSION=5
    44AUBIO_VERSION_STATUS='~alpha'
    55LIBAUBIO_LT_CUR=5
    6 LIBAUBIO_LT_REV=0
    7 LIBAUBIO_LT_AGE=4
     6LIBAUBIO_LT_REV=1
     7LIBAUBIO_LT_AGE=5
  • doc/Makefile

    r71f2e5f r41b985f  
    4040
    4141clean:
     42        -rm -rf _static
    4243        -rm -rf $(BUILDDIR)/*
    4344
    4445html:
     46        mkdir -p _static
    4547        $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
    4648        @echo
  • doc/aubiocut.txt

    r71f2e5f r41b985f  
    3535
    3636  -t, --onset-threshold thres  Set the threshold value for the onset peak
    37   picking. Typical values are typically within 0.001 and 0.900. Defaults to
    38   0.1. Lower threshold values imply more onsets detected. Try 0.5 in case of
    39   over-detections. Defaults to 0.3.
     37  picking. Values are typically in the range [0.001, 0.900]. Lower threshold
     38  values imply more onsets detected. Increasing this threshold should reduce
     39  the number of incorrect detections. Defaults to 0.3.
    4040
    4141  -c, --cut  Cut input sound file at detected labels. A new sound files for
  • doc/aubionotes.txt

    r71f2e5f r41b985f  
    5050  0.1. Lower threshold values imply more onsets detected. Try 0.5 in case of
    5151  over-detections. Defaults to 0.3.
     52
     53  -M, --minioi value  Set the minimum inter-onset interval, in seconds, the
     54  shortest interval between two consecutive notes. Defaults to 0.030
    5255
    5356  -p, --pitch method  The pitch detection method to use. See PITCH METHODS
  • doc/aubioonset.txt

    r71f2e5f r41b985f  
    1010             [-T time-format]
    1111             [-s sil] [-m] [-f]
    12              [-j] [-v] [-h]
     12             [-j] [-N miditap-note] [-V miditap-velo]
     13             [-v] [-h]
    1314
    1415DESCRIPTION
     
    4950
    5051  -t, --onset-threshold thres  Set the threshold value for the onset peak
    51   picking. Typical values are typically within 0.001 and 0.900. Defaults to
    52   0.1. Lower threshold values imply more onsets detected. Try 0.5 in case of
    53   over-detections. Defaults to 0.3.
     52  picking. Values are typically in the range [0.001, 0.900]. Lower threshold
     53  values imply more onsets detected. Increasing this threshold should reduce
     54  the number of incorrect detections. Defaults to 0.3.
    5455
    55   -s, --silence sil  Set the silence threshold, in dB, under which the pitch
     56  -M, --minioi value  Set the minimum inter-onset interval, in seconds, the
     57  shortest interval between two consecutive onsets. Defaults to 0.020
     58
     59  -s, --silence sil  Set the silence threshold, in dB, under which the onset
    5660  will not be detected. A value of -20.0 would eliminate most onsets but the
    5761  loudest ones. A value of -90.0 would select all onsets. Defaults to -90.0.
     
    6771  -j, --jack  Use Jack input/output. You will need a Jack connection
    6872  controller to feed aubio some signal and listen to its output.
     73
     74  -N, --miditap-note  Override note value for MIDI tap. Defaults to 69.
     75
     76  -V, --miditap-velop  Override velocity value for MIDI tap. Defaults to 65.
    6977
    7078  -h, --help  Print a short help message and exit.
  • doc/aubiotrack.txt

    r71f2e5f r41b985f  
    99             [-T time-format]
    1010             [-s sil] [-m]
    11              [-j] [-v] [-h]
     11             [-j] [-N miditap-note] [-V miditap-velo]
     12             [-v] [-h]
    1213
    1314DESCRIPTION
     
    5556  controller to feed aubio some signal and listen to its output.
    5657
     58  -N, --miditap-note  Override note value for MIDI tap. Defaults to 69.
     59
     60  -V, --miditap-velop  Override velocity value for MIDI tap. Defaults to 65.
     61
    5762  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
    5863  seconds.
  • doc/cli.rst

    r71f2e5f r41b985f  
    1717
    1818 - ``aubiocut`` slices sound files at onset or beat timestamps
     19
     20
     21.. toctree::
     22
     23   cli_features
    1924
    2025
  • doc/conf.py

    r71f2e5f r41b985f  
    1717# add these directories to sys.path here. If the directory is relative to the
    1818# documentation root, use os.path.abspath to make it absolute, like shown here.
    19 sys.path.insert(0, os.path.abspath('../../python/build/lib.macosx-10.6-intel-2.7'))
     19#sys.path.insert(0, os.path.abspath('../../python/build/...'))
    2020
    2121# -- General configuration -----------------------------------------------------
     
    5151version = '0.4'
    5252# The full version, including alpha/beta/rc tags.
    53 release = 'latest'
     53release = '0.4.5~alpha'
    5454
    5555# The language for content autogenerated by Sphinx. Refer to documentation
     
    9292# The theme to use for HTML and HTML Help pages.  See the documentation for
    9393# a list of builtin themes.
    94 html_theme = 'default'
     94#html_theme = 'agogo'
     95#html_theme = 'default'
     96#html_theme = 'haiku'
     97html_theme = 'pyramid'
    9598
    9699# Theme options are theme-specific and customize the look and feel of a theme
     
    121124# relative to this directory. They are copied after the builtin static files,
    122125# so a file named "default.css" will overwrite the builtin "default.css".
    123 html_static_path = ['_static']
     126html_static_path = [] #['_static']
    124127
    125128# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
     
    151154
    152155# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
    153 #html_show_sphinx = True
     156html_show_sphinx = False
    154157
    155158# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
     
    241244# How to display URL addresses: 'footnote', 'no', or 'inline'.
    242245#texinfo_show_urls = 'footnote'
     246
     247def setup(app):
     248    if release.endswith('~alpha'): app.tags.add('devel')
  • doc/develop.rst

    r71f2e5f r41b985f  
     1.. _develop:
     2
    13Developping with aubio
    24======================
     
    7577   :lines: 6-11
    7678
    77 The processing loop could know look like:
     79The processing loop could now look like:
    7880
    7981.. literalinclude:: ../tests/src/spectral/test-phasevoc.c
  • doc/download.rst

    r71f2e5f r41b985f  
    66A number of distributions already include aubio. Check your favorite package
    77management system, or have a look at the `aubio download page
    8 <http://aubio.org/download>`_ for more options.
     8<https://aubio.org/download>`_ for more options.
    99
    1010To use aubio in a macOS or iOS application, see :ref:`xcode-frameworks-label`.
  • doc/full.cfg

    r71f2e5f r41b985f  
    3939# control system is used.
    4040
    41 PROJECT_NUMBER         = "0.4.2~alpha full"
     41PROJECT_NUMBER         = "0.4.5~alpha"
    4242
    4343# Using the PROJECT_BRIEF tag one can provide an optional one line description
     
    14651465# This tag requires that the tag USE_MATHJAX is set to YES.
    14661466
    1467 MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
     1467MATHJAX_RELPATH        = https://cdn.mathjax.org/mathjax/latest
    14681468
    14691469# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
  • doc/index.rst

    r71f2e5f r41b985f  
    1010performing pitch detection, tapping the beat and producing midi streams from
    1111live audio.
     12
     13Quick links
     14===========
     15
     16* :ref:`python`
     17* :ref:`manpages`
     18* :ref:`develop`
     19* :ref:`building`
     20
     21.. only:: devel
     22
     23    .. include:: statuslinks.rst
     24
     25Project pages
     26=============
     27
     28* `Project homepage`_: https://aubio.org
     29* `aubio on github`_: https://github.com/aubio/aubio
     30* `aubio on pypi`_: https://pypi.python.org/pypi/aubio
     31* `Doxygen documentation`_: https://aubio.org/doc/latest/
     32* `Mailing lists`_: https://lists.aubio.org
     33
     34.. _Project homepage: https://aubio.org
     35.. _aubio on github: https://github.com/aubio/aubio
     36.. _aubio on pypi: https://pypi.python.org/pypi/aubio
     37.. _Doxygen documentation: https://aubio.org/doc/latest/
     38.. _Mailing lists: https://lists.aubio.org/
     39
     40* `Travis Continuous integration page <https://travis-ci.org/aubio/aubio>`_
     41* `Appveyor Continuous integration page <https://ci.appveyor.com/project/piem/aubio>`_
     42* `Landscape python code validation <https://landscape.io/github/aubio/aubio/master>`_
     43* `ReadTheDocs documentation <https://aubio.readthedocs.io/en/latest/>`_
    1244
    1345Features
     
    3163found in the results.
    3264
     65Copyright
     66=========
     67
     68Copyright © 2003-2016 Paul Brossier <piem@aubio.org>
     69
     70License
     71=======
     72
     73aubio is a `free <http://www.debian.org/intro/free>`_ and `open source
     74<http://www.opensource.org/docs/definition.php>`_ software; **you** can
     75redistribute it and/or modify it under the terms of the `GNU
     76<https://www.gnu.org/>`_ `General Public License
     77<https://www.gnu.org/licenses/gpl.html>`_ as published by the `Free Software
     78Foundation <https://fsf.org>`_, either version 3 of the License, or (at your
     79option) any later version.
     80
     81.. note::
     82
     83   aubio is not MIT or BSD licensed. Contact the author if you need it in your
     84   commercial product.
     85
    3386Content
    3487=======
     
    3891
    3992   installing
     93   python_module
    4094   cli
    41    python_module
    4295   develop
    43 
    44 Project pages
    45 =============
    46 
    47 * `Project homepage`_: https://aubio.org
    48 * `aubio on github`_: https://github.com/aubio/aubio
    49 * `aubio on pypi`_: https://pypi.python.org/pypi/aubio
    50 * `Doxygen documentation`_: https://aubio.org/doc/latest/
    51 * `Mailing lists`_: https://lists.aubio.org
    52 
    53 .. _Project homepage: https://aubio.org
    54 .. _aubio on github: https://github.com/aubio/aubio
    55 .. _aubio on pypi: https://pypi.python.org/pypi/aubio
    56 .. _Doxygen documentation: https://aubio.org/doc/latest/
    57 .. _Mailing lists: https://lists.aubio.org/
    58 
    59 Current status
    60 ==============
    61 
    62 .. image:: https://travis-ci.org/aubio/aubio.svg?branch=master
    63    :target: https://travis-ci.org/aubio/aubio
    64    :alt: Travis build status
    65 
    66 .. image:: https://ci.appveyor.com/api/projects/status/f3lhy3a57rkgn5yi?svg=true
    67    :target: https://ci.appveyor.com/project/piem/aubio/
    68    :alt: Appveyor build status
    69 
    70 .. image:: https://landscape.io/github/aubio/aubio/master/landscape.svg?style=flat
    71    :target: https://landscape.io/github/aubio/aubio/master
    72    :alt: Landscape code health
    73 
    74 .. image:: https://readthedocs.org/projects/aubio/badge/?version=latest
    75    :target: http://aubio.readthedocs.io/en/latest/?badge=latest
    76    :alt: Documentation status
    77 
    78 .. image:: https://img.shields.io/github/commits-since/aubio/aubio/0.4.3.svg?maxAge=2592000
    79    :target: https://github.com/aubio/aubio
    80    :alt: Commits since last release
    81 
    82 * `Travis Continuous integration page <https://travis-ci.org/aubio/aubio>`_
    83 * `Appveyor Continuous integration page <https://ci.appveyor.com/project/piem/aubio>`_
    84 * `Landscape python code validation <https://landscape.io/github/aubio/aubio/master>`_
    85 * `ReadTheDocs documentation <http://aubio.readthedocs.io/en/latest/>`_
    86 
    87 Copyright and License
    88 =====================
    89 
    90 Copyright © 2003-2016 Paul Brossier <piem@aubio.org>
    91 
    92 aubio is a `free <http://www.debian.org/intro/free>`_ and `open source
    93 <http://www.opensource.org/docs/definition.php>`_ software; **you** can
    94 redistribute it and/or modify it under the terms of the `GNU
    95 <http://www.gnu.org/>`_ `General Public License
    96 <https://www.gnu.org/licenses/gpl.html>`_ as published by the `Free Software
    97 Foundation <https://fsf.org>`_, either version 3 of the License, or (at your
    98 option) any later version.
    99 
    100 .. Note:: aubio is not MIT or BSD licensed. Contact the author if you need it
    101   in your commercial product.
  • doc/installing.rst

    r71f2e5f r41b985f  
    1616
    1717   download
     18   building
    1819   requirements
    19    building
  • doc/python_module.rst

    r71f2e5f r41b985f  
    3030
    3131Once you have python-aubio installed, you should be able to run ``python -c
    32 "import aubio"``.
     32"import aubio; print(aubio.version)"``.
    3333
    3434A simple example
  • doc/requirements.rst

    r71f2e5f r41b985f  
    11.. _requirements:
    22
    3 Requirements
    4 ============
    5 
    6 While aubio can be built without any external dependencies, we **recommend** to
    7 use at least some of the following libraries.
    8 
    9 Platform notes
    10 --------------
    11 
    12 On all platforms, you will need to have installed:
    13 
    14  - a compiler (gcc, clang, msvc, ...)
    15  - python (any version >= 2.7, including 3.x)
    16  - a terminal to run command lines in
    17 
    18 Linux
    19 .....
    20 
    21 The following `External libraries`_ will be used if found: `libav`_,
    22 `libsamplerate`_, `libsndfile`_, `libfftw3`_.
    23 
    24 macOS
    25 .....
    26 
    27 The following system frameworks will be used on Mac OS X systems:
    28 
    29   - `Accelerate <https://developer.apple.com/reference/accelerate>`_ to compute
    30     FFTs and other vectorized operations optimally.
    31 
    32   - `CoreAudio <https://developer.apple.com/reference/coreaudio>`_ and
    33     `AudioToolbox <https://developer.apple.com/reference/audiotoolbox>`_ to
    34     decode audio from files and network streams.
    35 
    36 .. note::
    37 
    38   To build a fat binary for both ``i386`` and ``x86_64``, use ``./waf configure
    39   --enable-fat``.
    40 
    41 The following `External libraries`_ will also be checked: `libav`_,
    42 `libsamplerate`_, `libsndfile`_, `libfftw3`_.
    43 
    44 Windows
    45 .......
    46 
    47 To use a specific version of the compiler, ``--msvc_version``. To build for a
    48 specific architecture, use ``--msvc_target``. For instance, to build aubio
    49 for ``x86`` using ``msvc 12.0``, use:
    50 
    51 .. code:: bash
    52 
    53     waf configure --msvc_version='msvc 12.0' --msvc_target='x86'
    54 
    55 
    56 The following `External libraries`_ will be used if found: `libav`_,
    57 `libsamplerate`_, `libsndfile`_, `libfftw3`_.
    58 
    59 iOS
    60 ...
    61 
    62 The following system frameworks will be used on iOS and iOS Simulator.
    63 
    64   - `Accelerate <https://developer.apple.com/reference/accelerate>`_ to compute
    65     FFTs and other vectorized operations optimally.
    66 
    67   - `CoreAudio <https://developer.apple.com/reference/coreaudio>`_ and
    68     `AudioToolbox <https://developer.apple.com/reference/audiotoolbox>`_ to
    69     decode audio from files and network streams.
    70 
    71 To build aubio for iOS, configure with ``--with-target-platform=ios``. For the
    72 iOS Simulator, use ``--with-target-platform=iosimulator`` instead.
    73 
    74 By default, aubio is built with the following flags on iOS:
    75 
    76 .. code:: bash
    77 
    78     CFLAGS="-fembed-bitcode -arch arm64 -arch armv7 -arch armv7s -miphoneos-version-min=6.1"
    79 
    80 and on iOS Simulator:
    81 
    82 .. code::
    83 
    84     CFLAGS="-arch i386 -arch x86_64 -mios-simulator-version-min=6.1"
    85 
    86 Set ``CFLAGS`` and ``LINKFLAGS`` to change these default values, or edit
    87 ``wscript`` directly.
    88 
    893Build options
    90 -------------
    91 
    92 Some additional options can be passed to the configure step. For the complete
    93 list of options, run:
    94 
    95 .. code:: bash
    96 
    97     $ ./waf configure --help
    98 
    99 Double precision
    100 ................
    101 
    102 To compile aubio in double precision mode, configure with ``--enable-double``.
    103 
    104 To compile aubio in single precision mode, use ``--disable-double`` (default).
    105 
    106 Fat binary
    107 ..........
    108 
    109 To build a fat binary on Mac OS platforms, configure with ``--enable-fat``.
     4=============
     5
     6If built without any external dependencies aubio can be somewhat useful, for
     7instance to read, process, and write simple wav files.
     8
     9To support more media input formas add more features to aubio, you can use one
     10or all of the `following libraries <extlibs>`_.
     11
     12You may also want to know more about the `other options`_ and the `platform
     13notes`_
     14
     15The configure script will automatically for these extra libraries. To make sure
     16the library or feature is used, pass the `--enable-flag` to waf. To disable
     17this feature, use `--disable-feature`.
     18
     19To find out more about the build commands, use the `--verbose` option.
    11020
    11121External libraries
     
    18393configure with ``--disable-fftw3``
    18494
    185 External tools
     95Platform notes
    18696--------------
    18797
    188 If the following tools are found, additional documentations are built:
     98On all platforms, you will need to have installed:
     99
     100 - a compiler (gcc, clang, msvc, ...)
     101 - python (any version >= 2.7, including 3.x)
     102 - a terminal to run command lines in
     103
     104Linux
     105.....
     106
     107The following `External libraries`_ will be used if found: `libav`_,
     108`libsamplerate`_, `libsndfile`_, `libfftw3`_.
     109
     110macOS
     111.....
     112
     113The following system frameworks will be used on Mac OS X systems:
     114
     115  - `Accelerate <https://developer.apple.com/reference/accelerate>`_ to compute
     116    FFTs and other vectorized operations optimally.
     117
     118  - `CoreAudio <https://developer.apple.com/reference/coreaudio>`_ and
     119    `AudioToolbox <https://developer.apple.com/reference/audiotoolbox>`_ to
     120    decode audio from files and network streams.
     121
     122.. note::
     123
     124  To build a fat binary for both ``i386`` and ``x86_64``, use ``./waf configure
     125  --enable-fat``.
     126
     127The following `External libraries`_ will also be checked: `libav`_,
     128`libsamplerate`_, `libsndfile`_, `libfftw3`_.
     129
     130To build a fat binary on a darwin like system (macOS, tvOS, appleOS, ...)
     131platforms, configure with ``--enable-fat``.
     132
     133Windows
     134.......
     135
     136To use a specific version of the compiler, ``--msvc_version``. To build for a
     137specific architecture, use ``--msvc_target``. For instance, to build aubio
     138for ``x86`` using ``msvc 12.0``, use:
     139
     140.. code:: bash
     141
     142    waf configure --msvc_version='msvc 12.0' --msvc_target='x86'
     143
     144
     145The following `External libraries`_ will be used if found: `libav`_,
     146`libsamplerate`_, `libsndfile`_, `libfftw3`_.
     147
     148iOS
     149...
     150
     151The following system frameworks will be used on iOS and iOS Simulator.
     152
     153  - `Accelerate <https://developer.apple.com/reference/accelerate>`_ to compute
     154    FFTs and other vectorized operations optimally.
     155
     156  - `CoreAudio <https://developer.apple.com/reference/coreaudio>`_ and
     157    `AudioToolbox <https://developer.apple.com/reference/audiotoolbox>`_ to
     158    decode audio from files and network streams.
     159
     160To build aubio for iOS, configure with ``--with-target-platform=ios``. For the
     161iOS Simulator, use ``--with-target-platform=iosimulator`` instead.
     162
     163By default, aubio is built with the following flags on iOS:
     164
     165.. code:: bash
     166
     167    CFLAGS="-fembed-bitcode -arch arm64 -arch armv7 -arch armv7s -miphoneos-version-min=6.1"
     168
     169and on iOS Simulator:
     170
     171.. code::
     172
     173    CFLAGS="-arch i386 -arch x86_64 -mios-simulator-version-min=6.1"
     174
     175Set ``CFLAGS`` and ``LINKFLAGS`` to change these default values, or edit
     176``wscript`` directly.
     177
     178Other options
     179-------------
     180
     181Some additional options can be passed to the configure step. For the complete
     182list of options, run:
     183
     184.. code:: bash
     185
     186    $ ./waf --help
     187
     188Here is an example of a custom command:
     189
     190.. code:: bash
     191
     192    $ ./waf --verbose configure build install \
     193                --enable-avcodec --enable-wavread --disable-wavwrite \
     194                --enable-sndfile --enable-samplerate --enable-docs \
     195                --destdir $PWD/build/destdir --testcmd="echo %s" \
     196                --prefix=/opt --libdir=/opt/lib/multiarch \
     197                --manpagesdir=/opt/share/man  \
     198                uninstall clean distclean dist distcheck
     199
     200Double precision
     201................
     202
     203To compile aubio in double precision mode, configure with ``--enable-double``.
     204
     205To compile aubio in single precision mode, use ``--disable-double`` (default).
     206
     207Disabling the tests
     208...................
     209
     210In some case, for instance when cross-compiling, unit tests should not be run.
     211Option ``--notests`` can be used for this purpose. The tests will not be
     212executed, but the binaries will be compiled, ensuring that linking against
     213libaubio works as expected.
     214
     215.. note::
     216
     217  The ``--notests`` option should be passed to both ``build`` and ``install``
     218  targets, otherwise waf will try to run them.
     219
     220Edit wscript
     221............
     222
     223Many of the options are gathered in the file `wscript`. a good starting point
     224when looking for additional options.
     225
     226.. _build_docs:
     227
     228Building the docs
     229-----------------
     230
     231If the following command line tools are found, the documentation will be built
     232built:
    189233
    190234 - `doxygen <http://doxygen.org>`_ to build the :ref:`doxygen-documentation`.
    191235 - `txt2man <https://github.com/mvertes/txt2man>`_ to build the :ref:`manpages`
     236 - `sphinx <http://sphinx-doc.org>`_ to build this document
    192237
    193238These tools are searched for in the current ``PATH`` environment variable.
     
    196241To disable the documentation, configure with ``--disable-docs``. To build with
    197242the documentation, configure with ``--enable-docs``.
    198 
  • doc/web.cfg

    r71f2e5f r41b985f  
    3939# control system is used.
    4040
    41 PROJECT_NUMBER         = "0.4.2~alpha"
     41PROJECT_NUMBER         = "0.4.5~alpha"
    4242
    4343# Using the PROJECT_BRIEF tag one can provide an optional one line description
     
    791791EXCLUDE                = ../src/aubio_priv.h \
    792792                         ../src/mathutils.h \
     793                         ../src/io/ioutils.h \
    793794                         ../src/io/audio_unit.h \
    794795                         ../src/io/source_sndfile.h \
     
    14841485# This tag requires that the tag USE_MATHJAX is set to YES.
    14851486
    1486 MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
     1487MATHJAX_RELPATH        = https://cdn.mathjax.org/mathjax/latest
    14871488
    14881489# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
  • doc/xcode_frameworks.rst

    r71f2e5f r41b985f  
    3535    import aubio
    3636
     37Using aubio from swift
     38......................
     39
     40Here is a short example showing how to read a sound file in swift:
     41
     42
     43  .. code-block:: swift
     44
     45    import aubio
     46
     47    let path = Bundle.main.path(forResource: "example", ofType: "mp4")
     48    if (path != nil) {
     49        let hop_size : uint_t = 512
     50        let a = new_fvec(hop_size)
     51        let b = new_aubio_source(path, 0, hop_size)
     52        var read: uint_t = 0
     53        var total_frames : uint_t = 0
     54        while (true) {
     55            aubio_source_do(b, a, &read)
     56            total_frames += read
     57            if (read < hop_size) { break }
     58        }
     59        print("read", total_frames, "frames at", aubio_source_get_samplerate(b), "Hz")
     60        del_aubio_source(b)
     61        del_fvec(a)
     62    } else {
     63        print("could not find file")
     64    }
     65
     66
    3767.. _Binary frameworks: https://aubio.org/download
    3868.. _iOS: https://aubio.org/download#ios
  • examples/aubionotes.c

    r71f2e5f r41b985f  
    3535  // did we get a note off?
    3636  if (obuf->data[2] != 0) {
    37     lastmidi = aubio_freqtomidi (obuf->data[2]) + .5;
     37    lastmidi = obuf->data[2];
    3838    send_noteon(lastmidi, 0);
    3939  }
    4040  // did we get a note on?
    4141  if (obuf->data[0] != 0) {
    42     lastmidi = aubio_freqtomidi (obuf->data[0]) + .5;
     42    lastmidi = obuf->data[0];
    4343    send_noteon(lastmidi, obuf->data[1]);
    4444  }
     
    7070  if (notes == NULL) { ret = 1; goto beach; }
    7171
     72  if (onset_minioi != 0.) {
     73    aubio_notes_set_minioi_ms(notes, onset_minioi);
     74  }
     75  if (onset_threshold != 0.) {
     76    errmsg ("warning: onset threshold not supported yet\n");
     77    //aubio_onset_set_threshold(aubio_notes_get_aubio_onset(o), onset_threshold);
     78  }
     79  if (silence_threshold != -90.) {
     80    if (aubio_notes_set_silence (notes, silence_threshold) != 0) {
     81      errmsg ("failed setting notes silence threshold to %.2f\n",
     82          silence_threshold);
     83    }
     84  }
     85
    7286  examples_common_process((aubio_process_func_t)process_block, process_print);
    7387
    74   // send a last note off
    75   send_noteon (lastmidi, 0);
     88  // send a last note off if required
     89  if (lastmidi) {
     90    send_noteon (lastmidi, 0);
     91  }
    7692
    7793  del_aubio_notes (notes);
  • examples/aubioonset.c

    r71f2e5f r41b985f  
    7575  if (silence_threshold != -90.)
    7676    aubio_onset_set_silence (o, silence_threshold);
     77  if (onset_minioi != 0.)
     78    aubio_onset_set_minioi_s (o, onset_minioi);
    7779
    7880  onset = new_fvec (1);
     
    8587
    8688  // send a last note off
    87   send_noteon (miditap_note, 0);
     89  if (usejack) {
     90    send_noteon (miditap_note, 0);
     91  }
    8892
    8993  del_aubio_onset (o);
  • examples/aubiotrack.c

    r71f2e5f r41b985f  
    8181  // aubio_tempo_set_silence(tempo, -1000.);
    8282  if (onset_threshold != 0.) aubio_tempo_set_threshold (tempo, onset_threshold);
     83  if (onset_minioi != 0.) errmsg ("warning: minioio not supported yet\n");
    8384
    8485  wavetable = new_aubio_wavetable (samplerate, hop_size);
     
    8990
    9091  // send a last note off
    91   send_noteon (miditap_note, 0);
     92  if (usejack) {
     93    send_noteon (miditap_note, 0);
     94  }
    9295
    9396  del_aubio_tempo(tempo);
  • examples/parse_args.h

    r71f2e5f r41b985f  
    3737extern char_t * onset_method;
    3838extern smpl_t onset_threshold;
     39extern smpl_t onset_minioi;
    3940// pitch stuff
    4041extern char_t * pitch_method;
     
    9293      "       -t      --onset-threshold  set onset detection threshold\n"
    9394      "                 a value between 0.1 (more detections) and 1 (less); default=0.3\n"
     95      "       -M      --minioi           set minimum inter-onset interval\n"
     96      "                 a value in second; default=0.012\n"
    9497#endif /* PROG_HAS_ONSET */
    9598#ifdef PROG_HAS_PITCH
     
    115118#ifdef PROG_HAS_JACK
    116119      "       -j      --jack             use Jack\n"
     120#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
     121      "       -N      --miditap-note     MIDI note; default=69.\n"
     122      "       -V      --miditap-velo     MIDI velocity; default=65.\n"
     123#endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */
    117124#endif /* PROG_HAS_JACK */
    118125      "       -v      --verbose          be verbose\n"
     
    134141#ifdef PROG_HAS_JACK
    135142    "j"
     143#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
     144    "N:V:"
     145#endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */
    136146#endif /* PROG_HAS_JACK */
    137147#ifdef PROG_HAS_OUTPUT
     
    139149#endif /* PROG_HAS_OUTPUT */
    140150#ifdef PROG_HAS_ONSET
    141     "O:t:"
     151    "O:t:M:"
    142152#endif /* PROG_HAS_ONSET */
    143153#ifdef PROG_HAS_PITCH
     
    162172#ifdef PROG_HAS_JACK
    163173    {"jack",                  0, NULL, 'j'},
     174#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
     175    {"miditap-note",          1, NULL, 'N'},
     176    {"miditap-velo",          1, NULL, 'V'},
     177#endif /* PROG_HAS_ONSET !PROG_HAS_PITCH */
    164178#endif /* PROG_HAS_JACK */
    165179#ifdef PROG_HAS_OUTPUT
     
    169183    {"onset",                 1, NULL, 'O'},
    170184    {"onset-threshold",       1, NULL, 't'},
     185    {"onset-minioi",          1, NULL, 'M'},
    171186#endif /* PROG_HAS_ONSET */
    172187#ifdef PROG_HAS_PITCH
     
    204219        usejack = 1;
    205220        break;
     221      case 'N':
     222        miditap_note = (smpl_t) atoi (optarg);
     223        break;
     224      case 'V':
     225        miditap_velo = (smpl_t) atoi (optarg);
     226        break;
    206227      case 'i':
    207228        source_uri = optarg;
     
    227248      case 't':                /* threshold value for onset */
    228249        onset_threshold = (smpl_t) atof (optarg);
     250        break;
     251      case 'M':                /* minimum inter-onset-interval */
     252        onset_minioi = (smpl_t) atof (optarg);
    229253        break;
    230254      case 'p':
  • examples/utils.c

    r71f2e5f r41b985f  
    4444char_t * onset_method = "default";
    4545smpl_t onset_threshold = 0.0; // will be set if != 0.
     46smpl_t onset_minioi = 0.0; // will be set if != 0.
    4647// pitch stuff
    4748char_t * pitch_unit = "default";
     
    7677#if HAVE_JACK
    7778aubio_jack_t *jack_setup;
     79jack_midi_event_t ev;
    7880#endif /* HAVE_JACK */
    7981
     
    127129void examples_common_del (void)
    128130{
     131#ifdef HAVE_JACK
     132  if (ev.buffer) free(ev.buffer);
     133#endif
    129134  del_fvec (ibuf);
    130135  del_fvec (obuf);
     
    142147
    143148#ifdef HAVE_JACK
     149    ev.size = 3;
     150    ev.buffer = malloc (3 * sizeof (jack_midi_data_t));
     151    ev.time = 0; // send it now
    144152    debug ("Jack activation ...\n");
    145153    aubio_jack_activate (jack_setup, process_func);
     
    185193{
    186194#ifdef HAVE_JACK
    187   jack_midi_event_t ev;
    188   ev.size = 3;
    189   ev.buffer = malloc (3 * sizeof (jack_midi_data_t)); // FIXME
    190   ev.time = 0;
    191195  if (usejack) {
    192196    ev.buffer[2] = velo;
  • python/README.md

    r71f2e5f r41b985f  
    3636-------------------------
    3737
     38Python tests are in `python/tests` and use the [nose2 python package][nose2].
     39
    3840To run the all the python tests, use the script:
    3941
     
    4345
    4446    $ ./python/tests/test_note2midi.py -v
     47
     48[nose2]: https://github.com/nose-devs/nose2
    4549
    4650Install in a virtualenv
  • python/demos/demo_timestretch_online.py

    r71f2e5f r41b985f  
    1212import numpy as np
    1313
    14 win_s = 1024
     14win_s = 512
    1515hop_s = win_s // 8 # 87.5 % overlap
    1616
     
    9393    old_grain.phas = np.copy(cur_grain.phas)
    9494
     95    # until end of file
     96    if read < hop_s: break
     97    # increment block counter
    9598    block_read += 1
    96     if read < hop_s: break
    9799
    98100for t in range(warmup + 2): # purge the last frames from the phase vocoder
  • python/ext/aubio-types.h

    r71f2e5f r41b985f  
    2828#include "aubio.h"
    2929#else
    30 #include "aubio/aubio.h"
     30#include <aubio/aubio.h>
    3131#endif
    3232
     
    4545#define AUBIO_NPY_SMPL_STR "float32"
    4646#define AUBIO_NPY_SMPL_CHR "f"
     47#endif
     48
     49#ifndef PATH_MAX
     50#ifdef MAX_PATH
     51#define PATH_MAX MAX_PATH
     52#else
     53#define PATH_MAX 1024
     54#endif
    4755#endif
    4856
  • python/ext/aubiomodule.c

    r71f2e5f r41b985f  
    22#include "aubio-types.h"
    33#include "py-musicutils.h"
     4
     5// this dummy macro is used to convince windows that a string passed as -D flag
     6// is just that, a string, and not a double.
     7#define REDEFINESTRING(x) #x
     8#define DEFINEDSTRING(x) REDEFINESTRING(x)
    49
    510static char aubio_module_doc[] = "Python module for the aubio library";
     
    324329
    325330  PyModule_AddStringConstant(m, "float_type", AUBIO_NPY_SMPL_STR);
     331  PyModule_AddStringConstant(m, "__version__", DEFINEDSTRING(AUBIO_VERSION));
    326332
    327333  // add generated objects
  • python/ext/py-cvec.c

    r71f2e5f r41b985f  
    148148  if (length != vec->length) {
    149149    PyErr_Format (PyExc_ValueError,
    150         "input array has length %ld, but cvec has length %d", length,
     150        "input array has length %" NPY_INTP_FMT ", but cvec has length %d", length,
    151151        vec->length);
    152152    return 1;
     
    169169  if (length != vec->length) {
    170170    PyErr_Format (PyExc_ValueError,
    171         "input array has length %ld, but cvec has length %d", length,
     171        "input array has length %" NPY_INTP_FMT ", but cvec has length %d", length,
    172172        vec->length);
    173173    return 1;
  • python/ext/py-sink.c

    r71f2e5f r41b985f  
    8181  }
    8282
    83   self->uri = "none";
     83  self->uri = NULL;
    8484  if (uri != NULL) {
    85     self->uri = uri;
     85    self->uri = (char_t *)malloc(sizeof(char_t) * (strnlen(uri, PATH_MAX) + 1));
     86    strncpy(self->uri, uri, strnlen(uri, PATH_MAX) + 1);
    8687  }
    8788
    8889  self->samplerate = Py_aubio_default_samplerate;
    89   if ((sint_t)samplerate > 0) {
     90  if (samplerate != 0) {
    9091    self->samplerate = samplerate;
    91   } else if ((sint_t)samplerate < 0) {
    92     PyErr_SetString (PyExc_ValueError,
    93         "can not use negative value for samplerate");
    94     return NULL;
    9592  }
    9693
    9794  self->channels = 1;
    98   if ((sint_t)channels > 0) {
     95  if (channels != 0) {
    9996    self->channels = channels;
    100   } else if ((sint_t)channels < 0) {
    101     PyErr_SetString (PyExc_ValueError,
    102         "can not use negative or null value for channels");
    103     return NULL;
    10497  }
    10598
     
    110103Py_sink_init (Py_sink * self, PyObject * args, PyObject * kwds)
    111104{
    112   if (self->channels == 1) {
    113     self->o = new_aubio_sink ( self->uri, self->samplerate );
    114   } else {
    115     self->o = new_aubio_sink ( self->uri, 0 );
    116     aubio_sink_preset_channels ( self->o, self->channels );
    117     aubio_sink_preset_samplerate ( self->o, self->samplerate );
    118   }
     105  self->o = new_aubio_sink ( self->uri, 0 );
    119106  if (self->o == NULL) {
    120     PyErr_SetString (PyExc_RuntimeError, "error creating sink with this uri");
     107    // error string was set in new_aubio_sink
    121108    return -1;
    122109  }
     110  if (aubio_sink_preset_channels(self->o, self->channels) != 0) {
     111    // error string was set in aubio_sink_preset_channels
     112    return -1;
     113  }
     114  if (aubio_sink_preset_samplerate(self->o, self->samplerate) != 0) {
     115    // error string was set in aubio_sink_preset_samplerate
     116    return -1;
     117  }
     118
    123119  self->samplerate = aubio_sink_get_samplerate ( self->o );
    124120  self->channels = aubio_sink_get_channels ( self->o );
     
    132128  del_aubio_sink(self->o);
    133129  free(self->mwrite_data.data);
     130  if (self->uri) {
     131    free(self->uri);
     132  }
    134133  Py_TYPE(self)->tp_free((PyObject *) self);
    135134}
     
    205204}
    206205
     206static char Pyaubio_sink_enter_doc[] = "";
     207static PyObject* Pyaubio_sink_enter(Py_sink *self, PyObject *unused) {
     208  Py_INCREF(self);
     209  return (PyObject*)self;
     210}
     211
     212static char Pyaubio_sink_exit_doc[] = "";
     213static PyObject* Pyaubio_sink_exit(Py_sink *self, PyObject *unused) {
     214  return Pyaubio_sink_close(self, unused);
     215}
     216
    207217static PyMethodDef Py_sink_methods[] = {
    208218  {"do", (PyCFunction) Py_sink_do, METH_VARARGS, Py_sink_do_doc},
    209219  {"do_multi", (PyCFunction) Py_sink_do_multi, METH_VARARGS, Py_sink_do_multi_doc},
    210220  {"close", (PyCFunction) Pyaubio_sink_close, METH_NOARGS, Py_sink_close_doc},
     221  {"__enter__", (PyCFunction)Pyaubio_sink_enter, METH_NOARGS,
     222    Pyaubio_sink_enter_doc},
     223  {"__exit__",  (PyCFunction)Pyaubio_sink_exit, METH_VARARGS,
     224    Pyaubio_sink_exit_doc},
    211225  {NULL} /* sentinel */
    212226};
  • python/ext/py-source.c

    r71f2e5f r41b985f  
    101101  }
    102102
    103   self->uri = "none";
     103  self->uri = NULL;
    104104  if (uri != NULL) {
    105     self->uri = uri;
     105    self->uri = (char_t *)malloc(sizeof(char_t) * (strnlen(uri, PATH_MAX) + 1));
     106    strncpy(self->uri, uri, strnlen(uri, PATH_MAX) + 1);
    106107  }
    107108
     
    163164    del_aubio_source(self->o);
    164165    free(self->c_mread_to.data);
     166  }
     167  if (self->uri) {
     168    free(self->uri);
    165169  }
    166170  Py_XDECREF(self->read_to);
     
    243247Pyaubio_source_close (Py_source *self, PyObject *unused)
    244248{
    245   aubio_source_close (self->o);
     249  if (aubio_source_close(self->o) != 0) return NULL;
    246250  Py_RETURN_NONE;
    247251}
     
    271275  }
    272276  Py_RETURN_NONE;
     277}
     278
     279static char Pyaubio_source_enter_doc[] = "";
     280static PyObject* Pyaubio_source_enter(Py_source *self, PyObject *unused) {
     281  Py_INCREF(self);
     282  return (PyObject*)self;
     283}
     284
     285static char Pyaubio_source_exit_doc[] = "";
     286static PyObject* Pyaubio_source_exit(Py_source *self, PyObject *unused) {
     287  return Pyaubio_source_close(self, unused);
     288}
     289
     290static PyObject* Pyaubio_source_iter(PyObject *self) {
     291  Py_INCREF(self);
     292  return (PyObject*)self;
     293}
     294
     295static PyObject* Pyaubio_source_iter_next(Py_source *self) {
     296  PyObject *done, *size;
     297  if (self->channels == 1) {
     298    done = Py_source_do(self, NULL);
     299  } else {
     300    done = Py_source_do_multi(self, NULL);
     301  }
     302  if (!PyTuple_Check(done)) {
     303    PyErr_Format(PyExc_ValueError,
     304        "error when reading source: not opened?");
     305    return NULL;
     306  }
     307  size = PyTuple_GetItem(done, 1);
     308  if (size != NULL && PyLong_Check(size)) {
     309    if (PyLong_AsLong(size) == (long)self->hop_size) {
     310      PyObject *vec = PyTuple_GetItem(done, 0);
     311      return vec;
     312    } else if (PyLong_AsLong(size) > 0) {
     313      // short read, return a shorter array
     314      PyArrayObject *shortread = (PyArrayObject*)PyTuple_GetItem(done, 0);
     315      PyArray_Dims newdims;
     316      PyObject *reshaped;
     317      newdims.len = PyArray_NDIM(shortread);
     318      newdims.ptr = PyArray_DIMS(shortread);
     319      // mono or multiple channels?
     320      if (newdims.len == 1) {
     321        newdims.ptr[0] = PyLong_AsLong(size);
     322      } else {
     323        newdims.ptr[1] = PyLong_AsLong(size);
     324      }
     325      reshaped = PyArray_Newshape(shortread, &newdims, NPY_CORDER);
     326      Py_DECREF(shortread);
     327      return reshaped;
     328    } else {
     329      PyErr_SetNone(PyExc_StopIteration);
     330      return NULL;
     331    }
     332  } else {
     333    PyErr_SetNone(PyExc_StopIteration);
     334    return NULL;
     335  }
    273336}
    274337
     
    286349  {"seek", (PyCFunction) Pyaubio_source_seek,
    287350    METH_VARARGS, Py_source_seek_doc},
     351  {"__enter__", (PyCFunction)Pyaubio_source_enter, METH_NOARGS,
     352    Pyaubio_source_enter_doc},
     353  {"__exit__",  (PyCFunction)Pyaubio_source_exit, METH_VARARGS,
     354    Pyaubio_source_exit_doc},
    288355  {NULL} /* sentinel */
    289356};
     
    315382  0,
    316383  0,
    317   0,
    318   0,
     384  Pyaubio_source_iter,
     385  (unaryfunc)Pyaubio_source_iter_next,
    319386  Py_source_methods,
    320387  Py_source_members,
  • python/lib/aubio/__init__.py

    r71f2e5f r41b985f  
    22
    33import numpy
     4from ._aubio import __version__ as version
     5from ._aubio import float_type
    46from ._aubio import *
    5 from ._aubio import float_type
    67from .midiconv import *
    78from .slicing import *
  • python/lib/aubio/midiconv.py

    r71f2e5f r41b985f  
    1616    " convert note name to midi note number, e.g. [C-1, G9] -> [0, 127] "
    1717    _valid_notenames = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
    18     _valid_modifiers = {None: 0, u'♮': 0, '#': +1, u'♯': +1, u'\udd2a': +2,
    19                         'b': -1, u'♭': -1, u'\ufffd': -2}
     18    _valid_modifiers = {
     19            u'𝄫': -2,                        # double flat
     20            u'♭': -1, 'b': -1, '\u266d': -1, # simple flat
     21            u'♮': 0, '\u266e': 0, None: 0,   # natural
     22            '#': +1, u'♯': +1, '\u266f': +1, # sharp
     23            u'𝄪': +2,                        # double sharp
     24            }
    2025    _valid_octaves = range(-1, 10)
    2126    if not isinstance(note, str_instances):
  • python/lib/gen_external.py

    r71f2e5f r41b985f  
    1515  'filter',
    1616  'filterbank',
    17   #'resampler',
    1817  # AUBIO_UNSTABLE
    1918  'hist',
     
    7978    return cpp_cmd
    8079
    81 def get_cpp_objects(header=header):
     80def get_cpp_objects(header=header, usedouble=False):
    8281    cpp_cmd = get_preprocessor()
    8382
    8483    macros = [('AUBIO_UNSTABLE', 1)]
     84    if usedouble:
     85        macros += [('HAVE_AUBIO_DOUBLE', 1)]
    8586
    8687    if not os.path.isfile(header):
     
    180181    elif not overwrite: return sorted(glob.glob(os.path.join(output_path, '*.c')))
    181182
    182     cpp_output, cpp_objects = get_cpp_objects(header)
     183    cpp_output, cpp_objects = get_cpp_objects(header, usedouble=usedouble)
    183184
    184185    lib = analyze_cpp_output(cpp_objects, cpp_output)
     
    251252        # no need to add header to list of sources
    252253
    253     return sources_list
     254    return sorted(sources_list)
    254255
    255256if __name__ == '__main__':
  • python/lib/moresetuptools.py

    r71f2e5f r41b985f  
    44import distutils, distutils.command.clean, distutils.dir_util
    55from .gen_external import generate_external, header, output_path
     6
     7def get_aubio_version():
     8    # read from VERSION
     9    this_file_dir = os.path.dirname(os.path.abspath(__file__))
     10    version_file = os.path.join(this_file_dir, '..', '..', 'VERSION')
     11
     12    if not os.path.isfile(version_file):
     13        raise SystemError("VERSION file not found.")
     14
     15    for l in open(version_file).readlines():
     16        #exec (l.strip())
     17        if l.startswith('AUBIO_MAJOR_VERSION'):
     18            AUBIO_MAJOR_VERSION = int(l.split('=')[1])
     19        if l.startswith('AUBIO_MINOR_VERSION'):
     20            AUBIO_MINOR_VERSION = int(l.split('=')[1])
     21        if l.startswith('AUBIO_PATCH_VERSION'):
     22            AUBIO_PATCH_VERSION = int(l.split('=')[1])
     23        if l.startswith('AUBIO_VERSION_STATUS'):
     24            AUBIO_VERSION_STATUS = l.split('=')[1].strip()[1:-1]
     25
     26    if AUBIO_MAJOR_VERSION is None or AUBIO_MINOR_VERSION is None \
     27            or AUBIO_PATCH_VERSION is None:
     28        raise SystemError("Failed parsing VERSION file.")
     29
     30    verstr = '.'.join(map(str, [AUBIO_MAJOR_VERSION,
     31                                     AUBIO_MINOR_VERSION,
     32                                     AUBIO_PATCH_VERSION]))
     33
     34    if AUBIO_VERSION_STATUS is not None:
     35        verstr += AUBIO_VERSION_STATUS
     36    return verstr
     37
     38def get_aubio_pyversion():
     39    # convert to version for python according to pep 440
     40    # see https://www.python.org/dev/peps/pep-0440/
     41    verstr = get_aubio_version()
     42    if '~alpha' in verstr:
     43        verstr = verstr.split('~')[0] + 'a1'
     44    # TODO: add rc, .dev, and .post suffixes, add numbering
     45    return verstr
    646
    747# inspired from https://gist.github.com/abergmeier/9488990
     
    2262
    2363    for package in packages:
     64        print("checking for {:s}".format(package))
    2465        cmd = ['pkg-config', '--libs', '--cflags', package]
    2566        try:
     
    5394    ext.libraries += ['aubio']
    5495
    55 def add_local_aubio_sources(ext):
     96def add_local_aubio_sources(ext, usedouble = False):
    5697    """ build aubio inside python module instead of linking against libaubio """
    57     print("Warning: libaubio was not built with waf, adding src/")
    58     # create an empty header, macros will be passed on the command line
    59     fake_config_header = os.path.join('python', 'ext', 'config.h')
    60     distutils.file_util.write_file(fake_config_header, "")
     98    print("Info: libaubio was not installed or built locally with waf, adding src/")
    6199    aubio_sources = sorted(glob.glob(os.path.join('src', '**.c')))
    62100    aubio_sources += sorted(glob.glob(os.path.join('src', '*', '**.c')))
    63101    ext.sources += aubio_sources
     102
     103def add_local_macros(ext, usedouble = False):
    64104    # define macros (waf puts them in build/src/config.h)
    65105    for define_macro in ['HAVE_STDLIB_H', 'HAVE_STDIO_H',
     
    70110        ext.define_macros += [(define_macro, 1)]
    71111
     112def add_external_deps(ext, usedouble = False):
    72113    # loof for additional packages
    73114    print("Info: looking for *optional* additional packages")
    74115    packages = ['libavcodec', 'libavformat', 'libavutil', 'libavresample',
    75116                'jack',
    76                 'sndfile', 'samplerate',
     117                'sndfile',
     118                'samplerate',
    77119                'rubberband',
    78120                #'fftw3f',
    79121               ]
     122    # samplerate only works with float
     123    if usedouble is False:
     124        packages += ['samplerate']
     125    else:
     126        print("Info: not adding libsamplerate in double precision mode")
    80127    add_packages(packages, ext=ext)
    81128    if 'avcodec' in ext.libraries \
     
    116163def add_system_aubio(ext):
    117164    # use pkg-config to find aubio's location
    118     add_packages(['aubio'], ext)
     165    aubio_version = get_aubio_version()
     166    add_packages(['aubio = ' + aubio_version], ext)
    119167    if 'aubio' not in ext.libraries:
    120         print("Error: libaubio not found")
     168        print("Info: aubio " + aubio_version + " was not found by pkg-config")
     169    else:
     170        print("Info: using system aubio " + aubio_version + " found in " + ' '.join(ext.library_dirs))
    121171
    122172class CleanGenerated(distutils.command.clean.clean):
    123173    def run(self):
    124         distutils.dir_util.remove_tree(output_path)
    125         distutils.command.clean.clean.run(self)
     174        if os.path.isdir(output_path):
     175            distutils.dir_util.remove_tree(output_path)
    126176
    127177from distutils.command.build_ext import build_ext as _build_ext
     
    145195
    146196    def build_extension(self, extension):
    147         if self.enable_double:
     197        if self.enable_double or 'HAVE_AUBIO_DOUBLE' in os.environ:
    148198            extension.define_macros += [('HAVE_AUBIO_DOUBLE', 1)]
    149         if os.path.isfile('src/aubio.h'):
    150             # if aubio headers are found in this directory
    151             add_local_aubio_header(extension)
    152             # was waf used to build the shared lib?
    153             if os.path.isdir(os.path.join('build','src')):
    154                 # link against build/src/libaubio, built with waf
     199            enable_double = True
     200        else:
     201            enable_double = False
     202        # seack for aubio headers and lib in PKG_CONFIG_PATH
     203        add_system_aubio(extension)
     204        # the lib was not installed on this system
     205        if 'aubio' not in extension.libraries:
     206            # use local src/aubio.h
     207            if os.path.isfile(os.path.join('src', 'aubio.h')):
     208                add_local_aubio_header(extension)
     209            add_local_macros(extension)
     210            # look for a local waf build
     211            if os.path.isfile(os.path.join('build','src', 'fvec.c.1.o')):
    155212                add_local_aubio_lib(extension)
    156213            else:
     214                # check for external dependencies
     215                add_external_deps(extension, usedouble=enable_double)
    157216                # add libaubio sources and look for optional deps with pkg-config
    158                 add_local_aubio_sources(extension, usedouble=self.enable_double)
    159         else:
    160             # look for aubio headers and lib using pkg-config
    161             add_system_aubio(extension)
     217                add_local_aubio_sources(extension, usedouble=enable_double)
    162218        # generate files python/gen/*.c, python/gen/aubio-generated.h
    163219        extension.sources += generate_external(header, output_path, overwrite = False,
    164                 usedouble=self.enable_double)
     220                usedouble=enable_double)
    165221        return _build_ext.build_extension(self, extension)
  • python/scripts/aubiocut

    r71f2e5f r41b985f  
    66
    77import sys
    8 #from aubio.task import *
    98
    109usage = "usage: %s [options] -i soundfile" % sys.argv[0]
     
    118117            action = "store", dest = "cut_until_nsamples", default = None,
    119118            help="how many extra samples should be added at the end of each slice")
     119    parser.add_option("--cut-every-nslices", type = int,
     120            metavar = "<samples>",
     121            action = "store", dest = "cut_every_nslices", default = None,
     122            help="how many slices should be groupped together at each cut")
    120123    parser.add_option("--cut-until-nslices", type = int,
    121124            metavar = "<slices>",
     
    188191        from aubio.slicing import slice_source_at_stamps
    189192        timestamps_end = None
     193        if options.cut_every_nslices:
     194            timestamps = timestamps[::options.cut_every_nslices]
     195            nstamps = len(timestamps)
    190196        if options.cut_until_nslices and options.cut_until_nsamples:
    191197            print ("warning: using cut_until_nslices, but cut_until_nsamples is set")
  • python/tests/eval_pitch

    r71f2e5f r41b985f  
    2525import os.path
    2626import numpy
    27 from utils import array_from_text_file, array_from_yaml_file
     27from .utils import array_from_text_file, array_from_yaml_file
    2828from aubio import source, pitch, freqtomidi
    2929
  • python/tests/test_aubio.py

    r71f2e5f r41b985f  
    1010        import aubio
    1111
     12    def test_version(self):
     13        """ test aubio.version """
     14        import aubio
     15        self.assertEqual('0', aubio.version[0])
     16
    1217if __name__ == '__main__':
    1318    main()
  • python/tests/test_fft.py

    r71f2e5f r41b985f  
    3434        fftgrain = f (timegrain)
    3535        assert_equal ( fftgrain.norm, 0 )
    36         assert_equal ( fftgrain.phas, 0 )
     36        try:
     37            assert_equal ( fftgrain.phas, 0 )
     38        except AssertionError:
     39            assert_equal (fftgrain.phas[fftgrain.phas > 0], +pi)
     40            assert_equal (fftgrain.phas[fftgrain.phas < 0], -pi)
     41            assert_equal (np.abs(fftgrain.phas[np.abs(fftgrain.phas) != pi]), 0)
     42            self.skipTest('fft(fvec(%d)).phas != +0, ' % win_s \
     43                    + 'This is expected when using fftw3 on powerpc.')
    3744
    3845    def test_impulse(self):
  • python/tests/test_filter.py

    r71f2e5f r41b985f  
    44from numpy.testing import TestCase, assert_equal, assert_almost_equal
    55from aubio import fvec, digital_filter
    6 from utils import array_from_text_file
     6from .utils import array_from_text_file
    77
    88class aubio_filter_test_case(TestCase):
  • python/tests/test_filterbank.py

    r71f2e5f r41b985f  
    66import numpy as np
    77from aubio import cvec, filterbank, float_type
    8 from utils import array_from_text_file
     8from .utils import array_from_text_file
    99
    1010class aubio_filterbank_test_case(TestCase):
  • python/tests/test_midi2note.py

    r71f2e5f r41b985f  
    33
    44from aubio import midi2note
     5from nose2.tools import params
    56import unittest
    67
     
    1718class midi2note_good_values(unittest.TestCase):
    1819
    19     def test_midi2note_known_values(self):
     20    @params(*list_of_known_midis)
     21    def test_midi2note_known_values(self, midi, note):
    2022        " known values are correctly converted "
    21         for midi, note in list_of_known_midis:
    22             self.assertEqual ( midi2note(midi), note )
     23        self.assertEqual ( midi2note(midi), note )
    2324
    2425class midi2note_wrong_values(unittest.TestCase):
     
    4142
    4243if __name__ == '__main__':
    43     unittest.main()
     44    import nose2
     45    nose2.main()
  • python/tests/test_note2midi.py

    r71f2e5f r41b985f  
    55
    66from aubio import note2midi, freq2note
     7from nose2.tools import params
    78import unittest
    89
     
    1415        ( 'B3', 59 ),
    1516        ( 'B#3', 60 ),
     17        ( 'C♯4', 61 ),
    1618        ( 'A4', 69 ),
    1719        ( 'A#4', 70 ),
     20        ( 'A♯4', 70 ),
     21        ( 'A\u266f4', 70 ),
    1822        ( 'Bb4', 70 ),
    1923        ( 'B♭4', 70 ),
     24        ( 'B\u266d4', 70 ),
    2025        ( 'G8', 115 ),
    2126        ( 'G♯8', 116 ),
    2227        ( 'G9', 127 ),
    23         ( 'G\udd2a2', 45 ),
    24         ( 'B\ufffd2', 45 ),
    2528        ( 'A♮2', 45 ),
     29        )
     30
     31list_of_known_notes_with_unicode_issues = (
     32        ('C𝄪4', 62 ),
     33        ('E𝄫4', 62 ),
     34        )
     35
     36list_of_unknown_notes = (
     37        ( 'G\udd2a2' ),
     38        ( 'B\ufffd2' ),
     39        ( 'B\u266e\u266e2' ),
     40        ( 'B\u266f\u266d3' ),
     41        ( 'B33' ),
     42        ( 'C.3' ),
     43        ( 'A' ),
     44        ( '2' ),
    2645        )
    2746
    2847class note2midi_good_values(unittest.TestCase):
    2948
    30     def test_note2midi_known_values(self):
     49    @params(*list_of_known_notes)
     50    def test_note2midi_known_values(self, note, midi):
    3151        " known values are correctly converted "
    32         for note, midi in list_of_known_notes:
     52        self.assertEqual ( note2midi(note), midi )
     53
     54    @params(*list_of_known_notes_with_unicode_issues)
     55    def test_note2midi_known_values_with_unicode_issues(self, note, midi):
     56        " known values are correctly converted, unless decoding is expected to fail"
     57        try:
    3358            self.assertEqual ( note2midi(note), midi )
     59        except UnicodeEncodeError as e:
     60            import sys
     61            strfmt = "len(u'\\U0001D12A') != 1, excpected decoding failure | {:s} | {:s} {:s}"
     62            strres = strfmt.format(e, sys.platform, sys.version)
     63            # happens with: darwin 2.7.10, windows 2.7.12
     64            if len('\U0001D12A') != 1 and sys.version[0] == '2':
     65                self.skipTest(strres + " | upgrade to Python 3 to fix")
     66            else:
     67                raise
    3468
    3569class note2midi_wrong_values(unittest.TestCase):
     
    67101        self.assertRaises(TypeError, note2midi, 123)
    68102
     103    def test_note2midi_wrong_data_too_long(self):
     104        " fails when passed a note with a note name longer than expected"
     105        self.assertRaises(ValueError, note2midi, 'CB+-3')
     106
     107    @params(*list_of_unknown_notes)
     108    def test_note2midi_unknown_values(self, note):
     109        " unknown values throw out an error "
     110        self.assertRaises(ValueError, note2midi, note)
    69111
    70112class freq2note_simple_test(unittest.TestCase):
     
    75117
    76118if __name__ == '__main__':
    77     unittest.main()
     119    import nose2
     120    nose2.main()
  • python/tests/test_phasevoc.py

    r71f2e5f r41b985f  
    4747            assert_equal ( t, 0.)
    4848            assert_equal ( s.norm, 0.)
    49             assert_equal ( s.phas, 0.)
     49            try:
     50                assert_equal ( s.phas, 0 )
     51            except AssertionError:
     52                assert_equal (s.phas[s.phas > 0], +np.pi)
     53                assert_equal (s.phas[s.phas < 0], -np.pi)
     54                assert_equal (np.abs(s.phas[np.abs(s.phas) != np.pi]), 0)
     55                self.skipTest('pvoc(fvec(%d)).phas != +0, ' % win_s \
     56                        + 'This is expected when using fftw3 on powerpc.')
    5057            assert_equal ( r, 0.)
    5158
  • python/tests/test_sink.py

    r71f2e5f r41b985f  
    55from numpy.testing import TestCase
    66from aubio import fvec, source, sink
    7 from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
     7from .utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
     8
     9import warnings
     10warnings.filterwarnings('ignore', category=UserWarning, append=True)
    811
    912list_of_sounds = list_all_sounds('sounds')
     
    2629        if not len(list_of_sounds):
    2730            self.skipTest('add some sound files in \'python/tests/sounds\'')
     31
     32    def test_wrong_filename(self):
     33        with self.assertRaises(RuntimeError):
     34            sink('')
     35
     36    def test_wrong_samplerate(self):
     37        with self.assertRaises(RuntimeError):
     38            sink(get_tmp_sink_path(), -1)
     39
     40    def test_wrong_samplerate_too_large(self):
     41        with self.assertRaises(RuntimeError):
     42            sink(get_tmp_sink_path(), 1536001, 2)
     43
     44    def test_wrong_channels(self):
     45        with self.assertRaises(RuntimeError):
     46            sink(get_tmp_sink_path(), 44100, -1)
     47
     48    def test_wrong_channels_too_large(self):
     49        with self.assertRaises(RuntimeError):
     50            sink(get_tmp_sink_path(), 44100, 202020)
    2851
    2952    def test_many_sinks(self):
     
    94117        del_tmp_sink_path(sink_path)
    95118
     119    def test_read_with(self):
     120        sink_path =get_tmp_sink_path()
     121        vec = fvec(128)
     122        with sink(sink_path, samplerate) as g:
     123            for i in range(10):
     124                g(vec, 128)
     125
    96126if __name__ == '__main__':
    97127    main()
  • python/tests/test_slicing.py

    r71f2e5f r41b985f  
    44from numpy.testing import TestCase, assert_equal
    55from aubio import slice_source_at_stamps
    6 from utils import count_files_in_directory, get_default_test_sound
    7 from utils import count_samples_in_directory, count_samples_in_file
     6from .utils import count_files_in_directory, get_default_test_sound
     7from .utils import count_samples_in_directory, count_samples_in_file
    88
    99import tempfile
  • python/tests/test_source.py

    r71f2e5f r41b985f  
    55from numpy.testing import TestCase, assert_equal
    66from aubio import source
    7 from utils import list_all_sounds
     7from .utils import list_all_sounds
    88import numpy as np
    99
     
    5757            if read < f.hop_size:
    5858                assert_equal(samples[read:], 0)
    59                 if 'brownnoise' in f.uri:
    60                     self.assertEquals(np.count_nonzero(samples[:read]), read)
    6159                break
    6260        #result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"
     
    7270            self.skipTest('failed opening with hop_s = {:d}, samplerate = {:d} ({:s})'.format(hop_size, samplerate, str(e)))
    7371        assert f.samplerate != 0
    74         self.read_from_source(f)
     72        read_frames = self.read_from_source(f)
     73        if 'f_' in soundfile and samplerate == 0:
     74            import re
     75            f = re.compile('.*_\([0:9]*f\)_.*')
     76            match_f = re.findall('([0-9]*)f_', soundfile)
     77            if len(match_f) == 1:
     78                expected_frames = int(match_f[0])
     79                self.assertEqual(expected_frames, read_frames)
    7580
    7681    @params(*list_of_sounds)
     
    159164            if read < f.hop_size:
    160165                assert_equal(samples[:,read:], 0)
    161                 if 'brownnoise' in f.uri:
    162                     self.assertEquals(np.count_nonzero(samples[:,:read]), read)
    163166                break
    164167        #result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"
     
    167170        return total_frames
    168171
     172class aubio_source_with(aubio_source_test_case_base):
     173
     174    #@params(*list_of_sounds)
     175    @params(*list_of_sounds)
     176    def test_read_from_mono(self, filename):
     177        total_frames = 0
     178        hop_size = 2048
     179        with source(filename, 0, hop_size) as input_source:
     180            assert_equal(input_source.hop_size, hop_size)
     181            #assert_equal(input_source.samplerate, samplerate)
     182            total_frames = 0
     183            for frames in input_source:
     184                total_frames += frames.shape[-1]
     185            # check we read as many samples as we expected
     186            assert_equal(total_frames, input_source.duration)
     187
    169188if __name__ == '__main__':
    170189    main()
  • scripts/build_apple_frameworks

    r71f2e5f r41b985f  
    11#! /bin/sh
     2
     3# cd to aubio directory for consistency
     4cd `dirname $0`/..
    25
    36AUBIO_TMPDIR=`mktemp -d /var/tmp/aubio-build-XXXX`
  • scripts/setenv_local.sh

    r71f2e5f r41b985f  
    99# PYTHONPATH variables.
    1010
    11 PYTHON_PLATFORM=`python -c "import pkg_resources, sys; print '%s-%s' % (pkg_resources.get_build_platform(), '.'.join(map(str, sys.version_info[0:2])))"`
     11PYTHON_PLATFORM=`python -c "import pkg_resources, sys; print ('%s-%s' % (pkg_resources.get_build_platform(), '.'.join(map(str, sys.version_info[0:2]))))"`
    1212
    1313AUBIODIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
  • setup.py

    r71f2e5f r41b985f  
    77from python.lib.gen_external import generate_external, header, output_path
    88
    9 # read from VERSION
    10 for l in open('VERSION').readlines(): exec (l.strip())
    11 
    12 if AUBIO_MAJOR_VERSION is None or AUBIO_MINOR_VERSION is None \
    13         or AUBIO_PATCH_VERSION is None:
    14     raise SystemError("Failed parsing VERSION file.")
    15 
    16 __version__ = '.'.join(map(str, [AUBIO_MAJOR_VERSION,
    17                                  AUBIO_MINOR_VERSION,
    18                                  AUBIO_PATCH_VERSION]))
    19 if AUBIO_VERSION_STATUS is not None:
    20     if AUBIO_VERSION_STATUS.startswith('~'):
    21         AUBIO_VERSION_STATUS = AUBIO_VERSION_STATUS[1:]
    22     __version__ += AUBIO_VERSION_STATUS
     9__version__ = get_aubio_pyversion()
    2310
    2411include_dirs = []
    2512library_dirs = []
    26 define_macros = []
     13define_macros = [('AUBIO_VERSION', '%s' % __version__)]
    2714extra_link_args = []
    2815
     
    4936if os.path.isfile('src/aubio.h'):
    5037    if not os.path.isdir(os.path.join('build','src')):
    51         __version__ += 'a2' # python only version
     38        pass
     39        #__version__ += 'a2' # python only version
    5240
    5341classifiers = [
     
    7967    maintainer = 'Paul Brossier',
    8068    maintainer_email = 'piem@aubio.org',
    81     url = 'http://aubio.org/',
     69    url = 'https://aubio.org/',
    8270    platforms = 'any',
    8371    classifiers = classifiers,
    8472    install_requires = ['numpy'],
     73    setup_requires = ['numpy'],
    8574    cmdclass = {
    8675        'clean': CleanGenerated,
     
    8877        },
    8978    test_suite = 'nose2.collector.collector',
     79    extras_require = {
     80        'tests': ['numpy'],
     81        },
    9082    )
  • src/aubio.h

    r71f2e5f r41b985f  
    110110
    111111  Several examples of C programs are available in the \p examples/ and \p tests/src
    112   directories of the source tree. See more examples:
    113   @ref spectral/test-fft.c
    114   @ref spectral/test-phasevoc.c
    115   @ref onset/test-onset.c
    116   @ref pitch/test-pitch.c
    117   @ref tempo/test-tempo.c
    118   @ref test-fvec.c
    119   @ref test-cvec.c
     112  directories of the source tree.
     113
     114  Some examples:
     115  - @ref spectral/test-fft.c
     116  - @ref spectral/test-phasevoc.c
     117  - @ref onset/test-onset.c
     118  - @ref pitch/test-pitch.c
     119  - @ref tempo/test-tempo.c
     120  - @ref test-fvec.c
     121  - @ref test-cvec.c
    120122
    121123  \subsection unstable_api Unstable API
     
    138140
    139141  Latest versions, further documentation, examples, wiki, and mailing lists can
    140   be found at http://aubio.org .
     142  be found at https://aubio.org .
    141143
    142144 */
  • src/aubio_priv.h

    r71f2e5f r41b985f  
    3434 */
    3535
     36#ifdef HAVE_CONFIG_H
    3637#include "config.h"
     38#endif
    3739
    3840#ifdef HAVE_STDLIB_H
     
    182184#ifdef HAVE_C99_VARARGS_MACROS
    183185#define AUBIO_ERR(...)               aubio_log(AUBIO_LOG_ERR, "AUBIO ERROR: " __VA_ARGS__)
     186#define AUBIO_INF(...)               aubio_log(AUBIO_LOG_INF, "AUBIO INFO: " __VA_ARGS__)
    184187#define AUBIO_MSG(...)               aubio_log(AUBIO_LOG_MSG, __VA_ARGS__)
    185188#define AUBIO_DBG(...)               aubio_log(AUBIO_LOG_DBG, __VA_ARGS__)
    186189#define AUBIO_WRN(...)               aubio_log(AUBIO_LOG_WRN, "AUBIO WARNING: " __VA_ARGS__)
    187190#else
    188 #define AUBIO_ERR(format, args...)   aubio_log(stderr, "AUBIO ERROR: " format , ##args)
    189 #define AUBIO_MSG(format, args...)   aubio_log(stdout, format , ##args)
    190 #define AUBIO_DBG(format, args...)   aubio_log(stderr, format , ##args)
    191 #define AUBIO_WRN(format, args...)   aubio_log(stderr, "AUBIO WARNING: " format, ##args)
     191#define AUBIO_ERR(format, args...)   aubio_log(AUBIO_LOG_ERR, "AUBIO ERROR: " format , ##args)
     192#define AUBIO_INF(format, args...)   aubio_log(AUBIO_LOG_INF, "AUBIO INFO: " format , ##args)
     193#define AUBIO_MSG(format, args...)   aubio_log(AUBIO_LOG_MSG, format , ##args)
     194#define AUBIO_DBG(format, args...)   aubio_log(AUBIO_LOG_DBG, format , ##args)
     195#define AUBIO_WRN(format, args...)   aubio_log(AUBIO_LOG_WRN, "AUBIO WARNING: " format, ##args)
    192196#endif
    193197
     
    196200#define AUBIO_QUIT(_s)               exit(_s)
    197201#define AUBIO_SPRINTF                sprintf
     202
     203#define AUBIO_MAX_SAMPLERATE (192000*8)
     204#define AUBIO_MAX_CHANNELS 1024
    198205
    199206/* pi and 2*pi */
  • src/fmat.c

    r71f2e5f r41b985f  
    111111  uint_t i,j;
    112112  for (i=0; i< s->height; i++) {
    113     for (j=0; j< FLOOR(s->length/2); j++) {
     113    for (j=0; j< FLOOR((smpl_t)s->length/2); j++) {
    114114      ELEM_SWAP(s->data[i][j], s->data[i][s->length-1-j]);
    115115    }
  • src/fvec.c

    r71f2e5f r41b985f  
    9191void fvec_rev(fvec_t *s) {
    9292  uint_t j;
    93   for (j=0; j< FLOOR(s->length/2); j++) {
     93  for (j=0; j< FLOOR((smpl_t)s->length/2); j++) {
    9494    ELEM_SWAP(s->data[j], s->data[s->length-1-j]);
    9595  }
  • src/io/audio_unit.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
     21#include "aubio_priv.h"
    2222#ifdef HAVE_AUDIO_UNIT
    23 #include "aubio_priv.h"
    2423
    2524#include "fvec.h"
  • src/io/sink.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
    2221#include "aubio_priv.h"
    2322#include "fvec.h"
     
    9998  }
    10099#endif /* HAVE_WAVWRITE */
    101   AUBIO_ERROR("sink: failed creating %s with samplerate %dHz\n",
    102       uri, samplerate);
     100#if !defined(HAVE_WAVWRITE) && \
     101  !defined(HAVE_SNDFILE) && \
     102  !defined(HAVE_SINK_APPLE_AUDIO)
     103  AUBIO_ERROR("sink: failed creating '%s' at %dHz (no sink built-in)\n", uri, samplerate);
     104#endif
    103105  AUBIO_FREE(s);
    104106  return NULL;
  • src/io/sink_apple_audio.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
     21#include "aubio_priv.h"
    2222
    2323#ifdef HAVE_SINK_APPLE_AUDIO
    24 
    25 #include "aubio_priv.h"
    2624#include "fvec.h"
    2725#include "fmat.h"
    2826#include "io/sink_apple_audio.h"
     27#include "io/ioutils.h"
    2928
    3029// CFURLRef, CFURLCreateWithFileSystemPath, ...
     
    6362  s->async = false;
    6463
    65   if (uri == NULL) {
     64  if ( (uri == NULL) || (strlen(uri) < 1) ) {
    6665    AUBIO_ERROR("sink_apple_audio: Aborted opening null path\n");
    6766    goto beach;
     
    7473  s->channels = 0;
    7574
    76   // negative samplerate given, abort
    77   if ((sint_t)samplerate < 0) goto beach;
    7875  // zero samplerate given. do not open yet
    79   if ((sint_t)samplerate == 0) return s;
     76  if ((sint_t)samplerate == 0) {
     77    return s;
     78  }
     79  // invalid samplerate given, abort
     80  if (aubio_io_validate_samplerate("sink_apple_audio", s->path, samplerate)) {
     81    goto beach;
     82  }
    8083
    8184  s->samplerate = samplerate;
     
    9598uint_t aubio_sink_apple_audio_preset_samplerate(aubio_sink_apple_audio_t *s, uint_t samplerate)
    9699{
    97   if ((sint_t)(samplerate) <= 0) return AUBIO_FAIL;
     100  if (aubio_io_validate_samplerate("sink_apple_audio", s->path, samplerate)) {
     101    return AUBIO_FAIL;
     102  }
    98103  s->samplerate = samplerate;
    99104  // automatically open when both samplerate and channels have been set
     
    106111uint_t aubio_sink_apple_audio_preset_channels(aubio_sink_apple_audio_t *s, uint_t channels)
    107112{
    108   if ((sint_t)(channels) <= 0) return AUBIO_FAIL;
     113  if (aubio_io_validate_channels("sink_apple_audio", s->path, channels)) {
     114    return AUBIO_FAIL;
     115  }
    109116  s->channels = channels;
    110117  // automatically open when both samplerate and channels have been set
  • src/io/sink_sndfile.c

    r71f2e5f r41b985f  
    2020
    2121
    22 #include "config.h"
     22#include "aubio_priv.h"
    2323
    2424#ifdef HAVE_SNDFILE
     
    2626#include <sndfile.h>
    2727
    28 #include "aubio_priv.h"
    2928#include "fvec.h"
    3029#include "fmat.h"
    3130#include "io/sink_sndfile.h"
    32 
    33 #define MAX_CHANNELS 6
     31#include "io/ioutils.h"
     32
    3433#define MAX_SIZE 4096
    3534
     
    7069  s->channels = 0;
    7170
    72   // negative samplerate given, abort
    73   if ((sint_t)samplerate < 0) goto beach;
    7471  // zero samplerate given. do not open yet
    75   if ((sint_t)samplerate == 0) return s;
     72  if ((sint_t)samplerate == 0) {
     73    return s;
     74  }
     75  // invalid samplerate given, abort
     76  if (aubio_io_validate_samplerate("sink_sndfile", s->path, samplerate)) {
     77    goto beach;
     78  }
    7679
    7780  s->samplerate = samplerate;
     
    9093uint_t aubio_sink_sndfile_preset_samplerate(aubio_sink_sndfile_t *s, uint_t samplerate)
    9194{
    92   if ((sint_t)(samplerate) <= 0) return AUBIO_FAIL;
     95  if (aubio_io_validate_samplerate("sink_sndfile", s->path, samplerate)) {
     96    return AUBIO_FAIL;
     97  }
    9398  s->samplerate = samplerate;
    9499  // automatically open when both samplerate and channels have been set
     
    101106uint_t aubio_sink_sndfile_preset_channels(aubio_sink_sndfile_t *s, uint_t channels)
    102107{
    103   if ((sint_t)(channels) <= 0) return AUBIO_FAIL;
     108  if (aubio_io_validate_channels("sink_sndfile", s->path, channels)) {
     109    return AUBIO_FAIL;
     110  }
    104111  s->channels = channels;
    105112  // automatically open when both samplerate and channels have been set
     
    133140  if (s->handle == NULL) {
    134141    /* show libsndfile err msg */
    135     AUBIO_ERR("sink_sndfile: Failed opening %s. %s\n", s->path, sf_strerror (NULL));
     142    AUBIO_ERR("sink_sndfile: Failed opening \"%s\" with %d channels, %dHz: %s\n",
     143        s->path, s->channels, s->samplerate, sf_strerror (NULL));
    136144    return AUBIO_FAIL;
    137145  }
     
    139147  s->scratch_size = s->max_size*s->channels;
    140148  /* allocate data for de/interleaving reallocated when needed. */
    141   if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) {
     149  if (s->scratch_size >= MAX_SIZE * AUBIO_MAX_CHANNELS) {
     150    abort();
    142151    AUBIO_ERR("sink_sndfile: %d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n",
    143         s->max_size, s->channels, MAX_CHANNELS * MAX_CHANNELS);
     152        s->max_size, s->channels, MAX_SIZE * AUBIO_MAX_CHANNELS);
    144153    return AUBIO_FAIL;
    145154  }
  • src/io/sink_wavwrite.c

    r71f2e5f r41b985f  
    2020
    2121
    22 #include "config.h"
     22#include "aubio_priv.h"
    2323
    2424#ifdef HAVE_WAVWRITE
    2525
    26 #include "aubio_priv.h"
    2726#include "fvec.h"
    2827#include "fmat.h"
    2928#include "io/sink_wavwrite.h"
     29#include "io/ioutils.h"
    3030
    3131#include <errno.h>
    3232
    33 #define MAX_CHANNELS 6
    3433#define MAX_SIZE 4096
    3534
     
    105104  s->channels = 0;
    106105
    107   // negative samplerate given, abort
    108   if ((sint_t)samplerate < 0) goto beach;
    109106  // zero samplerate given. do not open yet
    110   if ((sint_t)samplerate == 0) return s;
    111   // samplerate way too large, fail
    112   if ((sint_t)samplerate > 192000 * 4) goto beach;
     107  if ((sint_t)samplerate == 0) {
     108    return s;
     109  }
     110  // invalid samplerate given, abort
     111  if (aubio_io_validate_samplerate("sink_wavwrite", s->path, samplerate)) {
     112    goto beach;
     113  }
    113114
    114115  s->samplerate = samplerate;
     
    130131uint_t aubio_sink_wavwrite_preset_samplerate(aubio_sink_wavwrite_t *s, uint_t samplerate)
    131132{
    132   if ((sint_t)(samplerate) <= 0) return AUBIO_FAIL;
     133  if (aubio_io_validate_samplerate("sink_wavwrite", s->path, samplerate)) {
     134    return AUBIO_FAIL;
     135  }
    133136  s->samplerate = samplerate;
    134137  // automatically open when both samplerate and channels have been set
     
    141144uint_t aubio_sink_wavwrite_preset_channels(aubio_sink_wavwrite_t *s, uint_t channels)
    142145{
    143   if ((sint_t)(channels) <= 0) return AUBIO_FAIL;
     146  if (aubio_io_validate_channels("sink_wavwrite", s->path, channels)) {
     147    return AUBIO_FAIL;
     148  }
    144149  s->channels = channels;
    145150  // automatically open when both samplerate and channels have been set
     
    214219  s->scratch_size = s->max_size * s->channels;
    215220  /* allocate data for de/interleaving reallocated when needed. */
    216   if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) {
     221  if (s->scratch_size >= MAX_SIZE * AUBIO_MAX_CHANNELS) {
    217222    AUBIO_ERR("sink_wavwrite: %d x %d exceeds SIZE maximum buffer size %d\n",
    218         s->max_size, s->channels, MAX_SIZE * MAX_CHANNELS);
     223        s->max_size, s->channels, MAX_SIZE * AUBIO_MAX_CHANNELS);
    219224    goto beach;
    220225  }
  • src/io/source.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
    2221#include "aubio_priv.h"
    2322#include "fvec.h"
     
    116115  }
    117116#endif /* HAVE_WAVREAD */
    118   //AUBIO_ERROR("source: failed creating aubio source with %s"
    119   //   " at samplerate %d with hop_size %d\n", uri, samplerate, hop_size);
     117#if !defined(HAVE_WAVREAD) && \
     118  !defined(HAVE_LIBAV) && \
     119  !defined(HAVE_SOURCE_APPLE_AUDIO) && \
     120  !defined(HAVE_SNDFILE)
     121  AUBIO_ERROR("source: failed creating with %s at %dHz with hop size %d"
     122     " (no source built-in)\n", uri, samplerate, hop_size);
     123#endif
    120124  AUBIO_FREE(s);
    121125  return NULL;
  • src/io/source_apple_audio.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
     21#include "aubio_priv.h"
    2222
    2323#ifdef HAVE_SOURCE_APPLE_AUDIO
    2424
    25 #include "aubio_priv.h"
    2625#include "fvec.h"
    2726#include "fmat.h"
     
    281280{
    282281  OSStatus err = noErr;
    283   if (!s->audioFile) { return AUBIO_FAIL; }
     282  if (!s->audioFile) { return AUBIO_OK; }
    284283  err = ExtAudioFileDispose(s->audioFile);
    285284  s->audioFile = NULL;
  • src/io/source_avcodec.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 
    22 #include "config.h"
     21#include "aubio_priv.h"
    2322
    2423#ifdef HAVE_LIBAV
     24
     25#include <libavcodec/avcodec.h>
     26#include <libavformat/avformat.h>
     27#include <libavresample/avresample.h>
     28#include <libavutil/opt.h>
     29#include <stdlib.h>
    2530
    2631// determine whether we use libavformat from ffmpeg or from libav
     
    3338      )
    3439
    35 #include <libavcodec/avcodec.h>
    36 #include <libavformat/avformat.h>
    37 #include <libavresample/avresample.h>
    38 #include <libavutil/opt.h>
    39 #include <stdlib.h>
     40// backward compatibility with libavcodec55
     41#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
     42#warning "libavcodec55 is deprecated"
     43#define HAVE_AUBIO_LIBAVCODEC_DEPRECATED 1
     44#define av_frame_alloc  avcodec_alloc_frame
     45#define av_frame_free avcodec_free_frame
     46#define av_packet_unref av_free_packet
     47#endif
    4048
    4149#include "aubio_priv.h"
     
    6068  AVCodecContext *avCodecCtx;
    6169  AVFrame *avFrame;
     70  AVPacket avPacket;
    6271  AVAudioResampleContext *avr;
    63   float *output;
     72  smpl_t *output;
    6473  uint_t read_samples;
    6574  uint_t read_index;
     
    151160  sint_t selected_stream = -1;
    152161  for (i = 0; i < avFormatCtx->nb_streams; i++) {
     162#if FF_API_LAVF_AVCTX
     163    if (avFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
     164#else
    153165    if (avFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
     166#endif
    154167      if (selected_stream == -1) {
    155168        selected_stream = i;
     
    168181
    169182  AVCodecContext *avCodecCtx = s->avCodecCtx;
     183#if FF_API_LAVF_AVCTX
     184  AVCodecParameters *codecpar = avFormatCtx->streams[selected_stream]->codecpar;
     185  if (codecpar == NULL) {
     186    AUBIO_ERR("source_avcodec: Could not find decoder for %s", s->path);
     187    goto beach;
     188  }
     189  AVCodec *codec = avcodec_find_decoder(codecpar->codec_id);
     190
     191  /* Allocate a codec context for the decoder */
     192  avCodecCtx = avcodec_alloc_context3(codec);
     193  if (!avCodecCtx) {
     194    AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context for path %s\n",
     195        av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
     196    goto beach;
     197  }
     198#else
    170199  avCodecCtx = avFormatCtx->streams[selected_stream]->codec;
    171200  AVCodec *codec = avcodec_find_decoder(avCodecCtx->codec_id);
     201#endif
    172202  if (codec == NULL) {
    173203    AUBIO_ERR("source_avcodec: Could not find decoder for %s", s->path);
    174204    goto beach;
    175205  }
     206
     207#if FF_API_LAVF_AVCTX
     208  /* Copy codec parameters from input stream to output codec context */
     209  if ((err = avcodec_parameters_to_context(avCodecCtx, codecpar)) < 0) {
     210    AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to decoder context for %s\n",
     211       av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
     212    goto beach;
     213  }
     214#endif
    176215
    177216  if ( ( err = avcodec_open2(avCodecCtx, codec, NULL) ) < 0) {
     
    206245
    207246  /* allocate output for avr */
    208   s->output = (float *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE * sizeof(float));
     247  s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE * sizeof(smpl_t));
    209248
    210249  s->read_samples = 0;
     
    233272
    234273void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi) {
     274  // create or reset resampler to/from mono/multi-channel
    235275  if ( (multi != s->multi) || (s->avr == NULL) ) {
    236276    int64_t input_layout = av_get_default_channel_layout(s->input_channels);
    237277    uint_t output_channels = multi ? s->input_channels : 1;
    238278    int64_t output_layout = av_get_default_channel_layout(output_channels);
    239     if (s->avr != NULL) {
    240       avresample_close( s->avr );
    241       av_free ( s->avr );
    242       s->avr = NULL;
    243     }
    244     AVAudioResampleContext *avr = s->avr;
    245     avr = avresample_alloc_context();
     279    AVAudioResampleContext *avr = avresample_alloc_context();
     280    AVAudioResampleContext *oldavr = s->avr;
    246281
    247282    av_opt_set_int(avr, "in_channel_layout",  input_layout,           0);
     
    250285    av_opt_set_int(avr, "out_sample_rate",    s->samplerate,          0);
    251286    av_opt_set_int(avr, "in_sample_fmt",      s->avCodecCtx->sample_fmt, 0);
     287#if HAVE_AUBIO_DOUBLE
     288    av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_DBL,      0);
     289#else
    252290    av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLT,      0);
     291#endif
     292    // TODO: use planar?
     293    //av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLTP,      0);
    253294    int err;
    254295    if ( ( err = avresample_open(avr) ) < 0) {
     
    261302    }
    262303    s->avr = avr;
     304    if (oldavr != NULL) {
     305      avresample_close( oldavr );
     306      av_free ( oldavr );
     307      oldavr = NULL;
     308    }
    263309    s->multi = multi;
    264310  }
     
    269315  AVCodecContext *avCodecCtx = s->avCodecCtx;
    270316  AVFrame *avFrame = s->avFrame;
    271   AVPacket avPacket;
     317  AVPacket avPacket = s->avPacket;
    272318  av_init_packet (&avPacket);
    273319  AVAudioResampleContext *avr = s->avr;
    274   float *output = s->output;
     320  smpl_t *output = s->output;
    275321  *read_samples = 0;
    276322
     
    291337
    292338  int got_frame = 0;
     339#if FF_API_LAVF_AVCTX
     340  int ret = avcodec_send_packet(avCodecCtx, &avPacket);
     341  if (ret < 0 && ret != AVERROR_EOF) {
     342    AUBIO_ERR("source_avcodec: error when sending packet for %s\n", s->path);
     343    goto beach;
     344  }
     345  ret = avcodec_receive_frame(avCodecCtx, avFrame);
     346  if (ret >= 0) {
     347    got_frame = 1;
     348  }
     349  if (ret < 0) {
     350    if (ret == AVERROR(EAGAIN)) {
     351      AUBIO_WRN("source_avcodec: output is not available right now - user must try to send new input\n");
     352    } else if (ret == AVERROR_EOF) {
     353      AUBIO_WRN("source_avcodec: the decoder has been fully flushed, and there will be no more output frames\n");
     354    } else {
     355      AUBIO_ERR("source_avcodec: decoding errors on %s\n", s->path);
     356      goto beach;
     357    }
     358  }
     359#else
    293360  int len = avcodec_decode_audio4(avCodecCtx, avFrame, &got_frame, &avPacket);
    294361
    295362  if (len < 0) {
    296     AUBIO_ERR("Error while decoding %s\n", s->path);
    297     goto beach;
    298   }
     363    AUBIO_ERR("source_avcodec: error while decoding %s\n", s->path);
     364    goto beach;
     365  }
     366#endif
    299367  if (got_frame == 0) {
    300     //AUBIO_ERR("Could not get frame for (%s)\n", s->path);
     368    AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n", s->path);
    301369    goto beach;
    302370  }
     
    312380        (uint8_t **)avFrame->data, in_linesize, in_samples);
    313381  if (out_samples <= 0) {
    314     //AUBIO_ERR("No sample found while converting frame (%s)\n", s->path);
     382    AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path);
    315383    goto beach;
    316384  }
     
    329397
    330398void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data, uint_t * read){
    331   if (s->multi == 1) aubio_source_avcodec_reset_resampler(s, 0);
    332399  uint_t i;
    333400  uint_t end = 0;
    334401  uint_t total_wrote = 0;
     402  // switch from multi
     403  if (s->multi == 1) aubio_source_avcodec_reset_resampler(s, 0);
    335404  while (total_wrote < s->hop_size) {
    336405    end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote);
     
    360429
    361430void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s, fmat_t * read_data, uint_t * read){
    362   if (s->multi == 0) aubio_source_avcodec_reset_resampler(s, 1);
    363431  uint_t i,j;
    364432  uint_t end = 0;
    365433  uint_t total_wrote = 0;
     434  // switch from mono
     435  if (s->multi == 0) aubio_source_avcodec_reset_resampler(s, 1);
    366436  while (total_wrote < s->hop_size) {
    367437    end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote);
     
    408478  int64_t max_ts = MIN(resampled_pos + 2000, INT64_MAX);
    409479  int seek_flags = AVSEEK_FLAG_FRAME | AVSEEK_FLAG_ANY;
    410   int ret = avformat_seek_file(s->avFormatCtx, s->selected_stream,
     480  int ret = AUBIO_FAIL;
     481  if (s->avFormatCtx != NULL && s->avr != NULL) {
     482    ret = AUBIO_OK;
     483  } else {
     484    AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)", s->path);
     485    return ret;
     486  }
     487  if ((sint_t)pos < 0) {
     488    AUBIO_ERR("source_avcodec: could not seek %s at %d (seeking position"
     489       " should be >= 0)\n", s->path, pos);
     490    return AUBIO_FAIL;
     491  }
     492  ret = avformat_seek_file(s->avFormatCtx, s->selected_stream,
    411493      min_ts, resampled_pos, max_ts, seek_flags);
    412494  if (ret < 0) {
    413     AUBIO_ERR("Failed seeking to %d in file %s", pos, s->path);
     495    AUBIO_ERR("source_avcodec: failed seeking to %d in file %s", pos, s->path);
    414496  }
    415497  // reset read status
     
    442524  s->avCodecCtx = NULL;
    443525  if (s->avFormatCtx != NULL) {
    444     avformat_close_input ( &(s->avFormatCtx) );
    445   }
    446   s->avFormatCtx = NULL;
     526    avformat_close_input(&s->avFormatCtx);
     527#ifndef HAVE_AUBIO_LIBAVCODEC_DEPRECATED // avoid crash on old libavcodec54
     528    avformat_free_context(s->avFormatCtx);
     529#endif
     530    s->avFormatCtx = NULL;
     531  }
     532  av_packet_unref(&s->avPacket);
    447533  return AUBIO_OK;
    448534}
     
    458544    av_frame_free( &(s->avFrame) );
    459545  }
    460   if (s->path) AUBIO_FREE(s->path);
    461546  s->avFrame = NULL;
     547  if (s->path) {
     548    AUBIO_FREE(s->path);
     549  }
     550  s->path = NULL;
    462551  AUBIO_FREE(s);
    463552}
  • src/io/source_sndfile.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 
    22 #include "config.h"
     21#include "aubio_priv.h"
    2322
    2423#ifdef HAVE_SNDFILE
     
    2625#include <sndfile.h>
    2726
    28 #include "aubio_priv.h"
    2927#include "fvec.h"
    3028#include "fmat.h"
     
    3331#include "temporal/resampler.h"
    3432
    35 #define MAX_CHANNELS 6
    3633#define MAX_SIZE 4096
    37 #define MAX_SAMPLES MAX_CHANNELS * MAX_SIZE
     34#define MAX_SAMPLES AUBIO_MAX_CHANNELS * MAX_SIZE
    3835
    3936#if !HAVE_AUBIO_DOUBLE
     
    141138    if (s->ratio > 1) {
    142139      // we would need to add a ring buffer for these
    143       if ( (uint_t)(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
     140      if ( (uint_t)FLOOR(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
    144141        AUBIO_ERR("source_sndfile: can not upsample %s from %d to %d\n", s->path,
    145142            s->input_samplerate, s->samplerate);
     
    298295uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
    299296  uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio);
    300   sf_count_t sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
     297  sf_count_t sf_ret;
     298  if (s->handle == NULL) {
     299    AUBIO_ERR("source_sndfile: failed seeking in %s (file not opened?)\n",
     300        s->path);
     301    return AUBIO_FAIL;
     302  }
     303  if ((sint_t)pos < 0) {
     304    AUBIO_ERR("source_sndfile: could not seek %s at %d (seeking position"
     305       " should be >= 0)\n", s->path, pos);
     306    return AUBIO_FAIL;
     307  }
     308  sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
    301309  if (sf_ret == -1) {
    302310    AUBIO_ERR("source_sndfile: Failed seeking %s at %d: %s\n", s->path, pos, sf_strerror (NULL));
     
    313321uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) {
    314322  if (!s->handle) {
    315     return AUBIO_FAIL;
     323    return AUBIO_OK;
    316324  }
    317325  if(sf_close(s->handle)) {
  • src/io/source_wavread.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
     21#include "aubio_priv.h"
    2222
    2323#ifdef HAVE_WAVREAD
    2424
    25 #include "aubio_priv.h"
    2625#include "fvec.h"
    2726#include "fmat.h"
     
    330329  uint_t end = 0;
    331330  uint_t total_wrote = 0;
     331  if (s->fid == NULL) {
     332    AUBIO_ERR("source_wavread: could not read from %s (file not opened)\n",
     333        s->path);
     334    return;
     335  }
    332336  while (total_wrote < s->hop_size) {
    333337    end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote);
     
    364368  uint_t end = 0;
    365369  uint_t total_wrote = 0;
     370  if (s->fid == NULL) {
     371    AUBIO_ERR("source_wavread: could not read from %s (file not opened)\n",
     372        s->path);
     373    return;
     374  }
    366375  while (total_wrote < s->hop_size) {
    367376    end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote);
     
    404413uint_t aubio_source_wavread_seek (aubio_source_wavread_t * s, uint_t pos) {
    405414  uint_t ret = 0;
     415  if (s->fid == NULL) {
     416    AUBIO_ERR("source_wavread: could not seek %s (file not opened?)\n", s->path, pos);
     417    return AUBIO_FAIL;
     418  }
    406419  if ((sint_t)pos < 0) {
     420    AUBIO_ERR("source_wavread: could not seek %s at %d (seeking position should be >= 0)\n", s->path, pos);
    407421    return AUBIO_FAIL;
    408422  }
     
    426440
    427441uint_t aubio_source_wavread_close (aubio_source_wavread_t * s) {
    428   if (!s->fid) {
    429     return AUBIO_FAIL;
     442  if (s->fid == NULL) {
     443    return AUBIO_OK;
    430444  }
    431445  if (fclose(s->fid)) {
  • src/io/utils_apple_audio.c

    r71f2e5f r41b985f  
    1 #include "config.h"
     1#include "aubio_priv.h"
    22
    33#if defined(HAVE_SOURCE_APPLE_AUDIO) || defined(HAVE_SINK_APPLE_AUDIO)
     
    77// ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ...
    88#include <AudioToolbox/AudioToolbox.h>
    9 #include "aubio_priv.h"
    109
    1110int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize);
  • src/mathutils.c

    r71f2e5f r41b985f  
    2525#include "mathutils.h"
    2626#include "musicutils.h"
    27 #include "config.h"
    2827
    2928/** Window types */
  • src/notes/notes.c

    r71f2e5f r41b985f  
    2525#include "notes/notes.h"
    2626
     27#define AUBIO_DEFAULT_NOTES_SILENCE -70.
     28// increase to 10. for .1  cent precision
     29//      or to 100. for .01 cent precision
     30#define AUBIO_DEFAULT_CENT_PRECISION 1.
     31#define AUBIO_DEFAULT_NOTES_MINIOI_MS 30.
     32
    2733struct _aubio_notes_t {
    2834
     
    7985  o->pitch = new_aubio_pitch (pitch_method, o->pitch_buf_size, o->hop_size, o->samplerate);
    8086  if (o->pitch_tolerance != 0.) aubio_pitch_set_tolerance (o->pitch, o->pitch_tolerance);
     87  aubio_pitch_set_unit (o->pitch, "midi");
    8188  o->pitch_output = new_fvec (1);
    8289
     
    9198  o->newnote = 0.;
    9299
    93   o->silence_threshold = -90.;
     100  aubio_notes_set_silence(o, AUBIO_DEFAULT_NOTES_SILENCE);
     101  aubio_notes_set_minioi_ms (o, AUBIO_DEFAULT_NOTES_MINIOI_MS);
    94102
    95103  return o;
     
    98106  del_aubio_notes(o);
    99107  return NULL;
     108}
     109
     110uint_t aubio_notes_set_silence(aubio_notes_t *o, smpl_t silence)
     111{
     112  uint_t err = AUBIO_OK;
     113  if (aubio_pitch_set_silence(o->pitch, silence) != AUBIO_OK) {
     114    err = AUBIO_FAIL;
     115  }
     116  if (aubio_onset_set_silence(o->onset, silence) != AUBIO_OK) {
     117    err = AUBIO_FAIL;
     118  }
     119  o->silence_threshold = silence;
     120  return err;
     121}
     122
     123smpl_t aubio_notes_get_silence(const aubio_notes_t *o)
     124{
     125  return aubio_pitch_get_silence(o->pitch);
     126}
     127
     128uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms)
     129{
     130  uint_t err = AUBIO_OK;
     131  if (!o->onset || (aubio_onset_set_minioi_ms(o->onset, minioi_ms) != 0)) {
     132    err = AUBIO_FAIL;
     133  }
     134  return err;
     135}
     136
     137smpl_t aubio_notes_get_minioi_ms(const aubio_notes_t *o)
     138{
     139  return aubio_onset_get_minioi_ms(o->onset);
    100140}
    101141
     
    109149    note_buffer->data[i] = note_buffer->data[i + 1];
    110150  }
    111   note_buffer->data[note_buffer->length - 1] = curnote;
     151  //note_buffer->data[note_buffer->length - 1] = ROUND(10.*curnote)/10.;
     152  note_buffer->data[note_buffer->length - 1] = ROUND(AUBIO_DEFAULT_CENT_PRECISION*curnote);
    112153  return;
    113154}
    114155
    115 static uint_t
     156static smpl_t
    116157aubio_notes_get_latest_note (aubio_notes_t *o)
    117158{
    118   uint_t i;
    119   for (i = 0; i < o->note_buffer->length; i++) {
    120     o->note_buffer2->data[i] = o->note_buffer->data[i];
    121   }
    122   return fvec_median (o->note_buffer2);
     159  fvec_copy(o->note_buffer, o->note_buffer2);
     160  return fvec_median (o->note_buffer2) / AUBIO_DEFAULT_CENT_PRECISION;
    123161}
    124162
  • src/notes/notes.h

    r71f2e5f r41b985f  
    1616  You should have received a copy of the GNU General Public License
    1717  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
     18
     19*/
     20
     21/** \file
     22
     23  Note detection object
    1824
    1925*/
     
    5258
    5359  \param o note detection object as returned by new_aubio_notes()
    54   \param in input signal of size [hop_size]
    55   \param out output notes of size [3] ? FIXME
     60  \param input input signal of size [hop_size]
     61  \param output output notes, fvec of length 3
     62
     63  The notes output is a vector of length 3 containing:
     64   - 0. the midi note value, or 0 if no note was found
     65   - 1. the note velocity
     66   - 2. the midi note to turn off
    5667
    5768*/
    5869void aubio_notes_do (aubio_notes_t *o, const fvec_t * input, fvec_t * output);
     70
     71/** set notes detection silence threshold
     72
     73  \param o notes detection object as returned by new_aubio_notes()
     74  \param silence new silence detection threshold
     75
     76  \return 0 on success, non-zero otherwise
     77
     78*/
     79uint_t aubio_notes_set_silence(aubio_notes_t * o, smpl_t silence);
     80
     81/** get notes detection silence threshold
     82
     83  \param o notes detection object as returned by new_aubio_notes()
     84
     85  \return current silence threshold
     86
     87*/
     88smpl_t aubio_notes_get_silence(const aubio_notes_t * o);
     89
     90/** get notes detection minimum inter-onset interval, in millisecond
     91
     92  \param o notes detection object as returned by new_aubio_notes()
     93
     94  \return current minimum inter onset interval
     95
     96 */
     97smpl_t aubio_notes_get_minioi_ms(const aubio_notes_t *o);
     98
     99/** set notes detection minimum inter-onset interval, in millisecond
     100
     101  \param o notes detection object as returned by new_aubio_notes()
     102  \param minioi_ms new inter-onset interval
     103
     104  \return 0 on success, non-zero otherwise
     105
     106*/
     107uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms);
    59108
    60109#ifdef __cplusplus
  • src/onset/peakpicker.c

    r71f2e5f r41b985f  
    186186   */
    187187  t->biquad = new_aubio_filter_biquad (0.15998789, 0.31997577, 0.15998789,
    188       -0.59488894, 0.23484048);
     188      // FIXME: broken since c9e20ca, revert for now
     189      //-0.59488894, 0.23484048);
     190      0.23484048, 0);
    189191
    190192  return t;
  • src/pitch/pitch.c

    r71f2e5f r41b985f  
    112112  aubio_pitch_t *p = AUBIO_NEW (aubio_pitch_t);
    113113  aubio_pitch_type pitch_type;
     114  if (pitch_mode == NULL) {
     115    AUBIO_ERR ("pitch: can not use ‘NULL‘ for pitch detection method\n");
     116    goto beach;
     117  }
    114118  if (strcmp (pitch_mode, "mcomb") == 0)
    115119    pitch_type = aubio_pitcht_mcomb;
     
    139143    goto beach;
    140144  } else if (bufsize < hopsize) {
    141     AUBIO_ERR("pitch: hop size (%d) is larger than win size (%d)\n", bufsize, hopsize);
     145    AUBIO_ERR("pitch: hop size (%d) is larger than win size (%d)\n", hopsize, bufsize);
    142146    goto beach;
    143147  } else if ((sint_t)samplerate < 1) {
     
    156160      p->buf = new_fvec (bufsize);
    157161      p->p_object = new_aubio_pitchyin (bufsize);
     162      if (!p->p_object) goto beach;
    158163      p->detect_cb = aubio_pitch_do_yin;
    159164      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyin_get_confidence;
     
    163168      p->filtered = new_fvec (hopsize);
    164169      p->pv = new_aubio_pvoc (bufsize, hopsize);
     170      if (!p->pv) goto beach;
    165171      p->fftgrain = new_cvec (bufsize);
    166172      p->p_object = new_aubio_pitchmcomb (bufsize, hopsize);
     
    171177      p->buf = new_fvec (bufsize);
    172178      p->p_object = new_aubio_pitchfcomb (bufsize, hopsize);
     179      if (!p->p_object) goto beach;
    173180      p->detect_cb = aubio_pitch_do_fcomb;
    174181      break;
     
    181188      p->buf = new_fvec (bufsize);
    182189      p->p_object = new_aubio_pitchyinfft (samplerate, bufsize);
     190      if (!p->p_object) goto beach;
    183191      p->detect_cb = aubio_pitch_do_yinfft;
    184192      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfft_get_confidence;
     
    188196      p->buf = new_fvec (bufsize);
    189197      p->p_object = new_aubio_pitchspecacf (bufsize);
     198      if (!p->p_object) goto beach;
    190199      p->detect_cb = aubio_pitch_do_specacf;
    191200      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchspecacf_get_tolerance;
     
    198207
    199208beach:
     209  if (p->filtered) del_fvec(p->filtered);
     210  if (p->buf) del_fvec(p->buf);
    200211  AUBIO_FREE(p);
    201212  return NULL;
  • src/pitch/pitch.h

    r71f2e5f r41b985f  
    151151  \param mode set pitch units for output
    152152
     153  mode can be one of "Hz", "midi", "cent", or "bin". Defaults to "Hz".
     154
    153155  \return 0 if successfull, non-zero otherwise
    154156
  • src/pitch/pitchfcomb.c

    r71f2e5f r41b985f  
    5454  p->fftSize = bufsize;
    5555  p->stepSize = hopsize;
     56  p->fft = new_aubio_fft (bufsize);
     57  if (!p->fft) goto beach;
    5658  p->winput = new_fvec (bufsize);
    5759  p->fftOut = new_cvec (bufsize);
    5860  p->fftLastPhase = new_fvec (bufsize);
    59   p->fft = new_aubio_fft (bufsize);
    6061  p->win = new_aubio_window ("hanning", bufsize);
    6162  return p;
     63
     64beach:
     65  AUBIO_FREE(p);
     66  return NULL;
    6267}
    6368
  • src/pitch/pitchspecacf.c

    r71f2e5f r41b985f  
    4343{
    4444  aubio_pitchspecacf_t *p = AUBIO_NEW (aubio_pitchspecacf_t);
     45  p->fft = new_aubio_fft (bufsize);
     46  if (!p->fft) goto beach;
    4547  p->win = new_aubio_window ("hanningz", bufsize);
    4648  p->winput = new_fvec (bufsize);
    47   p->fft = new_aubio_fft (bufsize);
    4849  p->fftout = new_fvec (bufsize);
    4950  p->sqrmag = new_fvec (bufsize);
     
    5253  p->confidence = 0.;
    5354  return p;
     55
     56beach:
     57  AUBIO_FREE(p);
     58  return NULL;
    5459}
    5560
  • src/pitch/pitchyin.c

    r71f2e5f r41b985f  
    128128}
    129129
    130 
    131130/* all the above in one */
    132131void
    133132aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out)
    134133{
    135   smpl_t tol = o->tol;
    136   fvec_t *yin = o->yin;
    137   uint_t j, tau = 0;
     134  const smpl_t tol = o->tol;
     135  fvec_t* yin = o->yin;
     136  const smpl_t *input_data = input->data;
     137  const uint_t length = yin->length;
     138  smpl_t *yin_data = yin->data;
     139  uint_t j, tau;
    138140  sint_t period;
    139   smpl_t tmp = 0., tmp2 = 0.;
    140   yin->data[0] = 1.;
    141   for (tau = 1; tau < yin->length; tau++) {
    142     yin->data[tau] = 0.;
    143     for (j = 0; j < yin->length; j++) {
    144       tmp = input->data[j] - input->data[j + tau];
    145       yin->data[tau] += SQR (tmp);
     141  smpl_t tmp, tmp2 = 0.;
     142
     143  yin_data[0] = 1.;
     144  for (tau = 1; tau < length; tau++) {
     145    yin_data[tau] = 0.;
     146    for (j = 0; j < length; j++) {
     147      tmp = input_data[j] - input_data[j + tau];
     148      yin_data[tau] += SQR (tmp);
    146149    }
    147     tmp2 += yin->data[tau];
     150    tmp2 += yin_data[tau];
    148151    if (tmp2 != 0) {
    149152      yin->data[tau] *= tau / tmp2;
     
    152155    }
    153156    period = tau - 3;
    154     if (tau > 4 && (yin->data[period] < tol) &&
    155         (yin->data[period] < yin->data[period + 1])) {
     157    if (tau > 4 && (yin_data[period] < tol) &&
     158        (yin_data[period] < yin_data[period + 1])) {
    156159      out->data[0] = fvec_quadratic_peak_pos (yin, period);
    157160      goto beach;
  • src/pitch/pitchyinfft.c

    r71f2e5f r41b985f  
    6363  p->winput = new_fvec (bufsize);
    6464  p->fft = new_aubio_fft (bufsize);
     65  if (!p->fft) goto beach;
    6566  p->fftout = new_fvec (bufsize);
    6667  p->sqrmag = new_fvec (bufsize);
     
    9697  p->short_period = (uint_t)ROUND(samplerate / 1300.);
    9798  return p;
     99
     100beach:
     101  if (p->winput) del_fvec(p->winput);
     102  AUBIO_FREE(p);
     103  return NULL;
    98104}
    99105
  • src/spectral/ooura_fft8g.c

    r71f2e5f r41b985f  
    33//  - include "aubio_priv.h" (for config.h and types.h)
    44//  - add missing prototypes
    5 //  - use COS and SIN macros
     5//  - use COS, SIN, and ATAN macros
     6//  - add cast to (smpl_t) to avoid float conversion warnings
    67//  - declare initialization as static
    78//  - prefix public function with aubio_ooura_
     
    364365        a[1] = xi;
    365366    } else {
    366         a[1] = 0.5 * (a[0] - a[1]);
     367        a[1] = (smpl_t)0.5 * (a[0] - a[1]);
    367368        a[0] -= a[1];
    368369        if (n > 4) {
     
    693694    if (nw > 2) {
    694695        nwh = nw >> 1;
    695         delta = atan(1.0) / nwh;
     696        delta = ATAN(1.0) / nwh;
    696697        w[0] = 1;
    697698        w[1] = 0;
     
    727728    if (nc > 1) {
    728729        nch = nc >> 1;
    729         delta = atan(1.0) / nch;
    730         c[0] = cos(delta * nch);
    731         c[nch] = 0.5 * c[0];
     730        delta = ATAN(1.0) / nch;
     731        c[0] = COS(delta * nch);
     732        c[nch] = (smpl_t)0.5 * c[0];
    732733        for (j = 1; j < nch; j++) {
    733             c[j] = 0.5 * cos(delta * j);
    734             c[nc - j] = 0.5 * sin(delta * j);
     734            c[j] = (smpl_t)0.5 * COS(delta * j);
     735            c[nc - j] = (smpl_t)0.5 * SIN(delta * j);
    735736        }
    736737    }
     
    15881589        k = n - j;
    15891590        kk += ks;
    1590         wkr = 0.5 - c[nc - kk];
     1591        wkr = (smpl_t)0.5 - c[nc - kk];
    15911592        wki = c[kk];
    15921593        xr = a[j] - a[k];
     
    16141615        k = n - j;
    16151616        kk += ks;
    1616         wkr = 0.5 - c[nc - kk];
     1617        wkr = (smpl_t)0.5 - c[nc - kk];
    16171618        wki = c[kk];
    16181619        xr = a[j] - a[k];
  • src/spectral/phasevoc.c

    r71f2e5f r41b985f  
    8989    goto beach;
    9090  } else if (win_s < hop_s) {
    91     AUBIO_ERR("pvoc: hop size (%d) is larger than win size (%d)\n", win_s, hop_s);
     91    AUBIO_ERR("pvoc: hop size (%d) is larger than win size (%d)\n", hop_s, win_s);
    9292    goto beach;
    9393  }
  • src/synth/sampler.c

    r71f2e5f r41b985f  
    2121#include <assert.h>
    2222
    23 #include "config.h"
    2423#include "aubio_priv.h"
    2524#include "fvec.h"
  • src/synth/wavetable.c

    r71f2e5f r41b985f  
    2020
    2121
    22 #include "config.h"
    2322#include "aubio_priv.h"
    2423#include "fvec.h"
  • src/tempo/tempo.h

    r71f2e5f r41b985f  
    155155  \param o beat tracking object
    156156
    157   \return confidence with which the tempo has been observed, `0` if no
    158   consistent value is found.
     157  \return confidence with which the tempo has been observed, the higher the
     158  more confidence, `0` if no consistent value is found.
    159159
    160160*/
  • src/temporal/biquad.c

    r71f2e5f r41b985f  
    4242  as->data[0] = 1.;
    4343  as->data[1] = a1;
    44   as->data[1] = a2;
     44  as->data[2] = a2;
    4545  return AUBIO_OK;
    4646}
  • src/temporal/resampler.c

    r71f2e5f r41b985f  
    1818
    1919*/
    20 
    21 #include "config.h"
    2220
    2321#include "aubio_priv.h"
  • src/utils/log.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
    2221#include "aubio_priv.h"
    2322#include "log.h"
     
    3635  FILE *out;
    3736  out = stdout;
    38   if (level == AUBIO_LOG_DBG || level == AUBIO_LOG_ERR) {
     37  if (level == AUBIO_LOG_ERR || level == AUBIO_LOG_DBG || level == AUBIO_LOG_WRN) {
    3938    out = stderr;
    4039  }
  • src/utils/log.h

    r71f2e5f r41b985f  
    4646enum aubio_log_level {
    4747  AUBIO_LOG_ERR, /**< critical errors */
    48   AUBIO_LOG_WRN, /**< warnings */
     48  AUBIO_LOG_INF, /**< infos */
    4949  AUBIO_LOG_MSG, /**< general messages */
    5050  AUBIO_LOG_DBG, /**< debug messages */
     51  AUBIO_LOG_WRN, /**< warnings */
    5152  AUBIO_LOG_LAST_LEVEL, /**< number of valid levels */
    5253};
  • src/utils/parameter.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 #include "config.h"
    2221#include "aubio_priv.h"
    2322#include "parameter.h"
  • src/utils/windll.c

    r71f2e5f r41b985f  
    2525*/
    2626
    27 #include "config.h"
     27#include "aubio_priv.h"
    2828
    2929#ifdef HAVE_WIN_HACKS
  • src/vecutils.c

    r71f2e5f r41b985f  
    1 #include "config.h"
    21#include "aubio_priv.h"
    32#include "types.h"
  • src/wscript_build

    r71f2e5f r41b985f  
    2929elif ctx.env['DEST_OS'] in ['emscripten']:
    3030    build_features = ['cstlib']
    31 else: #linux, darwin, android, mingw, ...
     31elif '--static' in ctx.env['LDFLAGS'] or '--static' in ctx.env['LINKFLAGS']:
     32    # static in cflags, ...
     33    build_features = ['cstlib']
     34else:
     35    # linux, darwin, android, mingw, ...
    3236    build_features = ['cstlib', 'cshlib']
     37
     38# also install static lib
     39from waflib.Tools.c import cstlib
     40from waflib.Tools.fc import fcstlib
     41fcstlib.inst_to = cstlib.inst_to = '${LIBDIR}'
    3342
    3443for target in build_features:
     
    3948
    4049# install headers, except _priv.h ones
    41 ctx.install_files('${PREFIX}/include/aubio/',
     50ctx.install_files('${INCLUDEDIR}/aubio/',
    4251        ctx.path.ant_glob('**/*.h', excl = ['**_priv.h', 'config.h']),
    4352        relative_trick=True)
  • tests/src/io/test-sink_sndfile-multi.c

    r71f2e5f r41b985f  
    11#define AUBIO_UNSTABLE 1
    22#include <aubio.h>
    3 #include "config.h"
    43#include "utils_tests.h"
    54
  • tests/src/io/test-sink_sndfile.c

    r71f2e5f r41b985f  
    11#define AUBIO_UNSTABLE 1
    22#include <aubio.h>
    3 #include "config.h"
    43#include "utils_tests.h"
    54
  • tests/src/spectral/test-phasevoc.c

    r71f2e5f r41b985f  
    2929    cvec_print (fftgrain);
    3030
    31     // optionnaly rebuild the signa
     31    // optionally rebuild the signal
    3232    aubio_pvoc_rdo(pv,fftgrain,out);
    3333
  • tests/src/utils/test-log.c

    r71f2e5f r41b985f  
    1010void logging(int level, const char_t *message, void *data) {
    1111  FILE *out;
    12   fprintf(stdout, "using custom logging function\n");
     12  //fprintf(stdout, "using custom logging function\n");
    1313  if (level == AUBIO_LOG_ERR) {
    1414    out = stderr;
     
    2626  fprintf(stdout, "### testing normal logging\n");
    2727  AUBIO_ERR("testing normal AUBIO_LOG_ERR\n");
     28  AUBIO_INF("testing normal AUBIO_LOG_INF\n");
    2829  AUBIO_WRN("testing normal AUBIO_LOG_WRN\n");
    2930  AUBIO_MSG("testing normal AUBIO_LOG_MSG\n");
     
    3233  fprintf(stdout, "### testing with one custom function\n");
    3334  aubio_log_set_function(logging, (void *)hdr);
    34   AUBIO_ERR("testing recustom AUBIO_LOG_ERR\n");
    35   AUBIO_WRN("testing recustom AUBIO_LOG_WRN\n");
    36   AUBIO_MSG("testing recustom AUBIO_LOG_MSG\n");
    37   AUBIO_DBG("testing recustom AUBIO_LOG_DBG\n");
     35  AUBIO_ERR("testing custom set_function AUBIO_LOG_ERR\n");
     36  AUBIO_INF("testing custom set_function AUBIO_LOG_INF\n");
     37  AUBIO_WRN("testing custom set_function AUBIO_LOG_WRN\n");
     38  AUBIO_MSG("testing custom set_function AUBIO_LOG_MSG\n");
     39  AUBIO_DBG("testing custom set_function AUBIO_LOG_DBG\n");
    3840
    3941  fprintf(stdout, "### testing resetted logging\n");
    4042  aubio_log_reset();
    41   AUBIO_ERR("testing uncustom AUBIO_LOG_ERR\n");
    42   AUBIO_WRN("testing uncustom AUBIO_LOG_WRN\n");
    43   AUBIO_MSG("testing uncustom AUBIO_LOG_MSG\n");
    44   AUBIO_DBG("testing uncustom AUBIO_LOG_DBG\n");
     43  AUBIO_ERR("testing again normal AUBIO_LOG_ERR\n");
     44  AUBIO_INF("testing again normal AUBIO_LOG_INF\n");
     45  AUBIO_WRN("testing again normal AUBIO_LOG_WRN\n");
     46  AUBIO_MSG("testing again normal AUBIO_LOG_MSG\n");
     47  AUBIO_DBG("testing again normal AUBIO_LOG_DBG\n");
    4548
    4649  fprintf(stdout, "### testing per level customization\n");
     
    4851  aubio_log_set_level_function(AUBIO_LOG_WRN, logging, NULL);
    4952  aubio_log_set_level_function(AUBIO_LOG_MSG, logging, (void *)hdr);
    50   AUBIO_ERR("testing custom AUBIO_LOG_ERR\n");
    51   AUBIO_WRN("testing custom AUBIO_LOG_WRN with data=NULL\n");
    52   AUBIO_MSG("testing custom AUBIO_LOG_MSG\n");
    53   AUBIO_DBG("testing uncustomized AUBIO_LOG_DBG\n");
     53  AUBIO_ERR("testing custom set_level_function AUBIO_LOG_ERR\n");
     54  AUBIO_INF("testing again normal AUBIO_LOG_INF\n");
     55  AUBIO_WRN("testing custom set_level_function AUBIO_LOG_WRN with data=NULL\n");
     56  AUBIO_MSG("testing custom set_level_function AUBIO_LOG_MSG\n");
     57  AUBIO_DBG("testing again normal AUBIO_LOG_DBG\n");
    5458
    5559  return 0;
  • wscript

    r71f2e5f r41b985f  
    4848
    4949def options(ctx):
     50    ctx.add_option('--build-type', action = 'store',
     51            default = "release",
     52            choices = ('debug', 'release'),
     53            dest = 'build_type',
     54            help = 'whether to compile with (--build-type=release) or without (--build-type=debug) '\
     55              ' compiler opimizations [default: release]')
    5056    add_option_enable_disable(ctx, 'fftw3f', default = False,
    5157            help_str = 'compile with fftw3f instead of ooura (recommended)',
     
    8793            help_str = 'use CoreFoundation (darwin only) (auto)',
    8894            help_disable_str = 'do not use CoreFoundation framework')
    89     add_option_enable_disable(ctx, 'atlas', default = None,
    90             help_str = 'use Atlas library (auto)',
     95    add_option_enable_disable(ctx, 'atlas', default = False,
     96            help_str = 'use Atlas library (no)',
    9197            help_disable_str = 'do not use Atlas library')
    9298    add_option_enable_disable(ctx, 'wavread', default = True,
     
    134140    ctx.env['DEST_OS'] = target_platform
    135141
     142    if ctx.options.build_type == "debug":
     143        ctx.define('DEBUG', 1)
     144    else:
     145        ctx.define('NDEBUG', 1)
     146
    136147    if ctx.env.CC_NAME != 'msvc':
    137         ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
     148        if ctx.options.build_type == "debug":
     149            # no optimization in debug mode
     150            ctx.env.prepend_value('CFLAGS', ['-O0'])
     151        else:
     152            # default to -O2 in release mode
     153            ctx.env.prepend_value('CFLAGS', ['-O2'])
     154        # enable debug symbols and configure warnings
     155        ctx.env.prepend_value('CFLAGS', ['-g', '-Wall', '-Wextra'])
    138156    else:
    139         ctx.env.CFLAGS += ['/W4', '/MD']
    140         ctx.env.CFLAGS += ['/D_CRT_SECURE_NO_WARNINGS']
     157        # enable debug symbols
     158        ctx.env.CFLAGS += ['/Z7', '/FS']
     159        ctx.env.LINKFLAGS += ['/DEBUG', '/INCREMENTAL:NO']
     160        # configure warnings
     161        ctx.env.CFLAGS += ['/W4', '/D_CRT_SECURE_NO_WARNINGS']
     162        # set optimization level and runtime libs
     163        if (ctx.options.build_type == "release"):
     164            ctx.env.CFLAGS += ['/Ox']
     165            ctx.env.CFLAGS += ['/MD']
     166        else:
     167            assert(ctx.options.build_type == "debug")
     168            ctx.env.CFLAGS += ['/MDd']
    141169
    142170    ctx.check_cc(lib='m', uselib_store='M', mandatory=False)
     
    160188            ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
    161189            ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
     190            ctx.msg('Checking for AudioToolbox.framework', 'yes')
     191        else:
     192            ctx.msg('Checking for AudioToolbox.framework', 'no (disabled)', color = 'YELLOW')
    162193        if (ctx.options.enable_accelerate != False):
    163194            ctx.define('HAVE_ACCELERATE', 1)
    164195            ctx.env.FRAMEWORK += ['Accelerate']
     196            ctx.msg('Checking for Accelerate framework', 'yes')
     197        else:
     198            ctx.msg('Checking for Accelerate framework', 'no (disabled)', color = 'YELLOW')
    165199
    166200    if target_platform in [ 'ios', 'iosimulator' ]:
     
    270304
    271305    # check for libsamplerate
     306    if (ctx.options.enable_double):
     307        if (ctx.options.enable_samplerate):
     308            ctx.fatal("Could not compile aubio in double precision mode with libsamplerate")
     309        else:
     310            ctx.options.enable_samplerate = False
     311            ctx.msg('Checking if using samplerate', 'no (disabled in double precision mode)',
     312                    color = 'YELLOW')
    272313    if (ctx.options.enable_samplerate != False):
    273314        ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
     
    330371    # the following defines will be passed as arguments to the compiler
    331372    # instead of being written to src/config.h
     373    ctx.define('HAVE_CONFIG_H', 1)
    332374
    333375    # add some defines used in examples
     
    362404    bld.env['LIB_VERSION'] = LIB_VERSION
    363405
     406    # main source
     407    bld.recurse('src')
     408
    364409    # add sub directories
    365     bld.recurse('src')
    366410    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
    367411        bld.recurse('examples')
    368412        bld.recurse('tests')
    369413
     414    # pkg-config template
    370415    bld( source = 'aubio.pc.in' )
    371416
     417    # documentation
     418    txt2man(bld)
     419    doxygen(bld)
     420    sphinx(bld)
     421
     422def txt2man(bld):
    372423    # build manpages from txt files using txt2man
    373424    if bld.env['TXT2MAN']:
    374425        from waflib import TaskGen
    375426        if 'MANDIR' not in bld.env:
    376             bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
     427            bld.env['MANDIR'] = bld.env['DATAROOTDIR'] + '/man'
     428        bld.env.VERSION = VERSION
    377429        rule_str = '${TXT2MAN} -t `basename ${TGT} | cut -f 1 -d . | tr a-z A-Z`'
    378430        rule_str += ' -r ${PACKAGE}\\ ${VERSION} -P ${PACKAGE}'
     
    389441        bld( source = bld.path.ant_glob('doc/*.txt') )
    390442
     443def doxygen(bld):
    391444    # build documentation from source files using doxygen
    392445    if bld.env['DOXYGEN']:
    393446        bld( name = 'doxygen', rule = 'doxygen ${SRC} > /dev/null',
    394447                source = 'doc/web.cfg',
     448                target = '../doc/web/html/index.html',
    395449                cwd = 'doc')
    396         bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc',
     450        bld.install_files( '${DATAROOTDIR}' + '/doc/libaubio-doc',
    397451                bld.path.ant_glob('doc/web/html/**'),
    398452                cwd = bld.path.find_dir ('doc/web'),
    399453                relative_trick = True)
    400454
     455def sphinx(bld):
    401456    # build documentation from source files using sphinx-build
     457    # note: build in ../doc/_build/html, otherwise waf wont install unsigned files
    402458    if bld.env['SPHINX']:
    403         bld( name = 'sphinx', rule = 'make html',
    404                 source = ['doc/conf.py'] + bld.path.ant_glob('doc/**.rst'),
    405                 cwd = 'doc')
    406         bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc/sphinx',
     459        bld.env.VERSION = VERSION
     460        bld( name = 'sphinx',
     461                rule = '${SPHINX} -b html -D release=${VERSION} -D version=${VERSION} -a -q `dirname ${SRC}` `dirname ${TGT}`',
     462                source = 'doc/conf.py',
     463                target = '../doc/_build/html/index.html')
     464        bld.install_files( '${DATAROOTDIR}' + '/doc/libaubio-doc/sphinx',
    407465                bld.path.ant_glob('doc/_build/html/**'),
    408                 cwd = bld.path.find_dir ('doc/_build/html'),
     466                cwd = bld.path.find_dir('doc/_build/html'),
    409467                relative_trick = True)
     468
     469# register the previous rules as build rules
     470from waflib.Build import BuildContext
     471
     472class build_txt2man(BuildContext):
     473    cmd = 'txt2man'
     474    fun = 'txt2man'
     475
     476class build_manpages(BuildContext):
     477    cmd = 'manpages'
     478    fun = 'txt2man'
     479
     480class build_sphinx(BuildContext):
     481    cmd = 'sphinx'
     482    fun = 'sphinx'
     483
     484class build_doxygen(BuildContext):
     485    cmd = 'doxygen'
     486    fun = 'doxygen'
    410487
    411488def shutdown(bld):
     
    418495
    419496def dist(ctx):
    420     ctx.excl  = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w* **/.git*'
     497    ctx.excl  = ' **/.waf* **/*~ **/*.pyc **/*.swp **/*.swo **/*.swn **/.lock-w* **/.git*'
    421498    ctx.excl += ' **/build/*'
    422499    ctx.excl += ' doc/_build'
     
    427504    ctx.excl += ' **.egg-info'
    428505    ctx.excl += ' **/**.zip **/**.tar.bz2'
     506    ctx.excl += ' **.tar.bz2'
    429507    ctx.excl += ' **/doc/full/* **/doc/web/*'
     508    ctx.excl += ' **/doc/full.cfg'
    430509    ctx.excl += ' **/python/*.db'
    431510    ctx.excl += ' **/python.old/*'
Note: See TracChangeset for help on using the changeset viewer.