Changes in / [00d0275:155cc10]


Ignore:
Files:
51 added
8 deleted
207 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r00d0275 r155cc10  
    3131doc/web/
    3232doc/full/
     33doc/_build/
    3334
    3435python/gen
     
    4041aubio-*.tar.bz2
    4142aubio-*.zip
     43
     44# test sounds
     45python/tests/sounds
     46aubio.egg-info
  • .travis.yml

    r00d0275 r155cc10  
    1 language: c
     1language: python
    22
    3 sudo: false
     3matrix:
     4  include:
     5    - python: 3.5
     6      os: linux
     7      compiler: gcc
     8    - python: 3.4
     9      os: linux
     10      compiler: gcc
     11    - python: 2.7
     12      os: linux
     13      compiler: gcc
     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"
     26    - python: 2.7
     27      os: linux
     28      compiler: gcc
     29      env: CFLAGS="`dpkg-buildflags --get CFLAGS`" LDFLAGS="`dpkg-buildflags --get LDFLAGS`"
     30    - language: C
     31      os: osx
     32      osx_image: xcode8
     33      compiler: clang
     34      env: CFLAGS="-Os" HAVE_AUBIO_DOUBLE=1 WAFOPTS="--disable-accelerate"
     35    - language: C
     36      os: osx
     37      osx_image: xcode8
     38      compiler: clang
     39      env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile"
     40    - language: C
     41      os: osx
     42      osx_image: xcode8
     43      compiler: clang
     44      env: WAFOPTS="--with-target-platform=ios --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
     45    - language: C
     46      os: osx
     47      osx_image: xcode8
     48      compiler: clang
     49      env: WAFOPTS="--with-target-platform=iosimulator --disable-avcodec --disable-sndfile" AUBIO_NOTESTS=1
     50    - language: C
     51      os: osx
     52      osx_image: xcode8.2
     53      compiler: clang
     54      env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile"
     55    - language: C
     56      os: osx
     57      osx_image: xcode8.2
     58      compiler: clang
     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
    465
    5 compiler:
    6   - gcc
    7   - clang
    8 
    9 env:
    10   - ARCH=i386
    11   - ARCH=x86_64
     66# use trusty
     67dist: trusty
     68sudo: required
    1269
    1370addons:
     
    1572    packages:
    1673    - bzip2
     74    - libavcodec-dev
     75    - libavformat-dev
     76    - libavresample-dev
     77    - libavutil-dev
    1778    - libsndfile1-dev
    1879    - libsamplerate-dev
     
    2081    - libasound2-dev
    2182    - libfftw3-dev
    22     - python-dev
    23     - python-numpy
     83    - sox
     84
     85before_install:
     86   - |
     87     if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
     88       brew update
     89       brew install sox
     90       brew install ffmpeg
     91       brew install libsndfile
     92       export PATH="$HOME/Library/Python/2.7/bin/:$PATH"
     93     fi;
     94
     95install:
     96  - travis_retry pip install --upgrade pip
     97  - travis_retry make getwaf expandwaf deps_python
     98  - which pip
     99  - pip --version
    24100
    25101script:
    26   - make build
    27   - make build_python
    28   - make clean_python
    29   - make clean
    30   - make distcheck
     102  - make create_test_sounds
     103  - |
     104    if [[ -z "$AUBIO_NOTESTS" ]]; then
     105      make test_lib_python_clean
     106      make test_python_only_clean
     107    else
     108      make test_lib_only_clean
     109    fi;
     110
     111notifications:
     112    irc:
     113        channels:
     114            - "irc.freenode.org#aubio"
     115        use_notice: true
     116    webhooks:
     117        urls:
     118            - https://webhooks.gitter.im/e/81e7733a5b1d977854b4
     119        on_success: change  # options: [always|never|change] default: always
     120        on_failure: always  # options: [always|never|change] default: always
     121        on_start: never     # options: [always|never|change] default: always
  • ChangeLog

    r00d0275 r155cc10  
     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
     2202016-08-16 Paul Brossier <piem@aubio.org>
     221
     222        [ Interface ]
     223
     224        * src/io/source.h, src/io/source_*.h: add _get_duration
     225        * src/notes/notes.h: add basic notes object
     226        * src/tempo/beattracking.{c,h}: add _get_period and _get_period_s
     227        * src/mathutils.h: add fvec_ishift
     228        * src/fvec.{c,h}: add fvec_weighted_copy
     229        * src/tempo/tempo.{c,h}: add _get_period and _get_period_s, also add tatum,
     230        a subdivision of the beat period, default to 4, implement get/set_delay
     231        * src/**.{c,h}: use #ifdef HAVE_FOO, not #if _HAVE_FOO, add const qualifiers
     232        to unmodified pointers (see #35)
     233
     234        [ Library ]
     235
     236        * src/{fmat,fvec,mathutils}.c: optimisations (using atlas or Accelerate when
     237        available) for fvec_sum, fvec_mean, fvec_shift, aubio_level_lin,
     238        fvec_set_all, fvec_zeros, fvec_weight, fvec_copy, fvec_weighted_copy,
     239        fmat_vecmul
     240        * src/aubio_priv.h: check for atlas cblas, use cblas_xswap, vDSP_dotpr,
     241        protect SQR parameters, avoid redefining MIN/MAX, define PATH_MAX and PI
     242        when needed, use _isnan on windows msvc 9 to avoid linking error, more
     243        windows hacks
     244        * src/mathutils.c: avoid for loop initial declarations [gcc], use
     245        HAVE_ATLAS, use smpl_t for constants
     246        * src/fmat.c: skip asserts
     247        * src/spectral/{filterbank,mfcc}.c: use accelerated fmat_vecmul
     248        * src/spectral/fft.c: fftw can be used odd length sizes, not Ooura,
     249        factorise double / single flags, use memcpy
     250        * src/spectral/phasevoc.c: fix arguments checks, return NULL when fft
     251        creation failed , apply windowing for resynthesized grain, use ishift for
     252        odd windows, fix scaling factors for correct reconstruction at 50 and 75%
     253        overlap
     254        * src/pitch/pitch.c: allow for silence == 0, improve error messages
     255        * src/pitch/pitchmcomb.c: fix candidates sorting function, really comparing
     256        current to next
     257        * src/notes/notes.c: equivalent to previous examples/aubionotes.c results
     258        * src/onset/onset.c: simplify selection of first onset, fix for "conversion
     259        from 'smpl_t' to 'uint_t', possible loss of data" with msvc
     260        * src/pitch/pitchmcomb.c: scan across all spectrum
     261        * src/pitch/pitchyinfft.c: use fvec_weighted_copy
     262        * src/{spectral/*.c,onset/*.c,tempo/*.c}: make sure win_size > 1
     263        * src/io/*.c: use custom defines for {source,sink}_apple_audio, take a copy
     264        of const char* path
     265        * src/io/source_avcodec.c:
     266         - update to libav10, libavcodec 55.34.1
     267         - avoid deprecation warning, detect if we use ffmpeg or libav version
     268         - check if the uri is a network stream using av_url_split, call
     269         avformat_network_init() if needed
     270         - check if we still need max_analyze_duration2 (closes #53, thanks to
     271         @anthonylauzon)
     272        * src/io/source_{avcodec,sndfile}.c: avoid modifying input param
     273        * src/io/{sink,source,utils}_apple_audio.c: fix memory leak calling
     274        CFRelease (closes #26, closes #27, and closes #28)
     275        * src/io/sink_apple_audio.c: disable async mode for now, factorise code
     276        * src/io/source_apple_audio.c: check out of bounds _seek, set s->path, quiet
     277        * src/io/source_sndfile.c: fix crash, zero-pad output vector when
     278        upsampling, use sf_read_double when compiling with AUBIO_DOUBLE, approximate
     279        duration when resampling
     280        * src/io/sink_sndfile.c: fix for double precision
     281        * src/synth/sampler.c: fix typo, keeps a copy of uri
     282        * src/tempo/tempo.c: do not write novelty function in output[1]
     283        * src/temporal/resampler.c: make msvc happier adding a dummy variable
     284        * src/temporal/filter.c: check parameters, fix filter_do_outplace to really
     285        avoid modifying input
     286        * src/utils/windll.c: add dll main entry point
     287
     288        [ Python ]
     289
     290        * General:
     291          - new build system, new code generator
     292          - Python 3 compatibility (#33), thanks to Nils Philippsen (@nphilipp)
     293          - double precision compatibility
     294          - simplify memory allocations, removed unneeded malloc/free calls
     295          - fix memory leak (#49), check input sizes (#63) and output sizes (#60)
     296          - improve indentation, clean up unused imports and variables
     297          - fix comparison to None and to False
     298        * setup.py: move from python/setup.py, add option to build libaubio inside
     299        python-aubio (for instance with pip), add command 'generate' with option
     300        '--enable-double', build with -Wdeclaration-after-statement -Werror
     301        * python/ext/aubiomodule.c: fix PyMethodDef sentinel
     302        * python/ext/aubioproxy.c: factorize input checks into
     303        PyAubio_IsValidVector, fix windows c89 compilation, use npy_intp, not long
     304        * python/ext: rewrite and simplify, safer and improved memory usage (#49),
     305        improve error strings, verify actual object creation
     306        * python/ext/py-source.c: added duration, check seek is not negative
     307        * python/ext/py-musicutils.c: do not overwrite PyArg_ParseTuple messages
     308        * python/lib/gen_code.py: new generator, switch to using custom PyObjects
     309        instead of fvec, cvec, fmat, ready for double precision (defaults to single)
     310        * python/lib/aubio__init__.py: use new aubio.float_type, make sure length is
     311        not zero and float_type is imported
     312        * python/lib/aubio/midiconv.py: fix instance checks, make sure midi2note
     313        uses midi int (#33)
     314        * python/lib/aubio/slicing.py: fix samplerate
     315        * python/ext/aubio-types.h: add new_py_ functions to create PyObjects
     316        instead of fvec_t, apply to generated and hard-coded objects
     317        * python/lib/gen_external.py: improve compiler detection, fixes build on
     318        windows (#55)
     319        * python/lib/moresetuptools.py: helpers for windows and macos compilations
     320
     321        [  Python demos ]
     322
     323        * python/demos/demo_reading_speed.py: new reading speed tests, external
     324        packages disabled by default
     325        * python/demos/demo_timestretch.py: new timescale algorithm
     326        * python/demos/demo_timestretch_online.py: new timescale algorithm (online
     327        version)
     328        * python/demos/demo_create_test_sounds.py: add script to create simple sound
     329        files to test on using sox
     330        * python/demos/demo_a_weighting.py: add simple demo for a_weighting
     331        * python/demos/demo_filter.py: moved from _a_weighting
     332        * python/demos/demo_mfcc.py: use n_coeffs
     333        * python/demos/demo_bpm_extract.py: add exception type, avoid {} as default
     334        argument value
     335        * python/demos/demo_pysoundcard_*: update to pysoundcard 0.5.2 (closes #42)
     336        * python/scripts/aubiocut: fix usage string output
     337
     338        [ Python tests ]
     339
     340        * python/tests/run_all_tests,*.py: switch to nose2, fix most prospect warnings
     341        * python/tests/test_fvec.py: add test_pass_to_numpy, cope with accumulated
     342        errors
     343        * python/tests/test_cvec.py: simplify, add more tests
     344        * python/tests/test_fft.py: more tests, fft.do to clash on wrong size
     345        inputs, f.rdo input size, cvec is large enough, memory tests, avoid
     346        VisibleDeprecationWarning
     347        * python/tests/test_filterbank.py: check for wrong values, ValueError raised
     348        * python/tests/test_filter.py: add tests
     349        * python/tests/test_musicutils.py: simplify, check TypeError is raised
     350        * python/tests/test_mfcc.py: more tests, check for wrong input size (see #63)
     351        * python/tests/test_mathutils: fix test_miditobin test, can also raise
     352        NotImplementedError (darwin)
     353        * python/tests/test_note2midi.py: more tests, use unicode_literals
     354        * python/tests/test_phasevoc.py: add a note about ocasional crash check
     355        perfect reconstruction for overlap > 75% add 50% overlap test, fix duplicate
     356        test name, add wrong sized input tests
     357        * python/tests/test_sink.py: remove useless many_sinks_not_closed and cruft
     358        * python/tests/test_source.py: simplify, quieten, skip tests if no test sounds
     359        * python/tests/test_specdesc.py: check for wrong values, skip wrong name
     360        test, use correct input size (see #63)
     361        * python/tests/utils.py: try reopening the file is deleting it fails on windows
     362        * python/VERSION: removed, use same VERSION file for libaubio and python-aubio
     363        * MANIFEST.in: move from python/, update contents
     364        * nose2.cfg: add minimal config, set multiprocess always-on=false (fixes
     365        coverage, pass -N to speed up the tests)
     366
     367        [ Tools ]
     368
     369        * examples/*.c: add time format option
     370        * examples/{aubioonset,aubiotrack}.c: also emit midi note, thanks to
     371        @topas-rec (closes #62)
     372        * examples/: use outmsg to print notes (fixes #8)
     373        * examples/aubionotes.c: use new aubio_notes object
     374        * examples/aubiotrack.c: enable -O and -t options, fix is_beat/is_silence
     375        types
     376        * examples/{parse_args,utils}.h: check in config.h if getopt.h was found, or
     377        build without for msvc, more windows hacks
     378        * examples/utils.c: change send_noteon to accept floating point midi note number
     379
     380        [ Tests ]
     381
     382        * tests/src/io/test-source_apple_audio.c: shorten long line
     383        * tests/src/io/test-source_avcodec.c: use HAVE_LIBAV, closes #10
     384        * tests/src/temporal: avoid crash, clarify
     385        * tests/src/tempo/test-tempo.c: tempo back to only one output
     386        * tests/src/test-delnull.c: improve test, avoid segfaults
     387        * tests/src/test-lvec.c: use AUBIO_LSMP_FMT
     388        * tests/utils_tests.h: add VA_ARGS versions of variadic macros
     389        * tests/utils_tests.h: also use custom srandom/random when compiling with
     390        -std=c99
     391        * tests/utils_tests.h: make sure M_PI and RAND_MAX are defined
     392
     393        [ Build ]
     394
     395        * Makefile: set waf to 1.8.22 for now, new targets create_test_sounds,
     396        build_python, test_python, clean_python, build_python3, clean_python3,
     397        test_pure_python, test_pure_python_wheel, (use test_pure_* targets to build
     398        without libaubio), use 'HAVE_DOUBLE=1 make' to build in double precision
     399        * scripts/build_apple_frameworks: add script to build macosx and ios
     400        frameworks (see #34, #43)
     401        * scripts/build_emscripten: add script to build with emcc and co
     402        * scripts/build_mingw: add script to cross-compile using mingw
     403        * scripts/get_waf.sh: added simple script to fetch latest waf
     404        * scripts/setenv_local.sh: set environment to run from built source tree
     405        * scripts/setenv_local.sh: update to new python-aubio build location
     406        * tests/wscript_build: do not install test programs
     407        * tests/wscript_build, src/wscript_build: use 'use =', simplify
     408        * src/wscript_build: enable shared lib on ios, static lib on windows
     409        * wscript:
     410          - update --enable-foo to fail if foo is not found
     411          - add -mmacosx-version-min=10.4 on darwin
     412          - add '-fembed-bitcode' on ios (closes #31), min to 6.1
     413          - make fat build, add option to not build with Accelerate framework
     414          - add option to not build with CoreAudio/AudioToolbox
     415          - add --disable-docs option
     416          - add -lm detection
     417          - pass HAVE_AUBIO_DOUBLE in compiler arguments
     418          - first check for headers, make getopt.h and unistd.h optional
     419          - check HAVE_AV* from ctx.env
     420          - make msvc compiler quieter, add /MD and /D_CRT_SECURE_NO_WARNINGS
     421          - check if we find atlas/cblas.h
     422          - new build platform emscripten
     423          - more cleanups and updates
     424
     425        [ Only in git ]
     426
     427        * .travis.yml: config for https://travis-ci.org/aubio/aubio
     428        * .appveyor.yml: config for https://ci.appveyor.com/project/piem/aubio
     429        * .landscape.yml: config for https://landscape.io/github/aubio/aubio
     430        * conda recipes: see https://github.com/conda/conda-recipes#387
     431        * .gitignore: add python/tests/sounds and .egg-info
     432
     433        [ General ]
     434
     435        * src/: remove trailing spaces, improve doxygen strings, update copyrights,
     436        fix typos
     437        * src/onset/onset.h: fix description of get/set_delay functions
     438        * src/spectral/mfcc.h: add link to reference implementation
     439        * src/spectral/filterbank_mel.h: update reference url
     440        * src/musicutils.h: update link to Bernardini's paper, improve doc
     441        * doc/aubiomfcc.txt: add a note about the output
     442        * doc/*.cfg: update to Doxygen 1.8.8
     443        * python/README.md: fix typo (thanks to Sam Alexander), document how to
     444        build in a virtualenv (see #2)
     445        * README.md: minor updates, link to python/README.md, switch to https
     446        * VERSION: bump to 0.4.3
     447
    14482015-08-01 Paul Brossier <piem@aubio.org>
    2449
  • Makefile

    r00d0275 r155cc10  
     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
     12WAFCMD=python waf
     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
     38
     39SOX=sox
     40
     41TESTSOUNDS := python/tests/sounds
     42
    143all: build
    244
     
    547
    648getwaf:
    7         curl https://waf.io/waf-1.8.14 > waf
    8         @[ -d wafilb ] || rm -fr waflib
    9         @chmod +x waf && ./waf --help > /dev/null
    10         @mv .waf*/waflib . && rm -fr .waf*
    11         @sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
    12         @chmod +x waf
    13 
    14 build: checkwaf
    15         ./waf configure
    16         ./waf build
     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*
     60
     61configure: checkwaf
     62        $(WAFCMD) configure $(WAFOPTS)
     63
     64build: configure
     65        $(WAFCMD) build $(WAFOPTS)
     66
     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
    1785
    1886build_python:
    19         cd python && ./setup.py build
     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
     132        # create links from ~/lib/lib* to build/src/lib*
     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
    20142
    21143clean_python:
    22         cd python && ./setup.py clean
    23 
    24 clean:
    25         ./waf clean
    26 
    27 distcheck: build
    28         ./waf distcheck
     144        ./setup.py clean
     145
     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
     161        $(WAFCMD) clean
     162
     163distclean:
     164        $(WAFCMD) distclean
     165        -rm -rf doc/_build/
     166        -rm -rf doc/web/
     167
     168check_distclean:
     169        make distclean
     170
     171distcheck: checkwaf
     172        $(WAFCMD) distcheck $(WAFOPTS)
    29173
    30174help:
    31         ./waf --help
     175        $(WAFCMD) --help
     176
     177create_test_sounds:
     178        -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
     179        -mkdir -p $(TESTSOUNDS)
     180        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"      trim 0 1s
     181        -$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav"   synth 5    brownnoise      vol 0.9
     182        -$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav"    synth 127s sine 440        vol 0.9
     183        -$(SOX) -r  8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav"      trim 0 30
     184        -$(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

    r00d0275 r155cc10  
    3131
    3232A python module to access the library functions is also provided. Please see
    33 the file `python/README` for more information on how to use it.
     33the file [`python/README.md`](python/README.md) for more information on how to
     34use it.
    3435
    3536Examples tools
     
    7172  https://aubio.org/documentation
    7273
    73 Installation and Build Instructions
    74 -----------------------------------
     74Build Instructions
     75------------------
    7576
    7677A number of distributions already include aubio. Check your favorite package
     
    8283    ./waf configure
    8384    ./waf build
    84     sudo ./waf install
    8585
    8686If waf is not found in the directory, you can download and install it with:
     
    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.
     91
     92Installation
     93------------
     94
     95To install aubio library and headers on your system, use:
     96
     97    sudo ./waf install
     98
     99To uninstall:
     100
     101    sudo ./waf uninstall
     102
     103If you don't have root access to install libaubio on your system, you can use
     104libaubio without installing libaubio either by setting `LD_LIBRARY_PATH`, or by
     105copying it to `~/lib`.
     106
     107On Linux, you should be able to set `LD_LIBRARY_PATH` with:
     108
     109    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/build/src
     110
     111On Mac OS X, a copy or a symlink can be made in `~/lib`:
     112
     113    $ mkdir -p ~/lib
     114    $ ln -sf $PWD/build/src/libaubio*.dylib ~/lib/
     115
     116Note on Mac OS X systems older than El Capitan (10.11), the `DYLD_LIBRARY_PATH`
     117variable can be set as follows:
     118
     119    $ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$PWD/build/src
    91120
    92121Credits and Publications
     
    134163
    135164To subscribe to the list, use the mailman form:
    136 http://lists.aubio.org/listinfo/aubio-user/
     165https://lists.aubio.org/listinfo/aubio-user/
    137166
    138167Alternatively, feel free to contact directly the author.
     
    142171---------------------------------
    143172
    144 Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org>
     173Copyright (C) 2003-2016 Paul Brossier <piem@aubio.org>
    145174
    146175aubio is free software: you can redistribute it and/or modify it under the
  • VERSION

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

    r00d0275 r155cc10  
    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

    r00d0275 r155cc10  
    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/aubiomfcc.txt

    r00d0275 r155cc10  
    77  aubiomfcc [[-i] source]
    88            [-r rate] [-B win] [-H hop]
     9            [-T time-format]
    910            [-v] [-h]
    1011
     
    3839  Defaults to 256.
    3940
     41  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
     42  seconds.
     43
    4044  -h, --help  Print a short help message and exit.
    4145
  • doc/aubionotes.txt

    r00d0275 r155cc10  
    99             [-O method] [-t thres]
    1010             [-p method] [-u unit] [-l thres]
     11             [-T time-format]
    1112             [-s sil]
    1213             [-j] [-v] [-h]
     
    5051  over-detections. Defaults to 0.3.
    5152
     53  -M, --minioi value  Set the minimum inter-onset interval, in seconds, the
     54  shortest interval between two consecutive notes. Defaults to 0.030
     55
    5256  -p, --pitch method  The pitch detection method to use. See PITCH METHODS
    5357  below. Defaults to 'default'.
     
    6468  will not be detected. A value of -20.0 would eliminate most onsets but the
    6569  loudest ones. A value of -90.0 would select all onsets. Defaults to -90.0.
     70
     71  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
     72  seconds.
    6673
    6774  -j, --jack  Use Jack input/output. You will need a Jack connection
  • doc/aubioonset.txt

    r00d0275 r155cc10  
    88             [-r rate] [-B win] [-H hop]
    99             [-O method] [-t thres]
     10             [-T time-format]
    1011             [-s sil] [-m] [-f]
    11              [-j] [-v] [-h]
     12             [-j] [-N miditap-note] [-V miditap-velo]
     13             [-v] [-h]
    1214
    1315DESCRIPTION
     
    4850
    4951  -t, --onset-threshold thres  Set the threshold value for the onset peak
    50   picking. Typical values are typically within 0.001 and 0.900. Defaults to
    51   0.1. Lower threshold values imply more onsets detected. Try 0.5 in case of
    52   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.
    5355
    54   -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
    5560  will not be detected. A value of -20.0 would eliminate most onsets but the
    5661  loudest ones. A value of -90.0 would select all onsets. Defaults to -90.0.
     62
     63  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
     64  seconds.
    5765
    5866  -m, --mix-input  Mix source signal to the output signal before writing to
     
    6371  -j, --jack  Use Jack input/output. You will need a Jack connection
    6472  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.
    6577
    6678  -h, --help  Print a short help message and exit.
  • doc/aubiopitch.txt

    r00d0275 r155cc10  
    88             [-r rate] [-B win] [-H hop]
    99             [-p method] [-u unit] [-l thres]
     10             [-T time-format]
    1011             [-s sil] [-f]
    1112             [-v] [-h] [-j]
     
    5960  will not be detected. A value of -20.0 would eliminate most onsets but the
    6061  loudest ones. A value of -90.0 would select all onsets. Defaults to -90.0.
     62
     63  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
     64  seconds.
    6165
    6266  -m, --mix-input  Mix source signal to the output signal before writing to
  • doc/aubioquiet.txt

    r00d0275 r155cc10  
    77  aubioquiet [[-i] source]
    88             [-r rate] [-B win] [-H hop]
     9             [-T time-format]
    910             [-s sil]
    1011             [-v] [-h]
     
    3940  will not be detected. Defaults to -90.0.
    4041
     42  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
     43  seconds.
     44
    4145  -h, --help  Print a short help message and exit.
    4246
  • doc/aubiotrack.txt

    r00d0275 r155cc10  
    77  aubiotrack [[-i] source] [-o sink]
    88             [-r rate] [-B win] [-H hop]
     9             [-T time-format]
    910             [-s sil] [-m]
    10              [-j] [-v] [-h]
     11             [-j] [-N miditap-note] [-V miditap-velo]
     12             [-v] [-h]
    1113
    1214DESCRIPTION
     
    5456  controller to feed aubio some signal and listen to its output.
    5557
     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
     62  -T, --timeformat format  Set time format (samples, ms, seconds). Defaults to
     63  seconds.
     64
    5665  -h, --help  Print a short help message and exit.
    5766
  • doc/conf.py

    r00d0275 r155cc10  
    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 -----------------------------------------------------
     
    4242# General information about the project.
    4343project = u'aubio'
    44 copyright = u'2014, Paul Brossier'
     44copyright = u'2016, Paul Brossier'
    4545
    4646# The version info for the project you're documenting, acts as replacement for
     
    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/full.cfg

    r00d0275 r155cc10  
    1 # Doxyfile 1.8.5
     1# Doxyfile 1.8.8
    22
    33# This file describes the settings to be used by the documentation system
     
    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
     
    7171CREATE_SUBDIRS         = NO
    7272
     73# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
     74# characters to appear in the names of generated files. If set to NO, non-ASCII
     75# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
     76# U+3044.
     77# The default value is: NO.
     78
     79ALLOW_UNICODE_NAMES    = NO
     80
    7381# The OUTPUT_LANGUAGE tag is used to specify the language in which all
    7482# documentation generated by doxygen is written. Doxygen will use this
    7583# information to generate all constant output in the proper language.
    76 # Possible values are: Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-
    77 # Traditional, Croatian, Czech, Danish, Dutch, English, Esperanto, Farsi,
    78 # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en,
    79 # Korean, Korean-en, Latvian, Norwegian, Macedonian, Persian, Polish,
    80 # Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish,
    81 # Turkish, Ukrainian and Vietnamese.
     84# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
     85# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
     86# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
     87# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
     88# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
     89# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
     90# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
     91# Ukrainian and Vietnamese.
    8292# The default value is: English.
    8393
     
    260270# using this tag. The format is ext=language, where ext is a file extension, and
    261271# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
    262 # C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make
    263 # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
    264 # (default is Fortran), use: inc=Fortran f=C.
     272# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
     273# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
     274# Fortran. In the later case the parser tries to guess whether the code is fixed
     275# or free formatted code, this is the default for Fortran type files), VHDL. For
     276# instance to make doxygen treat .inc files as Fortran files (default is PHP),
     277# and .f files as C (default is Fortran), use: inc=Fortran f=C.
    265278#
    266279# Note For files without extension you can use no_extension as a placeholder.
     
    501514SHOW_INCLUDE_FILES     = YES
    502515
     516# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
     517# grouped member an include statement to the documentation, telling the reader
     518# which file to include in order to use the member.
     519# The default value is: NO.
     520
     521SHOW_GROUPED_MEMB_INC  = NO
     522
    503523# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
    504524# files with double quotes in the documentation rather than with sharp brackets.
     
    522542# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
    523543# descriptions of file, namespace and class members alphabetically by member
    524 # name. If set to NO the members will appear in declaration order.
     544# name. If set to NO the members will appear in declaration order. Note that
     545# this will also influence the order of the classes in the class list.
    525546# The default value is: NO.
    526547
     
    660681# For LaTeX the style of the bibliography can be controlled using
    661682# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
    662 # search path. Do not use file names with spaces, bibtex cannot handle them. See
    663 # also \cite for info how to create references.
     683# search path. See also \cite for info how to create references.
    664684
    665685CITE_BIB_FILES         =
     
    959979
    960980VERBATIM_HEADERS       = YES
     981
     982# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the
     983# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
     984# cost of reduced performance. This can be particularly helpful with template
     985# rich C++ code for which doxygen's built-in parser lacks the necessary type
     986# information.
     987# Note: The availability of this option depends on whether or not doxygen was
     988# compiled with the --with-libclang option.
     989# The default value is: NO.
     990
     991CLANG_ASSISTED_PARSING = NO
     992
     993# If clang assisted parsing is enabled you can provide the compiler with command
     994# line options that you would normally use when invoking the compiler. Note that
     995# the include paths will already be set by doxygen for the files and directories
     996# specified with INPUT and INCLUDE_PATH.
     997# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
     998
     999CLANG_OPTIONS          =
    9611000
    9621001#---------------------------------------------------------------------------
     
    10521091HTML_STYLESHEET        =
    10531092
    1054 # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-
    1055 # defined cascading style sheet that is included after the standard style sheets
     1093# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
     1094# cascading style sheets that are included after the standard style sheets
    10561095# created by doxygen. Using this option one can overrule certain style aspects.
    10571096# This is preferred over using HTML_STYLESHEET since it does not replace the
    10581097# standard style sheet and is therefor more robust against future updates.
    1059 # Doxygen will copy the style sheet file to the output directory. For an example
    1060 # see the documentation.
     1098# Doxygen will copy the style sheet files to the output directory.
     1099# Note: The order of the extra stylesheet files is of importance (e.g. the last
     1100# stylesheet in the list overrules the setting of the previous ones in the
     1101# list). For an example see the documentation.
    10611102# This tag requires that the tag GENERATE_HTML is set to YES.
    10621103
     
    12231264
    12241265# The BINARY_TOC flag controls whether a binary table of contents is generated (
    1225 # YES) or a normal table of contents ( NO) in the .chm file.
     1266# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
     1267# enables the Previous and Next buttons.
    12261268# The default value is: NO.
    12271269# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
     
    14231465# This tag requires that the tag USE_MATHJAX is set to YES.
    14241466
    1425 MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
     1467MATHJAX_RELPATH        = https://cdn.mathjax.org/mathjax/latest
    14261468
    14271469# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
     
    14631505# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
    14641506# implemented using a web server instead of a web client using Javascript. There
    1465 # are two flavours of web server based searching depending on the
    1466 # EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for
    1467 # searching and an index file used by the script. When EXTERNAL_SEARCH is
    1468 # enabled the indexing and searching needs to be provided by external tools. See
    1469 # the section "External Indexing and Searching" for details.
     1507# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
     1508# setting. When disabled, doxygen will generate a PHP script for searching and
     1509# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
     1510# and searching needs to be provided by external tools. See the section
     1511# "External Indexing and Searching" for details.
    14701512# The default value is: NO.
    14711513# This tag requires that the tag SEARCHENGINE is set to YES.
     
    15951637# Note: Only use a user-defined header if you know what you are doing! The
    15961638# following commands have a special meaning inside the header: $title,
    1597 # $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will
    1598 # replace them by respectively the title of the page, the current date and time,
    1599 # only the current date, the version number of doxygen, the project name (see
    1600 # PROJECT_NAME), or the project number (see PROJECT_NUMBER).
     1639# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
     1640# $projectbrief, $projectlogo. Doxygen will replace $title with the empy string,
     1641# for the replacement values of the other commands the user is refered to
     1642# HTML_HEADER.
    16011643# This tag requires that the tag GENERATE_LATEX is set to YES.
    16021644
     
    16051647# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
    16061648# generated LaTeX document. The footer should contain everything after the last
    1607 # chapter. If it is left blank doxygen will generate a standard footer.
     1649# chapter. If it is left blank doxygen will generate a standard footer. See
     1650# LATEX_HEADER for more information on how to generate a default footer and what
     1651# special commands can be used inside the footer.
    16081652#
    16091653# Note: Only use a user-defined footer if you know what you are doing!
     
    16291673PDF_HYPERLINKS         = YES
    16301674
    1631 # If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
     1675# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
    16321676# the PDF file directly from the LaTeX files. Set this option to YES to get a
    16331677# higher quality PDF documentation.
     
    17551799MAN_EXTENSION          = .3
    17561800
     1801# The MAN_SUBDIR tag determines the name of the directory created within
     1802# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
     1803# MAN_EXTENSION with the initial . removed.
     1804# This tag requires that the tag GENERATE_MAN is set to YES.
     1805
     1806MAN_SUBDIR             =
     1807
    17571808# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
    17581809# will generate one additional man file for each entity documented in the real
     
    17821833XML_OUTPUT             = xml
    17831834
    1784 # The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
    1785 # validating XML parser to check the syntax of the XML files.
    1786 # This tag requires that the tag GENERATE_XML is set to YES.
    1787 
    1788 XML_SCHEMA             =
    1789 
    1790 # The XML_DTD tag can be used to specify a XML DTD, which can be used by a
    1791 # validating XML parser to check the syntax of the XML files.
    1792 # This tag requires that the tag GENERATE_XML is set to YES.
    1793 
    1794 XML_DTD                =
    1795 
    17961835# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
    17971836# listings (including syntax highlighting and cross-referencing information) to
     
    18201859
    18211860DOCBOOK_OUTPUT         = docbook
     1861
     1862# If the DOCBOOK_PROGRAMLISTING tag is set to YES doxygen will include the
     1863# program listings (including syntax highlighting and cross-referencing
     1864# information) to the DOCBOOK output. Note that enabling this will significantly
     1865# increase the size of the DOCBOOK output.
     1866# The default value is: NO.
     1867# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
     1868
     1869DOCBOOK_PROGRAMLISTING = NO
    18221870
    18231871#---------------------------------------------------------------------------
     
    19401988
    19411989# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
    1942 # remove all refrences to function-like macros that are alone on a line, have an
    1943 # all uppercase name, and do not end with a semicolon. Such function macros are
    1944 # typically used for boiler-plate code, and will confuse the parser if not
     1990# remove all references to function-like macros that are alone on a line, have
     1991# an all uppercase name, and do not end with a semicolon. Such function macros
     1992# are typically used for boiler-plate code, and will confuse the parser if not
    19451993# removed.
    19461994# The default value is: YES.
     
    19622010# section "Linking to external documentation" for more information about the use
    19632011# of tag files.
    1964 # Note: Each tag file must have an unique name (where the name does NOT include
     2012# Note: Each tag file must have a unique name (where the name does NOT include
    19652013# the path). If a tag file is not located in the directory in which doxygen is
    19662014# run, you must also specify the path to the tagfile here.
     
    20222070MSCGEN_PATH            =
    20232071
     2072# You can include diagrams made with dia in doxygen documentation. Doxygen will
     2073# then run dia to produce the diagram and insert it in the documentation. The
     2074# DIA_PATH tag allows you to specify the directory where the dia binary resides.
     2075# If left empty dia is assumed to be found in the default search path.
     2076
     2077DIA_PATH               =
     2078
    20242079# If set to YES, the inheritance and collaboration graphs will hide inheritance
    20252080# and usage relations if the target is undocumented or is not a class.
     
    20332088# Bell Labs. The other options in this section have no effect if this option is
    20342089# set to NO
    2035 # The default value is: NO.
     2090# The default value is: YES.
    20362091
    20372092HAVE_DOT               = NO
     
    20472102DOT_NUM_THREADS        = 0
    20482103
    2049 # When you want a differently looking font n the dot files that doxygen
     2104# When you want a differently looking font in the dot files that doxygen
    20502105# generates you can specify the font name using DOT_FONTNAME. You need to make
    20512106# sure dot is able to find the font, which can be done by putting it in a
     
    21852240# to make the SVG files visible in IE 9+ (other browsers do not have this
    21862241# requirement).
    2187 # Possible values are: png, jpg, gif and svg.
     2242# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
     2243# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
     2244# gif:cairo:gd, gif:gd, gif:gd:gd and svg.
    21882245# The default value is: png.
    21892246# This tag requires that the tag HAVE_DOT is set to YES.
     
    22212278
    22222279MSCFILE_DIRS           =
     2280
     2281# The DIAFILE_DIRS tag can be used to specify one or more directories that
     2282# contain dia files that are included in the documentation (see the \diafile
     2283# command).
     2284
     2285DIAFILE_DIRS           =
     2286
     2287# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
     2288# path where java can find the plantuml.jar file. If left blank, it is assumed
     2289# PlantUML is not used or called during a preprocessing step. Doxygen will
     2290# generate a warning when it encounters a \startuml command in this case and
     2291# will not generate output for the diagram.
     2292# This tag requires that the tag HAVE_DOT is set to YES.
     2293
     2294PLANTUML_JAR_PATH      =
    22232295
    22242296# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
  • doc/index.rst

    r00d0275 r155cc10  
    1 aubio documentation
    2 ===================
     1Welcome
     2=======
    33
    4 aubio is a collection of algorithms and tools to label music and sounds. It
    5 listens to audio signals and attempts to detect events. For instance, when a
    6 drum is hit, at which frequency is a note, or at what tempo is a rhythmic
    7 melody.
     4aubio is a collection of algorithms and tools to label and transform music and
     5sounds. It scans or `listens` to audio signals and attempts to detect musical
     6events. For instance, when a drum is hit, at which frequency is a note, or at
     7what tempo is a rhythmic melody.
    88
    9 Its features include segmenting a sound file before each of its attacks,
     9aubio features include segmenting a sound file before each of its attacks,
    1010performing pitch detection, tapping the beat and producing midi streams from
    1111live audio.
    1212
    13 aubio provide several algorithms and routines, including:
     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/>`_
     44
     45Features
     46========
     47
     48aubio provides several algorithms and routines, including:
    1449
    1550- several onset detection methods
     
    2257- spectral filtering
    2358- transient/steady-state separation
    24 - sound file and audio devices read and write access
     59- sound file read and write access
    2560- various mathematics utilities for music applications
    2661
     
    2863found in the results.
    2964
    30 Python module
    31 -------------
     65Copyright
     66=========
    3267
    33 A python module to access the library functions is also provided. Please see
    34 the file ``python/README`` for more information on how to use it.
     68Copyright © 2003-2016 Paul Brossier <piem@aubio.org>
    3569
    36 Examples tools
    37 --------------
     70License
     71=======
    3872
    39 A few simple command line tools are included along with the library:
     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.
    4080
    41  - ``aubioonset`` outputs the time stamp of detected note onsets
    42  - ``aubiopitch`` attempts to identify a fundamental frequency, or pitch, for
    43    each frame of the input sound
    44  - ``aubiomfcc`` computes Mel-frequency Cepstrum Coefficients
    45  - ``aubiotrack`` outputs the time stamp of detected beats
    46  - ``aubionotes`` emits midi-like notes, with an onset, a pitch, and a duration
    47  - ``aubioquiet`` extracts quiet and loud regions
     81.. note::
    4882
    49 Additionally, the python module comes with the following script:
     83   aubio is not MIT or BSD licensed. Contact the author if you need it in your
     84   commercial product.
    5085
    51  - ``aubiocut`` slices sound files at onset or beat timestamps
    52 
    53 C API basics
    54 ------------
    55 
    56 The library is written in C and is optimised for speed and portability.
    57 
    58 The C API is designed in the following way:
    59 
    60 .. code-block:: c
    61 
    62     aubio_something_t * new_aubio_something(void * args);
    63     audio_something_do(aubio_something_t * t, void * args);
    64     smpl_t aubio_something_get_a_parameter(aubio_something_t * t);
    65     uint_t aubio_something_set_a_parameter(aubio_something_t * t, smpl_t a_parameter);
    66     void del_aubio_something(aubio_something_t * t);
    67 
    68 For performance and real-time operation, no memory allocation or freeing take
    69 place in the ``_do`` methods. Instead, memory allocation should always take place
    70 in the ``new_`` methods, whereas free operations are done in the ``del_`` methods.
    71 
    72 .. code-block:: bash
    73 
    74     ./waf configure
    75     ./waf build
    76     sudo ./waf install
    77 
    78 aubio compiles on Linux, Mac OS X, Cygwin, and iPhone.
    79 
    80 Documentation
    81 -------------
    82 
    83 - Manual pages: http://aubio.org/documentation
    84 - API documentation: http://aubio.org/doc/latest/
    85 
    86 Contribute
    87 ----------
    88 
    89 - Issue Tracker: https://github.com/piem/aubio/issues
    90 - Source Code: https://github.com/piem/aubio
    91 
    92 Contact info
    93 ------------
    94 
    95 The home page of this project can be found at: http://aubio.org/
    96 
    97 Questions, comments, suggestions, and contributions are welcome. Use the
    98 mailing list: <aubio-user@aubio.org>.
    99 
    100 To subscribe to the list, use the mailman form:
    101 http://lists.aubio.org/listinfo/aubio-user/
    102 
    103 Alternatively, feel free to contact directly the author.
    104 
    105 
    106 Contents
    107 --------
     86Content
     87=======
    10888
    10989.. toctree::
    110    :maxdepth: 1
     90   :maxdepth: 2
    11191
    11292   installing
    11393   python_module
     94   cli
     95   develop
  • doc/installing.rst

    r00d0275 r155cc10  
    1 .. highlight:: bash
    2 
    31Installing aubio
    42================
    53
    6 A number of distributions already include aubio. Check your favorite package
    7 management system, or have a look at the `download page
    8 <http://aubio.org/download>`_.
     4aubio runs on Linux, Windows, macOS, iOS, Android, and probably a few others
     5operating systems.
    96
    10 aubio uses `waf <https://waf.io/>`_ to configure, compile, and test the source.
    11 A copy of ``waf`` is included along aubio, so all you need is a ``terminal``
    12 and a recent ``python`` installed.
     7To download a pre-compiled version of the library, head to :ref:`download`.
    138
    14 Source code
    15 -----------
     9To install the python extension, head to :ref:`python`.
    1610
    17 Check out the `download page <http://aubio.org/download>`_ for more options:
    18 http://aubio.org/download.
     11To compile aubio form source, first check the :ref:`requirements`, then read
     12:ref:`building`.
    1913
    20 The latest stable release can be found at http://aubio.org/pub/::
     14.. toctree::
     15   :maxdepth: 2
    2116
    22         $ curl -O http://aubio.org/pub/aubio-0.4.1.tar.bz2
    23         $ tar xf aubio-0.4.1.tar.bz2
    24         $ cd aubio-0.4.1
    25 
    26 The latest develop branch can be obtained with::
    27 
    28         $ git clone git://git.aubio.org/git/aubio/ aubio-devel
    29         $ cd aubio-devel
    30         $ git fetch origin develop:develop
    31         $ git checkout develop
    32 
    33 Compiling
    34 ---------
    35 
    36 To compile the C library, examples programs, and tests, run::
    37 
    38         $ ./waf configure
    39 
    40 Check out the available options using ``./waf configure --help | less``. Once
    41 you are done with configuration, you can start building::
    42 
    43         $ ./waf build
    44 
    45 To install the freshly built C library and tools, simply run the following
    46 command::
    47 
    48         $ sudo ./waf install
    49 
    50 Cleaning
    51 --------
    52 
    53 If you wish to uninstall the files installed by the ``install`` command, use
    54 ``uninstall``::
    55 
    56         $ sudo ./waf uninstall
    57 
    58 To clean the source directory, use the ``clean`` command::
    59 
    60         $ ./waf clean
    61 
    62 To also forget the options previously passed to the last ``./waf configure``
    63 invocation, use the ``distclean`` command::
    64 
    65         $ ./waf distclean
     17   download
     18   building
     19   requirements
  • doc/python_module.rst

    r00d0275 r155cc10  
    1 aubio Python module
    2 ===================
     1.. _python:
     2
     3Python module
     4=============
     5
     6The aubio extension for Python is available for Python 2.7 and Python 3.
     7
     8Installing aubio with pip
     9-------------------------
     10
     11aubio can now be installed using ``pip``:
     12
     13.. code-block:: bash
     14
     15    $ pip install aubio
    316
    417Building the module
     
    922.. code-block:: bash
    1023
    11     $ cd python
     24    $ ./setup.py clean
    1225    $ ./setup.py build
    1326    $ sudo ./setup.py install
    1427
    15 Using the module
    16 ----------------
     28Using aubio in python
     29---------------------
    1730
    18 To use the python module, simply import aubio:
     31Once you have python-aubio installed, you should be able to run ``python -c
     32"import aubio; print(aubio.version)"``.
    1933
    20 .. code-block:: python
     34A simple example
     35................
    2136
    22         #! /usr/bin/env python
    23         import aubio
     37Here is a :download:`simple script <../python/demos/demo_source_simple.py>`
     38that reads all the samples from a media file:
    2439
    25         s = aubio.source(sys.argv[1], 0, 256)
    26         while True:
    27           samples, read = s()
    28           print samples
    29           if read < 256: break
     40.. literalinclude:: ../python/demos/demo_source_simple.py
     41   :language: python
    3042
    31 Check out the `python demos for aubio
    32 <https://github.com/piem/aubio/blob/develop/python/demos/>`_ for more examples.
     43Filtering an input sound file
     44.............................
    3345
     46Here is a more complete example, :download:`demo_filter.py
     47<../python/demos/demo_filter.py>`. This files executes the following:
     48
     49* read an input media file (``aubio.source``)
     50
     51* filter it using an `A-weighting <https://en.wikipedia.org/wiki/A-weighting>`_
     52  filter (``aubio.digital_filter``)
     53
     54* write result to a new file (``aubio.sink``)
     55
     56.. literalinclude:: ../python/demos/demo_filter.py
     57   :language: python
     58
     59More demos
     60..........
     61
     62Check out the `python demos folder`_ for more examples.
     63
     64Python tests
     65------------
     66
     67A number of `python tests`_ are provided. To run them, use
     68``python/tests/run_all_tests``.
     69
     70.. _python demos folder: https://github.com/aubio/aubio/blob/master/python/demos
     71.. _demo_filter.py: https://github.com/aubio/aubio/blob/master/python/demos/demo_filter.py
     72.. _python tests: https://github.com/aubio/aubio/blob/master/python/tests
     73
  • doc/web.cfg

    r00d0275 r155cc10  
    1 # Doxyfile 1.8.5
     1# Doxyfile 1.8.8
    22
    33# This file describes the settings to be used by the documentation system
     
    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
     
    7171CREATE_SUBDIRS         = NO
    7272
     73# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
     74# characters to appear in the names of generated files. If set to NO, non-ASCII
     75# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
     76# U+3044.
     77# The default value is: NO.
     78
     79ALLOW_UNICODE_NAMES    = NO
     80
    7381# The OUTPUT_LANGUAGE tag is used to specify the language in which all
    7482# documentation generated by doxygen is written. Doxygen will use this
    7583# information to generate all constant output in the proper language.
    76 # Possible values are: Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-
    77 # Traditional, Croatian, Czech, Danish, Dutch, English, Esperanto, Farsi,
    78 # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en,
    79 # Korean, Korean-en, Latvian, Norwegian, Macedonian, Persian, Polish,
    80 # Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish,
    81 # Turkish, Ukrainian and Vietnamese.
     84# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
     85# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
     86# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
     87# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
     88# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
     89# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
     90# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
     91# Ukrainian and Vietnamese.
    8292# The default value is: English.
    8393
     
    260270# using this tag. The format is ext=language, where ext is a file extension, and
    261271# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
    262 # C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make
    263 # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
    264 # (default is Fortran), use: inc=Fortran f=C.
     272# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
     273# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
     274# Fortran. In the later case the parser tries to guess whether the code is fixed
     275# or free formatted code, this is the default for Fortran type files), VHDL. For
     276# instance to make doxygen treat .inc files as Fortran files (default is PHP),
     277# and .f files as C (default is Fortran), use: inc=Fortran f=C.
    265278#
    266279# Note For files without extension you can use no_extension as a placeholder.
     
    501514SHOW_INCLUDE_FILES     = YES
    502515
     516# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
     517# grouped member an include statement to the documentation, telling the reader
     518# which file to include in order to use the member.
     519# The default value is: NO.
     520
     521SHOW_GROUPED_MEMB_INC  = NO
     522
    503523# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
    504524# files with double quotes in the documentation rather than with sharp brackets.
     
    522542# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
    523543# descriptions of file, namespace and class members alphabetically by member
    524 # name. If set to NO the members will appear in declaration order.
     544# name. If set to NO the members will appear in declaration order. Note that
     545# this will also influence the order of the classes in the class list.
    525546# The default value is: NO.
    526547
     
    660681# For LaTeX the style of the bibliography can be controlled using
    661682# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
    662 # search path. Do not use file names with spaces, bibtex cannot handle them. See
    663 # also \cite for info how to create references.
     683# search path. See also \cite for info how to create references.
    664684
    665685CITE_BIB_FILES         =
     
    771791EXCLUDE                = ../src/aubio_priv.h \
    772792                         ../src/mathutils.h \
     793                         ../src/io/ioutils.h \
    773794                         ../src/io/audio_unit.h \
    774795                         ../src/io/source_sndfile.h \
     
    9791000VERBATIM_HEADERS       = YES
    9801001
     1002# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the
     1003# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
     1004# cost of reduced performance. This can be particularly helpful with template
     1005# rich C++ code for which doxygen's built-in parser lacks the necessary type
     1006# information.
     1007# Note: The availability of this option depends on whether or not doxygen was
     1008# compiled with the --with-libclang option.
     1009# The default value is: NO.
     1010
     1011CLANG_ASSISTED_PARSING = NO
     1012
     1013# If clang assisted parsing is enabled you can provide the compiler with command
     1014# line options that you would normally use when invoking the compiler. Note that
     1015# the include paths will already be set by doxygen for the files and directories
     1016# specified with INPUT and INCLUDE_PATH.
     1017# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
     1018
     1019CLANG_OPTIONS          =
     1020
    9811021#---------------------------------------------------------------------------
    9821022# Configuration options related to the alphabetical class index
     
    10711111HTML_STYLESHEET        =
    10721112
    1073 # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-
    1074 # defined cascading style sheet that is included after the standard style sheets
     1113# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
     1114# cascading style sheets that are included after the standard style sheets
    10751115# created by doxygen. Using this option one can overrule certain style aspects.
    10761116# This is preferred over using HTML_STYLESHEET since it does not replace the
    10771117# standard style sheet and is therefor more robust against future updates.
    1078 # Doxygen will copy the style sheet file to the output directory. For an example
    1079 # see the documentation.
     1118# Doxygen will copy the style sheet files to the output directory.
     1119# Note: The order of the extra stylesheet files is of importance (e.g. the last
     1120# stylesheet in the list overrules the setting of the previous ones in the
     1121# list). For an example see the documentation.
    10801122# This tag requires that the tag GENERATE_HTML is set to YES.
    10811123
     
    12421284
    12431285# The BINARY_TOC flag controls whether a binary table of contents is generated (
    1244 # YES) or a normal table of contents ( NO) in the .chm file.
     1286# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
     1287# enables the Previous and Next buttons.
    12451288# The default value is: NO.
    12461289# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
     
    14421485# This tag requires that the tag USE_MATHJAX is set to YES.
    14431486
    1444 MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
     1487MATHJAX_RELPATH        = https://cdn.mathjax.org/mathjax/latest
    14451488
    14461489# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
     
    14821525# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
    14831526# implemented using a web server instead of a web client using Javascript. There
    1484 # are two flavours of web server based searching depending on the
    1485 # EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for
    1486 # searching and an index file used by the script. When EXTERNAL_SEARCH is
    1487 # enabled the indexing and searching needs to be provided by external tools. See
    1488 # the section "External Indexing and Searching" for details.
     1527# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
     1528# setting. When disabled, doxygen will generate a PHP script for searching and
     1529# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
     1530# and searching needs to be provided by external tools. See the section
     1531# "External Indexing and Searching" for details.
    14891532# The default value is: NO.
    14901533# This tag requires that the tag SEARCHENGINE is set to YES.
     
    16141657# Note: Only use a user-defined header if you know what you are doing! The
    16151658# following commands have a special meaning inside the header: $title,
    1616 # $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will
    1617 # replace them by respectively the title of the page, the current date and time,
    1618 # only the current date, the version number of doxygen, the project name (see
    1619 # PROJECT_NAME), or the project number (see PROJECT_NUMBER).
     1659# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
     1660# $projectbrief, $projectlogo. Doxygen will replace $title with the empy string,
     1661# for the replacement values of the other commands the user is refered to
     1662# HTML_HEADER.
    16201663# This tag requires that the tag GENERATE_LATEX is set to YES.
    16211664
     
    16241667# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
    16251668# generated LaTeX document. The footer should contain everything after the last
    1626 # chapter. If it is left blank doxygen will generate a standard footer.
     1669# chapter. If it is left blank doxygen will generate a standard footer. See
     1670# LATEX_HEADER for more information on how to generate a default footer and what
     1671# special commands can be used inside the footer.
    16271672#
    16281673# Note: Only use a user-defined footer if you know what you are doing!
     
    16481693PDF_HYPERLINKS         = YES
    16491694
    1650 # If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
     1695# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
    16511696# the PDF file directly from the LaTeX files. Set this option to YES to get a
    16521697# higher quality PDF documentation.
     
    17741819MAN_EXTENSION          = .3
    17751820
     1821# The MAN_SUBDIR tag determines the name of the directory created within
     1822# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
     1823# MAN_EXTENSION with the initial . removed.
     1824# This tag requires that the tag GENERATE_MAN is set to YES.
     1825
     1826MAN_SUBDIR             =
     1827
    17761828# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
    17771829# will generate one additional man file for each entity documented in the real
     
    18011853XML_OUTPUT             = xml
    18021854
    1803 # The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
    1804 # validating XML parser to check the syntax of the XML files.
    1805 # This tag requires that the tag GENERATE_XML is set to YES.
    1806 
    1807 XML_SCHEMA             =
    1808 
    1809 # The XML_DTD tag can be used to specify a XML DTD, which can be used by a
    1810 # validating XML parser to check the syntax of the XML files.
    1811 # This tag requires that the tag GENERATE_XML is set to YES.
    1812 
    1813 XML_DTD                =
    1814 
    18151855# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
    18161856# listings (including syntax highlighting and cross-referencing information) to
     
    18391879
    18401880DOCBOOK_OUTPUT         = docbook
     1881
     1882# If the DOCBOOK_PROGRAMLISTING tag is set to YES doxygen will include the
     1883# program listings (including syntax highlighting and cross-referencing
     1884# information) to the DOCBOOK output. Note that enabling this will significantly
     1885# increase the size of the DOCBOOK output.
     1886# The default value is: NO.
     1887# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
     1888
     1889DOCBOOK_PROGRAMLISTING = NO
    18411890
    18421891#---------------------------------------------------------------------------
     
    19592008
    19602009# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
    1961 # remove all refrences to function-like macros that are alone on a line, have an
    1962 # all uppercase name, and do not end with a semicolon. Such function macros are
    1963 # typically used for boiler-plate code, and will confuse the parser if not
     2010# remove all references to function-like macros that are alone on a line, have
     2011# an all uppercase name, and do not end with a semicolon. Such function macros
     2012# are typically used for boiler-plate code, and will confuse the parser if not
    19642013# removed.
    19652014# The default value is: YES.
     
    19812030# section "Linking to external documentation" for more information about the use
    19822031# of tag files.
    1983 # Note: Each tag file must have an unique name (where the name does NOT include
     2032# Note: Each tag file must have a unique name (where the name does NOT include
    19842033# the path). If a tag file is not located in the directory in which doxygen is
    19852034# run, you must also specify the path to the tagfile here.
     
    20412090MSCGEN_PATH            =
    20422091
     2092# You can include diagrams made with dia in doxygen documentation. Doxygen will
     2093# then run dia to produce the diagram and insert it in the documentation. The
     2094# DIA_PATH tag allows you to specify the directory where the dia binary resides.
     2095# If left empty dia is assumed to be found in the default search path.
     2096
     2097DIA_PATH               =
     2098
    20432099# If set to YES, the inheritance and collaboration graphs will hide inheritance
    20442100# and usage relations if the target is undocumented or is not a class.
     
    20522108# Bell Labs. The other options in this section have no effect if this option is
    20532109# set to NO
    2054 # The default value is: NO.
     2110# The default value is: YES.
    20552111
    20562112HAVE_DOT               = NO
     
    20662122DOT_NUM_THREADS        = 0
    20672123
    2068 # When you want a differently looking font n the dot files that doxygen
     2124# When you want a differently looking font in the dot files that doxygen
    20692125# generates you can specify the font name using DOT_FONTNAME. You need to make
    20702126# sure dot is able to find the font, which can be done by putting it in a
     
    22042260# to make the SVG files visible in IE 9+ (other browsers do not have this
    22052261# requirement).
    2206 # Possible values are: png, jpg, gif and svg.
     2262# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
     2263# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
     2264# gif:cairo:gd, gif:gd, gif:gd:gd and svg.
    22072265# The default value is: png.
    22082266# This tag requires that the tag HAVE_DOT is set to YES.
     
    22402298
    22412299MSCFILE_DIRS           =
     2300
     2301# The DIAFILE_DIRS tag can be used to specify one or more directories that
     2302# contain dia files that are included in the documentation (see the \diafile
     2303# command).
     2304
     2305DIAFILE_DIRS           =
     2306
     2307# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
     2308# path where java can find the plantuml.jar file. If left blank, it is assumed
     2309# PlantUML is not used or called during a preprocessing step. Doxygen will
     2310# generate a warning when it encounters a \startuml command in this case and
     2311# will not generate output for the diagram.
     2312# This tag requires that the tag HAVE_DOT is set to YES.
     2313
     2314PLANTUML_JAR_PATH      =
    22422315
    22432316# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
  • examples/aubiomfcc.c

    r00d0275 r155cc10  
    4949
    5050int main(int argc, char **argv) {
     51  int ret = 0;
    5152  // change some default params
    5253  buffer_size  = 512;
     
    6364  mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate);
    6465  mfcc_out = new_fvec(n_coefs);
     66  if (pv == NULL || fftgrain == NULL || mfcc == NULL || mfcc_out == NULL) {
     67    ret = 1;
     68    goto beach;
     69  }
    6570
    6671  examples_common_process((aubio_process_func_t)process_block, process_print);
     
    7176  del_fvec(mfcc_out);
    7277
     78beach:
    7379  examples_common_del();
    74   return 0;
     80  return ret;
    7581}
    76 
  • examples/aubionotes.c

    r00d0275 r155cc10  
    1919*/
    2020
    21 #define AUBIO_UNSTABLE 1 // for fvec_median
    2221#include "utils.h"
    2322#define PROG_HAS_PITCH 1
    2423#define PROG_HAS_ONSET 1
     24#define PROG_HAS_SILENCE 1
    2525#define PROG_HAS_JACK 1
    2626// TODO add PROG_HAS_OUTPUT
    2727#include "parse_args.h"
    2828
    29 uint_t median = 6;
    30 
    31 fvec_t *note_buffer;
    32 fvec_t *note_buffer2;
    33 
    34 smpl_t curnote = 0.;
    35 smpl_t newnote = 0.;
    36 uint_t isready = 0;
    37 
    38 aubio_pitch_t *pitch;
    39 aubio_onset_t *o;
    40 fvec_t *onset;
    41 fvec_t *pitch_obuf;
    42 
    43 /** append new note candidate to the note_buffer and return filtered value. we
    44  * need to copy the input array as fvec_median destroy its input data.*/
    45 void note_append (fvec_t * note_buffer, smpl_t curnote);
    46 uint_t get_note (fvec_t * note_buffer, fvec_t * note_buffer2);
     29aubio_notes_t *notes;
     30smpl_t lastmidi = 0.;
    4731
    4832void process_block (fvec_t *ibuf, fvec_t *obuf)
    4933{
    50   smpl_t new_pitch, curlevel;
    51   fvec_zeros(obuf);
    52   aubio_onset_do(o, ibuf, onset);
    53 
    54   aubio_pitch_do (pitch, ibuf, pitch_obuf);
    55   new_pitch = fvec_get_sample(pitch_obuf, 0);
    56   if(median){
    57     note_append(note_buffer, new_pitch);
     34  aubio_notes_do (notes, ibuf, obuf);
     35  // did we get a note off?
     36  if (obuf->data[2] != 0) {
     37    lastmidi = obuf->data[2];
     38    send_noteon(lastmidi, 0);
    5839  }
    59 
    60   /* curlevel is negatif or 1 if silence */
    61   curlevel = aubio_level_detection(ibuf, silence_threshold);
    62   if (fvec_get_sample(onset, 0)) {
    63     /* test for silence */
    64     if (curlevel == 1.) {
    65       if (median) isready = 0;
    66       /* send note off */
    67       send_noteon(curnote,0);
    68     } else {
    69       if (median) {
    70         isready = 1;
    71       } else {
    72         /* kill old note */
    73         send_noteon(curnote,0);
    74         /* get and send new one */
    75         send_noteon(new_pitch,127+(int)floor(curlevel));
    76         curnote = new_pitch;
    77       }
    78     }
    79   } else {
    80     if (median) {
    81       if (isready > 0)
    82         isready++;
    83       if (isready == median)
    84       {
    85         /* kill old note */
    86         send_noteon(curnote,0);
    87         newnote = get_note(note_buffer, note_buffer2);
    88         curnote = newnote;
    89         /* get and send new one */
    90         if (curnote>45){
    91           send_noteon(curnote,127+(int)floor(curlevel));
    92         }
    93       }
    94     } // if median
     40  // did we get a note on?
     41  if (obuf->data[0] != 0) {
     42    lastmidi = obuf->data[0];
     43    send_noteon(lastmidi, obuf->data[1]);
    9544  }
    9645}
     
    10150}
    10251
    103 void
    104 note_append (fvec_t * note_buffer, smpl_t curnote)
    105 {
    106   uint_t i = 0;
    107   for (i = 0; i < note_buffer->length - 1; i++) {
    108     note_buffer->data[i] = note_buffer->data[i + 1];
    109   }
    110   note_buffer->data[note_buffer->length - 1] = curnote;
    111   return;
    112 }
     52int main(int argc, char **argv) {
     53  int ret = 0;
    11354
    114 uint_t
    115 get_note (fvec_t * note_buffer, fvec_t * note_buffer2)
    116 {
    117   uint_t i;
    118   for (i = 0; i < note_buffer->length; i++) {
    119     note_buffer2->data[i] = note_buffer->data[i];
    120   }
    121   return fvec_median (note_buffer2);
    122 }
    123 
    124 int main(int argc, char **argv) {
    12555  examples_common_init(argc,argv);
    12656
     
    13767  verbmsg ("tolerance: %f\n", pitch_tolerance);
    13868
    139   o = new_aubio_onset (onset_method, buffer_size, hop_size, samplerate);
    140   if (onset_threshold != 0.) aubio_onset_set_threshold (o, onset_threshold);
    141   onset = new_fvec (1);
     69  notes = new_aubio_notes ("default", buffer_size, hop_size, samplerate);
     70  if (notes == NULL) { ret = 1; goto beach; }
    14271
    143   pitch = new_aubio_pitch (pitch_method, buffer_size * 4, hop_size, samplerate);
    144   if (pitch_tolerance != 0.) aubio_pitch_set_tolerance (pitch, pitch_tolerance);
    145   pitch_obuf = new_fvec (1);
    146 
    147   if (median) {
    148       note_buffer = new_fvec (median);
    149       note_buffer2 = new_fvec (median);
     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    }
    15084  }
    15185
    15286  examples_common_process((aubio_process_func_t)process_block, process_print);
    15387
    154   // send a last note off
    155   send_noteon (curnote, 0);
     88  // send a last note off if required
     89  if (lastmidi) {
     90    send_noteon (lastmidi, 0);
     91  }
    15692
    157   del_aubio_pitch (pitch);
    158   if (median) {
    159       del_fvec (note_buffer);
    160       del_fvec (note_buffer2);
    161   }
    162   del_fvec (pitch_obuf);
     93  del_aubio_notes (notes);
    16394
     95beach:
    16496  examples_common_del();
    165   return 0;
     97  return ret;
    16698}
    167 
  • examples/aubioonset.c

    r00d0275 r155cc10  
    2222#define PROG_HAS_ONSET 1
    2323#define PROG_HAS_OUTPUT 1
     24#define PROG_HAS_SILENCE 1
    2425#define PROG_HAS_JACK 1
    2526#include "parse_args.h"
     
    3839  if ( is_onset ) {
    3940    aubio_wavetable_play ( wavetable );
     41    /* send a midi tap (default to C0) out to the midi output */
     42    if (usejack) send_noteon(miditap_note, miditap_velo);
    4043  } else {
    4144    aubio_wavetable_stop ( wavetable );
     
    5659
    5760int main(int argc, char **argv) {
     61  int ret = 0;
    5862  examples_common_init(argc,argv);
    5963
     
    6670
    6771  o = new_aubio_onset (onset_method, buffer_size, hop_size, samplerate);
     72  if (o == NULL) { ret = 1; goto beach; }
    6873  if (onset_threshold != 0.)
    6974    aubio_onset_set_threshold (o, onset_threshold);
    7075  if (silence_threshold != -90.)
    7176    aubio_onset_set_silence (o, silence_threshold);
     77  if (onset_minioi != 0.)
     78    aubio_onset_set_minioi_s (o, onset_minioi);
    7279
    7380  onset = new_fvec (1);
     
    7986  examples_common_process((aubio_process_func_t)process_block, process_print);
    8087
     88  // send a last note off
     89  if (usejack) {
     90    send_noteon (miditap_note, 0);
     91  }
     92
    8193  del_aubio_onset (o);
    8294  del_aubio_wavetable (wavetable);
    8395  del_fvec (onset);
    8496
     97beach:
    8598  examples_common_del();
    86   return 0;
     99  return ret;
    87100}
  • examples/aubiopitch.c

    r00d0275 r155cc10  
    2222#define PROG_HAS_PITCH 1
    2323#define PROG_HAS_OUTPUT 1
     24#define PROG_HAS_SILENCE 1
    2425#define PROG_HAS_JACK 1
    2526#include "parse_args.h"
     
    5253
    5354int main(int argc, char **argv) {
     55  int ret = 0;
    5456
    5557  buffer_size = 2048;
     
    6567
    6668  o = new_aubio_pitch (pitch_method, buffer_size, hop_size, samplerate);
     69  if (o == NULL) { ret = 1; goto beach; }
    6770  if (pitch_tolerance != 0.)
    6871    aubio_pitch_set_tolerance (o, pitch_tolerance);
     
    8386  del_fvec (pitch);
    8487
     88beach:
    8589  examples_common_del();
    86   return 0;
     90  return ret;
    8791}
    88 
  • examples/aubioquiet.c

    r00d0275 r155cc10  
    2020
    2121#include "utils.h"
     22#define PROG_HAS_SILENCE 1
    2223#include "parse_args.h"
    2324
  • examples/aubiotrack.c

    r00d0275 r155cc10  
    2121#include "utils.h"
    2222#define PROG_HAS_TEMPO 1
     23#define PROG_HAS_ONSET 1
     24#define PROG_HAS_SILENCE 1
    2325#define PROG_HAS_OUTPUT 1
    2426#define PROG_HAS_JACK 1
     
    2830aubio_wavetable_t *wavetable;
    2931fvec_t * tempo_out;
    30 smpl_t is_beat = 0;
    31 uint_t is_silence = 0.;
     32smpl_t is_beat = 0.;
     33uint_t is_silence = 0;
    3234
    3335void process_block(fvec_t * ibuf, fvec_t *obuf) {
     
    4042  if ( is_beat && !is_silence ) {
    4143    aubio_wavetable_play ( wavetable );
     44    /* send a midi tap (default to C0) out to the midi output */
     45    if (usejack) send_noteon(miditap_note, miditap_velo);
    4246  } else {
    4347    aubio_wavetable_stop ( wavetable );
     
    5761
    5862int main(int argc, char **argv) {
     63  int ret = 0;
    5964  // override general settings from utils.c
    6065  buffer_size = 1024;
     
    7277  tempo_out = new_fvec(2);
    7378  tempo = new_aubio_tempo(tempo_method, buffer_size, hop_size, samplerate);
     79  if (tempo == NULL) { ret = 1; goto beach; }
    7480  // set silence threshold very low to output beats even during silence
    7581  // aubio_tempo_set_silence(tempo, -1000.);
    7682  if (onset_threshold != 0.) aubio_tempo_set_threshold (tempo, onset_threshold);
     83  if (onset_minioi != 0.) errmsg ("warning: minioio not supported yet\n");
    7784
    7885  wavetable = new_aubio_wavetable (samplerate, hop_size);
     
    8289  examples_common_process((aubio_process_func_t)process_block,process_print);
    8390
     91  // send a last note off
     92  if (usejack) {
     93    send_noteon (miditap_note, 0);
     94  }
     95
    8496  del_aubio_tempo(tempo);
    8597  del_aubio_wavetable (wavetable);
    8698  del_fvec(tempo_out);
    8799
     100beach:
    88101  examples_common_del();
    89   return 0;
     102  return ret;
    90103}
    91 
  • examples/jackio.c

    r00d0275 r155cc10  
    2222#include "config.h"
    2323
    24 #if HAVE_JACK
     24#ifdef HAVE_JACK
    2525#include "utils.h" // for aubio_process_func_t
    2626#include "jackio.h"
  • examples/parse_args.h

    r00d0275 r155cc10  
    1818
    1919*/
     20
     21#include "config.h"
     22
     23#ifdef HAVE_GETOPT_H
     24#include <getopt.h>
     25#endif
    2026
    2127extern int verbose;
     
    3137extern char_t * onset_method;
    3238extern smpl_t onset_threshold;
     39extern smpl_t onset_minioi;
    3340// pitch stuff
    3441extern char_t * pitch_method;
     
    4249extern smpl_t silence_threshold;
    4350extern uint_t mix_input;
     51// midi tap
     52extern smpl_t miditap_note;
     53extern smpl_t miditap_velo;
    4454
    4555extern uint_t force_overwrite;
     
    6474void usage (FILE * stream, int exit_code)
    6575{
     76#ifdef HAVE_GETOPT_H
    6677  fprintf (stream, "usage: %s [ options ] \n", prog_name);
    6778  fprintf (stream,
     
    8293      "       -t      --onset-threshold  set onset detection threshold\n"
    8394      "                 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"
    8497#endif /* PROG_HAS_ONSET */
    8598#ifdef PROG_HAS_PITCH
     
    91104      "                 (yin, yinfft only) a value between 0.1 and 0.7; default=0.3\n"
    92105#endif /* PROG_HAS_PITCH */
     106#ifdef PROG_HAS_SILENCE
    93107      "       -s      --silence          select silence threshold\n"
    94108      "                 a value in dB, for instance -70, or -100; default=-90\n"
     109#endif /* PROG_HAS_SILENCE */
    95110      "       -T      --time-format      select time values output format\n"
    96111      "                 (samples, ms, seconds) default=seconds\n"
     
    100115      "       -f      --force-overwrite  overwrite output file if needed\n"
    101116      "                 do not fail if output file already exists\n"
    102 #endif
     117#endif /* PROG_HAS_OUTPUT */
    103118#ifdef PROG_HAS_JACK
    104119      "       -j      --jack             use Jack\n"
    105 #endif
     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) */
     124#endif /* PROG_HAS_JACK */
    106125      "       -v      --verbose          be verbose\n"
    107126      "       -h      --help             display this message\n"
    108127      );
     128#else /* HAVE_GETOPT_H */
     129  fprintf (stream, "warning: compiled with getopt.h, no argument parsing\n");
     130  fprintf (stream, "usage: %s <filename> \n", prog_name);
     131#endif /* HAVE_GETOPT_H */
    109132  exit (exit_code);
    110133}
     
    113136parse_args (int argc, char **argv)
    114137{
     138#ifdef HAVE_GETOPT_H
    115139  const char *options = "hv"
    116140    "i:r:B:H:"
    117141#ifdef PROG_HAS_JACK
    118142    "j"
     143#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
     144    "N:V:"
     145#endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */
    119146#endif /* PROG_HAS_JACK */
    120147#ifdef PROG_HAS_OUTPUT
     
    122149#endif /* PROG_HAS_OUTPUT */
    123150#ifdef PROG_HAS_ONSET
    124     "O:t:"
     151    "O:t:M:"
    125152#endif /* PROG_HAS_ONSET */
    126153#ifdef PROG_HAS_PITCH
     
    128155#endif /* PROG_HAS_PITCH */
    129156    "T:"
    130     "s:mf";
     157#ifdef PROG_HAS_SILENCE
     158    "s:"
     159#endif /* PROG_HAS_SILENCE */
     160#ifdef PROG_HAS_OUTPUT
     161    "mf"
     162#endif /* PROG_HAS_OUTPUT */
     163    ;
    131164  int next_option;
    132165  struct option long_options[] = {
     
    139172#ifdef PROG_HAS_JACK
    140173    {"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 */
    141178#endif /* PROG_HAS_JACK */
    142179#ifdef PROG_HAS_OUTPUT
     
    146183    {"onset",                 1, NULL, 'O'},
    147184    {"onset-threshold",       1, NULL, 't'},
     185    {"onset-minioi",          1, NULL, 'M'},
    148186#endif /* PROG_HAS_ONSET */
    149187#ifdef PROG_HAS_PITCH
     
    152190    {"pitch-tolerance",       1, NULL, 'l'},
    153191#endif /* PROG_HAS_PITCH */
     192#ifdef PROG_HAS_SILENCE
    154193    {"silence",               1, NULL, 's'},
     194#endif /* PROG_HAS_SILENCE */
    155195    {"time-format",           1, NULL, 'T'},
     196#ifdef PROG_HAS_OUTPUT
    156197    {"mix-input",             0, NULL, 'm'},
    157198    {"force-overwrite",       0, NULL, 'f'},
     199#endif /* PROG_HAS_OUTPUT */
    158200    {NULL,                    0, NULL, 0}
    159201  };
     202#endif /* HAVE_GETOPT_H */
    160203  prog_name = argv[0];
    161204  if (argc < 1) {
     
    163206    return -1;
    164207  }
     208#ifdef HAVE_GETOPT_H
    165209  do {
    166210    next_option = getopt_long (argc, argv, options, long_options, NULL);
     
    175219        usejack = 1;
    176220        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;
    177227      case 'i':
    178228        source_uri = optarg;
     
    198248      case 't':                /* threshold value for onset */
    199249        onset_threshold = (smpl_t) atof (optarg);
     250        break;
     251      case 'M':                /* minimum inter-onset-interval */
     252        onset_minioi = (smpl_t) atof (optarg);
    200253        break;
    201254      case 'p':
     
    236289  }
    237290  while (next_option != -1);
     291#else /* HAVE_GETOPT_H */
     292  int optind = 1;
     293#endif /* HAVE_GETOPT_H */
    238294
    239295  // if unique, use the non option argument as the source
  • examples/utils.c

    r00d0275 r155cc10  
    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";
     
    6566fvec_t *obuf;
    6667
     68smpl_t miditap_note = 69.;
     69smpl_t miditap_velo = 65.;
     70
    6771/* settings */
    6872int blocks = 0;
     
    7377#if HAVE_JACK
    7478aubio_jack_t *jack_setup;
    75 #endif
     79jack_midi_event_t ev;
     80#endif /* HAVE_JACK */
    7681
    7782void examples_common_init (int argc, char **argv);
     
    115120    samplerate = aubio_jack_get_samplerate (jack_setup);
    116121    source_uri = "jack";
    117 #endif
     122#endif /* HAVE_JACK */
    118123  }
    119124  ibuf = new_fvec (hop_size);
     
    124129void examples_common_del (void)
    125130{
     131#ifdef HAVE_JACK
     132  if (ev.buffer) free(ev.buffer);
     133#endif
    126134  del_fvec (ibuf);
    127135  del_fvec (obuf);
     
    138146  if (usejack) {
    139147
    140 #if HAVE_JACK
     148#ifdef HAVE_JACK
     149    ev.size = 3;
     150    ev.buffer = malloc (3 * sizeof (jack_midi_data_t));
     151    ev.time = 0; // send it now
    141152    debug ("Jack activation ...\n");
    142153    aubio_jack_activate (jack_setup, process_func);
     
    144155    pause ();
    145156    aubio_jack_close (jack_setup);
    146 #else
     157#else /* HAVE_JACK */
    147158    usage (stderr, 1);
    148159    outmsg ("Compiled without jack output, exiting.\n");
    149 #endif
     160#endif /* HAVE_JACK */
    150161
    151162  } else {
     
    179190
    180191void
    181 send_noteon (int pitch, int velo)
    182 {
    183   smpl_t mpitch = floor (aubio_freqtomidi (pitch) + .5);
    184 #if HAVE_JACK
    185   jack_midi_event_t ev;
    186   ev.size = 3;
    187   ev.buffer = malloc (3 * sizeof (jack_midi_data_t)); // FIXME
    188   ev.time = 0;
     192send_noteon (smpl_t pitch, smpl_t velo)
     193{
     194#ifdef HAVE_JACK
    189195  if (usejack) {
    190196    ev.buffer[2] = velo;
    191     ev.buffer[1] = mpitch;
     197    ev.buffer[1] = pitch;
    192198    if (velo == 0) {
    193199      ev.buffer[0] = 0x80;      /* note off */
     
    202208    outmsg ("\n");
    203209  } else {
    204     outmsg ("%f\t", mpitch);
     210    outmsg ("%f\t", pitch);
    205211    print_time (blocks * hop_size);
    206212    outmsg ("\t");
  • examples/utils.h

    r00d0275 r155cc10  
    1919*/
    2020
    21 #include <stdio.h>
    22 #include <stdlib.h>
    23 #include <stdarg.h>
    24 #include <getopt.h>
    25 #include <unistd.h>
    26 #include <math.h>               /* for isfinite */
    27 #include <string.h>             /* for strcmp */
    2821#include <aubio.h>
     22
    2923#include "config.h"
     24
     25#ifdef HAVE_STDIO_H
     26#include <stdio.h>              // for fprintf
     27#endif
     28#ifdef HAVE_STDLIB_H
     29#include <stdlib.h>             // for exit
     30#endif
     31#ifdef HAVE_UNISTD_H
     32#include <unistd.h>             // for access
     33#elif defined(HAVE_WIN_HACKS)
     34#include <io.h>
     35#define access _access
     36#define F_OK   0
     37#endif
     38#ifdef HAVE_MATH_H
     39#include <math.h>               // for isfinite
     40#endif
     41#ifdef HAVE_STRING_H
     42#include <string.h>             // for strcmp
     43#endif
    3044
    3145#ifdef HAVE_C99_VARARGS_MACROS
     
    5064
    5165typedef void (aubio_print_func_t) (void);
    52 void send_noteon (int pitch, int velo);
     66void send_noteon (smpl_t pitch, smpl_t velo);
    5367
    5468/** common process function */
  • examples/wscript_build

    r00d0275 r155cc10  
    11# vim:set syntax=python:
    22
    3 uselib = []
    4 uselib += ['FFTW3', 'FFTW3F']
    5 uselib += ['SAMPLERATE']
    6 uselib += ['SNDFILE']
    7 uselib += ['AVCODEC']
    8 uselib += ['AVFORMAT']
    9 uselib += ['AVRESAMPLE']
    10 uselib += ['AVUTIL']
     3import os.path
     4
     5uselib = ['aubio']
    116uselib += ['JACK']
    12 uselib += ['BLAS']
    137
     8includes = ['../src']
    149utils_source = ['utils.c', 'jackio.c']
    1510programs_source = ctx.path.ant_glob('*.c', excl = utils_source)
     
    1813bld(features = 'c',
    1914        source = utils_source,
    20         includes = ['../src'],
    21         uselib = uselib,
     15        includes = includes,
     16        use = uselib,
    2217        target = 'utilsio')
    2318
    2419# loop over all *.c filenames in examples to build them all
    2520for source_file in programs_source:
     21    target = os.path.basename(os.path.splitext(str(source_file))[0])
    2622    bld(features = 'c cprogram',
    27             includes = '../src',
    28             lib = 'm',
    29             use = ['aubio', 'utilsio'],
    30             uselib = uselib,
    3123            source = source_file,
    32             target = str(source_file).split('.')[0]
    33             )
     24            target = target,
     25            includes = includes,
     26            use = uselib + ['utilsio'],
     27       )
  • python/demos/demo_bpm_extract.py

    r00d0275 r155cc10  
    44from numpy import median, diff
    55
    6 def get_file_bpm(path, params = {}):
     6def get_file_bpm(path, params = None):
    77    """ Calculate the beats per minute (bpm) of a given file.
    88        path: path to the file
    99        param: dictionary of parameters
    1010    """
     11    if params is None:
     12        params = {}
    1113    try:
    1214        win_s = params['win_s']
    1315        samplerate = params['samplerate']
    1416        hop_s = params['hop_s']
    15     except:
     17    except KeyError:
    1618        """
    1719        # super fast
     
    4446
    4547    # Convert to periods and to bpm
    46     bpms = 60./diff(beats)
    47     b = median(bpms)
     48    if len(beats) > 1:
     49        if len(beats) < 4:
     50            print("few beats found in {:s}".format(path))
     51        bpms = 60./diff(beats)
     52        b = median(bpms)
     53    else:
     54        b = 0
     55        print("not enough beats found in {:s}".format(path))
    4856    return b
    4957
     
    5260    for f in sys.argv[1:]:
    5361        bpm = get_file_bpm(f)
    54         print "%6s" % ("%.2f" % bpm), f
     62        print("{:6s} {:s}".format("{:2f}".format(bpm), f))
  • python/demos/demo_filterbank.py

    r00d0275 r155cc10  
    22
    33from aubio import filterbank, fvec
    4 from pylab import loglog, show, subplot, xlim, ylim, xlabel, ylabel, title
     4from pylab import loglog, show, xlim, ylim, xlabel, ylabel, title
    55from numpy import vstack, arange
    66
     
    2020f.set_coeffs(coeffs)
    2121
    22 times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * n_filters)
     22times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * n_filters)
    2323title('Bank of filters built using a simple list of boundaries\nThe middle band has been amplified by 2.')
    2424loglog(times.T, f.get_coeffs().T, '.-')
  • python/demos/demo_filterbank_slaney.py

    r00d0275 r155cc10  
    22
    33from aubio import filterbank
    4 from numpy import array, arange, vstack
     4from numpy import arange, vstack
    55
    66win_s = 8192
     
    1212from pylab import loglog, title, show, xlim, ylim, xlabel, ylabel
    1313xlim([0,samplerate / 2])
    14 times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * 40)
     14times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * 40)
    1515loglog(times.T, f.get_coeffs().T, '.-')
    1616title('Mel frequency bands coefficients')
  • python/demos/demo_filterbank_triangle_bands.py

    r00d0275 r155cc10  
    1717subplot(211)
    1818title('Examples of filterbank built with set_triangle_bands and set_coeffs')
    19 times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * n_filters)
     19times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * n_filters)
    2020loglog(times.T, f.get_coeffs().T, '.-')
    2121xlim([50, samplerate/2])
     
    3838
    3939subplot(212)
    40 times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * n_filters)
     40times = vstack([arange(win_s // 2 + 1) * samplerate / win_s] * n_filters)
    4141loglog(times.T, f.get_coeffs().T, '.-')
    4242xlim([50, samplerate/2])
  • python/demos/demo_keyboard.py

    r00d0275 r155cc10  
    2626
    2727def create_keyboard_patches(firstnote, lastnote, ax = None):
    28     import numpy as np
    2928    import matplotlib.pyplot as plt
    3029    from matplotlib.path import Path
  • python/demos/demo_mel-energy.py

    r00d0275 r155cc10  
    22
    33import sys
    4 from aubio import fvec, source, pvoc, filterbank
     4from aubio import source, pvoc, filterbank
    55from numpy import vstack, zeros
    66
    77win_s = 512                 # fft size
    8 hop_s = win_s / 4           # hop size
     8hop_s = win_s // 4          # hop size
    99
    1010if len(sys.argv) < 2:
    11     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     11    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    1212    sys.exit(1)
    1313
     
    3535    fftgrain = pv(samples)
    3636    new_energies = f(fftgrain)
    37     print '%f' % (total_frames / float(samplerate) ),
    38     print ' '.join(['%f' % b for b in new_energies])
     37    timestr = '%f' % (total_frames / float(samplerate) )
     38    print('{:s} {:s}'.format(timestr, ' '.join(['%f' % b for b in new_energies])))
    3939    energies = vstack( [energies, new_energies] )
    4040    total_frames += read
     
    4242
    4343if 1:
    44     print "done computing, now plotting"
     44    print("done computing, now plotting")
    4545    import matplotlib.pyplot as plt
    4646    from demo_waveform_plot import get_waveform_plot
  • python/demos/demo_mfcc.py

    r00d0275 r155cc10  
    33import sys
    44from aubio import source, pvoc, mfcc
    5 from numpy import array, vstack, zeros
     5from numpy import vstack, zeros, diff
    66
    7 win_s = 512                 # fft size
    8 hop_s = win_s / 4           # hop size
    97n_filters = 40              # must be 40 for mfcc
    108n_coeffs = 13
    11 samplerate = 44100
    129
    1310if len(sys.argv) < 2:
    14     print "Usage: %s <source_filename>" % sys.argv[0]
     11    print("Usage: %s <source_filename> [samplerate] [win_s] [hop_s] [mode]" % sys.argv[0])
     12    print("  where [mode] can be 'delta' or 'ddelta' for first and second derivatives")
    1513    sys.exit(1)
    1614
    1715source_filename = sys.argv[1]
     16
     17if len(sys.argv) > 2: samplerate = int(sys.argv[2])
     18else: samplerate = 0
     19if len(sys.argv) > 3: win_s = int(sys.argv[3])
     20else: win_s = 512
     21if len(sys.argv) > 4: hop_s = int(sys.argv[4])
     22else: hop_s = win_s // 4
     23if len(sys.argv) > 5: mode = sys.argv[5]
     24else: mode = "default"
    1825
    1926samplerate = 0
     
    4956wave.yaxis.set_visible(False)
    5057
     58# compute first and second derivatives
     59if mode in ["delta", "ddelta"]:
     60    mfccs = diff(mfccs, axis = 0)
     61if mode == "ddelta":
     62    mfccs = diff(mfccs, axis = 0)
     63
    5164all_times = arange(mfccs.shape[0]) * hop_s
    5265n_coeffs = mfccs.shape[1]
     
    5467    ax = plt.axes ( [0.1, 0.75 - ((i+1) * 0.65 / n_coeffs),  0.8, 0.65 / n_coeffs], sharex = wave )
    5568    ax.xaxis.set_visible(False)
    56     ax.yaxis.set_visible(False)
     69    ax.set_yticks([])
     70    ax.set_ylabel('%d' % i)
    5771    ax.plot(all_times, mfccs.T[i])
    5872
    5973# add time to the last axis
    60 set_xlabels_sample2time( ax, frames_read, samplerate) 
     74set_xlabels_sample2time( ax, frames_read, samplerate)
    6175
    6276#plt.ylabel('spectral descriptor value')
    6377ax.xaxis.set_visible(True)
    64 wave.set_title('MFCC for %s' % source_filename)
     78title = 'MFCC for %s' % source_filename
     79if mode == "delta": title = mode + " " + title
     80elif mode == "ddelta": title = "double-delta" + " " + title
     81wave.set_title(title)
    6582plt.show()
  • python/demos/demo_onset.py

    r00d0275 r155cc10  
    55
    66win_s = 512                 # fft size
    7 hop_s = win_s / 2           # hop size
     7hop_s = win_s // 2          # hop size
    88
    99if len(sys.argv) < 2:
    10     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     10    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    1111    sys.exit(1)
    1212
     
    2929    samples, read = s()
    3030    if o(samples):
    31         print "%f" % o.get_last_s()
     31        print("%f" % o.get_last_s())
    3232        onsets.append(o.get_last())
    3333    total_frames += read
  • python/demos/demo_onset_plot.py

    r00d0275 r155cc10  
    33import sys
    44from aubio import onset, source
    5 from numpy import array, hstack, zeros
     5from numpy import hstack, zeros
    66
    77win_s = 512                 # fft size
    8 hop_s = win_s / 2           # hop size
     8hop_s = win_s // 2          # hop size
    99
    1010if len(sys.argv) < 2:
    11     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     11    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    1212    sys.exit(1)
    1313
     
    3535    samples, read = s()
    3636    if o(samples):
    37         print "%f" % (o.get_last_s())
     37        print("%f" % (o.get_last_s()))
    3838        onsets.append(o.get_last())
    3939    # keep some data to plot it later
    40     new_maxes = (abs(samples.reshape(hop_s/downsample, downsample))).max(axis=0)
     40    new_maxes = (abs(samples.reshape(hop_s//downsample, downsample))).max(axis=0)
    4141    allsamples_max = hstack([allsamples_max, new_maxes])
    4242    desc.append(o.get_descriptor())
     
    4747if 1:
    4848    # do plotting
    49     from numpy import arange
    5049    import matplotlib.pyplot as plt
    5150    allsamples_max = (allsamples_max > 0) * allsamples_max
     
    6362    plt1.yaxis.set_visible(False)
    6463    desc_times = [ float(t) * hop_s / samplerate for t in range(len(desc)) ]
    65     desc_plot = [d / max(desc) for d in desc]
     64    desc_max = max(desc) if max(desc) != 0 else 1.
     65    desc_plot = [d / desc_max for d in desc]
    6666    plt2.plot(desc_times, desc_plot, '-g')
    67     tdesc_plot = [d / max(desc) for d in tdesc]
     67    tdesc_plot = [d / desc_max for d in tdesc]
    6868    for stamp in onsets:
    6969        stamp /= float(samplerate)
  • python/demos/demo_pitch.py

    r00d0275 r155cc10  
    22
    33import sys
    4 from aubio import source, pitch, freqtomidi
     4from aubio import source, pitch
    55
    66if len(sys.argv) < 2:
    7     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     7    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    88    sys.exit(1)
    99
     
    1111
    1212downsample = 1
    13 samplerate = 44100 / downsample
     13samplerate = 44100 // downsample
    1414if len( sys.argv ) > 2: samplerate = int(sys.argv[2])
    1515
    16 win_s = 4096 / downsample # fft size
    17 hop_s = 512  / downsample # hop size
     16win_s = 4096 // downsample # fft size
     17hop_s = 512  // downsample # hop size
    1818
    1919s = source(filename, samplerate, hop_s)
     
    3737    confidence = pitch_o.get_confidence()
    3838    #if confidence < 0.8: pitch = 0.
    39     #print "%f %f %f" % (total_frames / float(samplerate), pitch, confidence)
     39    print("%f %f %f" % (total_frames / float(samplerate), pitch, confidence))
    4040    pitches += [pitch]
    4141    confidences += [confidence]
     
    4646
    4747#print pitches
     48import os.path
    4849from numpy import array, ma
    4950import matplotlib.pyplot as plt
     
    6465
    6566def array_from_text_file(filename, dtype = 'float'):
    66     import os.path
    67     from numpy import array
    6867    filename = os.path.join(os.path.dirname(__file__), filename)
    6968    return array([line.split() for line in open(filename).readlines()],
     
    7170
    7271ax2 = fig.add_subplot(312, sharex = ax1)
    73 import sys, os.path
    7472ground_truth = os.path.splitext(filename)[0] + '.f0.Corrected'
    7573if os.path.isfile(ground_truth):
  • python/demos/demo_pitch_sinusoid.py

    r00d0275 r155cc10  
    11#! /usr/bin/env python
    22
    3 from numpy import random, sin, arange, ones, zeros
    4 from math import pi
    5 from aubio import fvec, pitch
     3import numpy as np
     4import aubio
    65
    76def build_sinusoid(length, freqs, samplerate):
    8   return sin( 2. * pi * arange(length) * freqs / samplerate)
     7    return np.sin( 2. * np.pi * np.arange(length) * freqs / samplerate).astype(aubio.float_type)
    98
    109def run_pitch(p, input_vec):
    11   f = fvec (p.hop_size)
    12   cands = []
    13   count = 0
    14   for vec_slice in input_vec.reshape((-1, p.hop_size)):
    15     f[:] = vec_slice
    16     cands.append(p(f))
    17   return cands
     10    cands = []
     11    for vec_slice in input_vec.reshape((-1, p.hop_size)):
     12        a = p(vec_slice)[0]
     13        cands.append(a)
     14    return cands
    1815
    1916methods = ['default', 'schmitt', 'fcomb', 'mcomb', 'yin', 'yinfft']
     
    2421samplerate = 44100
    2522sin_length = (samplerate * 10) % 512 * 512
    26 freqs = zeros(sin_length)
     23freqs = np.zeros(sin_length)
    2724
    28 partition = sin_length / 8
     25partition = sin_length // 8
    2926pointer = 0
    3027
     
    4138pointer += partition
    4239pointer += partition
    43 freqs[ pointer : pointer + partition ] = 400 + 5 * random.random(sin_length/8)
     40freqs[ pointer : pointer + partition ] = 400 + 5 * np.random.random(sin_length/8)
    4441
    4542a = build_sinusoid(sin_length, freqs, samplerate)
    4643
    4744for method in methods:
    48   p = pitch(method, buf_size, hop_size, samplerate)
    49   cands[method] = run_pitch(p, a)
     45    p = aubio.pitch(method, buf_size, hop_size, samplerate)
     46    cands[method] = run_pitch(p, a)
     47    print(method)
     48    print(cands[method])
    5049
    51 print "done computing"
     50print("done computing")
    5251
    5352if 1:
    54   from pylab import plot, show, xlabel, ylabel, legend, ylim
    55   ramp = arange(0, sin_length / hop_size).astype('float') * hop_size / samplerate
    56   for method in methods:
    57     plot(ramp, cands[method],'.-')
     53    import matplotlib.pyplot as plt
    5854
    59   # plot ground truth
    60   ramp = arange(0, sin_length).astype('float') / samplerate
    61   plot(ramp, freqs, ':')
     55    # times
     56    ramp = np.arange(0, sin_length / hop_size).astype('float') * hop_size / samplerate
    6257
    63   legend(methods+['ground truth'], 'upper right')
    64   xlabel('time (s)')
    65   ylabel('frequency (Hz)')
    66   ylim([0,2000])
    67   show()
     58    # plot each result
     59    for method in methods:
     60        plt.plot(ramp, cands[method], '.-', label=method)
    6861
     62    # plot ground truth
     63    ramp = np.arange(0, sin_length).astype('float') / samplerate
     64    plt.plot(ramp, freqs, ':', label = 'ground truth')
     65
     66    plt.legend(loc='upper left')
     67
     68    plt.xlabel('time (s)')
     69    plt.ylabel('frequency (Hz)')
     70    plt.ylim([0,2000])
     71    plt.show()
  • python/demos/demo_pysoundcard_record.py

    r00d0275 r155cc10  
    1111    s = Stream(blocksize = hop_size, channels = 1)
    1212    g = sink(sink_path, samplerate = int(s.samplerate))
    13     print s.channels
    1413
    1514    s.start()
     
    2221            g(mono_vec, hop_size)
    2322            total_frames += hop_size
    24     except KeyboardInterrupt, e:
    25         print "stopped after", "%.2f seconds" % (total_frames / s.samplerate)
    26         pass
     23    except KeyboardInterrupt:
     24        duration = total_frames / float(s.samplerate)
     25        print("stopped after %.2f seconds" % duration)
    2726    s.stop()
    2827
  • python/demos/demo_simple_robot_voice.py

    r00d0275 r155cc10  
    55
    66if __name__ == '__main__':
    7   if len(sys.argv) < 2:
    8     print 'usage: %s <inputfile> <outputfile>' % sys.argv[0]
    9     sys.exit(1)
    10   samplerate = 44100
    11   f = source(sys.argv[1], samplerate, 256)
    12   g = sink(sys.argv[2], samplerate)
    13   total_frames, read = 0, 256
     7    if len(sys.argv) < 2:
     8        print('usage: %s <inputfile> <outputfile>' % sys.argv[0])
     9        sys.exit(1)
     10    samplerate = 44100
     11    f = source(sys.argv[1], samplerate, 256)
     12    g = sink(sys.argv[2], samplerate)
     13    total_frames, read = 0, 256
    1414
    15   win_s = 512                 # fft size
    16   hop_s = win_s / 2           # hop size
    17   pv = pvoc(win_s, hop_s)                            # phase vocoder
     15    win_s = 512                          # fft size
     16    hop_s = win_s // 2                   # hop size
     17    pv = pvoc(win_s, hop_s)              # phase vocoder
    1818
    19   while read:
    20     samples, read = f()
    21     spectrum = pv(samples)            # compute spectrum
    22     #spectrum.norm *= .8               # reduce amplitude a bit
    23     spectrum.phas[:] = 0.             # zero phase
    24     new_samples = pv.rdo(spectrum)    # compute modified samples
    25     g(new_samples, read)              # write to output
    26     total_frames += read
     19    while read:
     20        samples, read = f()
     21        spectrum = pv(samples)           # compute spectrum
     22        #spectrum.norm *= .8             # reduce amplitude a bit
     23        spectrum.phas[:] = 0.            # zero phase
     24        new_samples = pv.rdo(spectrum)   # compute modified samples
     25        g(new_samples, read)             # write to output
     26        total_frames += read
    2727
    28   print "wrote", total_frames, "from", f.uri, "to", g.uri
    29 
    30  
     28    format_str = "read {:d} samples from {:s}, written to {:s}"
     29    print(format_str.format(total_frames, f.uri, g.uri))
  • python/demos/demo_simple_spectral_weighting.py

    r00d0275 r155cc10  
    1414if __name__ == '__main__':
    1515    if len(sys.argv) < 2:
    16         print 'usage: %s <inputfile> <outputfile>' % sys.argv[0]
     16        print('usage: %s <inputfile> <outputfile>' % sys.argv[0])
    1717        sys.exit(1)
    1818    samplerate = 0
     
    2323
    2424    win_s = 512 # fft size
    25     hop_s = win_s / 2 # hop size
     25    hop_s = win_s // 2 # hop size
    2626    pv = pvoc(win_s, hop_s) # phase vocoder
    2727
     
    3131        zeros( 50 ),
    3232        1.3 * hanningz(100),
    33         zeros (win_s / 2 + 1 - 40 - 50 - 100),
     33        zeros (win_s // 2 + 1 - 40 - 50 - 100),
    3434        ] )
    3535
     
    5353        total_frames += read
    5454
    55     print "read", total_frames / float(samplerate), "seconds from", f.uri
     55    duration = total_frames / float(samplerate)
     56    print("read {:.3f}s from {:s}".format(duration, f.uri))
  • python/demos/demo_sink.py

    r00d0275 r155cc10  
    66if __name__ == '__main__':
    77    if len(sys.argv) < 3:
    8         print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0]
     8        print('usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0])
    99        sys.exit(1)
    1010
     
    2323        g(vec, read)
    2424        total_frames += read
    25     print "wrote", "%.2fs" % (total_frames / float(samplerate) ),
    26     print "(", total_frames, "frames", "in",
    27     print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
    28     print "from", f.uri,
    29     print "to", g.uri
     25    outstr = "wrote %.2fs" % (total_frames / float(samplerate))
     26    outstr += " (%d frames in" % total_frames
     27    outstr += " %d blocks" % (total_frames // f.hop_size)
     28    outstr += " at %dHz)" % f.samplerate
     29    outstr += " from " + f.uri
     30    outstr += " to " + g.uri
     31    print(outstr)
  • python/demos/demo_sink_create_woodblock.py

    r00d0275 r155cc10  
    33import sys
    44from math import pi, e
    5 from aubio import sink
    6 from numpy import arange, resize, sin, exp, zeros
     5from aubio import sink, float_type
     6from numpy import arange, sin, exp, zeros
    77
    88if len(sys.argv) < 2:
    9     print 'usage: %s <outputfile> [samplerate]' % sys.argv[0]
     9    print('usage: %s <outputfile> [samplerate]' % sys.argv[0])
    1010    sys.exit(1)
    1111
     
    2626# create a sine lookup table
    2727tablelen = 1000
    28 sinetable = arange(tablelen + 1, dtype = 'float32')
     28sinetable = arange(tablelen + 1, dtype = float_type)
    2929sinetable = 0.7 * sin(twopi * sinetable/tablelen)
    30 sinetone = zeros((duration,), dtype = 'float32')
     30sinetone = zeros((duration,), dtype = float_type)
    3131
    3232# compute sinetone at floating point period
     
    4040
    4141# apply some envelope
    42 float_ramp = arange(duration, dtype = 'float32')
     42float_ramp = arange(duration, dtype = float_type)
    4343sinetone *= exp( - e * float_ramp / duration / decay)
    4444sinetone[:attack] *= exp( e * ( float_ramp[:attack] / attack - 1 ) )
  • python/demos/demo_sink_multi.py

    r00d0275 r155cc10  
    66if __name__ == '__main__':
    77    if len(sys.argv) < 3:
    8         print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0]
     8        print('usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0])
    99        sys.exit(1)
    1010
     
    2323        g.do_multi(vec, read)
    2424        total_frames += read
    25     print "wrote", "%.2fs" % (total_frames / float(samplerate) ),
    26     print "(", total_frames, "frames", "in",
    27     print total_frames / f.hop_size, "blocks",
    28     print "of", f.channels, "channels",
    29     print "at", "%dHz" % f.samplerate, ")",
    30     print "from", f.uri,
    31     print "to", g.uri
     25    outstr = "wrote %.2fs" % (total_frames / float(samplerate))
     26    outstr += " (%d frames in" % total_frames
     27    outstr += " %d blocks" % (total_frames // f.hop_size)
     28    outstr += " of %d channels" % f.channels
     29    outstr += " at %dHz)" % f.samplerate
     30    outstr += " from " + f.uri
     31    outstr += " to " + g.uri
     32    print(outstr)
  • python/demos/demo_slicing.py

    r00d0275 r155cc10  
    77if __name__ == '__main__':
    88    if len(sys.argv) < 3:
    9         print 'usage: %s <inputfile> <duration>' % sys.argv[0]
     9        print('usage: %s <inputfile> <duration>' % sys.argv[0])
    1010        sys.exit(1)
    1111    source_file = sys.argv[1]
     
    4545    total_duration = total_frames_written / float(samplerate)
    4646    slice_n += 1
    47     print 'created %(slice_n)s slices from %(source_base_name)s%(source_ext)s' % locals(),
    48     print ' (total duration %(total_duration).2fs)' % locals()
     47    outstr = 'created %(slice_n)s slices from %(source_base_name)s%(source_ext)s' % locals()
     48    outstr += ' (total duration %(total_duration).2fs)' % locals()
     49    print(outstr)
    4950    # close source and sink files
    5051    del f, g
  • python/demos/demo_source.py

    r00d0275 r155cc10  
    66if __name__ == '__main__':
    77    if len(sys.argv) < 2:
    8         print 'usage: %s <inputfile> [samplerate] [hop_size]' % sys.argv[0]
     8        print('usage: %s <inputfile> [samplerate] [hop_size]' % sys.argv[0])
    99        sys.exit(1)
    1010    samplerate = 0
     
    2121        total_frames += read
    2222        if read < f.hop_size: break
    23     print "read", "%.2fs" % (total_frames / float(samplerate) ),
    24     print "(", total_frames, "frames", "in",
    25     print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
    26     print "from", f.uri
     23    outstr = "read %.2fs" % (total_frames / float(samplerate))
     24    outstr += " (%d frames in" % total_frames
     25    outstr += " %d blocks" % (total_frames // f.hop_size)
     26    outstr += " at %dHz)" % f.samplerate
     27    outstr += " from " + f.uri
     28    print(outstr)
  • python/demos/demo_specdesc.py

    r00d0275 r155cc10  
    22
    33import sys
    4 from aubio import fvec, source, pvoc, specdesc
    5 from numpy import hstack
     4import numpy as np
     5from aubio import source, pvoc, specdesc
    66
    77win_s = 512                 # fft size
    8 hop_s = win_s / 4           # hop size
     8hop_s = win_s // 4          # hop size
    99
    1010if len(sys.argv) < 2:
    11     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     11    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    1212    sys.exit(1)
    1313
     
    3131for method in methods:
    3232    cands = []
    33     all_descs[method] = fvec(0)
     33    all_descs[method] = np.array([])
    3434    o[method] = specdesc(method, win_s)
    3535
     
    4040    samples, read = s()
    4141    fftgrain = pv(samples)
    42     #print "%f" % ( total_frames / float(samplerate) ),
     42    #outstr = "%f" % ( total_frames / float(samplerate) )
    4343    for method in methods:
    4444        specdesc_val = o[method](fftgrain)[0]
    45         all_descs[method] = hstack ( [all_descs[method], specdesc_val] )
    46         #print "%f" % specdesc_val,
    47     #print
     45        all_descs[method] = np.append(all_descs[method], specdesc_val)
     46        #outstr += " %f" % specdesc_val
     47    #print(outstr)
    4848    total_frames += read
    4949    if read < hop_s: break
    5050
    5151if 1:
    52     print "done computing, now plotting"
     52    print("done computing, now plotting")
    5353    import matplotlib.pyplot as plt
    5454    from demo_waveform_plot import get_waveform_plot
  • python/demos/demo_spectrogram.py

    r00d0275 r155cc10  
    11#! /usr/bin/env python
    22
    3 import sys
    4 from aubio import pvoc, source
    5 from numpy import array, arange, zeros, shape, log10, vstack
    6 from pylab import imshow, show, cm, axis, ylabel, xlabel, xticks, yticks
     3import sys, os.path
     4from aubio import pvoc, source, float_type
     5from numpy import zeros, log10, vstack
     6import matplotlib.pyplot as plt
    77
    88def get_spectrogram(filename, samplerate = 0):
    9   win_s = 512                                        # fft window size
    10   hop_s = win_s / 2                                  # hop size
    11   fft_s = win_s / 2 + 1                              # spectrum bins
     9    win_s = 512                                        # fft window size
     10    hop_s = win_s // 2                                 # hop size
     11    fft_s = win_s // 2 + 1                             # spectrum bins
    1212
    13   a = source(filename, samplerate, hop_s)            # source file
    14   if samplerate == 0: samplerate = a.samplerate
    15   pv = pvoc(win_s, hop_s)                            # phase vocoder
    16   specgram = zeros([0, fft_s], dtype='float32')      # numpy array to store spectrogram
     13    a = source(filename, samplerate, hop_s)            # source file
     14    if samplerate == 0: samplerate = a.samplerate
     15    pv = pvoc(win_s, hop_s)                            # phase vocoder
     16    specgram = zeros([0, fft_s], dtype=float_type)     # numpy array to store spectrogram
    1717
    18   # analysis
    19   while True:
    20     samples, read = a()                              # read file
    21     specgram = vstack((specgram,pv(samples).norm))   # store new norm vector
    22     if read < a.hop_size: break
     18    # analysis
     19    while True:
     20        samples, read = a()                              # read file
     21        specgram = vstack((specgram,pv(samples).norm))   # store new norm vector
     22        if read < a.hop_size: break
    2323
    24   # plotting
    25   imshow(log10(specgram.T + .001), origin = 'bottom', aspect = 'auto', cmap=cm.gray_r)
    26   axis([0, len(specgram), 0, len(specgram[0])])
    27   # show axes in Hz and seconds
    28   time_step = hop_s / float(samplerate)
    29   total_time = len(specgram) * time_step
    30   print "total time: %0.2fs" % total_time,
    31   print ", samplerate: %.2fkHz" % (samplerate / 1000.)
    32   n_xticks = 10
    33   n_yticks = 10
     24    # plotting
     25    fig = plt.imshow(log10(specgram.T + .001), origin = 'bottom', aspect = 'auto', cmap=plt.cm.gray_r)
     26    ax = fig.axes
     27    ax.axis([0, len(specgram), 0, len(specgram[0])])
     28    # show axes in Hz and seconds
     29    time_step = hop_s / float(samplerate)
     30    total_time = len(specgram) * time_step
     31    outstr = "total time: %0.2fs" % total_time
     32    print(outstr + ", samplerate: %.2fkHz" % (samplerate / 1000.))
     33    n_xticks = 10
     34    n_yticks = 10
    3435
    35   def get_rounded_ticks( top_pos, step, n_ticks ):
    36       top_label = top_pos * step
    37       # get the first label
    38       ticks_first_label = top_pos * step / n_ticks
    39       # round to the closest .1
    40       ticks_first_label = round ( ticks_first_label * 10. ) / 10.
    41       # compute all labels from the first rounded one
    42       ticks_labels = [ ticks_first_label * n for n in range(n_ticks) ] + [ top_label ]
    43       # get the corresponding positions
    44       ticks_positions = [ ticks_labels[n] / step for n in range(n_ticks) ] + [ top_pos ]
    45       # convert to string
    46       ticks_labels = [  "%.1f" % x for x in ticks_labels ]
    47       # return position, label tuple to use with x/yticks
    48       return ticks_positions, ticks_labels
    49 
    50   # apply to the axis
    51   xticks( *get_rounded_ticks ( len(specgram), time_step, n_xticks ) )
    52   yticks( *get_rounded_ticks ( len(specgram[0]), (samplerate / 2. / 1000.) / len(specgram[0]), n_yticks ) )
    53   ylabel('Frequency (kHz)')
    54   xlabel('Time (s)')
     36    def get_rounded_ticks( top_pos, step, n_ticks ):
     37        top_label = top_pos * step
     38        # get the first label
     39        ticks_first_label = top_pos * step / n_ticks
     40        # round to the closest .1
     41        ticks_first_label = round ( ticks_first_label * 10. ) / 10.
     42        # compute all labels from the first rounded one
     43        ticks_labels = [ ticks_first_label * n for n in range(n_ticks) ] + [ top_label ]
     44        # get the corresponding positions
     45        ticks_positions = [ ticks_labels[n] / step for n in range(n_ticks) ] + [ top_pos ]
     46        # convert to string
     47        ticks_labels = [  "%.1f" % x for x in ticks_labels ]
     48        # return position, label tuple to use with x/yticks
     49        return ticks_positions, ticks_labels
     50 
     51    # apply to the axis
     52    x_ticks, x_labels = get_rounded_ticks ( len(specgram), time_step, n_xticks )
     53    y_ticks, y_labels = get_rounded_ticks ( len(specgram[0]), (samplerate / 1000. / 2.) / len(specgram[0]), n_yticks )
     54    ax.set_xticks( x_ticks )
     55    ax.set_yticks ( y_ticks )
     56    ax.set_xticklabels( x_labels )
     57    ax.set_yticklabels ( y_labels )
     58    ax.set_ylabel('Frequency (kHz)')
     59    ax.set_xlabel('Time (s)')
     60    ax.set_title(os.path.basename(filename))
     61    for item in ([ax.title, ax.xaxis.label, ax.yaxis.label] +
     62            ax.get_xticklabels() + ax.get_yticklabels()):
     63        item.set_fontsize('x-small')
     64    return fig
    5565
    5666if __name__ == '__main__':
    57   if len(sys.argv) < 2:
    58     print "Usage: %s <filename>" % sys.argv[0]
    59   else:
    60     for soundfile in sys.argv[1:]:
    61       get_spectrogram(soundfile)
    62       # display graph
    63       show()
     67    if len(sys.argv) < 2:
     68        print("Usage: %s <filename>" % sys.argv[0])
     69    else:
     70        for soundfile in sys.argv[1:]:
     71            fig = get_spectrogram(soundfile)
     72            # display graph
     73            plt.show()
     74            #outimage = os.path.basename(soundfile) + '.png'
     75            #print ("writing: " + outimage)
     76            #plt.savefig(outimage)
     77            plt.close()
  • python/demos/demo_tempo.py

    r00d0275 r155cc10  
    55
    66win_s = 512                 # fft size
    7 hop_s = win_s / 2           # hop size
     7hop_s = win_s // 2          # hop size
    88
    99if len(sys.argv) < 2:
    10     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     10    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    1111    sys.exit(1)
    1212
     
    3434    if is_beat:
    3535        this_beat = int(total_frames - delay + is_beat[0] * hop_s)
    36         print "%f" % (this_beat / float(samplerate))
     36        print("%f" % (this_beat / float(samplerate)))
    3737        beats.append(this_beat)
    3838    total_frames += read
  • python/demos/demo_tempo_plot.py

    r00d0275 r155cc10  
    55
    66win_s = 512                 # fft size
    7 hop_s = win_s / 2           # hop size
     7hop_s = win_s // 2          # hop size
    88
    99if len(sys.argv) < 2:
    10     print "Usage: %s <filename> [samplerate]" % sys.argv[0]
     10    print("Usage: %s <filename> [samplerate]" % sys.argv[0])
    1111    sys.exit(1)
    1212
     
    4040if len(beats) > 1:
    4141    # do plotting
    42     from numpy import array, arange, mean, median, diff
     42    from numpy import mean, median, diff
    4343    import matplotlib.pyplot as plt
    4444    bpms = 60./ diff(beats)
    45     print 'mean period:', "%.2f" % mean(bpms), 'bpm', 'median', "%.2f" % median(bpms), 'bpm'
    46     print 'plotting', filename
     45    print('mean period: %.2fbpm, median: %.2fbpm' % (mean(bpms), median(bpms)))
     46    print('plotting %s' % filename)
    4747    plt1 = plt.axes([0.1, 0.75, 0.8, 0.19])
    4848    plt2 = plt.axes([0.1, 0.1, 0.8, 0.65], sharex = plt1)
     
    7676
    7777else:
    78     print 'mean period:', "%.2f" % 0, 'bpm', 'median', "%.2f" % 0, 'bpm',
    79     print 'nothing to plot, file too short?'
     78    print('mean period: %.2fbpm, median: %.2fbpm' % (0, 0))
     79    print('plotting %s' % filename)
  • python/demos/demo_tss.py

    r00d0275 r155cc10  
    55
    66if __name__ == '__main__':
    7   if len(sys.argv) < 2:
    8     print 'usage: %s <inputfile> <outputfile_transient> <outputfile_steady>' % sys.argv[0]
    9     sys.exit(1)
     7    if len(sys.argv) < 2:
     8        print('usage: %s <inputfile> <outputfile_transient> <outputfile_steady>' % sys.argv[0])
     9        sys.exit(1)
    1010
    11   samplerate = 44100
    12   win_s = 1024      # fft size
    13   hop_s = win_s / 4 # block size
    14   threshold = 0.5
     11    samplerate = 44100
     12    win_s = 1024       # fft size
     13    hop_s = win_s // 8 # block size
    1514
    16   f = source(sys.argv[1], samplerate, hop_s)
    17   g = sink(sys.argv[2], samplerate)
    18   h = sink(sys.argv[3], samplerate)
     15    f = source(sys.argv[1], samplerate, hop_s)
     16    g = sink(sys.argv[2], samplerate)
     17    h = sink(sys.argv[3], samplerate)
    1918
    20   pva = pvoc(win_s, hop_s)    # a phase vocoder
    21   pvb = pvoc(win_s, hop_s)    # another phase vocoder
    22   t = tss(win_s, hop_s)       # transient steady state separation
     19    pva = pvoc(win_s, hop_s)    # a phase vocoder
     20    pvb = pvoc(win_s, hop_s)    # another phase vocoder
     21    t = tss(win_s, hop_s)       # transient steady state separation
    2322
    24   t.set_threshold(threshold)
     23    t.set_threshold(0.01)
     24    t.set_alpha(3.)
     25    t.set_beta(4.)
    2526
    26   read = hop_s
     27    read = hop_s
    2728
    28   while read:
    29     samples, read = f()               # read file
    30     spec = pva(samples)                # compute spectrum
    31     trans_spec, stead_spec = t(spec)  # transient steady-state separation
    32     transients = pva.rdo(trans_spec)   # overlap-add synthesis of transients
    33     steadstate = pvb.rdo(stead_spec)   # overlap-add synthesis of steady states
    34     g(transients, read)               # write transients to output
    35     h(steadstate, read)               # write steady states to output
     29    while read:
     30        samples, read = f()               # read file
     31        spec = pva(samples)               # compute spectrum
     32        trans_spec, stead_spec = t(spec)  # transient steady-state separation
     33        transients = pva.rdo(trans_spec)  # overlap-add synthesis of transients
     34        steadstate = pvb.rdo(stead_spec)  # overlap-add synthesis of steady states
     35        g(transients, read)               # write transients to output
     36        h(steadstate, read)               # write steady states to output
    3637
    37   del f, g, h                         # finish writing the files now
     38    del f, g, h                           # finish writing the files now
     39    sys.exit(0)
    3840
    39   from demo_spectrogram import get_spectrogram
    40   from pylab import subplot, show
    41   subplot(311)
    42   get_spectrogram(sys.argv[1])
    43   subplot(312)
    44   get_spectrogram(sys.argv[2])
    45   subplot(313)
    46   get_spectrogram(sys.argv[3])
    47   show()
     41    from demo_spectrogram import get_spectrogram
     42    from pylab import subplot, show
     43    subplot(311)
     44    get_spectrogram(sys.argv[1])
     45    subplot(312)
     46    get_spectrogram(sys.argv[2])
     47    subplot(313)
     48    get_spectrogram(sys.argv[3])
     49    show()
  • python/demos/demo_waveform_plot.py

    r00d0275 r155cc10  
    22
    33import sys
    4 from aubio import pvoc, source
     4from aubio import source
    55from numpy import zeros, hstack
    66
     
    2222        samples, read = a()
    2323        # keep some data to plot it later
    24         new_maxes = (abs(samples.reshape(hop_s/downsample, downsample))).max(axis=0)
     24        new_maxes = (abs(samples.reshape(hop_s//downsample, downsample))).max(axis=0)
    2525        allsamples_max = hstack([allsamples_max, new_maxes])
    2626        total_frames += read
     
    4949    import matplotlib.pyplot as plt
    5050    if len(sys.argv) < 2:
    51         print "Usage: %s <filename>" % sys.argv[0]
     51        print("Usage: %s <filename>" % sys.argv[0])
    5252    else:
    5353        for soundfile in sys.argv[1:]:
  • python/ext/aubio-types.h

    r00d0275 r155cc10  
    11#include <Python.h>
    22#include <structmember.h>
     3
     4#include "aubio-generated.h"
    35
    46#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
     
    2628#include "aubio.h"
    2729#else
    28 #include "aubio/aubio.h"
     30#include <aubio/aubio.h>
    2931#endif
    3032
     
    3436
    3537#if HAVE_AUBIO_DOUBLE
    36 #error "Ouch! Python interface for aubio has not been much tested yet."
     38// 64 bit precision with HAVE_AUBIO_DOUBLE=1
    3739#define AUBIO_NPY_SMPL NPY_DOUBLE
     40#define AUBIO_NPY_SMPL_STR "float64"
     41#define AUBIO_NPY_SMPL_CHR "d"
    3842#else
     43// default is 32 bit precision
    3944#define AUBIO_NPY_SMPL NPY_FLOAT
     45#define AUBIO_NPY_SMPL_STR "float32"
     46#define AUBIO_NPY_SMPL_CHR "f"
    4047#endif
    4148
    42 // special python type for cvec
    43 typedef struct
    44 {
    45   PyObject_HEAD
    46   cvec_t * o;
    47   uint_t length;
    48   uint_t channels;
    49 } Py_cvec;
     49#ifndef PATH_MAX
     50#ifdef MAX_PATH
     51#define PATH_MAX MAX_PATH
     52#else
     53#define PATH_MAX 1024
     54#endif
     55#endif
     56
     57// compat with Python < 2.6
     58#ifndef Py_TYPE
     59#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
     60#endif
     61
    5062extern PyTypeObject Py_cvecType;
    5163
     64PyObject * new_py_fvec(uint_t length);
     65PyObject * new_py_cvec(uint_t length);
     66PyObject * new_py_fmat(uint_t height, uint_t length);
     67
    5268// defined in aubio-proxy.c
     69extern int PyAubio_IsValidVector (PyObject *input);
     70
    5371extern PyObject *PyAubio_CFvecToArray (fvec_t * self);
    54 extern fvec_t *PyAubio_ArrayToCFvec (PyObject * self);
     72extern int PyAubio_ArrayToCFvec (PyObject * self, fvec_t *out);
    5573
    56 extern Py_cvec *PyAubio_CCvecToPyCvec (cvec_t * self);
    57 extern cvec_t *PyAubio_ArrayToCCvec (PyObject *input);
     74extern int PyAubio_PyCvecToCCvec (PyObject *input, cvec_t *i);
    5875
    5976extern PyObject *PyAubio_CFmatToArray (fmat_t * self);
    60 extern fmat_t *PyAubio_ArrayToCFmat (PyObject *input);
     77extern int PyAubio_ArrayToCFmat (PyObject *input, fmat_t *out);
    6178
    6279// hand written wrappers
  • python/ext/aubiomodule.c

    r00d0275 r155cc10  
    11#define PY_AUBIO_MODULE_MAIN
    22#include "aubio-types.h"
    3 #include "aubio-generated.h"
    43#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)
    59
    610static char aubio_module_doc[] = "Python module for the aubio library";
     
    7680">>> min_removal(a)";
    7781
    78 extern void add_generated_objects ( PyObject *m );
    7982extern void add_ufuncs ( PyObject *m );
    8083extern int generated_types_ready(void);
     
    8487{
    8588  PyObject *input;
    86   fvec_t *vec;
     89  fvec_t vec;
    8790  smpl_t alpha;
    8891  PyObject *result;
    8992
    90   if (!PyArg_ParseTuple (args, "Of:alpha_norm", &input, &alpha)) {
     93  if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":alpha_norm", &input, &alpha)) {
    9194    return NULL;
    9295  }
     
    9699  }
    97100
    98   vec = PyAubio_ArrayToCFvec (input);
    99 
    100   if (vec == NULL) {
     101  if (!PyAubio_ArrayToCFvec(input, &vec)) {
    101102    return NULL;
    102103  }
    103104
    104105  // compute the function
    105   result = Py_BuildValue ("f", fvec_alpha_norm (vec, alpha));
     106  result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, fvec_alpha_norm (&vec, alpha));
    106107  if (result == NULL) {
    107108    return NULL;
     
    117118  smpl_t output;
    118119
    119   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     120  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
    120121    return NULL;
    121122  }
     
    132133  smpl_t output;
    133134
    134   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     135  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
    135136    return NULL;
    136137  }
     
    147148  smpl_t output;
    148149
    149   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     150  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
    150151    return NULL;
    151152  }
     
    162163  smpl_t output;
    163164
    164   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     165  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
    165166    return NULL;
    166167  }
     
    175176{
    176177  PyObject *input;
    177   fvec_t *vec;
     178  fvec_t vec;
    178179  PyObject *result;
    179180
     
    186187  }
    187188
    188   vec = PyAubio_ArrayToCFvec (input);
    189 
    190   if (vec == NULL) {
     189  if (!PyAubio_ArrayToCFvec(input, &vec)) {
    191190    return NULL;
    192191  }
    193192
    194193  // compute the function
    195   result = Py_BuildValue ("f", aubio_zero_crossing_rate (vec));
     194  result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, aubio_zero_crossing_rate (&vec));
    196195  if (result == NULL) {
    197196    return NULL;
     
    205204{
    206205  PyObject *input;
    207   fvec_t *vec;
     206  fvec_t vec;
    208207
    209208  if (!PyArg_ParseTuple (args, "O:min_removal", &input)) {
     
    215214  }
    216215
    217   vec = PyAubio_ArrayToCFvec (input);
    218 
    219   if (vec == NULL) {
     216  if (!PyAubio_ArrayToCFvec(input, &vec)) {
    220217    return NULL;
    221218  }
    222219
    223220  // compute the function
    224   fvec_min_removal (vec);
     221  fvec_min_removal (&vec);
    225222
    226223  // since this function does not return, we could return None
    227224  //Py_RETURN_NONE;
    228225  // however it is convenient to return the modified vector
    229   return (PyObject *) PyAubio_CFvecToArray(vec);
     226  return (PyObject *) PyAubio_CFvecToArray(&vec);
    230227  // or even without converting it back to an array
    231228  //Py_INCREF(vec);
     
    246243  {"level_detection", Py_aubio_level_detection, METH_VARARGS, Py_aubio_level_detection_doc},
    247244  {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc},
    248   {NULL, NULL} /* Sentinel */
     245  {NULL, NULL, 0, NULL} /* Sentinel */
    249246};
    250247
    251 PyMODINIT_FUNC
    252 init_aubio (void)
    253 {
    254   PyObject *m;
     248#if PY_MAJOR_VERSION >= 3
     249// Python3 module definition
     250static struct PyModuleDef moduledef = {
     251   PyModuleDef_HEAD_INIT,
     252   "_aubio",          /* m_name */
     253   aubio_module_doc,  /* m_doc */
     254   -1,                /* m_size */
     255   aubio_methods,     /* m_methods */
     256   NULL,              /* m_reload */
     257   NULL,              /* m_traverse */
     258   NULL,              /* m_clear */
     259   NULL,              /* m_free */
     260};
     261#endif
     262
     263void
     264aubio_log_function(int level, const char *message, void *data)
     265{
     266  // remove trailing \n
     267  char *pos;
     268  if ((pos=strchr(message, '\n')) != NULL) {
     269        *pos = '\0';
     270  }
     271  // warning or error
     272  if (level == AUBIO_LOG_ERR) {
     273    PyErr_Format(PyExc_RuntimeError, "%s", message);
     274  } else {
     275    PyErr_WarnEx(PyExc_UserWarning, message, 1);
     276  }
     277}
     278
     279static PyObject *
     280initaubio (void)
     281{
     282  PyObject *m = NULL;
    255283  int err;
    256284
     
    266294      || (generated_types_ready() < 0 )
    267295  ) {
    268     return;
    269   }
    270 
     296    return m;
     297  }
     298
     299#if PY_MAJOR_VERSION >= 3
     300  m = PyModule_Create(&moduledef);
     301#else
    271302  m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
     303#endif
    272304
    273305  if (m == NULL) {
    274     return;
     306    return m;
    275307  }
    276308
     
    296328  PyModule_AddObject (m, "sink", (PyObject *) & Py_sinkType);
    297329
     330  PyModule_AddStringConstant(m, "float_type", AUBIO_NPY_SMPL_STR);
     331  PyModule_AddStringConstant(m, "__version__", DEFINEDSTRING(AUBIO_VERSION));
     332
    298333  // add generated objects
    299334  add_generated_objects(m);
     
    301336  // add ufunc
    302337  add_ufuncs(m);
    303 }
     338
     339  aubio_log_set_level_function(AUBIO_LOG_ERR, aubio_log_function, NULL);
     340  aubio_log_set_level_function(AUBIO_LOG_WRN, aubio_log_function, NULL);
     341  return m;
     342}
     343
     344#if PY_MAJOR_VERSION >= 3
     345    // Python3 init
     346    PyMODINIT_FUNC PyInit__aubio(void)
     347    {
     348        return initaubio();
     349    }
     350#else
     351    // Python 2 init
     352    PyMODINIT_FUNC init_aubio(void)
     353    {
     354        initaubio();
     355    }
     356#endif
  • python/ext/aubioproxy.c

    r00d0275 r155cc10  
    11#include "aubio-types.h"
    22
    3 fvec_t *
    4 PyAubio_ArrayToCFvec (PyObject *input) {
    5   PyObject *array;
    6   fvec_t *vec;
    7   if (input == NULL) {
    8     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
    9     goto fail;
    10   }
    11   // parsing input object into a Py_fvec
    12   if (PyArray_Check(input)) {
     3PyObject *
     4new_py_fvec(uint_t length) {
     5    npy_intp dims[] = { length, 1 };
     6    return PyArray_ZEROS(1, dims, AUBIO_NPY_SMPL, 0);
     7}
    138
    14     // we got an array, convert it to an fvec
    15     if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
    16       PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    17       goto fail;
    18     } else if (PyArray_NDIM ((PyArrayObject *)input) > 1) {
    19       PyErr_SetString (PyExc_ValueError,
    20           "input array has more than one dimensions");
    21       goto fail;
    22     }
    23 
    24     if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
    25       PyErr_SetString (PyExc_ValueError, "input array should be float");
    26       goto fail;
    27     } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    28       PyErr_SetString (PyExc_ValueError, "input array should be float32");
    29       goto fail;
    30     } else {
    31       // input data type is float32, nothing else to do
    32       array = input;
    33     }
    34 
    35     // vec = new_fvec (vec->length);
    36     // no need to really allocate fvec, just its struct member
    37     vec = (fvec_t *)malloc(sizeof(fvec_t));
    38     long length = PyArray_SIZE ((PyArrayObject *)array);
    39     if (length > 0) {
    40       vec->length = (uint_t)length;
    41     } else {
    42       PyErr_SetString (PyExc_ValueError, "input array size should be greater than 0");
    43       goto fail;
    44     }
    45     vec->data = (smpl_t *) PyArray_GETPTR1 ((PyArrayObject *)array, 0);
    46 
    47   } else if (PyObject_TypeCheck (input, &PyList_Type)) {
    48     PyErr_SetString (PyExc_ValueError, "does not convert from list yet");
    49     return NULL;
    50   } else {
    51     PyErr_SetString (PyExc_ValueError, "can only accept vector of float as input");
    52     return NULL;
    53   }
    54 
    55   return vec;
    56 
    57 fail:
    58   return NULL;
     9PyObject *
     10new_py_fmat(uint_t height, uint_t length) {
     11    npy_intp dims[] = { height, length, 1 };
     12    return PyArray_ZEROS(2, dims, AUBIO_NPY_SMPL, 0);
    5913}
    6014
     
    6620}
    6721
    68 Py_cvec *
    69 PyAubio_CCvecToPyCvec (cvec_t * input) {
    70   Py_cvec *vec = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
    71   vec->length = input->length;
    72   vec->o = input;
    73   Py_INCREF(vec);
    74   return vec;
     22int
     23PyAubio_IsValidVector (PyObject * input) {
     24  npy_intp length;
     25  if (input == NULL) {
     26    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     27    return 0;
     28  }
     29  // parsing input object into a Py_fvec
     30  if (PyArray_Check(input)) {
     31
     32    // we got an array, convert it to an fvec
     33    if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
     34      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
     35      return 0;
     36    } else if (PyArray_NDIM ((PyArrayObject *)input) > 1) {
     37      PyErr_SetString (PyExc_ValueError,
     38          "input array has more than one dimensions");
     39      return 0;
     40    }
     41
     42    if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
     43      PyErr_SetString (PyExc_ValueError, "input array should be float");
     44      return 0;
     45    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
     46      PyErr_SetString (PyExc_ValueError, "input array should be " AUBIO_NPY_SMPL_STR);
     47      return 0;
     48    }
     49
     50    length = PyArray_SIZE ((PyArrayObject *)input);
     51    if (length <= 0) {
     52      PyErr_SetString (PyExc_ValueError, "input array size should be greater than 0");
     53      return 0;
     54    }
     55
     56  } else if (PyObject_TypeCheck (input, &PyList_Type)) {
     57    PyErr_SetString (PyExc_ValueError, "does not convert from list yet");
     58    return 0;
     59  } else {
     60    PyErr_SetString (PyExc_ValueError, "can only accept vector of float as input");
     61    return 0;
     62  }
     63  return 1;
    7564}
    7665
    77 cvec_t *
    78 PyAubio_ArrayToCCvec (PyObject *input) {
    79   if (PyObject_TypeCheck (input, &Py_cvecType)) {
    80       return ((Py_cvec*)input)->o;
    81   } else {
    82       PyErr_SetString (PyExc_ValueError, "input array should be float32");
    83       return NULL;
     66int
     67PyAubio_ArrayToCFvec (PyObject *input, fvec_t *out) {
     68
     69  if (!PyAubio_IsValidVector(input)){
     70    return 0;
    8471  }
     72
     73  out->length = (uint_t) PyArray_SIZE ((PyArrayObject *)input);
     74  out->data = (smpl_t *) PyArray_GETPTR1 ((PyArrayObject *)input, 0);
     75  return 1;
    8576}
    8677
     
    10293}
    10394
    104 fmat_t *
    105 PyAubio_ArrayToCFmat (PyObject *input) {
    106   PyObject *array;
    107   fmat_t *mat;
    108   uint_t i;
     95int
     96PyAubio_ArrayToCFmat (PyObject *input, fmat_t *mat) {
     97  uint_t i, new_height;
     98  npy_intp length, height;
    10999  if (input == NULL) {
    110100    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
    111     goto fail;
     101    return 0;
    112102  }
    113103  // parsing input object into a Py_fvec
     
    117107    if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
    118108      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    119       goto fail;
     109      return 0;
    120110    } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
    121111      PyErr_SetString (PyExc_ValueError,
    122112          "input array has more than two dimensions");
    123       goto fail;
     113      return 0;
    124114    }
    125115
    126116    if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
    127117      PyErr_SetString (PyExc_ValueError, "input array should be float");
    128       goto fail;
     118      return 0;
    129119    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    130       PyErr_SetString (PyExc_ValueError, "input array should be float32");
    131       goto fail;
    132     } else {
    133       // input data type is float32, nothing else to do
    134       array = input;
     120      PyErr_SetString (PyExc_ValueError, "input array should be " AUBIO_NPY_SMPL_STR);
     121      return 0;
    135122    }
    136123
    137124    // no need to really allocate fvec, just its struct member
    138     mat = (fmat_t *)malloc(sizeof(fmat_t));
    139     long length = PyArray_DIM ((PyArrayObject *)array, 1);
    140     if (length > 0) {
    141       mat->length = (uint_t)length;
    142     } else {
     125    length = PyArray_DIM ((PyArrayObject *)input, 1);
     126    if (length <= 0) {
    143127      PyErr_SetString (PyExc_ValueError, "input array dimension 1 should be greater than 0");
    144       goto fail;
     128      return 0;
    145129    }
    146     long height = PyArray_DIM ((PyArrayObject *)array, 0);
    147     if (height > 0) {
    148       mat->height = (uint_t)height;
    149     } else {
     130    height = PyArray_DIM ((PyArrayObject *)input, 0);
     131    if (height <= 0) {
    150132      PyErr_SetString (PyExc_ValueError, "input array dimension 0 should be greater than 0");
    151       goto fail;
    152     }
    153     mat->data = (smpl_t **)malloc(sizeof(smpl_t*) * mat->height);
    154     for (i=0; i< mat->height; i++) {
    155       mat->data[i] = (smpl_t*)PyArray_GETPTR1 ((PyArrayObject *)array, i);
     133      return 0;
    156134    }
    157135
    158136  } else if (PyObject_TypeCheck (input, &PyList_Type)) {
    159137    PyErr_SetString (PyExc_ValueError, "can not convert list to fmat");
    160     return NULL;
     138    return 0;
    161139  } else {
    162140    PyErr_SetString (PyExc_ValueError, "can only accept matrix of float as input");
    163     return NULL;
     141    return 0;
    164142  }
    165143
    166   return mat;
     144  new_height = (uint_t)PyArray_DIM ((PyArrayObject *)input, 0);
     145  if (mat->height != new_height) {
     146    if (mat->data) {
     147      free(mat->data);
     148    }
     149    mat->data = (smpl_t **)malloc(sizeof(smpl_t*) * new_height);
     150  }
    167151
    168 fail:
    169   return NULL;
     152  mat->height = new_height;
     153  mat->length = (uint_t)PyArray_DIM ((PyArrayObject *)input, 1);
     154  for (i=0; i< mat->height; i++) {
     155    mat->data[i] = (smpl_t*)PyArray_GETPTR1 ((PyArrayObject *)input, i);
     156  }
     157  return 1;
    170158}
    171 
  • python/ext/py-cvec.c

    r00d0275 r155cc10  
    11#include "aubio-types.h"
    22
    3 /* cvec type definition 
     3/* cvec type definition
    44
    55class cvec():
    6     def __init__(self, length = 1024):
    7         self.length = length
    8         self.norm = array(length)
    9         self.phas = array(length)
     6    def __new__(self, length = 1024):
     7        self.length = length / 2 + 1
     8        self.norm = np.zeros(length / 2 + 1)
     9        self.phas = np.zeros(length / 2 + 1)
    1010
    1111*/
    1212
     13// special python type for cvec
     14typedef struct
     15{
     16  PyObject_HEAD
     17  PyObject *norm;
     18  PyObject *phas;
     19  uint_t length;
     20} Py_cvec;
     21
    1322static char Py_cvec_doc[] = "cvec object";
     23
     24
     25PyObject *
     26new_py_cvec(uint_t length) {
     27  Py_cvec* vec = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
     28  npy_intp dims[] = { length / 2 + 1, 1 };
     29  vec->norm = PyArray_ZEROS(1, dims, AUBIO_NPY_SMPL, 0);
     30  vec->phas = PyArray_ZEROS(1, dims, AUBIO_NPY_SMPL, 0);
     31  vec->length = length / 2 + 1;
     32  return (PyObject*)vec;
     33}
     34
     35int
     36PyAubio_PyCvecToCCvec (PyObject *input, cvec_t *i) {
     37  if (PyObject_TypeCheck (input, &Py_cvecType)) {
     38      Py_cvec * in = (Py_cvec *)input;
     39      i->norm = (smpl_t *) PyArray_GETPTR1 ((PyArrayObject *)(in->norm), 0);
     40      i->phas = (smpl_t *) PyArray_GETPTR1 ((PyArrayObject *)(in->phas), 0);
     41      i->length = ((Py_cvec*)input)->length;
     42      return 1;
     43  } else {
     44      PyErr_SetString (PyExc_ValueError, "input array should be aubio.cvec");
     45      return 0;
     46  }
     47}
    1448
    1549static PyObject *
     
    2458    return NULL;
    2559  }
    26 
    2760
    2861  self = (Py_cvec *) type->tp_alloc (type, 0);
     
    4881Py_cvec_init (Py_cvec * self, PyObject * args, PyObject * kwds)
    4982{
    50   self->o = new_cvec ((self->length - 1) * 2);
    51   if (self->o == NULL) {
    52     return -1;
    53   }
    54 
     83  npy_intp dims[] = { self->length, 1 };
     84  self->phas = PyArray_ZEROS(1, dims, AUBIO_NPY_SMPL, 0);
     85  self->norm = PyArray_ZEROS(1, dims, AUBIO_NPY_SMPL, 0);
    5586  return 0;
    5687}
     
    5990Py_cvec_del (Py_cvec * self)
    6091{
    61   del_cvec (self->o);
    62   self->ob_type->tp_free ((PyObject *) self);
     92  Py_DECREF(self->norm);
     93  Py_DECREF(self->phas);
     94  Py_TYPE(self)->tp_free ((PyObject *) self);
    6395}
    6496
     
    70102  PyObject *result = NULL;
    71103
    72   format = PyString_FromString ("aubio cvec of %d elements");
     104  format = PyUnicode_FromString ("aubio cvec of %d elements");
    73105  if (format == NULL) {
    74106    goto fail;
     
    79111    goto fail;
    80112  }
    81   cvec_print ( self->o );
    82 
    83   result = PyString_Format (format, args);
     113  // hide actual norm / phas content
     114
     115  result = PyUnicode_Format (format, args);
    84116
    85117fail:
     
    91123
    92124PyObject *
    93 PyAubio_CvecNormToArray (Py_cvec * self)
    94 {
    95   npy_intp dims[] = { self->o->length, 1 };
    96   return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm);
    97 }
    98 
    99 
    100 PyObject *
    101 PyAubio_CvecPhasToArray (Py_cvec * self)
    102 {
    103   npy_intp dims[] = { self->o->length, 1 };
    104   return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas);
    105 }
    106 
    107 PyObject *
    108 PyAubio_ArrayToCvecPhas (PyObject * self)
    109 {
    110   return NULL;
    111 }
    112 
    113 PyObject *
    114125Py_cvec_get_norm (Py_cvec * self, void *closure)
    115126{
    116   return PyAubio_CvecNormToArray(self);
     127  // we want self->norm to still exist after our caller return it
     128  Py_INCREF(self->norm);
     129  return (PyObject*)(self->norm);
    117130}
    118131
     
    120133Py_cvec_get_phas (Py_cvec * self, void *closure)
    121134{
    122   return PyAubio_CvecPhasToArray(self);
     135  // we want self->phas to still exist after our caller return it
     136  Py_INCREF(self->phas);
     137  return (PyObject *)(self->phas);
    123138}
    124139
     
    126141Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
    127142{
    128   PyArrayObject * array;
    129   if (input == NULL) {
    130     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
    131     goto fail;
    132   }
    133   if (PyArray_Check(input)) {
    134 
    135     // we got an array, convert it to a cvec.norm
    136     if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
    137       PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    138       goto fail;
    139     } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
    140       PyErr_SetString (PyExc_ValueError,
    141           "input array has more than two dimensions");
    142       goto fail;
    143     }
    144 
    145     if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
    146       PyErr_SetString (PyExc_ValueError, "input array should be float");
    147       goto fail;
    148     } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    149       PyErr_SetString (PyExc_ValueError, "input array should be float32");
    150       goto fail;
    151     }
    152     array = (PyArrayObject *)input;
    153 
    154     // check input array dimensions
    155     if (PyArray_NDIM (array) != 1) {
    156       PyErr_Format (PyExc_ValueError,
    157           "input array has %d dimensions, not 1",
    158           PyArray_NDIM (array));
    159       goto fail;
    160     } else {
    161       if (vec->o->length != PyArray_SIZE (array)) {
    162           PyErr_Format (PyExc_ValueError,
    163                   "input array has length %d, but cvec has length %d",
    164                   (int)PyArray_SIZE (array), vec->o->length);
    165           goto fail;
    166       }
    167     }
    168 
    169     vec->o->norm = (smpl_t *) PyArray_GETPTR1 (array, 0);
    170 
    171   } else {
    172     PyErr_SetString (PyExc_ValueError, "can only accept array as input");
    173     return 1;
    174   }
    175 
    176   Py_INCREF(array);
     143  npy_intp length;
     144  if (!PyAubio_IsValidVector(input)) {
     145    return 1;
     146  }
     147  length = PyArray_SIZE ((PyArrayObject *)input);
     148  if (length != vec->length) {
     149    PyErr_Format (PyExc_ValueError,
     150        "input array has length %" NPY_INTP_FMT ", but cvec has length %d", length,
     151        vec->length);
     152    return 1;
     153  }
     154
     155  Py_XDECREF(vec->norm);
     156  vec->norm = input;
     157  Py_INCREF(vec->norm);
    177158  return 0;
    178 
    179 fail:
    180   return 1;
    181159}
    182160
     
    184162Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure)
    185163{
    186   PyArrayObject * array;
    187   if (input == NULL) {
    188     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
    189     goto fail;
    190   }
    191   if (PyArray_Check(input)) {
    192 
    193     // we got an array, convert it to a cvec.phas
    194     if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
    195       PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    196       goto fail;
    197     } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
    198       PyErr_SetString (PyExc_ValueError,
    199           "input array has more than two dimensions");
    200       goto fail;
    201     }
    202 
    203     if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
    204       PyErr_SetString (PyExc_ValueError, "input array should be float");
    205       goto fail;
    206     } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    207       PyErr_SetString (PyExc_ValueError, "input array should be float32");
    208       goto fail;
    209     }
    210     array = (PyArrayObject *)input;
    211 
    212     // check input array dimensions
    213     if (PyArray_NDIM (array) != 1) {
    214       PyErr_Format (PyExc_ValueError,
    215           "input array has %d dimensions, not 1",
    216           PyArray_NDIM (array));
    217       goto fail;
    218     } else {
    219       if (vec->o->length != PyArray_SIZE (array)) {
    220           PyErr_Format (PyExc_ValueError,
    221                   "input array has length %d, but cvec has length %d",
    222                   (int)PyArray_SIZE (array), vec->o->length);
    223           goto fail;
    224       }
    225     }
    226 
    227     vec->o->phas = (smpl_t *) PyArray_GETPTR1 (array, 0);
    228 
    229   } else {
    230     PyErr_SetString (PyExc_ValueError, "can only accept array as input");
    231     return 1;
    232   }
    233 
    234   Py_INCREF(array);
     164  npy_intp length;
     165  if (!PyAubio_IsValidVector(input)) {
     166    return 1;
     167  }
     168  length = PyArray_SIZE ((PyArrayObject *)input);
     169  if (length != vec->length) {
     170    PyErr_Format (PyExc_ValueError,
     171        "input array has length %" NPY_INTP_FMT ", but cvec has length %d", length,
     172        vec->length);
     173    return 1;
     174  }
     175
     176  Py_XDECREF(vec->phas);
     177  vec->phas = input;
     178  Py_INCREF(vec->phas);
    235179  return 0;
    236 
    237 fail:
    238   return 1;
    239180}
    240181
     
    261202
    262203PyTypeObject Py_cvecType = {
    263   PyObject_HEAD_INIT (NULL)
    264   0,                            /* ob_size           */
     204  PyVarObject_HEAD_INIT(NULL, 0)
    265205  "aubio.cvec",                 /* tp_name           */
    266206  sizeof (Py_cvec),             /* tp_basicsize      */
     
    273213  (reprfunc) Py_cvec_repr,      /* tp_repr           */
    274214  0,                            /* tp_as_number      */
    275   0, //&Py_cvec_tp_as_sequence,      /* tp_as_sequence    */
     215  0, //&Py_cvec_tp_as_sequence, /* tp_as_sequence    */
    276216  0,                            /* tp_as_mapping     */
    277217  0,                            /* tp_hash           */
     
    300240  0,                            /* tp_alloc          */
    301241  Py_cvec_new,                  /* tp_new            */
    302 };
     242  0,
     243  0,
     244  0,
     245  0,
     246  0,
     247  0,
     248  0,
     249  0,
     250  0,
     251};
  • python/ext/py-fft.c

    r00d0275 r155cc10  
    1 #include "aubiowraphell.h"
     1#include "aubio-types.h"
    22
    33static char Py_fft_doc[] = "fft object";
    44
    5 AUBIO_DECLARE(fft, uint_t win_s)
     5typedef struct
     6{
     7  PyObject_HEAD
     8  aubio_fft_t * o;
     9  uint_t win_s;
     10  // do / rdo input vectors
     11  fvec_t vecin;
     12  cvec_t cvecin;
     13  // do / rdo output results
     14  PyObject *doout;
     15  PyObject *rdoout;
     16} Py_fft;
    617
    7 //AUBIO_NEW(fft)
    818static PyObject *
    919Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
     
    3747}
    3848
     49static int
     50Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds)
     51{
     52  self->o = new_aubio_fft (self->win_s);
     53  if (self->o == NULL) {
     54    // PyErr_Format(PyExc_RuntimeError, ...) was set above by new_ which called
     55    // AUBIO_ERR when failing
     56    return -1;
     57  }
    3958
    40 AUBIO_INIT(fft, self->win_s)
     59  self->doout = new_py_cvec(self->win_s);
     60  self->rdoout = new_py_fvec(self->win_s);
    4161
    42 AUBIO_DEL(fft)
     62  return 0;
     63}
    4364
    44 static PyObject *
    45 Py_fft_do(PyObject * self, PyObject * args)
     65static void
     66Py_fft_del (Py_fft *self, PyObject *unused)
     67{
     68  Py_XDECREF(self->doout);
     69  Py_XDECREF(self->rdoout);
     70  if (self->o) {
     71    del_aubio_fft(self->o);
     72  }
     73  Py_TYPE(self)->tp_free((PyObject *) self);
     74}
     75
     76static PyObject *
     77Py_fft_do(Py_fft * self, PyObject * args)
    4678{
    4779  PyObject *input;
    48   fvec_t *vec;
    49   cvec_t *output;
     80  cvec_t c_out;
    5081
    5182  if (!PyArg_ParseTuple (args, "O", &input)) {
     
    5384  }
    5485
    55   vec = PyAubio_ArrayToCFvec (input);
    56 
    57   if (vec == NULL) {
     86  if (!PyAubio_ArrayToCFvec(input, &(self->vecin))) {
    5887    return NULL;
    5988  }
    6089
    61   output = new_cvec(((Py_fft *) self)->win_s);
     90  if (self->vecin.length != self->win_s) {
     91    PyErr_Format(PyExc_ValueError,
     92                 "input array has length %d, but fft expects length %d",
     93                 self->vecin.length, self->win_s);
     94    return NULL;
     95  }
    6296
     97  Py_INCREF(self->doout);
     98  if (!PyAubio_PyCvecToCCvec(self->doout, &c_out)) {
     99    return NULL;
     100  }
    63101  // compute the function
    64   aubio_fft_do (((Py_fft *)self)->o, vec, output);
    65   return (PyObject *)PyAubio_CCvecToPyCvec(output);
     102  aubio_fft_do (self->o, &(self->vecin), &c_out);
     103  return self->doout;
    66104}
    67105
    68 AUBIO_MEMBERS_START(fft)
     106static PyMemberDef Py_fft_members[] = {
    69107  {"win_s", T_INT, offsetof (Py_fft, win_s), READONLY,
    70108    "size of the window"},
    71 AUBIO_MEMBERS_STOP(fft)
     109  {NULL}
     110};
    72111
    73 static PyObject * 
     112static PyObject *
    74113Py_fft_rdo(Py_fft * self, PyObject * args)
    75114{
    76115  PyObject *input;
    77   cvec_t *vec;
    78   fvec_t *output;
     116  fvec_t out;
    79117
    80118  if (!PyArg_ParseTuple (args, "O", &input)) {
     
    82120  }
    83121
    84   vec = PyAubio_ArrayToCCvec (input);
    85 
    86   if (vec == NULL) {
     122  if (!PyAubio_PyCvecToCCvec (input, &(self->cvecin)) ) {
    87123    return NULL;
    88124  }
    89125
    90   output = new_fvec(self->win_s);
     126  if (self->cvecin.length != self->win_s / 2 + 1) {
     127    PyErr_Format(PyExc_ValueError,
     128                 "input cvec has length %d, but fft expects length %d",
     129                 self->cvecin.length, self->win_s / 2 + 1);
     130    return NULL;
     131  }
    91132
     133  Py_INCREF(self->rdoout);
     134  if (!PyAubio_ArrayToCFvec(self->rdoout, &out) ) {
     135    return NULL;
     136  }
    92137  // compute the function
    93   aubio_fft_rdo (((Py_fft *)self)->o, vec, output);
    94   return (PyObject *)PyAubio_CFvecToArray(output);
     138  aubio_fft_rdo (self->o, &(self->cvecin), &out);
     139  return self->rdoout;
    95140}
    96141
     
    101146};
    102147
    103 AUBIO_TYPEOBJECT(fft, "aubio.fft")
     148PyTypeObject Py_fftType = {
     149  PyVarObject_HEAD_INIT (NULL, 0)
     150  "aubio.fft",
     151  sizeof (Py_fft),
     152  0,
     153  (destructor) Py_fft_del,
     154  0,
     155  0,
     156  0,
     157  0,
     158  0,
     159  0,
     160  0,
     161  0,
     162  0,
     163  (ternaryfunc)Py_fft_do,
     164  0,
     165  0,
     166  0,
     167  0,
     168  Py_TPFLAGS_DEFAULT,
     169  Py_fft_doc,
     170  0,
     171  0,
     172  0,
     173  0,
     174  0,
     175  0,
     176  Py_fft_methods,
     177  Py_fft_members,
     178  0,
     179  0,
     180  0,
     181  0,
     182  0,
     183  0,
     184  (initproc) Py_fft_init,
     185  0,
     186  Py_fft_new,
     187  0,
     188  0,
     189  0,
     190  0,
     191  0,
     192  0,
     193  0,
     194  0,
     195  0,
     196};
  • python/ext/py-filter.c

    r00d0275 r155cc10  
    66  aubio_filter_t * o;
    77  uint_t order;
     8  fvec_t vec;
     9  PyObject *out;
     10  fvec_t c_out;
    811} Py_filter;
    912
     
    4851    return -1;
    4952  }
    50 
     53  self->out = NULL;
    5154  return 0;
    5255}
     
    5558Py_filter_del (Py_filter * self)
    5659{
     60  Py_XDECREF(self->out);
    5761  del_aubio_filter (self->o);
    58   self->ob_type->tp_free ((PyObject *) self);
    59 }
    60 
    61 static PyObject * 
     62  Py_TYPE(self)->tp_free ((PyObject *) self);
     63}
     64
     65static PyObject *
    6266Py_filter_do(Py_filter * self, PyObject * args)
    6367{
    6468  PyObject *input;
    65   fvec_t *vec;
    6669
    6770  if (!PyArg_ParseTuple (args, "O:digital_filter.do", &input)) {
     
    7376  }
    7477
    75   vec = PyAubio_ArrayToCFvec (input);
    76 
    77   if (vec == NULL) {
    78     return NULL;
    79   }
    80 
     78  if (!PyAubio_ArrayToCFvec(input, &(self->vec))) {
     79    return NULL;
     80  }
     81
     82  // initialize output now
     83  if (self->out == NULL) {
     84    self->out = new_py_fvec(self->vec.length);
     85  }
     86
     87  Py_INCREF(self->out);
     88  if (!PyAubio_ArrayToCFvec(self->out, &(self->c_out)) ) {
     89    return NULL;
     90  }
    8191  // compute the function
    82   fvec_t * out = new_fvec(vec->length);
    83   aubio_filter_do_outplace (self->o, vec, out);
    84   return PyAubio_CFvecToArray(out);
    85 }
    86 
    87 static PyObject *
     92  aubio_filter_do_outplace (self->o, &(self->vec), &(self->c_out));
     93  return self->out;
     94}
     95
     96static PyObject *
    8897Py_filter_set_c_weighting (Py_filter * self, PyObject *args)
    8998{
     
    103112}
    104113
    105 static PyObject * 
     114static PyObject *
    106115Py_filter_set_a_weighting (Py_filter * self, PyObject *args)
    107116{
     
    157166
    158167PyTypeObject Py_filterType = {
    159   PyObject_HEAD_INIT (NULL)
    160   0,                            /* ob_size           */
     168  PyVarObject_HEAD_INIT(NULL, 0)
    161169  "aubio.digital_filter",       /* tp_name           */
    162170  sizeof (Py_filter),           /* tp_basicsize      */
     
    196204  0,                            /* tp_alloc          */
    197205  Py_filter_new,                /* tp_new            */
     206  0,
     207  0,
     208  0,
     209  0,
     210  0,
     211  0,
     212  0,
     213  0,
     214  0,
    198215};
  • python/ext/py-filterbank.c

    r00d0275 r155cc10  
    1 #include "aubiowraphell.h"
     1#include "aubio-types.h"
    22