#include "musicutils.h"
#include "config.h"
+#ifdef HAVE_ACCELERATE
+#include <Accelerate/Accelerate.h>
+#endif
/** Window types */
typedef enum
smpl_t
fvec_max (fvec_t * s)
{
+#ifndef HAVE_ACCELERATE
uint_t j;
smpl_t tmp = 0.0;
for (j = 0; j < s->length; j++) {
tmp = (tmp > s->data[j]) ? tmp : s->data[j];
}
+#else
+ smpl_t tmp = 0.;
+#if !HAVE_AUBIO_DOUBLE
+ vDSP_maxv(s->data, 1, &tmp, s->length);
+#else
+ vDSP_maxvD(s->data, 1, &tmp, s->length);
+#endif
+#endif
return tmp;
}
smpl_t
fvec_min (fvec_t * s)
{
+#ifndef HAVE_ACCELERATE
uint_t j;
smpl_t tmp = s->data[0];
for (j = 0; j < s->length; j++) {
tmp = (tmp < s->data[j]) ? tmp : s->data[j];
}
+#else
+ smpl_t tmp = 0.;
+#if !HAVE_AUBIO_DOUBLE
+ vDSP_minv(s->data, 1, &tmp, s->length);
+#else
+ vDSP_minvD(s->data, 1, &tmp, s->length);
+#endif
+#endif
return tmp;
}
uint_t
fvec_min_elem (fvec_t * s)
{
+#ifndef HAVE_ACCELERATE
uint_t j, pos = 0.;
smpl_t tmp = s->data[0];
for (j = 0; j < s->length; j++) {
pos = (tmp < s->data[j]) ? pos : j;
tmp = (tmp < s->data[j]) ? tmp : s->data[j];
}
+#else
+ smpl_t tmp = 0.;
+ uint_t pos = 0.;
+#if !HAVE_AUBIO_DOUBLE
+ vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
+#else
+ vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
+#endif
+#endif
return pos;
}
uint_t
fvec_max_elem (fvec_t * s)
{
+#ifndef HAVE_ACCELERATE
uint_t j, pos = 0;
smpl_t tmp = 0.0;
for (j = 0; j < s->length; j++) {
pos = (tmp > s->data[j]) ? pos : j;
tmp = (tmp > s->data[j]) ? tmp : s->data[j];
}
+#else
+ smpl_t tmp = 0.;
+ uint_t pos = 0.;
+#if !HAVE_AUBIO_DOUBLE
+ vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
+#else
+ vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
+#endif
+#endif
return pos;
}