Unified · Split
| @@ -7,27 +7,27 @@ environment: · 6 unmodified lines | ||
| 7 | 7 | |
| 8 | 8 | # pre-installed python version, see: |
| 9 | 9 | # http://www.appveyor.com/docs/installed-software#python |
| 10 | − - PYTHON: "C:\\Python27" | |
| 10 | + - PYTHONDIR: "C:\\Python27" | |
| 11 | 11 | PYTHON_VERSION: "2.7.x" |
| 12 | 12 | PYTHON_ARCH: "32" |
| 13 | 13 | |
| 14 | − - PYTHON: "C:\\Python27-x64" | |
| 14 | + - PYTHONDIR: "C:\\Python27-x64" | |
| 15 | 15 | PYTHON_VERSION: "2.7.x" |
| 16 | 16 | PYTHON_ARCH: "64" |
| 17 | 17 | |
| 18 | − - PYTHON: "C:\\Python34" | |
| 18 | + - PYTHONDIR: "C:\\Python34" | |
| 19 | 19 | PYTHON_VERSION: "3.4.x" |
| 20 | 20 | PYTHON_ARCH: "32" |
| 21 | 21 | |
| 22 | − - PYTHON: "C:\\Python34-x64" | |
| 22 | + - PYTHONDIR: "C:\\Python34-x64" | |
| 23 | 23 | PYTHON_VERSION: "3.4.x" |
| 24 | 24 | PYTHON_ARCH: "64" |
| 25 | 25 | |
| 26 | − - PYTHON: "C:\\Python35" | |
| 26 | + - PYTHONDIR: "C:\\Python35" | |
| 27 | 27 | PYTHON_VERSION: "3.5.x" |
| 28 | 28 | PYTHON_ARCH: "32" |
| 29 | 29 | |
| 30 | − - PYTHON: "C:\\Python35-x64" | |
| 30 | + - PYTHONDIR: "C:\\Python35-x64" | |
| 31 | 31 | PYTHON_VERSION: "3.5.x" |
| 32 | 32 | PYTHON_ARCH: "64" |
| 33 | 33 | # add path required to run preprocessor step |
| @@ -39,20 +39,19 @@ install: · 5 unmodified lines | ||
| 39 | 39 | - ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\"" |
| 40 | 40 | |
| 41 | 41 | # Check that we have the expected version and architecture for Python |
| 42 | − - "%PYTHON%\\python.exe --version" | |
| 43 | − - "%PYTHON%\\python.exe -c \"import struct; print(struct.calcsize('P') * 8)\"" | |
| 42 | + - "%PYTHONDIR%\\python.exe --version" | |
| 43 | + - "%PYTHONDIR%\\python.exe -c \"import struct; print(struct.calcsize('P') * 8)\"" | |
| 44 | 44 | |
| 45 | 45 | # We need wheel installed to build wheels |
| 46 | − - "%PYTHON%\\python.exe -m pip install wheel" | |
| 46 | + - "%PYTHONDIR%\\python.exe -m pip install wheel" | |
| 47 | 47 | |
| 48 | − - "SET PATH=%PATH_EXTRAS%;%PYTHON%;%PYTHON%\\Scripts;%PATH%" | |
| 48 | + - "SET PATH=%PATH_EXTRAS%;%PYTHONDIR%;%PYTHONDIR%\\Scripts;%PATH%" | |
| 49 | 49 | |
| 50 | 50 | - "pip install --disable-pip-version-check --user --upgrade pip" |
| 51 | 51 | - "pip install --upgrade setuptools" |
| 52 | 52 | |
| 53 | 53 | before_build: |
| 54 | − - curl -fsS -o waf https://waf.io/waf-1.8.22 | |
| 55 | − - curl -fsS -o waf.bat https://raw.githubusercontent.com/waf-project/waf/master/utils/waf.bat | |
| 54 | + - "bash scripts/get_waf.sh" | |
| 56 | 55 | |
| 57 | 56 | build_script: |
| 58 | 57 | # build python module without using libaubio |
| @@ -62,8 +61,6 @@ build_script: · 3 unmodified lines | ||
| 62 | 61 | - "python python\\demos\\demo_create_test_sounds.py" |
| 63 | 62 | - "nose2 --verbose" |
| 64 | 63 | # clean up |
| 65 | − - waf distclean | |
| 64 | + - "python waf distclean" | |
| 66 | 65 | # build libaubio |
| 67 | − - waf configure build --verbose | |
| 68 | − # build python module using libaubio dll | |
| 69 | − - "python setup.py build" | |
| 66 | + - python waf configure build --verbose --msvc_version="msvc 14.0" | |
| @@ -0,0 +1,3 @@ | ||
| 1 | +[run] | |
| 2 | +branch = True | |
| 3 | +source = aubio | |
| @@ -81,6 +81,7 @@ addons: · 80 unmodified lines | ||
| 81 | 81 | - libasound2-dev |
| 82 | 82 | - libfftw3-dev |
| 83 | 83 | - sox |
| 84 | + - lcov | |
| 84 | 85 | |
| 85 | 86 | before_install: |
| 86 | 87 | - | |
| @@ -89,6 +90,7 @@ before_install: · 2 unmodified lines | ||
| 89 | 90 | brew install sox |
| 90 | 91 | brew install ffmpeg |
| 91 | 92 | brew install libsndfile |
| 93 | + brew install lcov | |
| 92 | 94 | export PATH="$HOME/Library/Python/2.7/bin/:$PATH" |
| 93 | 95 | fi; |
| 94 | 96 | |
| @@ -97,17 +99,30 @@ install: · 2 unmodified lines | ||
| 97 | 99 | - travis_retry make getwaf expandwaf deps_python |
| 98 | 100 | - which pip |
| 99 | 101 | - pip --version |
| 102 | + - pip install python-coveralls | |
| 103 | + - gem install coveralls-lcov | |
| 100 | 104 | |
| 101 | 105 | script: |
| 102 | 106 | - make create_test_sounds |
| 103 | 107 | - | |
| 104 | 108 | if [[ -z "$AUBIO_NOTESTS" ]]; then |
| 105 | 109 | make test_lib_python_clean |
| 106 | − make test_python_only_clean | |
| 110 | + make coverage | |
| 107 | 111 | else |
| 108 | 112 | make test_lib_only_clean |
| 109 | 113 | fi; |
| 110 | 114 | |
| 115 | +after_success: | |
| 116 | + - | | |
| 117 | + if [[ -z "$AUBIO_NOTESTS" ]]; then | |
| 118 | + # upload lcov coverage to coveralls.io | |
| 119 | + coveralls-lcov build/coverage.info | |
| 120 | + # upload python coverage | |
| 121 | + #coveralls | |
| 122 | + # upload to codecov | |
| 123 | + bash <(curl -s https://codecov.io/bash) | |
| 124 | + fi | |
| 125 | + | |
| 111 | 126 | notifications: |
| 112 | 127 | irc: |
| 113 | 128 | channels: |
| @@ -1,3 +1,70 @@ | ||
| 1 | +2017-10-02 Paul Brossier <piem@aubio.org> | |
| 2 | + | |
| 3 | + [ Overview ] | |
| 4 | + | |
| 5 | + * VERSION: bump to 0.4.6 | |
| 6 | + * src/spectral/fft.c, src/*.c: add support for Intel IPP (many thanks to | |
| 7 | + Eduard Mueller) | |
| 8 | + * wscript: add support for emscripten (thanks to Martin Hermant) | |
| 9 | + * src/pitch/pitchyinfast.h: new fast method to compute YIN algorithm | |
| 10 | + * src/pitch/pitchyin*.c: improve confidence measure, making sure its value | |
| 11 | + corresponds to the selected period (thanks to Eduard Mueller) | |
| 12 | + * python/lib/aubio/cmd.py: add `quiet`, `cut`, and `help` subcommands | |
| 13 | + | |
| 14 | + [ Library ] | |
| 15 | + | |
| 16 | + * src/aubio_priv.h: add missing aubio_vDSP_vclr (Eduard Mueller) | |
| 17 | + * src/io/source_avcodec.c: improve error message, prevent un-opened bracket, | |
| 18 | + no declaration after statements for older compilers, avoid unused variable | |
| 19 | + * src/mathutils.c: prevent segfault with Accelerate.framework (closes #58, | |
| 20 | + closes #102) | |
| 21 | + * src/spectral/phasevoc.h: add aubio_pvoc_set_window to change the windowing | |
| 22 | + function | |
| 23 | + * src/mathutils.c: add window type `ones` (no windowing) | |
| 24 | + | |
| 25 | + [ Python ] | |
| 26 | + | |
| 27 | + * python/demos/demo_tapthebeat.py: add a real-time example to play beats | |
| 28 | + using pyaudio | |
| 29 | + * python/lib/gen_external.py: improve parsing and syntax, use results in | |
| 30 | + emscripten build (Martin Hermant) | |
| 31 | + * python/lib/aubio/cmd.py: add option `-u` to `aubio pitch`, improve error | |
| 32 | + messages, add `quiet` subcommand (closes #124), improve syntax, add some | |
| 33 | + documentation, add `cut` and `help` subcommand, add silence and time format | |
| 34 | + options | |
| 35 | + * python/lib/aubio/cut.py: upgrade to argparse, set samplerate as needed | |
| 36 | + * python/demos/demo_yin_compare.py: add comparison of yin implementations | |
| 37 | + * python/demos/demo_wav2midi.py: add an example to create a midi from a | |
| 38 | + sound file using mido (closes: #134) | |
| 39 | + * python/demos/demo_bpm_extract.py: use argparse, use beats_to_bpm function | |
| 40 | + * python/ext/py-cvec.c: fix support for pypy by changing setters to return a | |
| 41 | + negative value on error (closes #17) | |
| 42 | + | |
| 43 | + [ Documentation ] | |
| 44 | + | |
| 45 | + * src/tempo/beattracking.h: fix typo (thanks to Hannes Fritz) | |
| 46 | + * doc/requirements.rst: fix broken link (thanks to @ssj71, closes #99) | |
| 47 | + * doc/aubiomfcc.txt: fix typo in 'coefficients' | |
| 48 | + | |
| 49 | + [ Tests ] | |
| 50 | + | |
| 51 | + * python/tests/tests_aubio_{cmd,cut}.py: add basic tests | |
| 52 | + * python/tests/test_filterbank*.py: ignore UserWarnings, clean-up, | |
| 53 | + improve get_coeff tests | |
| 54 | + | |
| 55 | + [ Build system ] | |
| 56 | + | |
| 57 | + * wscript: add support for emscripten, see scripts/build_emscripten | |
| 58 | + * scripts/get_waf.sh: update waf to 2.0.1, build waf from source tarball | |
| 59 | + * scripts/build_emscripten: update to build aubio.js | |
| 60 | + * Makefile: add coverage and coverage_report targets, run tests once | |
| 61 | + | |
| 62 | + [ Continuous integration ] | |
| 63 | + | |
| 64 | + * .travis.yml: add coverage report on osx | |
| 65 | + * .appveyor.yml: use msvc 14.0 (VS 2015) and scripts/get_waf.sh | |
| 66 | + * .coveragerc: add minimal python coverage configuration | |
| 67 | + | |
| 1 | 68 | 2017-04-10 Paul Brossier <piem@aubio.org> |
| 2 | 69 | |
| 3 | 70 | [Overview] |
| @@ -35,6 +35,9 @@ INCLUDEDIR?=$(PREFIX)/include · 34 unmodified lines | ||
| 35 | 35 | DATAROOTDIR?=$(PREFIX)/share |
| 36 | 36 | MANDIR?=$(DATAROOTDIR)/man |
| 37 | 37 | |
| 38 | +# default nose2 command | |
| 39 | +NOSE2?=nose2 -N 4 --verbose | |
| 40 | + | |
| 38 | 41 | SOX=sox |
| 39 | 42 | |
| 40 | 43 | TESTSOUNDS := python/tests/sounds |
| @@ -135,9 +138,9 @@ test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR) · 94 unmodified lines | ||
| 135 | 138 | test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR) |
| 136 | 139 | test_python: local_dylib |
| 137 | 140 | # run test with installed package |
| 138 | − ./python/tests/run_all_tests --verbose | |
| 139 | − # also run with nose, multiple processes | |
| 140 | − nose2 -N 4 | |
| 141 | + # ./python/tests/run_all_tests --verbose | |
| 142 | + # run with nose2, multiple processes | |
| 143 | + $(NOSE2) | |
| 141 | 144 | |
| 142 | 145 | clean_python: |
| 143 | 146 | ./setup.py clean |
| @@ -231,6 +234,27 @@ test_python_only_clean: test_python_only \ · 87 unmodified lines | ||
| 231 | 234 | uninstall_python \ |
| 232 | 235 | check_clean_python |
| 233 | 236 | |
| 237 | +coverage: export CFLAGS=--coverage | |
| 238 | +coverage: export LDFLAGS=--coverage | |
| 239 | +coverage: export PYTHONPATH=$(PWD)/python/lib | |
| 240 | +coverage: export LD_LIBRARY_PATH=$(PWD)/build/src | |
| 241 | +coverage: force_uninstall_python deps_python \ | |
| 242 | + clean_python clean distclean build local_dylib | |
| 243 | + lcov --capture --no-external --directory . --output-file build/coverage_lib.info | |
| 244 | + pip install -v -e . | |
| 245 | + coverage run `which nose2` | |
| 246 | + lcov --capture --no-external --directory . --output-file build/coverage_python.info | |
| 247 | + lcov -a build/coverage_python.info -a build/coverage_lib.info -o build/coverage.info | |
| 248 | + | |
| 249 | +coverage_report: coverage | |
| 250 | + genhtml build/coverage.info --output-directory lcov_html | |
| 251 | + mkdir -p gcovr_html/ | |
| 252 | + gcovr -r . --html --html-details \ | |
| 253 | + --output gcovr_html/index.html \ | |
| 254 | + --exclude ".*tests/.*" --exclude ".*examples/.*" | |
| 255 | + coverage report | |
| 256 | + coverage html | |
| 257 | + | |
| 234 | 258 | sphinx: configure |
| 235 | 259 | $(WAFCMD) sphinx $(WAFOPTS) |
| 236 | 260 | |
| @@ -4,7 +4,7 @@ aubio · 3 unmodified lines | ||
| 4 | 4 | [](https://travis-ci.org/aubio/aubio "Travis build status") |
| 5 | 5 | [](https://ci.appveyor.com/project/piem/aubio "Appveyor build status") |
| 6 | 6 | [](https://landscape.io/github/aubio/aubio/master "Landscape code health") |
| 7 | −[](https://github.com/aubio/aubio "Commits since last release") | |
| 7 | +[](https://github.com/aubio/aubio "Commits since last release") | |
| 8 | 8 | |
| 9 | 9 | [](http://aubio.readthedocs.io/en/latest/?badge=latest "Latest documentation") |
| 10 | 10 | [](https://zenodo.org/badge/latestdoi/396389) |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | AUBIO_MAJOR_VERSION=0 |
| 2 | 2 | AUBIO_MINOR_VERSION=4 |
| 3 | −AUBIO_PATCH_VERSION=6 | |
| 3 | +AUBIO_PATCH_VERSION=7 | |
| 4 | 4 | AUBIO_VERSION_STATUS='~alpha' |
| 5 | 5 | LIBAUBIO_LT_CUR=5 |
| 6 | −LIBAUBIO_LT_REV=2 | |
| 7 | −LIBAUBIO_LT_AGE=6 | |
| 6 | +LIBAUBIO_LT_REV=3 | |
| 7 | +LIBAUBIO_LT_AGE=7 | |
| @@ -17,7 +17,7 @@ Current status · 16 unmodified lines | ||
| 17 | 17 | :target: https://aubio.readthedocs.io/en/latest/?badge=latest |
| 18 | 18 | :alt: Documentation status |
| 19 | 19 | |
| 20 | −.. image:: https://img.shields.io/github/commits-since/aubio/aubio/0.4.5.svg?maxAge=2592000 | |
| 20 | +.. image:: https://img.shields.io/github/commits-since/aubio/aubio/0.4.6.svg?maxAge=2592000 | |
| 21 | 21 | :target: https://github.com/aubio/aubio |
| 22 | 22 | :alt: Commits since last release |
| 23 | 23 | |
| @@ -142,14 +142,14 @@ Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure) · 141 unmodified lines | ||
| 142 | 142 | { |
| 143 | 143 | npy_intp length; |
| 144 | 144 | if (!PyAubio_IsValidVector(input)) { |
| 145 | − return 1; | |
| 145 | + return -1; | |
| 146 | 146 | } |
| 147 | 147 | length = PyArray_SIZE ((PyArrayObject *)input); |
| 148 | 148 | if (length != vec->length) { |
| 149 | 149 | PyErr_Format (PyExc_ValueError, |
| 150 | 150 | "input array has length %" NPY_INTP_FMT ", but cvec has length %d", length, |
| 151 | 151 | vec->length); |
| 152 | − return 1; | |
| 152 | + return -1; | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | Py_XDECREF(vec->norm); |
| @@ -163,14 +163,14 @@ Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure) · 7 unmodified lines | ||
| 163 | 163 | { |
| 164 | 164 | npy_intp length; |
| 165 | 165 | if (!PyAubio_IsValidVector(input)) { |
| 166 | − return 1; | |
| 166 | + return -1; | |
| 167 | 167 | } |
| 168 | 168 | length = PyArray_SIZE ((PyArrayObject *)input); |
| 169 | 169 | if (length != vec->length) { |
| 170 | 170 | PyErr_Format (PyExc_ValueError, |
| 171 | 171 | "input array has length %" NPY_INTP_FMT ", but cvec has length %d", length, |
| 172 | 172 | vec->length); |
| 173 | − return 1; | |
| 173 | + return -1; | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | Py_XDECREF(vec->phas); |
| @@ -10,7 +10,11 @@ class aubio_cmd(TestCase): · 9 unmodified lines | ||
| 10 | 10 | self.a_parser = aubio.cmd.aubio_parser() |
| 11 | 11 | |
| 12 | 12 | def test_default_creation(self): |
| 13 | − assert self.a_parser.parse_args(['-V']).show_version | |
| 13 | + try: | |
| 14 | + assert self.a_parser.parse_args(['-V']).show_version | |
| 15 | + except SystemExit: | |
| 16 | + url = 'https://bugs.python.org/issue9253' | |
| 17 | + self.skipTest('subcommand became optional in py3, see %s' % url) | |
| 14 | 18 | |
| 15 | 19 | class aubio_cmd_utils(TestCase): |
| 16 | 20 | |
| @@ -1,4 +1,4 @@ | ||
| 1 | −#! /bin/sh | |
| 1 | +#! /bin/bash | |
| 2 | 2 | |
| 3 | 3 | function checkprog() { |
| 4 | 4 | type $1 >/dev/null 2>&1 || { echo >&2 "$1 required but not found, aborting."; exit 1; } |
| @@ -9,13 +9,10 @@ checkprog emconfigure · 4 unmodified lines | ||
| 9 | 9 | checkprog emmake |
| 10 | 10 | |
| 11 | 11 | # clean |
| 12 | −emmake ./waf distclean | |
| 12 | +./waf distclean | |
| 13 | 13 | |
| 14 | 14 | # configure |
| 15 | −emconfigure ./waf configure --prefix=$EMSCRIPTEN/system/local/ --with-target-platform emscripten | |
| 15 | +emconfigure ./waf configure --with-target-platform emscripten $* | |
| 16 | 16 | |
| 17 | 17 | # build |
| 18 | −emmake ./waf --testcmd="node %s" | |
| 19 | − | |
| 20 | −# intall | |
| 21 | −#emmake ./waf install | |
| 18 | +emmake ./waf build | |
| @@ -14,7 +14,7 @@ python this_version.py -v · 13 unmodified lines | ||
| 14 | 14 | VERSION=`python $PWD/this_version.py -v` |
| 15 | 15 | |
| 16 | 16 | FFMPEG_BUILDS_URL="https://ffmpeg.zeranoe.com/builds" |
| 17 | −FFMPEG_DEFAULT="20170404-1229007" | |
| 17 | +FFMPEG_DEFAULT="3.3.3" | |
| 18 | 18 | |
| 19 | 19 | # define some default CFLAGS |
| 20 | 20 | DEF_CFLAGS="-Os -I/usr/share/mingw-w64" |
| @@ -80,10 +80,7 @@ function build_mingw() { · 59 unmodified lines | ||
| 80 | 80 | ./waf distclean configure build install $WAFOPTS_TGT --testcmd='echo %s' |
| 81 | 81 | # fix dll location (see https://github.com/waf-project/waf/issues/1860) |
| 82 | 82 | mv $DESTDIR/lib/libaubio-5.dll $DESTDIR/bin |
| 83 | − # generate def file (see https://github.com/aubio/aubio/issues/97) | |
| 84 | − ( echo -e "EXPORTS"; $NM $DESTDIR/bin/libaubio-5.dll | grep T\ | \ | |
| 85 | − egrep "(aubio|fvec|cvec|lvec|fmat)" | sed 's/^.* T _\?//' ) \ | |
| 86 | − > $DESTDIR/bin/libaubio-5.def | |
| 83 | + mv $DESTDIR/lib/libaubio-5.def $DESTDIR/bin | |
| 87 | 84 | zip -r $DESTDIR.zip `basename $DESTDIR` |
| 88 | 85 | rm -rf $DESTDIR |
| 89 | 86 | sha256sum $DESTDIR.zip > $DESTDIR.zip.sha256 |
| @@ -1,10 +1,37 @@ | ||
| 1 | −#! /bin/sh | |
| 1 | +#! /bin/bash | |
| 2 | 2 | |
| 3 | 3 | set -e |
| 4 | 4 | set -x |
| 5 | 5 | |
| 6 | −WAFURL=https://waf.io/waf-1.9.12 | |
| 6 | +WAFVERSION=2.0.1 | |
| 7 | +WAFTARBALL=waf-$WAFVERSION.tar.bz2 | |
| 8 | +WAFURL=https://waf.io/$WAFTARBALL | |
| 7 | 9 | |
| 8 | −( which wget > /dev/null && wget -qO waf $WAFURL ) || ( which curl > /dev/null && curl $WAFURL > waf ) | |
| 10 | +WAFBUILDDIR=`mktemp -d` | |
| 9 | 11 | |
| 10 | −chmod +x waf | |
| 12 | +function cleanup () { | |
| 13 | + rm -rf $WAFBUILDDIR | |
| 14 | +} | |
| 15 | + | |
| 16 | +trap cleanup SIGINT SIGTERM | |
| 17 | + | |
| 18 | +function buildwaf () { | |
| 19 | + pushd $WAFBUILDDIR | |
| 20 | + | |
| 21 | + ( which wget > /dev/null && wget -qO $WAFTARBALL $WAFURL ) || ( which curl > /dev/null && curl $WAFURL > $WAFTARBALL ) | |
| 22 | + | |
| 23 | + tar xf $WAFTARBALL | |
| 24 | + pushd waf-$WAFVERSION | |
| 25 | + NOCLIMB=1 python waf-light --tools=c_emscripten $* | |
| 26 | + | |
| 27 | + popd | |
| 28 | + popd | |
| 29 | + | |
| 30 | + cp -prv $WAFBUILDDIR/waf-$WAFVERSION/waf $PWD | |
| 31 | + | |
| 32 | + chmod +x waf | |
| 33 | +} | |
| 34 | + | |
| 35 | +buildwaf | |
| 36 | + | |
| 37 | +cleanup | |
| @@ -93,6 +93,7 @@ · 92 unmodified lines | ||
| 93 | 93 | #define aubio_vDSP_minv vDSP_minv |
| 94 | 94 | #define aubio_vDSP_minvi vDSP_minvi |
| 95 | 95 | #define aubio_vDSP_dotpr vDSP_dotpr |
| 96 | +#define aubio_vDSP_vclr vDSP_vclr | |
| 96 | 97 | #else /* HAVE_AUBIO_DOUBLE */ |
| 97 | 98 | #define aubio_vDSP_mmov vDSP_mmovD |
| 98 | 99 | #define aubio_vDSP_vmul vDSP_vmulD |
| @@ -104,6 +105,7 @@ · 5 unmodified lines | ||
| 104 | 105 | #define aubio_vDSP_minv vDSP_minvD |
| 105 | 106 | #define aubio_vDSP_minvi vDSP_minviD |
| 106 | 107 | #define aubio_vDSP_dotpr vDSP_dotprD |
| 108 | +#define aubio_vDSP_vclr vDSP_vclrD | |
| 107 | 109 | #endif /* HAVE_AUBIO_DOUBLE */ |
| 108 | 110 | #endif /* HAVE_ACCELERATE */ |
| 109 | 111 | |
| @@ -121,7 +123,38 @@ · 11 unmodified lines | ||
| 121 | 123 | #endif /* HAVE_AUBIO_DOUBLE */ |
| 122 | 124 | #endif /* HAVE_ATLAS */ |
| 123 | 125 | |
| 124 | −#if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) | |
| 126 | +#if defined HAVE_INTEL_IPP | |
| 127 | +#include <ippcore.h> | |
| 128 | +#include <ippvm.h> | |
| 129 | +#include <ipps.h> | |
| 130 | +#ifndef HAVE_AUBIO_DOUBLE | |
| 131 | +#define aubio_ippsSet ippsSet_32f | |
| 132 | +#define aubio_ippsZero ippsZero_32f | |
| 133 | +#define aubio_ippsCopy ippsCopy_32f | |
| 134 | +#define aubio_ippsMul ippsMul_32f | |
| 135 | +#define aubio_ippsMulC ippsMulC_32f | |
| 136 | +#define aubio_ippsAddC ippsAddC_32f | |
| 137 | +#define aubio_ippsLn ippsLn_32f_A21 | |
| 138 | +#define aubio_ippsMean(a,b,c) ippsMean_32f(a, b, c, ippAlgHintFast) | |
| 139 | +#define aubio_ippsSum(a,b,c) ippsSum_32f(a, b, c, ippAlgHintFast) | |
| 140 | +#define aubio_ippsMax ippsMax_32f | |
| 141 | +#define aubio_ippsMin ippsMin_32f | |
| 142 | +#else /* HAVE_AUBIO_DOUBLE */ | |
| 143 | +#define aubio_ippsSet ippsSet_64f | |
| 144 | +#define aubio_ippsZero ippsZero_64f | |
| 145 | +#define aubio_ippsCopy ippsCopy_64f | |
| 146 | +#define aubio_ippsMul ippsMul_64f | |
| 147 | +#define aubio_ippsMulC ippsMulC_64f | |
| 148 | +#define aubio_ippsAddC ippsAddC_64f | |
| 149 | +#define aubio_ippsLn ippsLn_64f_A26 | |
| 150 | +#define aubio_ippsMean ippsMean_64f | |
| 151 | +#define aubio_ippsSum ippsSum_64f | |
| 152 | +#define aubio_ippsMax ippsMax_64f | |
| 153 | +#define aubio_ippsMin ippsMin_64f | |
| 154 | +#endif /* HAVE_AUBIO_DOUBLE */ | |
| 155 | +#endif | |
| 156 | + | |
| 157 | +#if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) && !defined(HAVE_INTEL_IPP) | |
| 125 | 158 | #define HAVE_NOOPT 1 |
| 126 | 159 | #else |
| 127 | 160 | #undef HAVE_NOOPT |
| @@ -85,31 +85,40 @@ void cvec_copy(const cvec_t *s, cvec_t *t) { · 84 unmodified lines | ||
| 85 | 85 | s->length, t->length); |
| 86 | 86 | return; |
| 87 | 87 | } |
| 88 | −#ifdef HAVE_MEMCPY_HACKS | |
| 88 | +#if defined(HAVE_INTEL_IPP) | |
| 89 | + aubio_ippsCopy(s->phas, t->phas, (int)s->length); | |
| 90 | + aubio_ippsCopy(s->norm, t->norm, (int)s->length); | |
| 91 | +#elif defined(HAVE_MEMCPY_HACKS) | |
| 89 | 92 | memcpy(t->norm, s->norm, t->length * sizeof(smpl_t)); |
| 90 | 93 | memcpy(t->phas, s->phas, t->length * sizeof(smpl_t)); |
| 91 | −#else /* HAVE_MEMCPY_HACKS */ | |
| 94 | +#else | |
| 92 | 95 | uint_t j; |
| 93 | 96 | for (j=0; j< t->length; j++) { |
| 94 | 97 | t->norm[j] = s->norm[j]; |
| 95 | 98 | t->phas[j] = s->phas[j]; |
| 96 | 99 | } |
| 97 | −#endif /* HAVE_MEMCPY_HACKS */ | |
| 100 | +#endif | |
| 98 | 101 | } |
| 99 | 102 | |
| 100 | −void cvec_norm_set_all (cvec_t *s, smpl_t val) { | |
| 103 | +void cvec_norm_set_all(cvec_t *s, smpl_t val) { | |
| 104 | +#if defined(HAVE_INTEL_IPP) | |
| 105 | + aubio_ippsSet(val, s->norm, (int)s->length); | |
| 106 | +#else | |
| 101 | 107 | uint_t j; |
| 102 | 108 | for (j=0; j< s->length; j++) { |
| 103 | 109 | s->norm[j] = val; |
| 104 | 110 | } |
| 111 | +#endif | |
| 105 | 112 | } |
| 106 | 113 | |
| 107 | 114 | void cvec_norm_zeros(cvec_t *s) { |
| 108 | −#ifdef HAVE_MEMCPY_HACKS | |
| 115 | +#if defined(HAVE_INTEL_IPP) | |
| 116 | + aubio_ippsZero(s->norm, (int)s->length); | |
| 117 | +#elif defined(HAVE_MEMCPY_HACKS) | |
| 109 | 118 | memset(s->norm, 0, s->length * sizeof(smpl_t)); |
| 110 | −#else /* HAVE_MEMCPY_HACKS */ | |
| 119 | +#else | |
| 111 | 120 | cvec_norm_set_all (s, 0.); |
| 112 | −#endif /* HAVE_MEMCPY_HACKS */ | |
| 121 | +#endif | |
| 113 | 122 | } |
| 114 | 123 | |
| 115 | 124 | void cvec_norm_ones(cvec_t *s) { |
| @@ -117,14 +126,20 @@ void cvec_norm_ones(cvec_t *s) { · 1 unmodified line | ||
| 117 | 126 | } |
| 118 | 127 | |
| 119 | 128 | void cvec_phas_set_all (cvec_t *s, smpl_t val) { |
| 129 | +#if defined(HAVE_INTEL_IPP) | |
| 130 | + aubio_ippsSet(val, s->phas, (int)s->length); | |
| 131 | +#else | |
| 120 | 132 | uint_t j; |
| 121 | 133 | for (j=0; j< s->length; j++) { |
| 122 | 134 | s->phas[j] = val; |
| 123 | 135 | } |
| 136 | +#endif | |
| 124 | 137 | } |
| 125 | 138 | |
| 126 | 139 | void cvec_phas_zeros(cvec_t *s) { |
| 127 | −#ifdef HAVE_MEMCPY_HACKS | |
| 140 | +#if defined(HAVE_INTEL_IPP) | |
| 141 | + aubio_ippsZero(s->phas, (int)s->length); | |
| 142 | +#elif defined(HAVE_MEMCPY_HACKS) | |
| 128 | 143 | memset(s->phas, 0, s->length * sizeof(smpl_t)); |
| 129 | 144 | #else |
| 130 | 145 | cvec_phas_set_all (s, 0.); |
| @@ -141,8 +156,14 @@ void cvec_zeros(cvec_t *s) { · 10 unmodified lines | ||
| 141 | 156 | } |
| 142 | 157 | |
| 143 | 158 | void cvec_logmag(cvec_t *s, smpl_t lambda) { |
| 159 | +#if defined(HAVE_INTEL_IPP) | |
| 160 | + aubio_ippsMulC(s->norm, lambda, s->norm, (int)s->length); | |
| 161 | + aubio_ippsAddC(s->norm, 1.0, s->norm, (int)s->length); | |
| 162 | + aubio_ippsLn(s->norm, s->norm, (int)s->length); | |
| 163 | +#else | |
| 144 | 164 | uint_t j; |
| 145 | 165 | for (j=0; j< s->length; j++) { |
| 146 | 166 | s->norm[j] = LOG(lambda * s->norm[j] + 1); |
| 147 | 167 | } |
| 168 | +#endif | |
| 148 | 169 | } |
| @@ -60,27 +60,30 @@ void fvec_print(const fvec_t *s) { · 59 unmodified lines | ||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | void fvec_set_all (fvec_t *s, smpl_t val) { |
| 63 | −#if !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) | |
| 64 | − uint_t j; | |
| 65 | − for (j=0; j< s->length; j++) { | |
| 66 | − s->data[j] = val; | |
| 67 | − } | |
| 63 | +#if defined(HAVE_INTEL_IPP) | |
| 64 | + aubio_ippsSet(val, s->data, (int)s->length); | |
| 68 | 65 | #elif defined(HAVE_ATLAS) |
| 69 | 66 | aubio_catlas_set(s->length, val, s->data, 1); |
| 70 | 67 | #elif defined(HAVE_ACCELERATE) |
| 71 | 68 | aubio_vDSP_vfill(&val, s->data, 1, s->length); |
| 69 | +#else | |
| 70 | + uint_t j; | |
| 71 | + for ( j = 0; j< s->length; j++ ) | |
| 72 | + { | |
| 73 | + s->data[j] = val; | |
| 74 | + } | |
| 72 | 75 | #endif |
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | void fvec_zeros(fvec_t *s) { |
| 76 | −#if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) | |
| 77 | − fvec_set_all (s, 0.); | |
| 78 | −#else | |
| 79 | −#if defined(HAVE_MEMCPY_HACKS) | |
| 79 | +#if defined(HAVE_INTEL_IPP) | |
| 80 | + aubio_ippsZero(s->data, (int)s->length); | |
| 81 | +#elif defined(HAVE_ACCELERATE) | |
| 82 | + aubio_vDSP_vclr(s->data, 1, s->length); | |
| 83 | +#elif defined(HAVE_MEMCPY_HACKS) | |
| 80 | 84 | memset(s->data, 0, s->length * sizeof(smpl_t)); |
| 81 | 85 | #else |
| 82 | − aubio_vDSP_vclr(s->data, 1, s->length); | |
| 83 | −#endif | |
| 86 | + fvec_set_all(s, 0.); | |
| 84 | 87 | #endif |
| 85 | 88 | } |
| 86 | 89 | |
| @@ -96,27 +99,31 @@ void fvec_rev(fvec_t *s) { · 9 unmodified lines | ||
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | void fvec_weight(fvec_t *s, const fvec_t *weight) { |
| 99 | −#ifndef HAVE_ACCELERATE | |
| 100 | − uint_t j; | |
| 101 | 102 | uint_t length = MIN(s->length, weight->length); |
| 102 | − for (j=0; j< length; j++) { | |
| 103 | +#if defined(HAVE_INTEL_IPP) | |
| 104 | + aubio_ippsMul(s->data, weight->data, s->data, (int)length); | |
| 105 | +#elif defined(HAVE_ACCELERATE) | |
| 106 | + aubio_vDSP_vmul( s->data, 1, weight->data, 1, s->data, 1, length ); | |
| 107 | +#else | |
| 108 | + uint_t j; | |
| 109 | + for (j = 0; j < length; j++) { | |
| 103 | 110 | s->data[j] *= weight->data[j]; |
| 104 | 111 | } |
| 105 | −#else | |
| 106 | − aubio_vDSP_vmul(s->data, 1, weight->data, 1, s->data, 1, s->length); | |
| 107 | 112 | #endif /* HAVE_ACCELERATE */ |
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out) { |
| 111 | −#ifndef HAVE_ACCELERATE | |
| 116 | + uint_t length = MIN(in->length, MIN(out->length, weight->length)); | |
| 117 | +#if defined(HAVE_INTEL_IPP) | |
| 118 | + aubio_ippsMul(in->data, weight->data, out->data, (int)length); | |
| 119 | +#elif defined(HAVE_ACCELERATE) | |
| 120 | + aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, length); | |
| 121 | +#else | |
| 112 | 122 | uint_t j; |
| 113 | − uint_t length = MIN(out->length, weight->length); | |
| 114 | − for (j=0; j< length; j++) { | |
| 123 | + for (j = 0; j < length; j++) { | |
| 115 | 124 | out->data[j] = in->data[j] * weight->data[j]; |
| 116 | 125 | } |
| 117 | −#else | |
| 118 | − aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, out->length); | |
| 119 | −#endif /* HAVE_ACCELERATE */ | |
| 126 | +#endif | |
| 120 | 127 | } |
| 121 | 128 | |
| 122 | 129 | void fvec_copy(const fvec_t *s, fvec_t *t) { |
| @@ -125,16 +132,18 @@ void fvec_copy(const fvec_t *s, fvec_t *t) { · 2 unmodified lines | ||
| 125 | 132 | s->length, t->length); |
| 126 | 133 | return; |
| 127 | 134 | } |
| 128 | −#ifdef HAVE_NOOPT | |
| 129 | − uint_t j; | |
| 130 | − for (j=0; j< t->length; j++) { | |
| 131 | − t->data[j] = s->data[j]; | |
| 132 | − } | |
| 133 | −#elif defined(HAVE_MEMCPY_HACKS) | |
| 134 | − memcpy(t->data, s->data, t->length * sizeof(smpl_t)); | |
| 135 | +#if defined(HAVE_INTEL_IPP) | |
| 136 | + aubio_ippsCopy(s->data, t->data, (int)s->length); | |
| 135 | 137 | #elif defined(HAVE_ATLAS) |
| 136 | 138 | aubio_cblas_copy(s->length, s->data, 1, t->data, 1); |
| 137 | 139 | #elif defined(HAVE_ACCELERATE) |
| 138 | 140 | aubio_vDSP_mmov(s->data, t->data, 1, s->length, 1, 1); |
| 141 | +#elif defined(HAVE_MEMCPY_HACKS) | |
| 142 | + memcpy(t->data, s->data, t->length * sizeof(smpl_t)); | |
| 143 | +#else | |
| 144 | + uint_t j; | |
| 145 | + for (j = 0; j < t->length; j++) { | |
| 146 | + t->data[j] = s->data[j]; | |
| 147 | + } | |
| 139 | 148 | #endif |
| 140 | 149 | } |
| @@ -159,45 +159,53 @@ smpl_t · 158 unmodified lines | ||
| 159 | 159 | fvec_mean (fvec_t * s) |
| 160 | 160 | { |
| 161 | 161 | smpl_t tmp = 0.0; |
| 162 | −#ifndef HAVE_ACCELERATE | |
| 162 | +#if defined(HAVE_INTEL_IPP) | |
| 163 | + aubio_ippsMean(s->data, (int)s->length, &tmp); | |
| 164 | + return tmp; | |
| 165 | +#elif defined(HAVE_ACCELERATE) | |
| 166 | + aubio_vDSP_meanv(s->data, 1, &tmp, s->length); | |
| 167 | + return tmp; | |
| 168 | +#else | |
| 163 | 169 | uint_t j; |
| 164 | 170 | for (j = 0; j < s->length; j++) { |
| 165 | 171 | tmp += s->data[j]; |
| 166 | 172 | } |
| 167 | − return tmp / (smpl_t) (s->length); | |
| 168 | −#else | |
| 169 | − aubio_vDSP_meanv(s->data, 1, &tmp, s->length); | |
| 170 | − return tmp; | |
| 171 | −#endif /* HAVE_ACCELERATE */ | |
| 173 | + return tmp / (smpl_t)(s->length); | |
| 174 | +#endif | |
| 172 | 175 | } |
| 173 | 176 | |
| 174 | 177 | smpl_t |
| 175 | 178 | fvec_sum (fvec_t * s) |
| 176 | 179 | { |
| 177 | 180 | smpl_t tmp = 0.0; |
| 178 | −#ifndef HAVE_ACCELERATE | |
| 181 | +#if defined(HAVE_INTEL_IPP) | |
| 182 | + aubio_ippsSum(s->data, (int)s->length, &tmp); | |
| 183 | +#elif defined(HAVE_ACCELERATE) | |
| 184 | + aubio_vDSP_sve(s->data, 1, &tmp, s->length); | |
| 185 | +#else | |
| 179 | 186 | uint_t j; |
| 180 | 187 | for (j = 0; j < s->length; j++) { |
| 181 | 188 | tmp += s->data[j]; |
| 182 | 189 | } |
| 183 | −#else | |
| 184 | − aubio_vDSP_sve(s->data, 1, &tmp, s->length); | |
| 185 | −#endif /* HAVE_ACCELERATE */ | |
| 190 | +#endif | |
| 186 | 191 | return tmp; |
| 187 | 192 | } |
| 188 | 193 | |
| 189 | 194 | smpl_t |
| 190 | 195 | fvec_max (fvec_t * s) |
| 191 | 196 | { |
| 192 | −#ifndef HAVE_ACCELERATE | |
| 197 | +#if defined(HAVE_INTEL_IPP) | |
| 198 | + smpl_t tmp = 0.; | |
| 199 | + aubio_ippsMax( s->data, (int)s->length, &tmp); | |
| 200 | +#elif defined(HAVE_ACCELERATE) | |
| 201 | + smpl_t tmp = 0.; | |
| 202 | + aubio_vDSP_maxv( s->data, 1, &tmp, s->length ); | |
| 203 | +#else | |
| 193 | 204 | uint_t j; |
| 194 | − smpl_t tmp = 0.0; | |
| 195 | − for (j = 0; j < s->length; j++) { | |
| 205 | + smpl_t tmp = s->data[0]; | |
| 206 | + for (j = 1; j < s->length; j++) { | |
| 196 | 207 | tmp = (tmp > s->data[j]) ? tmp : s->data[j]; |
| 197 | 208 | } |
| 198 | −#else | |
| 199 | − smpl_t tmp = 0.; | |
| 200 | − aubio_vDSP_maxv(s->data, 1, &tmp, s->length); | |
| 201 | 209 | #endif |
| 202 | 210 | return tmp; |
| 203 | 211 | } |
| @@ -205,15 +213,18 @@ fvec_max (fvec_t * s) · 1 unmodified line | ||
| 205 | 213 | smpl_t |
| 206 | 214 | fvec_min (fvec_t * s) |
| 207 | 215 | { |
| 208 | −#ifndef HAVE_ACCELERATE | |
| 216 | +#if defined(HAVE_INTEL_IPP) | |
| 217 | + smpl_t tmp = 0.; | |
| 218 | + aubio_ippsMin(s->data, (int)s->length, &tmp); | |
| 219 | +#elif defined(HAVE_ACCELERATE) | |
| 220 | + smpl_t tmp = 0.; | |
| 221 | + aubio_vDSP_minv(s->data, 1, &tmp, s->length); | |
| 222 | +#else | |
| 209 | 223 | uint_t j; |
| 210 | 224 | smpl_t tmp = s->data[0]; |
| 211 | − for (j = 0; j < s->length; j++) { | |
| 225 | + for (j = 1; j < s->length; j++) { | |
| 212 | 226 | tmp = (tmp < s->data[j]) ? tmp : s->data[j]; |
| 213 | 227 | } |
| 214 | −#else | |
| 215 | − smpl_t tmp = 0.; | |
| 216 | − aubio_vDSP_minv(s->data, 1, &tmp, s->length); | |
| 217 | 228 | #endif |
| 218 | 229 | return tmp; |
| 219 | 230 | } |
| @@ -574,6 +585,17 @@ aubio_next_power_of_two (uint_t a) · 354 unmodified lines | ||
| 574 | 585 | return i; |
| 575 | 586 | } |
| 576 | 587 | |
| 588 | +uint_t | |
| 589 | +aubio_power_of_two_order (uint_t a) | |
| 590 | +{ | |
| 591 | + int order = 0; | |
| 592 | + int temp = aubio_next_power_of_two(a); | |
| 593 | + while (temp >>= 1) { | |
| 594 | + ++order; | |
| 595 | + } | |
| 596 | + return order; | |
| 597 | +} | |
| 598 | + | |
| 577 | 599 | smpl_t |
| 578 | 600 | aubio_db_spl (const fvec_t * o) |
| 579 | 601 | { |
| @@ -312,6 +312,9 @@ uint_t aubio_is_power_of_two(uint_t a); · 311 unmodified lines | ||
| 312 | 312 | /** return the next power of power of 2 greater than a */ |
| 313 | 313 | uint_t aubio_next_power_of_two(uint_t a); |
| 314 | 314 | |
| 315 | +/** return the log2 factor of the given power of 2 value a */ | |
| 316 | +uint_t aubio_power_of_two_order(uint_t a); | |
| 317 | + | |
| 315 | 318 | /** compute normalised autocorrelation function |
| 316 | 319 | |
| 317 | 320 | \param input vector to compute autocorrelation from |
| @@ -36,7 +36,7 @@ struct _aubio_pitchyin_t · 35 unmodified lines | ||
| 36 | 36 | { |
| 37 | 37 | fvec_t *yin; |
| 38 | 38 | smpl_t tol; |
| 39 | − smpl_t confidence; | |
| 39 | + uint_t peak_pos; | |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | 42 | /** compute difference function |
| @@ -67,6 +67,7 @@ new_aubio_pitchyin (uint_t bufsize) · 24 unmodified lines | ||
| 67 | 67 | aubio_pitchyin_t *o = AUBIO_NEW (aubio_pitchyin_t); |
| 68 | 68 | o->yin = new_fvec (bufsize / 2); |
| 69 | 69 | o->tol = 0.15; |
| 70 | + o->peak_pos = 0; | |
| 70 | 71 | return o; |
| 71 | 72 | } |
| 72 | 73 | |
| @@ -156,19 +157,18 @@ aubio_pitchyin_do (aubio_pitchyin_t * o, const fvec_t * input, fvec_t * out) · 83 unmodified lines | ||
| 156 | 157 | period = tau - 3; |
| 157 | 158 | if (tau > 4 && (yin_data[period] < tol) && |
| 158 | 159 | (yin_data[period] < yin_data[period + 1])) { |
| 159 | − out->data[0] = fvec_quadratic_peak_pos (yin, period); | |
| 160 | − goto beach; | |
| 160 | + o->peak_pos = (uint_t)period; | |
| 161 | + out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); | |
| 162 | + return; | |
| 161 | 163 | } |
| 162 | 164 | } |
| 163 | − out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin)); | |
| 164 | −beach: | |
| 165 | − return; | |
| 165 | + o->peak_pos = (uint_t)fvec_min_elem (yin); | |
| 166 | + out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); | |
| 166 | 167 | } |
| 167 | 168 | |
| 168 | 169 | smpl_t |
| 169 | 170 | aubio_pitchyin_get_confidence (aubio_pitchyin_t * o) { |
| 170 | − o->confidence = 1. - fvec_min (o->yin); | |
| 171 | − return o->confidence; | |
| 171 | + return 1. - o->yin->data[o->peak_pos]; | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | uint_t |
| @@ -38,7 +38,7 @@ struct _aubio_pitchyinfast_t · 37 unmodified lines | ||
| 38 | 38 | { |
| 39 | 39 | fvec_t *yin; |
| 40 | 40 | smpl_t tol; |
| 41 | − smpl_t confidence; | |
| 41 | + uint_t peak_pos; | |
| 42 | 42 | fvec_t *tmpdata; |
| 43 | 43 | fvec_t *sqdiff; |
| 44 | 44 | fvec_t *kernel; |
| @@ -59,6 +59,7 @@ new_aubio_pitchyinfast (uint_t bufsize) · 14 unmodified lines | ||
| 59 | 59 | o->kernel_fft = new_fvec (bufsize); |
| 60 | 60 | o->fft = new_aubio_fft (bufsize); |
| 61 | 61 | o->tol = 0.15; |
| 62 | + o->peak_pos = 0; | |
| 62 | 63 | return o; |
| 63 | 64 | } |
| 64 | 65 | |
| @@ -85,7 +86,6 @@ aubio_pitchyinfast_do (aubio_pitchyinfast_t * o, const fvec_t * input, fvec_t * · 20 unmodified lines | ||
| 85 | 86 | uint_t B = o->tmpdata->length; |
| 86 | 87 | uint_t W = o->yin->length; // B / 2 |
| 87 | 88 | fvec_t tmp_slice, kernel_ptr; |
| 88 | − smpl_t *yin_data = yin->data; | |
| 89 | 89 | uint_t tau; |
| 90 | 90 | sint_t period; |
| 91 | 91 | smpl_t tmp2 = 0.; |
| @@ -142,36 +142,36 @@ aubio_pitchyinfast_do (aubio_pitchyinfast_t * o, const fvec_t * input, fvec_t * · 50 unmodified lines | ||
| 142 | 142 | aubio_fft_rdo_complex(o->fft, compmul, rt_of_tau); |
| 143 | 143 | // compute square difference r_t(tau) = sqdiff - 2 * r_t_tau[W-1:-1] |
| 144 | 144 | for (tau = 0; tau < W; tau++) { |
| 145 | − yin_data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W]; | |
| 145 | + yin->data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W]; | |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | // now build yin and look for first minimum |
| 150 | − fvec_set_all(out, 0.); | |
| 151 | − yin_data[0] = 1.; | |
| 150 | + fvec_zeros(out); | |
| 151 | + yin->data[0] = 1.; | |
| 152 | 152 | for (tau = 1; tau < length; tau++) { |
| 153 | − tmp2 += yin_data[tau]; | |
| 153 | + tmp2 += yin->data[tau]; | |
| 154 | 154 | if (tmp2 != 0) { |
| 155 | 155 | yin->data[tau] *= tau / tmp2; |
| 156 | 156 | } else { |
| 157 | 157 | yin->data[tau] = 1.; |
| 158 | 158 | } |
| 159 | 159 | period = tau - 3; |
| 160 | − if (tau > 4 && (yin_data[period] < tol) && | |
| 161 | − (yin_data[period] < yin_data[period + 1])) { | |
| 162 | − out->data[0] = fvec_quadratic_peak_pos (yin, period); | |
| 163 | − goto beach; | |
| 160 | + if (tau > 4 && (yin->data[period] < tol) && | |
| 161 | + (yin->data[period] < yin->data[period + 1])) { | |
| 162 | + o->peak_pos = (uint_t)period; | |
| 163 | + out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); | |
| 164 | + return; | |
| 164 | 165 | } |
| 165 | 166 | } |
| 166 | − out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin) ); | |
| 167 | −beach: | |
| 168 | − return; | |
| 167 | + // use global minimum | |
| 168 | + o->peak_pos = (uint_t)fvec_min_elem (yin); | |
| 169 | + out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos); | |
| 169 | 170 | } |
| 170 | 171 | |
| 171 | 172 | smpl_t |
| 172 | 173 | aubio_pitchyinfast_get_confidence (aubio_pitchyinfast_t * o) { |
| 173 | − o->confidence = 1. - fvec_min (o->yin); | |
| 174 | − return o->confidence; | |
| 174 | + return 1. - o->yin->data[o->peak_pos]; | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | uint_t |
| @@ -36,7 +36,7 @@ struct _aubio_pitchyinfft_t · 35 unmodified lines | ||
| 36 | 36 | aubio_fft_t *fft; /**< fft object to compute square difference function */ |
| 37 | 37 | fvec_t *yinfft; /**< Yin function */ |
| 38 | 38 | smpl_t tol; /**< Yin tolerance */ |
| 39 | − smpl_t confidence; /**< confidence */ | |
| 39 | + uint_t peak_pos; /**< currently selected peak pos*/ | |
| 40 | 40 | uint_t short_period; /** shortest period under which to check for octave error */ |
| 41 | 41 | }; |
| 42 | 42 | |
| @@ -67,6 +67,7 @@ new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize) · 24 unmodified lines | ||
| 67 | 67 | p->sqrmag = new_fvec (bufsize); |
| 68 | 68 | p->yinfft = new_fvec (bufsize / 2 + 1); |
| 69 | 69 | p->tol = 0.85; |
| 70 | + p->peak_pos = 0; | |
| 70 | 71 | p->win = new_aubio_window ("hanningz", bufsize); |
| 71 | 72 | p->weight = new_fvec (bufsize / 2 + 1); |
| 72 | 73 | for (i = 0; i < p->weight->length; i++) { |
| @@ -161,11 +162,13 @@ aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, const fvec_t * input, fvec_t * ou · 88 unmodified lines | ||
| 161 | 162 | /* should compare the minimum value of each interpolated peaks */ |
| 162 | 163 | halfperiod = FLOOR (tau / 2 + .5); |
| 163 | 164 | if (yin->data[halfperiod] < p->tol) |
| 164 | − output->data[0] = fvec_quadratic_peak_pos (yin, halfperiod); | |
| 165 | + p->peak_pos = halfperiod; | |
| 165 | 166 | else |
| 166 | − output->data[0] = fvec_quadratic_peak_pos (yin, tau); | |
| 167 | + p->peak_pos = tau; | |
| 168 | + output->data[0] = fvec_quadratic_peak_pos (yin, p->peak_pos); | |
| 167 | 169 | } |
| 168 | 170 | } else { |
| 171 | + p->peak_pos = 0; | |
| 169 | 172 | output->data[0] = 0.; |
| 170 | 173 | } |
| 171 | 174 | } |
| @@ -185,8 +188,7 @@ del_aubio_pitchyinfft (aubio_pitchyinfft_t * p) · 13 unmodified lines | ||
| 185 | 188 | |
| 186 | 189 | smpl_t |
| 187 | 190 | aubio_pitchyinfft_get_confidence (aubio_pitchyinfft_t * o) { |
| 188 | − o->confidence = 1. - fvec_min (o->yinfft); | |
| 189 | − return o->confidence; | |
| 191 | + return 1. - o->yinfft->data[o->peak_pos]; | |
| 190 | 192 | } |
| 191 | 193 | |
| 192 | 194 | uint_t |
| @@ -77,8 +77,7 @@ typedef FFTW_TYPE fft_data_t; · 76 unmodified lines | ||
| 77 | 77 | // a global mutex for FFTW thread safety |
| 78 | 78 | pthread_mutex_t aubio_fftw_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 79 | 79 | |
| 80 | −#else | |
| 81 | −#ifdef HAVE_ACCELERATE // using ACCELERATE | |
| 80 | +#elif defined HAVE_ACCELERATE // using ACCELERATE | |
| 82 | 81 | // https://developer.apple.com/library/mac/#documentation/Accelerate/Reference/vDSPRef/Reference/reference.html |
| 83 | 82 | #include <Accelerate/Accelerate.h> |
| 84 | 83 | |
| @@ -112,32 +111,65 @@ pthread_mutex_t aubio_fftw_mutex = PTHREAD_MUTEX_INITIALIZER; · 27 unmodified lines | ||
| 112 | 111 | #define aubio_vvsqrt vvsqrt |
| 113 | 112 | #endif /* HAVE_AUBIO_DOUBLE */ |
| 114 | 113 | |
| 115 | −#else // using OOURA | |
| 114 | +#elif defined HAVE_INTEL_IPP // using INTEL IPP | |
| 115 | + | |
| 116 | +#if !HAVE_AUBIO_DOUBLE | |
| 117 | +#define aubio_IppFloat Ipp32f | |
| 118 | +#define aubio_IppComplex Ipp32fc | |
| 119 | +#define aubio_FFTSpec FFTSpec_R_32f | |
| 120 | +#define aubio_ippsMalloc_complex ippsMalloc_32fc | |
| 121 | +#define aubio_ippsFFTInit_R ippsFFTInit_R_32f | |
| 122 | +#define aubio_ippsFFTGetSize_R ippsFFTGetSize_R_32f | |
| 123 | +#define aubio_ippsFFTInv_CCSToR ippsFFTInv_CCSToR_32f | |
| 124 | +#define aubio_ippsFFTFwd_RToCCS ippsFFTFwd_RToCCS_32f | |
| 125 | +#define aubio_ippsAtan2 ippsAtan2_32f_A21 | |
| 126 | +#else /* HAVE_AUBIO_DOUBLE */ | |
| 127 | +#define aubio_IppFloat Ipp64f | |
| 128 | +#define aubio_IppComplex Ipp64fc | |
| 129 | +#define aubio_FFTSpec FFTSpec_R_64f | |
| 130 | +#define aubio_ippsMalloc_complex ippsMalloc_64fc | |
| 131 | +#define aubio_ippsFFTInit_R ippsFFTInit_R_64f | |
| 132 | +#define aubio_ippsFFTGetSize_R ippsFFTGetSize_R_64f | |
| 133 | +#define aubio_ippsFFTInv_CCSToR ippsFFTInv_CCSToR_64f | |
| 134 | +#define aubio_ippsFFTFwd_RToCCS ippsFFTFwd_RToCCS_64f | |
| 135 | +#define aubio_ippsAtan2 ippsAtan2_64f_A50 | |
| 136 | +#endif | |
| 137 | + | |
| 138 | + | |
| 139 | +#else // using OOURA | |
| 116 | 140 | // let's use ooura instead |
| 117 | 141 | extern void aubio_ooura_rdft(int, int, smpl_t *, int *, smpl_t *); |
| 118 | 142 | |
| 119 | −#endif /* HAVE_ACCELERATE */ | |
| 120 | −#endif /* HAVE_FFTW3 */ | |
| 143 | +#endif | |
| 121 | 144 | |
| 122 | 145 | struct _aubio_fft_t { |
| 123 | 146 | uint_t winsize; |
| 124 | 147 | uint_t fft_size; |
| 148 | + | |
| 125 | 149 | #ifdef HAVE_FFTW3 // using FFTW3 |
| 126 | 150 | real_t *in, *out; |
| 127 | 151 | fftw_plan pfw, pbw; |
| 128 | − fft_data_t * specdata; /* complex spectral data */ | |
| 129 | −#else | |
| 130 | −#ifdef HAVE_ACCELERATE // using ACCELERATE | |
| 152 | + fft_data_t * specdata; /* complex spectral data */ | |
| 153 | + | |
| 154 | +#elif defined HAVE_ACCELERATE // using ACCELERATE | |
| 131 | 155 | int log2fftsize; |
| 132 | 156 | aubio_FFTSetup fftSetup; |
| 133 | 157 | aubio_DSPSplitComplex spec; |
| 134 | 158 | smpl_t *in, *out; |
| 159 | + | |
| 160 | +#elif defined HAVE_INTEL_IPP // using Intel IPP | |
| 161 | + smpl_t *in, *out; | |
| 162 | + Ipp8u* memSpec; | |
| 163 | + Ipp8u* memInit; | |
| 164 | + Ipp8u* memBuffer; | |
| 165 | + struct aubio_FFTSpec* fftSpec; | |
| 166 | + aubio_IppComplex* complexOut; | |
| 135 | 167 | #else // using OOURA |
| 136 | 168 | smpl_t *in, *out; |
| 137 | 169 | smpl_t *w; |
| 138 | 170 | int *ip; |
| 139 | −#endif /* HAVE_ACCELERATE */ | |
| 140 | −#endif /* HAVE_FFTW3 */ | |
| 171 | +#endif /* using OOURA */ | |
| 172 | + | |
| 141 | 173 | fvec_t * compspec; |
| 142 | 174 | }; |
| 143 | 175 | |
| @@ -147,6 +179,7 @@ aubio_fft_t * new_aubio_fft (uint_t winsize) { · 3 unmodified lines | ||
| 147 | 179 | AUBIO_ERR("fft: got winsize %d, but can not be < 2\n", winsize); |
| 148 | 180 | goto beach; |
| 149 | 181 | } |
| 182 | + | |
| 150 | 183 | #ifdef HAVE_FFTW3 |
| 151 | 184 | uint_t i; |
| 152 | 185 | s->winsize = winsize; |
| @@ -175,17 +208,55 @@ aubio_fft_t * new_aubio_fft (uint_t winsize) { · 22 unmodified lines | ||
| 175 | 208 | for (i = 0; i < s->fft_size; i++) { |
| 176 | 209 | s->specdata[i] = 0.; |
| 177 | 210 | } |
| 178 | −#else | |
| 179 | −#ifdef HAVE_ACCELERATE // using ACCELERATE | |
| 211 | + | |
| 212 | +#elif defined HAVE_ACCELERATE // using ACCELERATE | |
| 180 | 213 | s->winsize = winsize; |
| 181 | 214 | s->fft_size = winsize; |
| 182 | 215 | s->compspec = new_fvec(winsize); |
| 183 | − s->log2fftsize = (uint_t)log2f(s->fft_size); | |
| 216 | + s->log2fftsize = aubio_power_of_two_order(s->fft_size); | |
| 184 | 217 | s->in = AUBIO_ARRAY(smpl_t, s->fft_size); |
| 185 | 218 | s->out = AUBIO_ARRAY(smpl_t, s->fft_size); |
| 186 | 219 | s->spec.realp = AUBIO_ARRAY(smpl_t, s->fft_size/2); |
| 187 | 220 | s->spec.imagp = AUBIO_ARRAY(smpl_t, s->fft_size/2); |
| 188 | 221 | s->fftSetup = aubio_vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2); |
| 222 | + | |
| 223 | +#elif defined HAVE_INTEL_IPP // using Intel IPP | |
| 224 | + const IppHintAlgorithm qualityHint = ippAlgHintAccurate; // OR ippAlgHintFast; | |
| 225 | + const int flags = IPP_FFT_NODIV_BY_ANY; // we're scaling manually afterwards | |
| 226 | + int order = aubio_power_of_two_order(winsize); | |
| 227 | + int sizeSpec, sizeInit, sizeBuffer; | |
| 228 | + IppStatus status; | |
| 229 | + | |
| 230 | + if (winsize <= 4 || aubio_is_power_of_two(winsize) != 1) | |
| 231 | + { | |
| 232 | + AUBIO_ERR("intel IPP fft: can only create with sizes > 4 and power of two, requested %d," | |
| 233 | + " try recompiling aubio with --enable-fftw3\n", winsize); | |
| 234 | + goto beach; | |
| 235 | + } | |
| 236 | + | |
| 237 | + status = aubio_ippsFFTGetSize_R(order, flags, qualityHint, | |
| 238 | + &sizeSpec, &sizeInit, &sizeBuffer); | |
| 239 | + if (status != ippStsNoErr) { | |
| 240 | + AUBIO_ERR("fft: failed to initialize fft. IPP error: %d\n", status); | |
| 241 | + goto beach; | |
| 242 | + } | |
| 243 | + s->fft_size = s->winsize = winsize; | |
| 244 | + s->compspec = new_fvec(winsize); | |
| 245 | + s->in = AUBIO_ARRAY(smpl_t, s->winsize); | |
| 246 | + s->out = AUBIO_ARRAY(smpl_t, s->winsize); | |
| 247 | + s->memSpec = ippsMalloc_8u(sizeSpec); | |
| 248 | + s->memBuffer = ippsMalloc_8u(sizeBuffer); | |
| 249 | + if (sizeInit > 0 ) { | |
| 250 | + s->memInit = ippsMalloc_8u(sizeInit); | |
| 251 | + } | |
| 252 | + s->complexOut = aubio_ippsMalloc_complex(s->fft_size / 2 + 1); | |
| 253 | + status = aubio_ippsFFTInit_R( | |
| 254 | + &s->fftSpec, order, flags, qualityHint, s->memSpec, s->memInit); | |
| 255 | + if (status != ippStsNoErr) { | |
| 256 | + AUBIO_ERR("fft: failed to initialize. IPP error: %d\n", status); | |
| 257 | + goto beach; | |
| 258 | + } | |
| 259 | + | |
| 189 | 260 | #else // using OOURA |
| 190 | 261 | if (aubio_is_power_of_two(winsize) != 1) { |
| 191 | 262 | AUBIO_ERR("fft: can only create with sizes power of two, requested %d," |
| @@ -200,9 +271,10 @@ aubio_fft_t * new_aubio_fft (uint_t winsize) { · 8 unmodified lines | ||
| 200 | 271 | s->ip = AUBIO_ARRAY(int , s->fft_size); |
| 201 | 272 | s->w = AUBIO_ARRAY(smpl_t, s->fft_size); |
| 202 | 273 | s->ip[0] = 0; |
| 203 | −#endif /* HAVE_ACCELERATE */ | |
| 204 | −#endif /* HAVE_FFTW3 */ | |
| 274 | +#endif /* using OOURA */ | |
| 275 | + | |
| 205 | 276 | return s; |
| 277 | + | |
| 206 | 278 | beach: |
| 207 | 279 | AUBIO_FREE(s); |
| 208 | 280 | return NULL; |
| @@ -210,25 +282,32 @@ beach: · 1 unmodified line | ||
| 210 | 282 | |
| 211 | 283 | void del_aubio_fft(aubio_fft_t * s) { |
| 212 | 284 | /* destroy data */ |
| 213 | − del_fvec(s->compspec); | |
| 214 | 285 | #ifdef HAVE_FFTW3 // using FFTW3 |
| 215 | 286 | pthread_mutex_lock(&aubio_fftw_mutex); |
| 216 | 287 | fftw_destroy_plan(s->pfw); |
| 217 | 288 | fftw_destroy_plan(s->pbw); |
| 218 | 289 | fftw_free(s->specdata); |
| 219 | 290 | pthread_mutex_unlock(&aubio_fftw_mutex); |
| 220 | −#else /* HAVE_FFTW3 */ | |
| 221 | −#ifdef HAVE_ACCELERATE // using ACCELERATE | |
| 291 | + | |
| 292 | +#elif defined HAVE_ACCELERATE // using ACCELERATE | |
| 222 | 293 | AUBIO_FREE(s->spec.realp); |
| 223 | 294 | AUBIO_FREE(s->spec.imagp); |
| 224 | 295 | aubio_vDSP_destroy_fftsetup(s->fftSetup); |
| 296 | + | |
| 297 | +#elif defined HAVE_INTEL_IPP // using Intel IPP | |
| 298 | + ippFree(s->memSpec); | |
| 299 | + ippFree(s->memInit); | |
| 300 | + ippFree(s->memBuffer); | |
| 301 | + ippFree(s->complexOut); | |
| 302 | + | |
| 225 | 303 | #else // using OOURA |
| 226 | 304 | AUBIO_FREE(s->w); |
| 227 | 305 | AUBIO_FREE(s->ip); |
| 228 | −#endif /* HAVE_ACCELERATE */ | |
| 229 | −#endif /* HAVE_FFTW3 */ | |
| 230 | − AUBIO_FREE(s->out); | |
| 306 | +#endif | |
| 307 | + | |
| 308 | + del_fvec(s->compspec); | |
| 231 | 309 | AUBIO_FREE(s->in); |
| 310 | + AUBIO_FREE(s->out); | |
| 232 | 311 | AUBIO_FREE(s); |
| 233 | 312 | } |
| 234 | 313 | |
| @@ -251,6 +330,7 @@ void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compsp · 16 unmodified lines | ||
| 251 | 330 | #else |
| 252 | 331 | memcpy(s->in, input->data, s->winsize * sizeof(smpl_t)); |
| 253 | 332 | #endif /* HAVE_MEMCPY_HACKS */ |
| 333 | + | |
| 254 | 334 | #ifdef HAVE_FFTW3 // using FFTW3 |
| 255 | 335 | fftw_execute(s->pfw); |
| 256 | 336 | #ifdef HAVE_COMPLEX_H |
| @@ -265,8 +345,8 @@ void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compsp · 8 unmodified lines | ||
| 265 | 345 | compspec->data[i] = s->specdata[i]; |
| 266 | 346 | } |
| 267 | 347 | #endif /* HAVE_COMPLEX_H */ |
| 268 | −#else /* HAVE_FFTW3 */ | |
| 269 | −#ifdef HAVE_ACCELERATE // using ACCELERATE | |
| 348 | + | |
| 349 | +#elif defined HAVE_ACCELERATE // using ACCELERATE | |
| 270 | 350 | // convert real data to even/odd format used in vDSP |
| 271 | 351 | aubio_vDSP_ctoz((aubio_DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2); |
| 272 | 352 | // compute the FFT |
| @@ -281,6 +361,19 @@ void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compsp · 8 unmodified lines | ||
| 281 | 361 | // apply scaling |
| 282 | 362 | smpl_t scale = 1./2.; |
| 283 | 363 | aubio_vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); |
| 364 | + | |
| 365 | +#elif defined HAVE_INTEL_IPP // using Intel IPP | |
| 366 | + | |
| 367 | + // apply fft | |
| 368 | + aubio_ippsFFTFwd_RToCCS(s->in, (aubio_IppFloat*)s->complexOut, s->fftSpec, s->memBuffer); | |
| 369 | + // convert complex buffer to [ r0, r1, ..., rN, iN-1, .., i2, i1] | |
| 370 | + compspec->data[0] = s->complexOut[0].re; | |
| 371 | + compspec->data[s->fft_size / 2] = s->complexOut[s->fft_size / 2].re; | |
| 372 | + for (i = 1; i < s->fft_size / 2; i++) { | |
| 373 | + compspec->data[i] = s->complexOut[i].re; | |
| 374 | + compspec->data[s->fft_size - i] = s->complexOut[i].im; | |
| 375 | + } | |
| 376 | + | |
| 284 | 377 | #else // using OOURA |
| 285 | 378 | aubio_ooura_rdft(s->winsize, 1, s->in, s->ip, s->w); |
| 286 | 379 | compspec->data[0] = s->in[0]; |
| @@ -289,8 +382,7 @@ void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compsp · 2 unmodified lines | ||
| 289 | 382 | compspec->data[i] = s->in[2 * i]; |
| 290 | 383 | compspec->data[s->winsize - i] = - s->in[2 * i + 1]; |
| 291 | 384 | } |
| 292 | −#endif /* HAVE_ACCELERATE */ | |
| 293 | −#endif /* HAVE_FFTW3 */ | |
| 385 | +#endif /* using OOURA */ | |
| 294 | 386 | } |
| 295 | 387 | |
| 296 | 388 | void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * output) { |
| @@ -313,8 +405,8 @@ void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * ou · 16 unmodified lines | ||
| 313 | 405 | for (i = 0; i < output->length; i++) { |
| 314 | 406 | output->data[i] = s->out[i]*renorm; |
| 315 | 407 | } |
| 316 | −#else /* HAVE_FFTW3 */ | |
| 317 | −#ifdef HAVE_ACCELERATE // using ACCELERATE | |
| 408 | + | |
| 409 | +#elif defined HAVE_ACCELERATE // using ACCELERATE | |
| 318 | 410 | // convert from real imag [ r0, r1, ..., rN, iN-1, .., i2, i1] |
| 319 | 411 | // to vDSP packed format [ r0, rN, r1, i1, ..., rN-1, iN-1 ] |
| 320 | 412 | s->out[0] = compspec->data[0]; |
| @@ -332,6 +424,23 @@ void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * ou · 11 unmodified lines | ||
| 332 | 424 | // apply scaling |
| 333 | 425 | smpl_t scale = 1.0 / s->winsize; |
| 334 | 426 | aubio_vDSP_vsmul(output->data, 1, &scale, output->data, 1, s->fft_size); |
| 427 | + | |
| 428 | +#elif defined HAVE_INTEL_IPP // using Intel IPP | |
| 429 | + | |
| 430 | + // convert from real imag [ r0, 0, ..., rN, iN-1, .., i2, i1, iN-1] to complex format | |
| 431 | + s->complexOut[0].re = compspec->data[0]; | |
| 432 | + s->complexOut[0].im = 0; | |
| 433 | + s->complexOut[s->fft_size / 2].re = compspec->data[s->fft_size / 2]; | |
| 434 | + s->complexOut[s->fft_size / 2].im = 0.0; | |
| 435 | + for (i = 1; i < s->fft_size / 2; i++) { | |
| 436 | + s->complexOut[i].re = compspec->data[i]; | |
| 437 | + s->complexOut[i].im = compspec->data[s->fft_size - i]; | |
| 438 | + } | |
| 439 | + // apply fft | |
| 440 | + aubio_ippsFFTInv_CCSToR((const aubio_IppFloat *)s->complexOut, output->data, s->fftSpec, s->memBuffer); | |
| 441 | + // apply scaling | |
| 442 | + aubio_ippsMulC(output->data, 1.0 / s->winsize, output->data, s->fft_size); | |
| 443 | + | |
| 335 | 444 | #else // using OOURA |
| 336 | 445 | smpl_t scale = 2.0 / s->winsize; |
| 337 | 446 | s->out[0] = compspec->data[0]; |
| @@ -344,8 +453,7 @@ void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * ou · 6 unmodified lines | ||
| 344 | 453 | for (i=0; i < s->winsize; i++) { |
| 345 | 454 | output->data[i] = s->out[i] * scale; |
| 346 | 455 | } |
| 347 | −#endif /* HAVE_ACCELERATE */ | |
| 348 | −#endif /* HAVE_FFTW3 */ | |
| 456 | +#endif | |
| 349 | 457 | } |
| 350 | 458 | |
| 351 | 459 | void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum) { |
| @@ -365,10 +473,26 @@ void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum) { · 13 unmodified lines | ||
| 365 | 473 | } else { |
| 366 | 474 | spectrum->phas[0] = 0.; |
| 367 | 475 | } |
| 476 | +#if defined(HAVE_INTEL_IPP) | |
| 477 | + // convert from real imag [ r0, r1, ..., rN, iN-1, ..., i2, i1, i0] | |
| 478 | + // to [ r0, r1, ..., rN, i0, i1, i2, ..., iN-1] | |
| 479 | + for (i = 1; i < spectrum->length / 2; i++) { | |
| 480 | + ELEM_SWAP(compspec->data[compspec->length - i], | |
| 481 | + compspec->data[spectrum->length + i - 1]); | |
| 482 | + } | |
| 483 | + aubio_ippsAtan2(compspec->data + spectrum->length, | |
| 484 | + compspec->data + 1, spectrum->phas + 1, spectrum->length - 1); | |
| 485 | + // revert the imaginary part back again | |
| 486 | + for (i = 1; i < spectrum->length / 2; i++) { | |
| 487 | + ELEM_SWAP(compspec->data[spectrum->length + i - 1], | |
| 488 | + compspec->data[compspec->length - i]); | |
| 489 | + } | |
| 490 | +#else | |
| 368 | 491 | for (i=1; i < spectrum->length - 1; i++) { |
| 369 | 492 | spectrum->phas[i] = ATAN2(compspec->data[compspec->length-i], |
| 370 | 493 | compspec->data[i]); |
| 371 | 494 | } |
| 495 | +#endif | |
| 372 | 496 | if (compspec->data[compspec->length/2] < 0) { |
| 373 | 497 | spectrum->phas[spectrum->length - 1] = PI; |
| 374 | 498 | } else { |
| @@ -3,6 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | uselib = [] |
| 4 | 4 | uselib += ['M'] |
| 5 | 5 | uselib += ['FFTW3', 'FFTW3F'] |
| 6 | +uselib += ['INTEL_IPP'] | |
| 6 | 7 | uselib += ['SAMPLERATE'] |
| 7 | 8 | uselib += ['SNDFILE'] |
| 8 | 9 | uselib += ['AVCODEC'] |
| @@ -24,7 +25,7 @@ ctx(features = 'c', · 15 unmodified lines | ||
| 24 | 25 | if ctx.env['DEST_OS'] in ['ios', 'iosimulator']: |
| 25 | 26 | build_features = ['cstlib', 'cshlib'] |
| 26 | 27 | elif ctx.env['DEST_OS'] in ['win32', 'win64']: |
| 27 | − build_features = ['cstlib', 'cshlib'] | |
| 28 | + build_features = ['cstlib', 'cshlib gensyms'] | |
| 28 | 29 | elif ctx.env['DEST_OS'] in ['emscripten']: |
| 29 | 30 | build_features = ['cstlib','cshlib'] |
| 30 | 31 | elif '--static' in ctx.env['LDFLAGS'] or '--static' in ctx.env['LINKFLAGS']: |
| @@ -36,13 +37,13 @@ else: · 5 unmodified lines | ||
| 36 | 37 | |
| 37 | 38 | # also install static lib |
| 38 | 39 | from waflib.Tools.c import cstlib |
| 39 | −from waflib.Tools.fc import fcstlib | |
| 40 | −fcstlib.inst_to = cstlib.inst_to = '${LIBDIR}' | |
| 40 | +cstlib.inst_to = '${LIBDIR}' | |
| 41 | 41 | |
| 42 | 42 | for target in build_features: |
| 43 | 43 | ctx(features = 'c ' + target, |
| 44 | 44 | use = uselib + ['lib_objects'], |
| 45 | 45 | target = 'aubio', |
| 46 | + export_symbols_regex=r'(?:.*aubio|fvec|lvec|cvec|fmat|new|del)_.*', | |
| 46 | 47 | vnum = ctx.env['LIB_VERSION']) |
| 47 | 48 | |
| 48 | 49 | # install headers, except _priv.h ones |
| @@ -1,9 +1,8 @@ | ||
| 1 | −#define AUBIO_UNSTABLE 1 | |
| 2 | 1 | #include <aubio.h> |
| 3 | 2 | #include "utils_tests.h" |
| 4 | 3 | |
| 5 | −// this file uses the unstable aubio api, please use aubio_sink instead | |
| 6 | −// see src/io/sink.h and tests/src/sink/test-sink.c | |
| 4 | +// same as test-sink.c, but uses aubio_source_do_multi to read multiple | |
| 5 | +// channels | |
| 7 | 6 | |
| 8 | 7 | int main (int argc, char **argv) |
| 9 | 8 | { |
| @@ -2,8 +2,8 @@ · 1 unmodified line | ||
| 2 | 2 | #include <aubio.h> |
| 3 | 3 | #include "utils_tests.h" |
| 4 | 4 | |
| 5 | −// this file uses the unstable aubio api, please use aubio_sink instead | |
| 6 | −// see src/io/sink.h and tests/src/sink/test-sink.c | |
| 5 | +// this file uses the unstable aubio api to test aubio_sink_apple_audio, please | |
| 6 | +// use aubio_sink instead see src/io/sink.h and tests/src/sink/test-sink.c | |
| 7 | 7 | |
| 8 | 8 | int main (int argc, char **argv) |
| 9 | 9 | { |
| @@ -2,8 +2,8 @@ · 1 unmodified line | ||
| 2 | 2 | #include <aubio.h> |
| 3 | 3 | #include "utils_tests.h" |
| 4 | 4 | |
| 5 | −// this file uses the unstable aubio api, please use aubio_sink instead | |
| 6 | −// see src/io/sink.h and tests/src/sink/test-sink.c | |
| 5 | +// this file uses the unstable aubio api to test aubio_sink_sndfile, please | |
| 6 | +// use aubio_sink instead see src/io/sink.h and tests/src/sink/test-sink.c | |
| 7 | 7 | |
| 8 | 8 | int main (int argc, char **argv) |
| 9 | 9 | { |
| @@ -2,8 +2,8 @@ · 1 unmodified line | ||
| 2 | 2 | #include <aubio.h> |
| 3 | 3 | #include "utils_tests.h" |
| 4 | 4 | |
| 5 | −// this file uses the unstable aubio api, please use aubio_sink instead | |
| 6 | −// see src/io/sink.h and tests/src/sink/test-sink.c | |
| 5 | +// this file uses the unstable aubio api to test aubio_sink_wavwrite, please | |
| 6 | +// use aubio_sink instead see src/io/sink.h and tests/src/sink/test-sink.c | |
| 7 | 7 | |
| 8 | 8 | int main (int argc, char **argv) |
| 9 | 9 | { |
| @@ -0,0 +1,40 @@ | ||
| 1 | +import re | |
| 2 | +import os.path | |
| 3 | +from waflib import TaskGen, Task | |
| 4 | +from waflib.Context import STDOUT | |
| 5 | +from waflib.Utils import O644 | |
| 6 | + | |
| 7 | +class gen_sym_file(Task.Task): | |
| 8 | + color = 'BLUE' | |
| 9 | + inst_to = '${LIBDIR}' | |
| 10 | + def run(self): | |
| 11 | + syms = {} | |
| 12 | + reg = getattr(self.generator, 'export_symbols_regex','.+?') | |
| 13 | + if 'msvc' in self.env.CC_NAME: | |
| 14 | + outputs = [x.abspath() for x in self.generator.link_task.outputs] | |
| 15 | + binary_path = list(filter(lambda x: x.endswith('lib'), outputs))[0] | |
| 16 | + reg_compiled = re.compile(r'External\s+\|\s+(?P<symbol>%s)\b' % reg) | |
| 17 | + cmd =(self.env.LINK_CC) + ['/dump', '/symbols', binary_path] | |
| 18 | + else: # using gcc? assume we have nm | |
| 19 | + outputs = [x.abspath() for x in self.generator.link_task.outputs] | |
| 20 | + binary_path = list(filter(lambda x: x.endswith('dll'), outputs))[0] | |
| 21 | + reg_compiled = re.compile(r'(T|D)\s+_(?P<symbol>%s)\b'%reg) | |
| 22 | + cmd = (self.env.NM or ['nm']) + ['-g', binary_path] | |
| 23 | + dump_output = self.generator.bld.cmd_and_log(cmd, quiet=STDOUT) | |
| 24 | + syms = set([]) | |
| 25 | + for m in reg_compiled.finditer(dump_output): | |
| 26 | + syms.add(m.group('symbol')) | |
| 27 | + syms = list(syms) | |
| 28 | + syms.sort() | |
| 29 | + self.outputs[0].write('EXPORTS\n'+'\n'.join(syms)) | |
| 30 | + | |
| 31 | +@TaskGen.feature('gensyms') | |
| 32 | +@TaskGen.after_method('process_source','process_use','apply_link','process_uselib_local','propagate_uselib_vars') | |
| 33 | +def gen_symbols(self): | |
| 34 | + #sym_file = self.path.find_or_declare(self.target + '.def') | |
| 35 | + sym_file_name = os.path.splitext(self.link_task.outputs[0].abspath())[0] + '.def' | |
| 36 | + sym_file = self.path.find_or_declare(sym_file_name) | |
| 37 | + symtask = self.create_task('gen_sym_file', self.link_task.outputs, sym_file) | |
| 38 | + self.add_install_files(install_to=self.link_task.inst_to, install_from=sym_file, | |
| 39 | + chmod=O644, task=self.link_task) | |
| 40 | + | |
| @@ -50,6 +50,9 @@ def options(ctx): · 49 unmodified lines | ||
| 50 | 50 | add_option_enable_disable(ctx, 'fftw3', default = False, |
| 51 | 51 | help_str = 'compile with fftw3 instead of ooura', |
| 52 | 52 | help_disable_str = 'do not compile with fftw3') |
| 53 | + add_option_enable_disable(ctx, 'intelipp', default = False, | |
| 54 | + help_str = 'use Intel IPP libraries (auto)', | |
| 55 | + help_disable_str = 'do not use Intel IPP libraries') | |
| 53 | 56 | add_option_enable_disable(ctx, 'complex', default = False, |
| 54 | 57 | help_str ='compile with C99 complex', |
| 55 | 58 | help_disable_str = 'do not use C99 complex (default)' ) |
| @@ -100,25 +103,24 @@ def options(ctx): · 44 unmodified lines | ||
| 100 | 103 | ctx.load('compiler_c') |
| 101 | 104 | ctx.load('waf_unit_test') |
| 102 | 105 | ctx.load('gnu_dirs') |
| 106 | + ctx.load('waf_gensyms', tooldir='.') | |
| 103 | 107 | |
| 104 | 108 | def configure(ctx): |
| 105 | − from waflib import Options | |
| 106 | − ctx.load('compiler_c') | |
| 107 | − ctx.load('waf_unit_test') | |
| 108 | − ctx.load('gnu_dirs') | |
| 109 | − | |
| 110 | 109 | target_platform = sys.platform |
| 111 | 110 | if ctx.options.target_platform: |
| 112 | 111 | target_platform = ctx.options.target_platform |
| 113 | 112 | |
| 113 | + from waflib import Options | |
| 114 | 114 | |
| 115 | 115 | if target_platform=='emscripten': |
| 116 | − # need to force spaces between flag -o and path | |
| 117 | − # inspired from : | |
| 118 | − # https://github.com/waf-project/waf/blob/master/waflib/extras/c_emscripten.py (#1885) | |
| 119 | − # (OSX /emscripten 1.37.9) | |
| 120 | − ctx.env.CC_TGT_F = ['-c', '-o', ''] | |
| 121 | − ctx.env.CCLNK_TGT_F = ['-o', ''] | |
| 116 | + ctx.load('c_emscripten') | |
| 117 | + else: | |
| 118 | + ctx.load('compiler_c') | |
| 119 | + | |
| 120 | + ctx.load('waf_unit_test') | |
| 121 | + ctx.load('gnu_dirs') | |
| 122 | + ctx.load('waf_gensyms', tooldir='.') | |
| 123 | + | |
| 122 | 124 | # check for common headers |
| 123 | 125 | ctx.check(header_name='stdlib.h') |
| 124 | 126 | ctx.check(header_name='stdio.h') |
| @@ -151,10 +153,17 @@ def configure(ctx): · 26 unmodified lines | ||
| 151 | 153 | ctx.env.prepend_value('CFLAGS', ['-g', '-Wall', '-Wextra']) |
| 152 | 154 | else: |
| 153 | 155 | # enable debug symbols |
| 154 | − ctx.env.CFLAGS += ['/Z7', '/FS'] | |
| 156 | + ctx.env.CFLAGS += ['/Z7'] | |
| 157 | + # /FS flag available in msvc >= 12 (2013) | |
| 158 | + if 'MSVC_VERSION' in ctx.env and ctx.env.MSVC_VERSION >= 12: | |
| 159 | + ctx.env.CFLAGS += ['/FS'] | |
| 155 | 160 | ctx.env.LINKFLAGS += ['/DEBUG', '/INCREMENTAL:NO'] |
| 156 | 161 | # configure warnings |
| 157 | 162 | ctx.env.CFLAGS += ['/W4', '/D_CRT_SECURE_NO_WARNINGS'] |
| 163 | + # ignore "possible loss of data" warnings | |
| 164 | + ctx.env.CFLAGS += ['/wd4305', '/wd4244', '/wd4245', '/wd4267'] | |
| 165 | + # ignore "unreferenced formal parameter" warnings | |
| 166 | + ctx.env.CFLAGS += ['/wd4100'] | |
| 158 | 167 | # set optimization level and runtime libs |
| 159 | 168 | if (ctx.options.build_type == "release"): |
| 160 | 169 | ctx.env.CFLAGS += ['/Ox'] |
| @@ -226,9 +235,6 @@ def configure(ctx): · 65 unmodified lines | ||
| 226 | 235 | ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT] |
| 227 | 236 | |
| 228 | 237 | if target_platform == 'emscripten': |
| 229 | − import os.path | |
| 230 | − ctx.env.CFLAGS += [ '-I' + os.path.join(os.environ['EMSCRIPTEN'], 'system', 'include') ] | |
| 231 | − | |
| 232 | 238 | if ctx.options.build_type == "debug": |
| 233 | 239 | ctx.env.cshlib_PATTERN = '%s.js' |
| 234 | 240 | ctx.env.LINKFLAGS += ['-s','ASSERTIONS=2'] |
| @@ -247,9 +253,11 @@ def configure(ctx): · 12 unmodified lines | ||
| 247 | 253 | ctx.env.cstlib_PATTERN = '%s.a' |
| 248 | 254 | |
| 249 | 255 | # tell emscripten functions we want to expose |
| 250 | − from python.lib.gen_external import get_c_declarations, get_cpp_objects_from_c_declarations, get_all_func_names_from_lib, generate_lib_from_c_declarations | |
| 256 | + from python.lib.gen_external import get_c_declarations, \ | |
| 257 | + get_cpp_objects_from_c_declarations, get_all_func_names_from_lib, \ | |
| 258 | + generate_lib_from_c_declarations | |
| 251 | 259 | c_decls = get_c_declarations(usedouble=False) # emscripten can't use double |
| 252 | − objects = get_cpp_objects_from_c_declarations(c_decls) | |
| 260 | + objects = list(get_cpp_objects_from_c_declarations(c_decls)) | |
| 253 | 261 | # ensure that aubio structs are exported |
| 254 | 262 | objects += ['fvec_t', 'cvec_t', 'fmat_t'] |
| 255 | 263 | lib = generate_lib_from_c_declarations(objects, c_decls) |
| @@ -286,6 +294,21 @@ def configure(ctx): · 30 unmodified lines | ||
| 286 | 294 | else: |
| 287 | 295 | ctx.msg('Checking if complex.h is enabled', 'no') |
| 288 | 296 | |
| 297 | + # check for Intel IPP | |
| 298 | + if (ctx.options.enable_intelipp != False): | |
| 299 | + has_ipp_headers = ctx.check(header_name=['ippcore.h', 'ippvm.h', 'ipps.h'], | |
| 300 | + mandatory = False) | |
| 301 | + has_ipp_libs = ctx.check(lib=['ippcore', 'ippvm', 'ipps'], | |
| 302 | + uselib_store='INTEL_IPP', mandatory = False) | |
| 303 | + if (has_ipp_headers and has_ipp_libs): | |
| 304 | + ctx.msg('Checking if Intel IPP is available', 'yes') | |
| 305 | + ctx.define('HAVE_INTEL_IPP', 1) | |
| 306 | + if ctx.env.CC_NAME == 'msvc': | |
| 307 | + # force linking multi-threaded static IPP libraries on Windows with msvc | |
| 308 | + ctx.define('_IPP_SEQUENTIAL_STATIC', 1) | |
| 309 | + else: | |
| 310 | + ctx.msg('Checking if Intel IPP is available', 'no') | |
| 311 | + | |
| 289 | 312 | # check for fftw3 |
| 290 | 313 | if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False): |
| 291 | 314 | # one of fftwf or fftw3f |
| @@ -309,13 +332,15 @@ def configure(ctx): · 17 unmodified lines | ||
| 309 | 332 | mandatory = ctx.options.enable_fftw3) |
| 310 | 333 | ctx.define('HAVE_FFTW3', 1) |
| 311 | 334 | |
| 312 | − # fftw not enabled, use vDSP or ooura | |
| 335 | + # fftw not enabled, use vDSP, intelIPP or ooura | |
| 313 | 336 | if 'HAVE_FFTW3F' in ctx.env.define_key: |
| 314 | 337 | ctx.msg('Checking for FFT implementation', 'fftw3f') |
| 315 | 338 | elif 'HAVE_FFTW3' in ctx.env.define_key: |
| 316 | 339 | ctx.msg('Checking for FFT implementation', 'fftw3') |
| 317 | 340 | elif 'HAVE_ACCELERATE' in ctx.env.define_key: |
| 318 | 341 | ctx.msg('Checking for FFT implementation', 'vDSP') |
| 342 | + elif 'HAVE_INTEL_IPP' in ctx.env.define_key: | |
| 343 | + ctx.msg('Checking for FFT implementation', 'Intel IPP') | |
| 319 | 344 | else: |
| 320 | 345 | ctx.msg('Checking for FFT implementation', 'ooura') |
| 321 | 346 | |
| @@ -446,6 +471,8 @@ def build(bld): · 124 unmodified lines | ||
| 446 | 471 | |
| 447 | 472 | # add sub directories |
| 448 | 473 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']: |
| 474 | + if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd: | |
| 475 | + bld.options.testcmd = 'node %s' | |
| 449 | 476 | bld.recurse('examples') |
| 450 | 477 | bld.recurse('tests') |
| 451 | 478 | |
| @@ -557,3 +584,4 @@ def dist(ctx): · 105 unmodified lines | ||
| 557 | 584 | ctx.excl += ' **/.travis.yml' |
| 558 | 585 | ctx.excl += ' **/.landscape.yml' |
| 559 | 586 | ctx.excl += ' **/.appveyor.yml' |
| 587 | + ctx.excl += ' **/circlei.yml' | |