mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 08:09:32 +02:00
Associated with r11696 / patch for bug 485. Just forgot to add/delete these files associated with the patch.
This commit is contained in:
parent
87fb427603
commit
c64adba308
40
lib-src/sbsms/m4/ax_check_compiler_flags.m4
Normal file
40
lib-src/sbsms/m4/ax_check_compiler_flags.m4
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
dnl @synopsis AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
|
||||||
|
dnl @summary check whether FLAGS are accepted by the compiler
|
||||||
|
dnl @category Misc
|
||||||
|
dnl
|
||||||
|
dnl Check whether the given compiler FLAGS work with the current language's
|
||||||
|
dnl compiler, or whether they give an error. (Warnings, however, are
|
||||||
|
dnl ignored.)
|
||||||
|
dnl
|
||||||
|
dnl ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||||
|
dnl success/failure.
|
||||||
|
dnl
|
||||||
|
dnl @version 2005-05-30
|
||||||
|
dnl @license GPLWithACException
|
||||||
|
dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Matteo Frigo.
|
||||||
|
AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
|
||||||
|
[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
|
||||||
|
AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
|
||||||
|
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
|
||||||
|
AS_LITERAL_IF([$1],
|
||||||
|
[AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
|
||||||
|
ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
|
||||||
|
_AC_LANG_PREFIX[]FLAGS="$1"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||||
|
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
|
||||||
|
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
|
||||||
|
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
|
||||||
|
[ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
|
||||||
|
_AC_LANG_PREFIX[]FLAGS="$1"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||||
|
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
|
||||||
|
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
|
||||||
|
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
|
||||||
|
eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)
|
||||||
|
AC_MSG_RESULT($ax_check_compiler_flags)
|
||||||
|
if test "x$ax_check_compiler_flags" = xyes; then
|
||||||
|
m4_default([$2], :)
|
||||||
|
else
|
||||||
|
m4_default([$3], :)
|
||||||
|
fi
|
||||||
|
])dnl AX_CHECK_COMPILER_FLAGS
|
30
lib-src/sbsms/m4/ax_compiler_vendor.m4
Normal file
30
lib-src/sbsms/m4/ax_compiler_vendor.m4
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
dnl @synopsis AX_COMPILER_VENDOR
|
||||||
|
dnl @summary find the vendor (gnu, intel, etc.) of the C/C++ compiler
|
||||||
|
dnl @category C
|
||||||
|
dnl @category C++
|
||||||
|
dnl
|
||||||
|
dnl Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm,
|
||||||
|
dnl sun, hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi,
|
||||||
|
dnl microsoft, watcom, etc. The vendor is returned in the cache variable
|
||||||
|
dnl $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
|
||||||
|
dnl
|
||||||
|
dnl @version 2007-08-01
|
||||||
|
dnl @license GPLWithACException
|
||||||
|
dnl @author Steven G. Johnson <stevenj@alum.mit.edu> with Matteo Frigo
|
||||||
|
|
||||||
|
AC_DEFUN([AX_COMPILER_VENDOR],
|
||||||
|
[
|
||||||
|
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
|
||||||
|
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
|
||||||
|
# note: don't check for gcc first since some other compilers define __GNUC__
|
||||||
|
for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale:__PATHCC__,__PATHSCALE__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
|
||||||
|
vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
|
||||||
|
#if !($vencpp)
|
||||||
|
thisisanerror;
|
||||||
|
#endif
|
||||||
|
])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
|
||||||
|
done
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "audio.h"
|
|
||||||
|
|
||||||
namespace _sbsms_ {
|
|
||||||
|
|
||||||
audio *make_audio_buf(long n) {
|
|
||||||
return (audio*)calloc(n,sizeof(audio));
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_audio_buf(audio *buf) {
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
long copy_audio_buf(audio *to, long off1, audio *from, long off2, long n)
|
|
||||||
{
|
|
||||||
memcpy(to+off1,from+off2,n*sizeof(audio));
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
long audio_convert_from(float *to, long off1, audio *from, long off2, long n)
|
|
||||||
{
|
|
||||||
for(int k=0;k<n;k++) {
|
|
||||||
int k2 = (k+off1)<<1;
|
|
||||||
to[k2] = (float)from[k+off2][0];
|
|
||||||
to[k2+1] = (float)from[k+off2][1];
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
long audio_convert_to(audio *to, long off1, float *from, long off2, long n)
|
|
||||||
{
|
|
||||||
for(int k=0;k<n;k++) {
|
|
||||||
int k2 = (k+off2)<<1;
|
|
||||||
to[k+off1][0] = (real)from[k2];
|
|
||||||
to[k+off1][1] = (real)from[k2+1];
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef SBSMS_AUDIO_H
|
|
||||||
#define SBSMS_AUDIO_H
|
|
||||||
|
|
||||||
#include "sbsms.h"
|
|
||||||
|
|
||||||
namespace _sbsms_ {
|
|
||||||
|
|
||||||
audio *make_audio_buf(long);
|
|
||||||
void free_audio_buf(audio *);
|
|
||||||
long copy_audio_buf(audio *, long off1, audio *, long off2, long n);
|
|
||||||
long audio_convert_from(float *to, long off1, audio *from, long off2, long n);
|
|
||||||
long audio_convert_to(audio *to, long off1, float *from, long off2, long n);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
4105
lib-src/sbsms/src/dBTable.cpp
Normal file
4105
lib-src/sbsms/src/dBTable.cpp
Normal file
File diff suppressed because it is too large
Load Diff
26
lib-src/sbsms/src/dBTable.h
Normal file
26
lib-src/sbsms/src/dBTable.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
#ifndef DBTABLE_H
|
||||||
|
#define DBTABLE_H
|
||||||
|
|
||||||
|
#include "real.h"
|
||||||
|
|
||||||
|
namespace _sbsms_ {
|
||||||
|
|
||||||
|
enum { dBTableSize = 4096, dBTableScale = dBTableSize - 1 };
|
||||||
|
|
||||||
|
extern float dBTable[dBTableSize];
|
||||||
|
|
||||||
|
inline float dBApprox(float x, float y)
|
||||||
|
{
|
||||||
|
if(x < y) {
|
||||||
|
return dBTable[lrintf(x/y*dBTableScale)];
|
||||||
|
} else if(x == 0.0f) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return dBTable[lrintf(y/x*dBTableScale)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -1,47 +0,0 @@
|
|||||||
#include "peak.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
namespace _sbsms_ {
|
|
||||||
|
|
||||||
PeakAllocator :: PeakAllocator()
|
|
||||||
{
|
|
||||||
size = 0;
|
|
||||||
count = 0;
|
|
||||||
peaks = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
PeakAllocator :: ~PeakAllocator()
|
|
||||||
{
|
|
||||||
if(peaks) free(peaks);
|
|
||||||
}
|
|
||||||
|
|
||||||
peak *PeakAllocator :: create()
|
|
||||||
{
|
|
||||||
if(count >= size) {
|
|
||||||
if(size == 0)
|
|
||||||
size = 1024;
|
|
||||||
else
|
|
||||||
size *= 2;
|
|
||||||
|
|
||||||
peak *newpeaks = (peak*)malloc(size*sizeof(peak));
|
|
||||||
if(peaks) {
|
|
||||||
memcpy(newpeaks,peaks,count*sizeof(peak));
|
|
||||||
free(peaks);
|
|
||||||
}
|
|
||||||
peaks = newpeaks;
|
|
||||||
}
|
|
||||||
return peaks+(count++);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeakAllocator :: destroy(peak *p)
|
|
||||||
{
|
|
||||||
count--;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeakAllocator :: destroyAll()
|
|
||||||
{
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
#ifndef PEAK_H
|
|
||||||
#define PEAK_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
Semantics are such that if destroy(p) or destroyAll() is called then all peaks create()'d after p are invalid. It is OK to create() a peak, destroy it before calling create() again, then create() another, or to create() a set of peaks, then destroy them ALL in any order, and repeat.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sbsms.h"
|
|
||||||
|
|
||||||
namespace _sbsms_ {
|
|
||||||
|
|
||||||
class peak {
|
|
||||||
public:
|
|
||||||
peak *tp;
|
|
||||||
peak *tn;
|
|
||||||
peak *tp2;
|
|
||||||
peak *tn2;
|
|
||||||
real x;
|
|
||||||
real y;
|
|
||||||
real y2;
|
|
||||||
int k;
|
|
||||||
real m;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PeakAllocator {
|
|
||||||
public:
|
|
||||||
PeakAllocator();
|
|
||||||
~PeakAllocator();
|
|
||||||
peak *create();
|
|
||||||
void destroy(peak *p);
|
|
||||||
void destroyAll();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
long count;
|
|
||||||
long size;
|
|
||||||
peak *peaks;
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
476
lib-src/sbsms/src/slide.cpp
Normal file
476
lib-src/sbsms/src/slide.cpp
Normal file
@ -0,0 +1,476 @@
|
|||||||
|
#include "sbsms.h"
|
||||||
|
#include "real.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include <algorithm>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace _sbsms_ {
|
||||||
|
|
||||||
|
class SlideImp {
|
||||||
|
public:
|
||||||
|
virtual ~SlideImp() {}
|
||||||
|
virtual float getTotalStretch()=0;
|
||||||
|
virtual float getStretchedTime(float t)=0;
|
||||||
|
virtual float getRate(float t)=0;
|
||||||
|
virtual float getStretch(float t)=0;
|
||||||
|
virtual float getRate()=0;
|
||||||
|
virtual float getStretch()=0;
|
||||||
|
virtual void step()=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IdentitySlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
IdentitySlide() {
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConstantSlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
ConstantSlide(float rate) {
|
||||||
|
this->rate = rate;
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return 1.0f / rate;
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
return t / rate;
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return 1.0f / rate;
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return 1.0f / rate;
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
float rate;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LinearInputRateSlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
LinearInputRateSlide(float rate0, float rate1, const SampleCountType &n) {
|
||||||
|
this->rate0 = rate0;
|
||||||
|
this->rate1 = rate1;
|
||||||
|
if(n) {
|
||||||
|
val = rate0;
|
||||||
|
inc = (rate1 - rate0) / (double)n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return log(rate1 / rate0) / (rate1 - rate0);
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
float ratet = getRate(t);
|
||||||
|
return log(ratet / rate0) / (rate1 - rate0);
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
return rate0 + (rate1 - rate0) * t;
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return 1.0f / getRate(t);
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return (float)val;
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return (float)(1.0 / val);
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
val += inc;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
float rate0, rate1;
|
||||||
|
double val, inc;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LinearOutputRateSlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
LinearOutputRateSlide(float rate0, float rate1, const SampleCountType &n) {
|
||||||
|
this->rate0 = rate0;
|
||||||
|
this->rate1 = rate1;
|
||||||
|
if(n) {
|
||||||
|
val = 0.0;
|
||||||
|
inc = 1.0 / (double)n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return 2.0f / (rate0 + rate1);
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
return (sqrt(rate0 * rate0 + (rate1 * rate1 - rate0 * rate0) * t) - rate0) * 2.0f / (rate1 * rate1 - rate0 * rate0);
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
return rate0 + (sqrt(rate0 * rate0 + (rate1 * rate1 - rate0 * rate0) * t) - rate0);
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return 1.0f / getRate(t);
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return getRate((float)val);
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return getStretch((float)val);
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
val += inc;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
float rate0, rate1;
|
||||||
|
double val, inc;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LinearInputStretchSlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
LinearInputStretchSlide(float rate0, float rate1, const SampleCountType &n) {
|
||||||
|
this->rate0 = rate0;
|
||||||
|
this->rate1 = rate1;
|
||||||
|
if(n) {
|
||||||
|
val = 1.0 / rate0;
|
||||||
|
inc = (1.0 / rate1 - 1.0 / rate0) / (double)n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return 0.5f / rate0 + 0.5f / rate1;
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
return t / rate0 * (1.0f + 0.5f * t * (rate0 / rate1 - 1.0f));
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
return 1.0f / getStretch(t);
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return (1.0f / rate0 + (1.0f / rate1 - 1.0f / rate0) * t);
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return (float)(1.0 / val);
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return (float)val;
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
val += inc;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
float rate0, rate1;
|
||||||
|
double val, inc;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LinearOutputStretchSlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
LinearOutputStretchSlide(float rate0, float rate1, const SampleCountType &n) {
|
||||||
|
this->rate0 = rate0;
|
||||||
|
this->rate1 = rate1;
|
||||||
|
c0 = rate0 / rate1;
|
||||||
|
c1 = 1.0f / (rate0 * log(c0));
|
||||||
|
if(n) {
|
||||||
|
val = 0.0;
|
||||||
|
inc = 1.0 / (double)n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return c1 * (c0 - 1.0f);
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
return c1 * (pow(c0, t) - 1.0f);
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
return rate0 * pow(c0, -t);
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return pow(c0, t) / rate0;
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return getRate((float)val);
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return getStretch((float)val);
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
val += inc;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
float rate0, rate1;
|
||||||
|
double val, inc;
|
||||||
|
float c0, c1;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GeometricInputSlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
GeometricInputSlide(float rate0, float rate1, const SampleCountType &n) {
|
||||||
|
this->rate0 = rate0;
|
||||||
|
this->rate1 = rate1;
|
||||||
|
if(n) {
|
||||||
|
val = rate0;
|
||||||
|
inc = pow((double)rate1 / rate0, 1.0 / (double)n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return (rate1 - rate0) / (log(rate1 / rate0) * (rate0 * rate1));
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
return (float)(pow(rate0 / rate1, t) - 1.0) / (rate0 * log(rate0 / rate1));
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
return rate0 * pow(rate1 / rate0, t);
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return 1.0f / getRate(t);
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return (float)val;
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return (float)(1.0 / val);
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
val *= inc;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
float rate0, rate1;
|
||||||
|
double val, inc;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GeometricOutputSlide : public SlideImp {
|
||||||
|
public:
|
||||||
|
GeometricOutputSlide(float rate0, float rate1, const SampleCountType &n) {
|
||||||
|
this->rate0 = rate0;
|
||||||
|
this->rate1 = rate1;
|
||||||
|
log10 = log(rate1 / rate0);
|
||||||
|
r10 = rate1 - rate0;
|
||||||
|
totalStretch = getTotalStretch();
|
||||||
|
if(n) {
|
||||||
|
val = 0.0;
|
||||||
|
inc = 1.0 / (double)n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float getTotalStretch() {
|
||||||
|
return log(rate1 / rate0) / (rate1 - rate0);
|
||||||
|
}
|
||||||
|
float getStretchedTime(float t) {
|
||||||
|
return log(r10 / rate0 * t + 1.0f) / r10;
|
||||||
|
}
|
||||||
|
float getRate(float t) {
|
||||||
|
float t1 = getStretchedTime(t) / totalStretch;
|
||||||
|
return rate0 * pow(rate1 / rate0, t1);
|
||||||
|
}
|
||||||
|
float getStretch(float t) {
|
||||||
|
return 1.0f / getRate(t);
|
||||||
|
}
|
||||||
|
float getRate() {
|
||||||
|
return getRate((float)val);
|
||||||
|
}
|
||||||
|
float getStretch() {
|
||||||
|
return getStretch((float)val);
|
||||||
|
}
|
||||||
|
void step() {
|
||||||
|
val += inc;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
float rate0, rate1;
|
||||||
|
float log10, r10, totalStretch;
|
||||||
|
double val, inc;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Slide :: Slide(SlideType slideType, float rate0, float rate1, const SampleCountType &n)
|
||||||
|
{
|
||||||
|
if(slideType == SlideIdentity) {
|
||||||
|
imp = new IdentitySlide();
|
||||||
|
} else if(slideType == SlideConstant || rate0 == rate1) {
|
||||||
|
imp = new ConstantSlide(rate0);
|
||||||
|
} else if(slideType == SlideLinearInputRate) {
|
||||||
|
imp = new LinearInputRateSlide(rate0,rate1,n);
|
||||||
|
} else if(slideType == SlideLinearOutputRate) {
|
||||||
|
imp = new LinearOutputRateSlide(rate0,rate1,n);
|
||||||
|
} else if(slideType == SlideLinearInputStretch) {
|
||||||
|
imp = new LinearInputStretchSlide(rate0,rate1,n);
|
||||||
|
} else if(slideType == SlideLinearOutputStretch) {
|
||||||
|
imp = new LinearOutputStretchSlide(rate0,rate1,n);
|
||||||
|
} else if(slideType == SlideGeometricInput) {
|
||||||
|
imp = new GeometricInputSlide(rate0,rate1,n);
|
||||||
|
} else if(slideType == SlideGeometricOutput) {
|
||||||
|
imp = new GeometricOutputSlide(rate0,rate1,n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Slide :: ~Slide()
|
||||||
|
{
|
||||||
|
delete imp;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slide :: getTotalStretch()
|
||||||
|
{
|
||||||
|
return imp->getTotalStretch();
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slide :: getRate(float t)
|
||||||
|
{
|
||||||
|
if(t > 1.0f) t = 1.0f;
|
||||||
|
return imp->getRate(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slide :: getStretch(float t)
|
||||||
|
{
|
||||||
|
if(t > 1.0f) t = 1.0f;
|
||||||
|
return imp->getStretch(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slide :: getStretchedTime(float t)
|
||||||
|
{
|
||||||
|
if(t > 1.0f) t = 1.0f;
|
||||||
|
return imp->getStretchedTime(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slide :: getRate()
|
||||||
|
{
|
||||||
|
return imp->getRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
float Slide :: getStretch()
|
||||||
|
{
|
||||||
|
return imp->getStretch();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Slide :: step()
|
||||||
|
{
|
||||||
|
imp->step();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SBSMSInterfaceSlidingImp {
|
||||||
|
public:
|
||||||
|
friend class SBSMSInterfaceSliding;
|
||||||
|
SBSMSInterfaceSlidingImp(Slide *rateSlide,
|
||||||
|
Slide *pitchSlide,
|
||||||
|
bool bPitchReferenceInput,
|
||||||
|
const SampleCountType &samplesToInput,
|
||||||
|
long preSamples,
|
||||||
|
SBSMSQuality *quality);
|
||||||
|
~SBSMSInterfaceSlidingImp() {}
|
||||||
|
inline float getStretch(float t);
|
||||||
|
inline float getPitch(float t);
|
||||||
|
inline long getPresamples();
|
||||||
|
SampleCountType getSamplesToInput();
|
||||||
|
SampleCountType getSamplesToOutput();
|
||||||
|
protected:
|
||||||
|
Slide *stretchSlide;
|
||||||
|
Slide *pitchSlide;
|
||||||
|
bool bPitchReferenceInput;
|
||||||
|
float totalStretch;
|
||||||
|
float stretchScale;
|
||||||
|
long preSamples;
|
||||||
|
SampleCountType samplesToInput;
|
||||||
|
SampleCountType samplesToOutput;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
SBSMSInterfaceSlidingImp :: SBSMSInterfaceSlidingImp(Slide *stretchSlide,
|
||||||
|
Slide *pitchSlide,
|
||||||
|
bool bPitchReferenceInput,
|
||||||
|
const SampleCountType &samplesToInput,
|
||||||
|
long preSamples,
|
||||||
|
SBSMSQuality *quality)
|
||||||
|
{
|
||||||
|
this->stretchSlide = stretchSlide;
|
||||||
|
this->pitchSlide = pitchSlide;
|
||||||
|
this->bPitchReferenceInput = bPitchReferenceInput;
|
||||||
|
this->samplesToInput = samplesToInput;
|
||||||
|
this->preSamples = preSamples;
|
||||||
|
this->totalStretch = stretchSlide->getTotalStretch();
|
||||||
|
this->samplesToOutput = (SampleCountType)((float)samplesToInput * totalStretch);
|
||||||
|
stretchScale = 1.0f;
|
||||||
|
|
||||||
|
if(quality) {
|
||||||
|
SampleCountType samplesIn = 0;
|
||||||
|
SampleCountType samplesOut = 0;
|
||||||
|
float outFrameSizefloat = 0.0f;
|
||||||
|
float stretch = 1.0f;
|
||||||
|
int inFrameSize = quality->getFrameSize();
|
||||||
|
while(samplesIn < samplesToInput) {
|
||||||
|
float t = (float)samplesIn / (float)samplesToInput;
|
||||||
|
stretch = stretchSlide->getStretch(t);
|
||||||
|
outFrameSizefloat += stretch * inFrameSize;
|
||||||
|
int outFrameSize = (int) outFrameSizefloat;
|
||||||
|
outFrameSizefloat -= (float) outFrameSize;
|
||||||
|
samplesIn += inFrameSize;
|
||||||
|
samplesOut += outFrameSize;
|
||||||
|
}
|
||||||
|
SampleCountType samplesOutputed = samplesOut - lrintf(stretch * (samplesIn - samplesToInput));
|
||||||
|
stretchScale = (float)samplesToOutput / (float)samplesOutputed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float SBSMSInterfaceSliding :: getStretch(float t) { return imp->getStretch(t); }
|
||||||
|
float SBSMSInterfaceSlidingImp :: getStretch(float t)
|
||||||
|
{
|
||||||
|
return stretchScale * stretchSlide->getStretch(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
float SBSMSInterfaceSliding :: getPitch(float t) { return imp->getPitch(t); }
|
||||||
|
float SBSMSInterfaceSlidingImp :: getPitch(float t)
|
||||||
|
{
|
||||||
|
if(bPitchReferenceInput) return pitchSlide->getRate(t);
|
||||||
|
else return pitchSlide->getRate(min(1.0f,stretchSlide->getStretchedTime(t) / totalStretch));
|
||||||
|
}
|
||||||
|
|
||||||
|
long SBSMSInterfaceSliding :: getPresamples() { return imp->getPresamples(); }
|
||||||
|
long SBSMSInterfaceSlidingImp :: getPresamples()
|
||||||
|
{
|
||||||
|
return preSamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleCountType SBSMSInterfaceSliding :: getSamplesToInput() { return imp->getSamplesToInput(); }
|
||||||
|
SampleCountType SBSMSInterfaceSlidingImp :: getSamplesToInput()
|
||||||
|
{
|
||||||
|
return samplesToInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleCountType SBSMSInterfaceSliding :: getSamplesToOutput() { return imp->getSamplesToOutput(); }
|
||||||
|
SampleCountType SBSMSInterfaceSlidingImp :: getSamplesToOutput()
|
||||||
|
{
|
||||||
|
return samplesToOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
SBSMSInterfaceSliding :: SBSMSInterfaceSliding(Slide *stretchSlide,
|
||||||
|
Slide *pitchSlide,
|
||||||
|
bool bPitchReferenceInput,
|
||||||
|
const SampleCountType &samplesToInput,
|
||||||
|
long preSamples,
|
||||||
|
SBSMSQuality *quality)
|
||||||
|
{
|
||||||
|
imp = new SBSMSInterfaceSlidingImp(stretchSlide, pitchSlide, bPitchReferenceInput,
|
||||||
|
samplesToInput, preSamples, quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
SBSMSInterfaceSliding :: ~SBSMSInterfaceSliding()
|
||||||
|
{
|
||||||
|
delete imp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
lib-src/sbsms/src/sse.h
Normal file
32
lib-src/sbsms/src/sse.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
#ifndef SSE_H
|
||||||
|
#define SSE_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#if defined(ENABLE_SSE) && !defined(APPLE_PPC)
|
||||||
|
|
||||||
|
#include <xmmintrin.h>
|
||||||
|
|
||||||
|
namespace _sbsms_ {
|
||||||
|
|
||||||
|
typedef __m128 simd_vector;
|
||||||
|
#define LOAD(p) _mm_loadu_ps((float*)(p))
|
||||||
|
#define STORE(v,p) _mm_storeu_ps((float*)(p),v)
|
||||||
|
#define LOAD16(p) _mm_load_ps((float*)(p))
|
||||||
|
#define STORE16(v,p) _mm_store_ps((float*)(p),v)
|
||||||
|
#define LOADL(v,p) _mm_loadl_pi(v,(const __m64*)(p))
|
||||||
|
#define LOADH(v,p) _mm_loadh_pi(v,(const __m64*)(p))
|
||||||
|
#define STOREL(v,p) _mm_storel_pi((__m64 *)(p), v)
|
||||||
|
#define STOREH(v,p) _mm_storeh_pi((__m64 *)(p), v)
|
||||||
|
#define VADD(v1,v2) _mm_add_ps(v1,v2)
|
||||||
|
#define VSUB(v1,v2) _mm_sub_ps(v1,v2)
|
||||||
|
#define VMUL(v1,v2) _mm_mul_ps(v1,v2)
|
||||||
|
#define SHUFFLE(a,b,w,x,y,z) _mm_shuffle_ps(a,b,_MM_SHUFFLE(z,y,x,w))
|
||||||
|
#define SET(f) _mm_set1_ps(f)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
1041
lib-src/sbsms/src/synthTable.h
Normal file
1041
lib-src/sbsms/src/synthTable.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,89 +0,0 @@
|
|||||||
#include <math.h>
|
|
||||||
#include "utils.h"
|
|
||||||
#include "real.h"
|
|
||||||
|
|
||||||
namespace _sbsms_ {
|
|
||||||
int COSSIZE;
|
|
||||||
real *COSTABLE = NULL;
|
|
||||||
real COSFACTOR;
|
|
||||||
|
|
||||||
int *factor(int n)
|
|
||||||
{
|
|
||||||
int *f = (int*)calloc(ilog2(n)+1,sizeof(int));
|
|
||||||
factor(n,f,0);
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void factor(int n, int *f, int m)
|
|
||||||
{
|
|
||||||
for(int k=2;k<=n;k++) {
|
|
||||||
if(n%k==0) {
|
|
||||||
f[m++] = k;
|
|
||||||
n /= k;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(n>1)
|
|
||||||
factor(n,f,m);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _evenodd2c(audio *eo, audio *even, audio *odd, int N)
|
|
||||||
{
|
|
||||||
for(int k=0;k<N;k++) {
|
|
||||||
eo[k][0] = (even[k][0] - odd[k][1]);
|
|
||||||
eo[k][1] = (even[k][1] + odd[k][0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _c2evenodd(audio *eo, audio *even, audio *odd, int N)
|
|
||||||
{
|
|
||||||
int Nover2 = N/2;
|
|
||||||
for(int k=0;k<=Nover2;k++) {
|
|
||||||
int fk = (k==0)?0:N-k;
|
|
||||||
|
|
||||||
real eok0 = eo[k][0];
|
|
||||||
real eok1 = eo[k][1];
|
|
||||||
real eofk0 = eo[fk][0];
|
|
||||||
real eofk1 = eo[fk][1];
|
|
||||||
|
|
||||||
even[k][0] = 0.5f*(eok0 + eofk0);
|
|
||||||
even[k][1] = 0.5f*(eok1 - eofk1);
|
|
||||||
|
|
||||||
odd[k][0] = 0.5f*(eok1 + eofk1);
|
|
||||||
odd[k][1] = 0.5f*(-eok0 + eofk0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cosinit(int size) {
|
|
||||||
COSSIZE = size;
|
|
||||||
COSFACTOR = (real)(COSSIZE-1)/PI;
|
|
||||||
if(COSTABLE) free(COSTABLE);
|
|
||||||
COSTABLE = (real*)malloc(size*sizeof(real));
|
|
||||||
for(int k=0;k<size;k++)
|
|
||||||
COSTABLE[k] = cos((real)k/(real)(COSSIZE-1)*PI);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _c2magphase(audio *g, int N)
|
|
||||||
{
|
|
||||||
for(int k=0;k<N;k++) {
|
|
||||||
real mag = norm(g[k]);
|
|
||||||
real phase = atan2(g[k][1],g[k][0]);
|
|
||||||
g[k][0] = mag;
|
|
||||||
g[k][1] = phase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _magphase2c(audio *g, int N)
|
|
||||||
{
|
|
||||||
for(int k=0;k<N;k++) {
|
|
||||||
real mag = g[k][0];
|
|
||||||
real phi = g[k][1];
|
|
||||||
real re = mag * cos(phi);
|
|
||||||
real im = mag * sin(phi);
|
|
||||||
|
|
||||||
g[k][0] = re;
|
|
||||||
g[k][1] = im;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
40
m4/ax_check_compiler_flags.m4
Normal file
40
m4/ax_check_compiler_flags.m4
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
dnl @synopsis AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
|
||||||
|
dnl @summary check whether FLAGS are accepted by the compiler
|
||||||
|
dnl @category Misc
|
||||||
|
dnl
|
||||||
|
dnl Check whether the given compiler FLAGS work with the current language's
|
||||||
|
dnl compiler, or whether they give an error. (Warnings, however, are
|
||||||
|
dnl ignored.)
|
||||||
|
dnl
|
||||||
|
dnl ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||||
|
dnl success/failure.
|
||||||
|
dnl
|
||||||
|
dnl @version 2005-05-30
|
||||||
|
dnl @license GPLWithACException
|
||||||
|
dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Matteo Frigo.
|
||||||
|
AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
|
||||||
|
[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
|
||||||
|
AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
|
||||||
|
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
|
||||||
|
AS_LITERAL_IF([$1],
|
||||||
|
[AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
|
||||||
|
ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
|
||||||
|
_AC_LANG_PREFIX[]FLAGS="$1"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||||
|
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
|
||||||
|
AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
|
||||||
|
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
|
||||||
|
[ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
|
||||||
|
_AC_LANG_PREFIX[]FLAGS="$1"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||||
|
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
|
||||||
|
eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
|
||||||
|
_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
|
||||||
|
eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)
|
||||||
|
AC_MSG_RESULT($ax_check_compiler_flags)
|
||||||
|
if test "x$ax_check_compiler_flags" = xyes; then
|
||||||
|
m4_default([$2], :)
|
||||||
|
else
|
||||||
|
m4_default([$3], :)
|
||||||
|
fi
|
||||||
|
])dnl AX_CHECK_COMPILER_FLAGS
|
30
m4/ax_compiler_vendor.m4
Normal file
30
m4/ax_compiler_vendor.m4
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
dnl @synopsis AX_COMPILER_VENDOR
|
||||||
|
dnl @summary find the vendor (gnu, intel, etc.) of the C/C++ compiler
|
||||||
|
dnl @category C
|
||||||
|
dnl @category C++
|
||||||
|
dnl
|
||||||
|
dnl Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm,
|
||||||
|
dnl sun, hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi,
|
||||||
|
dnl microsoft, watcom, etc. The vendor is returned in the cache variable
|
||||||
|
dnl $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
|
||||||
|
dnl
|
||||||
|
dnl @version 2007-08-01
|
||||||
|
dnl @license GPLWithACException
|
||||||
|
dnl @author Steven G. Johnson <stevenj@alum.mit.edu> with Matteo Frigo
|
||||||
|
|
||||||
|
AC_DEFUN([AX_COMPILER_VENDOR],
|
||||||
|
[
|
||||||
|
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
|
||||||
|
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
|
||||||
|
# note: don't check for gcc first since some other compilers define __GNUC__
|
||||||
|
for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale:__PATHCC__,__PATHSCALE__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
|
||||||
|
vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
|
||||||
|
#if !($vencpp)
|
||||||
|
thisisanerror;
|
||||||
|
#endif
|
||||||
|
])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
|
||||||
|
done
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user