shithub: aubio

Download patch

ref: 0969113110f96081523419ccde6ac0e8616e8eeb
parent: c9e3a4ec8da543f3309b4ee9377253f5279d8288
parent: f8340e1cf44061891b4d45d8c835bd140ee46318
author: Paul Brossier <[email protected]>
date: Sat Sep 5 07:55:53 EDT 2015

Merge branch 'develop' into accelerate

--- a/src/aubio_priv.h
+++ b/src/aubio_priv.h
@@ -196,10 +196,14 @@
 /* handy shortcuts */
 #define DB2LIN(g) (POW(10.0,(g)*0.05f))
 #define LIN2DB(v) (20.0*LOG10(v))
-#define SQR(_a)   (_a*_a)
+#define SQR(_a)   ((_a)*(_a))
 
-#define MAX(a,b)  ( a > b ? a : b)
-#define MIN(a,b)  ( a < b ? a : b)
+#ifndef MAX
+#define MAX(a,b)  (((a)>(b))?(a):(b))
+#endif /* MAX */
+#ifndef MIN
+#define MIN(a,b)  (((a)<(b))?(a):(b))
+#endif /* MIN */
 
 #define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; }
 
--- a/src/io/audio_unit.c
+++ b/src/io/audio_unit.c
@@ -19,7 +19,7 @@
 */
 
 #include "config.h"
-#ifdef TARGET_OS_IPHONE
+#ifdef HAVE_AUDIO_UNIT
 #include "aubio_priv.h"
 
 #include "fvec.h"
@@ -774,4 +774,4 @@
   return (int)err;
 }
 
-#endif /* TARGET_OS_IPHONE */
+#endif /* HAVE_AUDIO_UNIT */
--- a/src/io/sink_sndfile.c
+++ b/src/io/sink_sndfile.c
@@ -33,6 +33,12 @@
 #define MAX_CHANNELS 6
 #define MAX_SIZE 4096
 
+#if !HAVE_AUBIO_DOUBLE
+#define aubio_sf_write_smpl sf_write_float
+#else /* HAVE_AUBIO_DOUBLE */
+#define aubio_sf_write_smpl sf_write_double
+#endif /* HAVE_AUBIO_DOUBLE */
+
 struct _aubio_sink_sndfile_t {
   uint_t samplerate;
   uint_t channels;
@@ -125,7 +131,7 @@
     /* show libsndfile err msg */
     AUBIO_ERR("sink_sndfile: Failed opening %s. %s\n", s->path, sf_strerror (NULL));
     return AUBIO_FAIL;
-  }	
+  }
 
   s->scratch_size = s->max_size*s->channels;
   /* allocate data for de/interleaving reallocated when needed. */
@@ -134,13 +140,13 @@
         s->max_size, s->channels, MAX_CHANNELS * MAX_CHANNELS);
     return AUBIO_FAIL;
   }
-  s->scratch_data = AUBIO_ARRAY(float,s->scratch_size);
+  s->scratch_data = AUBIO_ARRAY(smpl_t,s->scratch_size);
 
   return AUBIO_OK;
 }
 
 void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t write){
-  uint_t i, j,	channels = s->channels;
+  uint_t i, j, channels = s->channels;
   int nsamples = 0;
   smpl_t *pwrite;
   sf_count_t written_frames;
@@ -161,7 +167,7 @@
     }
   }
 
-  written_frames = sf_write_float (s->handle, s->scratch_data, nsamples);
+  written_frames = aubio_sf_write_smpl (s->handle, s->scratch_data, nsamples);
   if (written_frames/channels != write) {
     AUBIO_WRN("sink_sndfile: trying to write %d frames to %s, but only %d could be written\n",
       write, s->path, (uint_t)written_frames);
@@ -170,7 +176,7 @@
 }
 
 void aubio_sink_sndfile_do_multi(aubio_sink_sndfile_t *s, fmat_t * write_data, uint_t write){
-  uint_t i, j,	channels = s->channels;
+  uint_t i, j, channels = s->channels;
   int nsamples = 0;
   smpl_t *pwrite;
   sf_count_t written_frames;
@@ -191,7 +197,7 @@
     }
   }
 
-  written_frames = sf_write_float (s->handle, s->scratch_data, nsamples);
+  written_frames = aubio_sf_write_smpl (s->handle, s->scratch_data, nsamples);
   if (written_frames/channels != write) {
     AUBIO_WRN("sink_sndfile: trying to write %d frames to %s, but only %d could be written\n",
       write, s->path, (uint_t)written_frames);
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -90,7 +90,7 @@
     /* show libsndfile err msg */
     AUBIO_ERR("source_sndfile: Failed opening %s: %s\n", s->path, sf_strerror (NULL));
     goto beach;
-  }	
+  }
 
   /* get input specs */
   s->input_samplerate = sfinfo.samplerate;
--- a/src/pitch/pitchyinfft.h
+++ b/src/pitch/pitchyinfft.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2003-2013 Paul Brossier <[email protected]>
+  Copyright (C) 2003-2015 Paul Brossier <[email protected]>
 
   This file is part of aubio.
 
--- a/src/spectral/mfcc.h
+++ b/src/spectral/mfcc.h
@@ -21,7 +21,14 @@
 
 /** \file
 
-  Mel-frequency cepstrum coefficients object
+  Mel-Frequency Cepstrum Coefficients object
+
+  This object computes MFCC coefficients on an input cvec_t.
+
+  The implementation follows the specifications established by Malcolm Slaney
+  in its Auditory Toolbox, available online (see file mfcc.m).
+
+  http://engineering.ecn.purdue.edu/~malcolm/interval/1998-010/
 
   \example spectral/test-mfcc.c
 
--- a/wscript
+++ b/wscript
@@ -78,6 +78,9 @@
     add_option_enable_disable(ctx, 'accelerate', default = None,
             help_str = 'use Accelerate framework (darwin only) (auto)',
             help_disable_str = 'do not use Accelerate framework')
+    add_option_enable_disable(ctx, 'apple-audio', default = None,
+            help_str = 'use CoreFoundation (darwin only) (auto)',
+            help_disable_str = 'do not use CoreFoundation framework')
 
     ctx.add_option('--with-target-platform', type='string',
             help='set target platform for cross-compilation', dest='target_platform')
@@ -113,17 +116,20 @@
         ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
 
     if target_platform in [ 'darwin', 'ios', 'iosimulator']:
-        ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox']
-        ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
-        ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
+        if (ctx.options.enable_apple_audio != False):
+            ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
+            ctx.define('HAVE_SOURCE_APPLE_AUDIO', 1)
+            ctx.define('HAVE_SINK_APPLE_AUDIO', 1)
         if (ctx.options.enable_accelerate != False):
             ctx.define('HAVE_ACCELERATE', 1)
             ctx.env.FRAMEWORK += ['Accelerate']
 
     if target_platform in [ 'ios', 'iosimulator' ]:
-        ctx.define('TARGET_OS_IPHONE', 1)
         MINSDKVER="6.1"
         ctx.env.CFLAGS += ['-std=c99']
+        if (ctx.options.enable_audio_unit != False):
+            ctx.define('HAVE_AUDIO_UNIT', 1)
+            #ctx.env.FRAMEWORK += ['CoreFoundation', 'AudioToolbox']
         if target_platform == 'ios':
             DEVROOT = "/Applications/Xcode.app/Contents"
             DEVROOT += "/Developer/Platforms/iPhoneOS.platform/Developer"