#include "mathutils.h"
#include "musicutils.h"
+ #if defined HAVE_INTEL_IPP
+ #include <ippcore.h>
+ #include <ippvm.h>
+ #include <ipps.h>
+ #endif
+
/** Window types */
typedef enum
{
+ aubio_win_ones,
aubio_win_rectangle,
aubio_win_hamming,
aubio_win_hanning,
if (window_type == NULL) {
AUBIO_ERR ("window type can not be null.\n");
return 1;
- } else if (strcmp (window_type, "rectangle") == 0)
+ } else if (strcmp (window_type, "ones") == 0)
+ wintype = aubio_win_ones;
+ else if (strcmp (window_type, "rectangle") == 0)
wintype = aubio_win_rectangle;
else if (strcmp (window_type, "hamming") == 0)
wintype = aubio_win_hamming;
return 1;
}
switch(wintype) {
+ case aubio_win_ones:
+ fvec_ones(win);
+ break;
case aubio_win_rectangle:
- for (i=0;i<size;i++)
- w[i] = 0.5;
+ fvec_set_all(win, .5);
break;
case aubio_win_hamming:
for (i=0;i<size;i++)
fvec_mean (fvec_t * s)
{
smpl_t tmp = 0.0;
- #ifndef HAVE_ACCELERATE
+ #if defined(HAVE_INTEL_IPP)
+ #if HAVE_AUBIO_DOUBLE
+ ippsMean_64f(s->data, (int)s->length, &tmp);
+ #else
+ ippsMean_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
+ #endif
+ return tmp;
+ #elif defined(HAVE_ACCELERATE)
+ aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
+ return tmp;
+ #else
uint_t j;
for (j = 0; j < s->length; j++) {
tmp += s->data[j];
}
- return tmp / (smpl_t) (s->length);
- #else
- aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
- return tmp;
- #endif /* HAVE_ACCELERATE */
+ return tmp / (smpl_t)(s->length);
+ #endif
}
smpl_t
fvec_sum (fvec_t * s)
{
smpl_t tmp = 0.0;
- #ifndef HAVE_ACCELERATE
+ #if defined(HAVE_INTEL_IPP)
+ #if HAVE_AUBIO_DOUBLE
+ ippsSum_64f(s->data, (int)s->length, &tmp);
+ #else
+ ippsSum_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
+ #endif
+ #elif defined(HAVE_ACCELERATE)
+ aubio_vDSP_sve(s->data, 1, &tmp, s->length);
+ #else
uint_t j;
for (j = 0; j < s->length; j++) {
tmp += s->data[j];
}
- #else
- aubio_vDSP_sve(s->data, 1, &tmp, s->length);
- #endif /* HAVE_ACCELERATE */
+ #endif
return tmp;
}
smpl_t
fvec_max (fvec_t * s)
{
- #ifndef HAVE_ACCELERATE
+ #if defined(HAVE_INTEL_IPP)
+ smpl_t tmp = 0.;
+ #if HAVE_AUBIO_DOUBLE
+ ippsMax_64f( s->data, (int)s->length, &tmp);
+ #else
+ ippsMax_32f( s->data, (int)s->length, &tmp);
+ #endif
+ #elif defined(HAVE_ACCELERATE)
+ smpl_t tmp = 0.;
+ aubio_vDSP_maxv( s->data, 1, &tmp, s->length );
+ #else
uint_t j;
- smpl_t tmp = 0.0;
- for (j = 0; j < s->length; j++) {
+ smpl_t tmp = s->data[0];
+ for (j = 1; j < s->length; j++) {
tmp = (tmp > s->data[j]) ? tmp : s->data[j];
}
- #else
- smpl_t tmp = 0.;
- aubio_vDSP_maxv(s->data, 1, &tmp, s->length);
#endif
return tmp;
}
smpl_t
fvec_min (fvec_t * s)
{
- #ifndef HAVE_ACCELERATE
+ #if defined(HAVE_INTEL_IPP)
+ smpl_t tmp = 0.;
+ #if HAVE_AUBIO_DOUBLE
+ ippsMin_64f(s->data, (int)s->length, &tmp);
+ #else
+ ippsMin_32f(s->data, (int)s->length, &tmp);
+ #endif
+ #elif defined(HAVE_ACCELERATE)
+ smpl_t tmp = 0.;
+ aubio_vDSP_minv(s->data, 1, &tmp, s->length);
+ #else
uint_t j;
smpl_t tmp = s->data[0];
- for (j = 0; j < s->length; j++) {
+ for (j = 1; j < s->length; j++) {
tmp = (tmp < s->data[j]) ? tmp : s->data[j];
}
- #else
- smpl_t tmp = 0.;
- aubio_vDSP_minv(s->data, 1, &tmp, s->length);
#endif
return tmp;
}
return i;
}
+ uint_t
+ aubio_power_of_two_order (uint_t a)
+ {
+ int order = 0;
+ int temp = aubio_next_power_of_two(a);
+ while (temp >>= 1) {
+ ++order;
+ }
+ return order;
+ }
+
smpl_t
aubio_db_spl (const fvec_t * o)
{
}
void
+ aubio_init (void)
+ {
+ /* initialize intel IPP */
+ #ifdef HAVE_INTEL_IPP
+ IppStatus status = ippInit();
+ if (status != ippStsNoErr) {
+ fprintf (stderr, "Error: failed to initialize Intel IPP - status %d\n", status);
+ }
+ #endif
+ }
+
+ void
aubio_cleanup (void)
{
#ifdef HAVE_FFTW3F
add_option_enable_disable(ctx, 'fftw3', default = False,
help_str = 'compile with fftw3 instead of ooura',
help_disable_str = 'do not compile with fftw3')
+ add_option_enable_disable(ctx, 'intelipp', default = None,
+ help_str = 'use Intel IPP libraries (auto)',
+ help_disable_str = 'do not use Intel IPP libraries')
add_option_enable_disable(ctx, 'complex', default = False,
help_str ='compile with C99 complex',
help_disable_str = 'do not use C99 complex (default)' )
ctx.load('gnu_dirs')
def configure(ctx):
- from waflib import Options
- ctx.load('compiler_c')
- ctx.load('waf_unit_test')
- ctx.load('gnu_dirs')
-
target_platform = sys.platform
if ctx.options.target_platform:
target_platform = ctx.options.target_platform
+ from waflib import Options
if target_platform=='emscripten':
- # need to force spaces between flag -o and path
- # inspired from :
- # https://github.com/waf-project/waf/blob/master/waflib/extras/c_emscripten.py (#1885)
- # (OSX /emscripten 1.37.9)
- ctx.env.CC_TGT_F = ['-c', '-o', '']
- ctx.env.CCLNK_TGT_F = ['-o', '']
+ ctx.load('c_emscripten')
+ else:
+ ctx.load('compiler_c')
+
+ ctx.load('waf_unit_test')
+ ctx.load('gnu_dirs')
+
# check for common headers
ctx.check(header_name='stdlib.h')
ctx.check(header_name='stdio.h')
ctx.env.prepend_value('CFLAGS', ['-g', '-Wall', '-Wextra'])
else:
# enable debug symbols
- ctx.env.CFLAGS += ['/Z7', '/FS']
+ ctx.env.CFLAGS += ['/Z7']
+ # /FS flag available in msvc >= 12 (2013)
+ if 'MSVC_VERSION' in ctx.env and ctx.env.MSVC_VERSION >= 12:
+ ctx.env.CFLAGS += ['/FS']
ctx.env.LINKFLAGS += ['/DEBUG', '/INCREMENTAL:NO']
# configure warnings
ctx.env.CFLAGS += ['/W4', '/D_CRT_SECURE_NO_WARNINGS']
+ # ignore "possible loss of data" warnings
+ ctx.env.CFLAGS += ['/wd4305', '/wd4244', '/wd4245', '/wd4267']
+ # ignore "unreferenced formal parameter" warnings
+ ctx.env.CFLAGS += ['/wd4100']
# set optimization level and runtime libs
if (ctx.options.build_type == "release"):
ctx.env.CFLAGS += ['/Ox']
ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
if target_platform == 'emscripten':
- import os.path
- ctx.env.CFLAGS += [ '-I' + os.path.join(os.environ['EMSCRIPTEN'], 'system', 'include') ]
-
if ctx.options.build_type == "debug":
ctx.env.cshlib_PATTERN = '%s.js'
ctx.env.LINKFLAGS += ['-s','ASSERTIONS=2']
# tell emscripten functions we want to expose
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
c_decls = get_c_declarations(usedouble=False) # emscripten can't use double
- objects = get_cpp_objects_from_c_declarations(c_decls)
+ objects = list(get_cpp_objects_from_c_declarations(c_decls))
# ensure that aubio structs are exported
objects += ['fvec_t', 'cvec_t', 'fmat_t']
lib = generate_lib_from_c_declarations(objects, c_decls)
ctx.check(header_name='complex.h')
else:
ctx.msg('Checking if complex.h is enabled', 'no')
-
+
+ # check for Intel IPP
+ if (ctx.options.enable_intelipp != False):
+ if (ctx.check(header_name=['ippcore.h', 'ippvm.h', 'ipps.h'], mandatory = False) and
+ ctx.check(lib=['ippcore', 'ippvm', 'ipps'], uselib_store='INTEL_IPP', mandatory = False)):
+ ctx.msg('Checking if Intel IPP is available', 'yes')
+ ctx.define('HAVE_INTEL_IPP', 1)
+ if ctx.env.CC_NAME == 'msvc':
+ # force linking multi-threaded static IPP libraries on Windows with msvc
+ ctx.define('_IPP_SEQUENTIAL_STATIC', 1)
+ else:
+ ctx.msg('Checking if Intel IPP is available', 'no')
+
# check for fftw3
if (ctx.options.enable_fftw3 != False or ctx.options.enable_fftw3f != False):
# one of fftwf or fftw3f
mandatory = ctx.options.enable_fftw3)
ctx.define('HAVE_FFTW3', 1)
- # fftw not enabled, use vDSP or ooura
+ # fftw not enabled, use vDSP, intelIPP or ooura
if 'HAVE_FFTW3F' in ctx.env.define_key:
ctx.msg('Checking for FFT implementation', 'fftw3f')
elif 'HAVE_FFTW3' in ctx.env.define_key:
ctx.msg('Checking for FFT implementation', 'fftw3')
elif 'HAVE_ACCELERATE' in ctx.env.define_key:
ctx.msg('Checking for FFT implementation', 'vDSP')
+ elif 'HAVE_INTEL_IPP' in ctx.env.define_key:
+ ctx.msg('Checking for FFT implementation', 'Intel IPP')
else:
ctx.msg('Checking for FFT implementation', 'ooura')
# add sub directories
if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
+ if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd:
+ bld.options.testcmd = 'node %s'
bld.recurse('examples')
bld.recurse('tests')