Add in tree aubio

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-05-01 06:57:49 +01:00
parent 0d952f80af
commit 2ae7009b0e
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
48 changed files with 8937 additions and 1 deletions

262
deps/aubio/src/temporal/a_weighting.c vendored Normal file
View file

@ -0,0 +1,262 @@
/*
Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aubio_priv.h"
#include "types.h"
#include "fvec.h"
#include "lvec.h"
#include "temporal/filter.h"
#include "temporal/a_weighting.h"
uint_t
aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate)
{
uint_t order; lsmp_t *a, *b; lvec_t *as, *bs;
if ((sint_t)samplerate <= 0) {
AUBIO_ERROR("aubio_filter: failed setting A-weighting with samplerate %d\n", samplerate);
return AUBIO_FAIL;
}
if (f == NULL) {
AUBIO_ERROR("aubio_filter: failed setting A-weighting with filter NULL\n");
return AUBIO_FAIL;
}
order = aubio_filter_get_order (f);
if (order != 7) {
AUBIO_ERROR ("aubio_filter: order of A-weighting filter must be 7, not %d\n", order);
return 1;
}
aubio_filter_set_samplerate (f, samplerate);
bs = aubio_filter_get_feedforward (f);
as = aubio_filter_get_feedback (f);
b = bs->data, a = as->data;
/* select coefficients according to sampling frequency */
switch (samplerate) {
case 8000:
b[0] = 6.306209468238731519207362907764036208391189575195312500e-01;
b[1] = -1.261241893647746525886077506584115326404571533203125000e+00;
b[2] = -6.306209468238730408984338282607495784759521484375000000e-01;
b[3] = 2.522483787295493051772155013168230652809143066406250000e+00;
b[4] = -6.306209468238730408984338282607495784759521484375000000e-01;
b[5] = -1.261241893647746525886077506584115326404571533203125000e+00;
b[6] = 6.306209468238731519207362907764036208391189575195312500e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -2.128467193009123015201566886389628052711486816406250000e+00;
a[2] = 2.948668980101234460278192273108288645744323730468750000e-01;
a[3] = 1.824183830735050637628091863007284700870513916015625000e+00;
a[4] = -8.056628943119792385374466903158463537693023681640625000e-01;
a[5] = -3.947497982842933517133587884018197655677795410156250000e-01;
a[6] = 2.098548546080332977137317129745497368276119232177734375e-01;
break;
case 11025:
b[0] = 6.014684165832374640459079273568931967020034790039062500e-01;
b[1] = -1.202936833166475150136420779745094478130340576171875000e+00;
b[2] = -6.014684165832373530236054648412391543388366699218750000e-01;
b[3] = 2.405873666332950300272841559490188956260681152343750000e+00;
b[4] = -6.014684165832373530236054648412391543388366699218750000e-01;
b[5] = -1.202936833166475150136420779745094478130340576171875000e+00;
b[6] = 6.014684165832374640459079273568931967020034790039062500e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -2.463578747722854345170162559952586889266967773437500000e+00;
a[2] = 1.096799662705210121060872552334330976009368896484375000e+00;
a[3] = 1.381222210556041218865175324026495218276977539062500000e+00;
a[4] = -1.013875696476876031582037285261321812868118286132812500e+00;
a[5] = -1.839132734476921215982514468123554252088069915771484375e-01;
a[6] = 1.833526393172056623281918064094497822225093841552734375e-01;
break;
case 16000:
b[0] = 5.314898298235570806014038680586963891983032226562500000e-01;
b[1] = -1.062979659647114161202807736117392778396606445312500000e+00;
b[2] = -5.314898298235570806014038680586963891983032226562500000e-01;
b[3] = 2.125959319294228322405615472234785556793212890625000000e+00;
b[4] = -5.314898298235570806014038680586963891983032226562500000e-01;
b[5] = -1.062979659647114161202807736117392778396606445312500000e+00;
b[6] = 5.314898298235570806014038680586963891983032226562500000e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -2.867832572992162987191022693878039717674255371093750000e+00;
a[2] = 2.221144410202312347024644623161293566226959228515625000e+00;
a[3] = 4.552683347886614662058946123579517006874084472656250000e-01;
a[4] = -9.833868636162828025248927588108927011489868164062500000e-01;
a[5] = 5.592994142413361402521587706360151059925556182861328125e-02;
a[6] = 1.188781038285612462468421313133148942142724990844726562e-01;
break;
case 22050:
b[0] = 4.492998504299193784916610638902056962251663208007812500e-01;
b[1] = -8.985997008598388680056245902960654348134994506835937500e-01;
b[2] = -4.492998504299192674693586013745516538619995117187500000e-01;
b[3] = 1.797199401719677958055854105623438954353332519531250000e+00;
b[4] = -4.492998504299192674693586013745516538619995117187500000e-01;
b[5] = -8.985997008598388680056245902960654348134994506835937500e-01;
b[6] = 4.492998504299193784916610638902056962251663208007812500e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -3.229078805225074955131958631682209670543670654296875000e+00;
a[2] = 3.354494881236033787530459449044428765773773193359375000e+00;
a[3] = -7.317843680657351024265722116979304701089859008789062500e-01;
a[4] = -6.271627581807257545420952737913466989994049072265625000e-01;
a[5] = 1.772142005020879151899748649157118052244186401367187500e-01;
a[6] = 5.631716697383508385410522123493137769401073455810546875e-02;
break;
case 24000:
b[0] = 4.256263892891054001488271296693710610270500183105468750e-01;
b[1] = -8.512527785782106892753517968230880796909332275390625000e-01;
b[2] = -4.256263892891054556599783609271980822086334228515625000e-01;
b[3] = 1.702505557156421378550703593646176159381866455078125000e+00;
b[4] = -4.256263892891054556599783609271980822086334228515625000e-01;
b[5] = -8.512527785782106892753517968230880796909332275390625000e-01;
b[6] = 4.256263892891054001488271296693710610270500183105468750e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -3.325996004241962733516402295208536088466644287109375000e+00;
a[2] = 3.677161079286316969216841243905946612358093261718750000e+00;
a[3] = -1.106476076828482035807610373012721538543701171875000000e+00;
a[4] = -4.726706734908718843257702246773988008499145507812500000e-01;
a[5] = 1.861941760230954034938122276798821985721588134765625000e-01;
a[6] = 4.178771337829546850262119050967157818377017974853515625e-02;
break;
case 32000:
b[0] = 3.434583386824304196416335344110848382115364074707031250e-01;
b[1] = -6.869166773648609503055695313378237187862396240234375000e-01;
b[2] = -3.434583386824303641304823031532578170299530029296875000e-01;
b[3] = 1.373833354729721900611139062675647437572479248046875000e+00;
b[4] = -3.434583386824303641304823031532578170299530029296875000e-01;
b[5] = -6.869166773648609503055695313378237187862396240234375000e-01;
b[6] = 3.434583386824304196416335344110848382115364074707031250e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -3.656446043233668063976438133977353572845458984375000000e+00;
a[2] = 4.831468450652579349480220116674900054931640625000000000e+00;
a[3] = -2.557597496581567764195597192156128585338592529296875000e+00;
a[4] = 2.533680394205302666144064005493419244885444641113281250e-01;
a[5] = 1.224430322452567110325105659285327419638633728027343750e-01;
a[6] = 6.764072168342137418572956875095769646577537059783935547e-03;
break;
case 44100:
b[0] = 2.557411252042575133813784304948057979345321655273437500e-01;
b[1] = -5.114822504085150267627568609896115958690643310546875000e-01;
b[2] = -2.557411252042575133813784304948057979345321655273437500e-01;
b[3] = 1.022964500817030053525513721979223191738128662109375000e+00;
b[4] = -2.557411252042575133813784304948057979345321655273437500e-01;
b[5] = -5.114822504085150267627568609896115958690643310546875000e-01;
b[6] = 2.557411252042575133813784304948057979345321655273437500e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -4.019576181115832369528106937650591135025024414062500000e+00;
a[2] = 6.189406442920693862674852425698190927505493164062500000e+00;
a[3] = -4.453198903544116404873420833609998226165771484375000000e+00;
a[4] = 1.420842949621876627475103305187076330184936523437500000e+00;
a[5] = -1.418254738303044160119270600262098014354705810546875000e-01;
a[6] = 4.351177233495117681327801761881346465088427066802978516e-03;
break;
case 48000:
b[0] = 2.343017922995132285013397677175817079842090606689453125e-01;
b[1] = -4.686035845990265125138307666929904371500015258789062500e-01;
b[2] = -2.343017922995132007457641520886681973934173583984375000e-01;
b[3] = 9.372071691980530250276615333859808743000030517578125000e-01;
b[4] = -2.343017922995132007457641520886681973934173583984375000e-01;
b[5] = -4.686035845990265125138307666929904371500015258789062500e-01;
b[6] = 2.343017922995132285013397677175817079842090606689453125e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -4.113043408775872045168853219365701079368591308593750000e+00;
a[2] = 6.553121752655050258340452273841947317123413085937500000e+00;
a[3] = -4.990849294163385074796224216697737574577331542968750000e+00;
a[4] = 1.785737302937575599059982778271660208702087402343750000e+00;
a[5] = -2.461905953194876706113802811159985139966011047363281250e-01;
a[6] = 1.122425003323123879339640041052916785702109336853027344e-02;
break;
case 88200:
b[0] = 1.118876366882113199130444058937428053468465805053710938e-01;
b[1] = -2.237752733764226120705131961585721001029014587402343750e-01;
b[2] = -1.118876366882113337908322137081995606422424316406250000e-01;
b[3] = 4.475505467528452241410263923171442002058029174804687500e-01;
b[4] = -1.118876366882113337908322137081995606422424316406250000e-01;
b[5] = -2.237752733764226120705131961585721001029014587402343750e-01;
b[6] = 1.118876366882113199130444058937428053468465805053710938e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -4.726938565651158441482948546763509511947631835937500000e+00;
a[2] = 9.076897983832765248735086061060428619384765625000000000e+00;
a[3] = -9.014855113464800950850985827855765819549560546875000000e+00;
a[4] = 4.852772261031594425162438710685819387435913085937500000e+00;
a[5] = -1.333877820398965186043938047077972441911697387695312500e+00;
a[6] = 1.460012549591642450064199465487035922706127166748046875e-01;
break;
case 96000:
b[0] = 9.951898975972744976203898659150581806898117065429687500e-02;
b[1] = -1.990379795194548995240779731830116361379623413085937500e-01;
b[2] = -9.951898975972744976203898659150581806898117065429687500e-02;
b[3] = 3.980759590389097990481559463660232722759246826171875000e-01;
b[4] = -9.951898975972744976203898659150581806898117065429687500e-02;
b[5] = -1.990379795194548995240779731830116361379623413085937500e-01;
b[6] = 9.951898975972744976203898659150581806898117065429687500e-02;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -4.802203044225376693532325589330866932868957519531250000e+00;
a[2] = 9.401807218627226347962277941405773162841796875000000000e+00;
a[3] = -9.566143943569164420637207513209432363510131835937500000e+00;
a[4] = 5.309775930392619081032989925006404519081115722656250000e+00;
a[5] = -1.517333360452622237346531619550660252571105957031250000e+00;
a[6] = 1.740971994228911745583587844521389342844486236572265625e-01;
break;
case 192000:
b[0] = 3.433213424548713782469278044118254911154508590698242188e-02;
b[1] = -6.866426849097426177159775306790834292769432067871093750e-02;
b[2] = -3.433213424548714476358668434841092675924301147460937500e-02;
b[3] = 1.373285369819485235431955061358166858553886413574218750e-01;
b[4] = -3.433213424548714476358668434841092675924301147460937500e-02;
b[5] = -6.866426849097426177159775306790834292769432067871093750e-02;
b[6] = 3.433213424548713782469278044118254911154508590698242188e-02;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -5.305923689674640009172890131594613194465637207031250000e+00;
a[2] = 1.165952437466175695135461864992976188659667968750000000e+01;
a[3] = -1.357560092700591525272102444432675838470458984375000000e+01;
a[4] = 8.828906932824192921316353022120893001556396484375000000e+00;
a[5] = -3.039490120988216581565666274400427937507629394531250000e+00;
a[6] = 4.325834301870381537469256727490574121475219726562500000e-01;
break;
default:
AUBIO_ERROR ("sampling rate of A-weighting filter is %d, should be one of\
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, 192000.\n", samplerate);
return 1;
}
return 0;
}
aubio_filter_t *
new_aubio_filter_a_weighting (uint_t samplerate)
{
aubio_filter_t *f = new_aubio_filter (7);
if (aubio_filter_set_a_weighting(f,samplerate) != AUBIO_OK) {
del_aubio_filter(f);
return NULL;
}
return f;
}

88
deps/aubio/src/temporal/a_weighting.h vendored Normal file
View file

@ -0,0 +1,88 @@
/*
Copyright (C) 2003-2015 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUBIO_FILTER_A_DESIGN_H
#define AUBIO_FILTER_A_DESIGN_H
/** \file
A-weighting filter coefficients
This file creates an A-weighting digital filter, which reduces low and high
frequencies and enhance the middle ones to reflect the ability of the human
hearing.
The implementation is based on the following standard:
- IEC/CD 1672: Electroacoustics-Sound Level Meters, IEC, Geneva, Nov. 1996,
for A- and C-weighting filters.
See also:
- <a href="http://en.wikipedia.org/wiki/A-weighting">A-Weighting on
Wikipedia</a>
- <a href="http://en.wikipedia.org/wiki/Weighting_filter">Weighting filter on
Wikipedia</a>
- <a href="http://www.mathworks.com/matlabcentral/fileexchange/69">Christophe
Couvreur's 'octave' toolbox</a>
The coefficients in this file have been computed using Christophe Couvreur's
scripts in octave 3.0 (debian package 1:3.0.5-6+b2 with octave-signal
1.0.9-1+b1 on i386), with <pre> [b, a] = adsign(1/Fs) </pre> for various
sampling frequencies (8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000,
88200, 96000, and 192000 Hz).
The sampling frequency should normally be higher than 20kHz, but most common
file sampling rates have been included for completeness.
\example temporal/test-a_weighting.c
*/
#ifdef __cplusplus
extern "C" {
#endif
/** create new A-design filter
\param samplerate sampling frequency of the signal to filter. Should be one of
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
192000 Hz
\return a new filter object
*/
aubio_filter_t *new_aubio_filter_a_weighting (uint_t samplerate);
/** set feedback and feedforward coefficients of a A-weighting filter
\param f filter object to get coefficients from
\param samplerate sampling frequency of the signal to filter. Should be one of
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
192000 Hz
*/
uint_t aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate);
#ifdef __cplusplus
}
#endif
#endif /* AUBIO_FILTER_A_DESIGN_H */

54
deps/aubio/src/temporal/biquad.c vendored Normal file
View file

@ -0,0 +1,54 @@
/*
Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aubio_priv.h"
#include "fvec.h"
#include "lvec.h"
#include "temporal/filter.h"
#include "temporal/biquad.h"
uint_t
aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1, lsmp_t b2,
lsmp_t a1, lsmp_t a2)
{
uint_t order = aubio_filter_get_order (f);
lvec_t *bs = aubio_filter_get_feedforward (f);
lvec_t *as = aubio_filter_get_feedback (f);
if (order != 3) {
AUBIO_ERROR ("order of biquad filter must be 3, not %d\n", order);
return AUBIO_FAIL;
}
bs->data[0] = b0;
bs->data[1] = b1;
bs->data[2] = b2;
as->data[0] = 1.;
as->data[1] = a1;
as->data[2] = a2;
return AUBIO_OK;
}
aubio_filter_t *
new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2)
{
aubio_filter_t *f = new_aubio_filter (3);
aubio_filter_set_biquad (f, b0, b1, b2, a1, a2);
return f;
}

75
deps/aubio/src/temporal/biquad.h vendored Normal file
View file

@ -0,0 +1,75 @@
/*
Copyright (C) 2003-2015 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUBIO_FILTER_BIQUAD_H
#define AUBIO_FILTER_BIQUAD_H
/** \file
Second order Infinite Impulse Response filter
This file implements a normalised biquad filter (second order IIR):
\f$ y[n] = b_0 x[n] + b_1 x[n-1] + b_2 x[n-2] - a_1 y[n-1] - a_2 y[n-2] \f$
The filtfilt version runs the filter twice, forward and backward, to
compensate the phase shifting of the forward operation.
See also <a href="http://en.wikipedia.org/wiki/Digital_biquad_filter">Digital
biquad filter</a> on wikipedia.
\example temporal/test-biquad.c
*/
#ifdef __cplusplus
extern "C" {
#endif
/** set coefficients of a biquad filter
\param f filter object as returned by new_aubio_filter()
\param b0 forward filter coefficient
\param b1 forward filter coefficient
\param b2 forward filter coefficient
\param a1 feedback filter coefficient
\param a2 feedback filter coefficient
*/
uint_t aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1,
lsmp_t b2, lsmp_t a1, lsmp_t a2);
/** create biquad filter with `b0`, `b1`, `b2`, `a1`, `a2` coeffs
\param b0 forward filter coefficient
\param b1 forward filter coefficient
\param b2 forward filter coefficient
\param a1 feedback filter coefficient
\param a2 feedback filter coefficient
*/
aubio_filter_t *new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2,
lsmp_t a1, lsmp_t a2);
#ifdef __cplusplus
}
#endif
#endif /* AUBIO_FILTER_BIQUAD_H */

217
deps/aubio/src/temporal/c_weighting.c vendored Normal file
View file

@ -0,0 +1,217 @@
/*
Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aubio_priv.h"
#include "types.h"
#include "fvec.h"
#include "lvec.h"
#include "temporal/filter.h"
#include "temporal/c_weighting.h"
uint_t
aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate)
{
uint_t order; lsmp_t *a, *b; lvec_t *as, *bs;
if ((sint_t)samplerate <= 0) {
AUBIO_ERROR("aubio_filter: failed setting C-weighting with samplerate %d\n", samplerate);
return AUBIO_FAIL;
}
if (f == NULL) {
AUBIO_ERROR("aubio_filter: failed setting C-weighting with filter NULL\n");
return AUBIO_FAIL;
}
order = aubio_filter_get_order (f);
if ( order != 5 ) {
AUBIO_ERROR ("aubio_filter: order of C-weighting filter must be 5, not %d\n", order);
return 1;
}
aubio_filter_set_samplerate (f, samplerate);
bs = aubio_filter_get_feedforward (f);
as = aubio_filter_get_feedback (f);
b = bs->data, a = as->data;
/* select coefficients according to sampling frequency */
switch (samplerate) {
case 8000:
b[0] = 6.782173932405135552414776611840352416038513183593750000e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -1.356434786481027110482955322368070483207702636718750000e+00;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 6.782173932405135552414776611840352416038513183593750000e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -6.589092811505605773447769024642184376716613769531250000e-01;
a[2] = -1.179445664897062595599663836765103042125701904296875000e+00;
a[3] = 4.243329729632123736848825501510873436927795410156250000e-01;
a[4] = 4.147270002091348328754349950031610205769538879394531250e-01;
break;
case 11025:
b[0] = 6.002357155402652244546857218665536493062973022460937500e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -1.200471431080530448909371443733107298612594604492187500e+00;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 6.002357155402652244546857218665536493062973022460937500e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -8.705602141280316397242700077185872942209243774414062500e-01;
a[2] = -9.037199507150940336330791069485712796449661254882812500e-01;
a[3] = 4.758433040929530011275971901341108605265617370605468750e-01;
a[4] = 2.987653956523212417373258631414500996470451354980468750e-01;
break;
case 16000:
b[0] = 4.971057193673903418229542694461997598409652709960937500e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -9.942114387347806836459085388923995196819305419921875000e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 4.971057193673903418229542694461997598409652709960937500e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -1.162322939286873690889478893950581550598144531250000000e+00;
a[2] = -4.771961355734982701548574368644040077924728393554687500e-01;
a[3] = 4.736145114694704227886745684372726827859878540039062500e-01;
a[4] = 1.660337524309875301131711466950946487486362457275390625e-01;
break;
case 22050:
b[0] = 4.033381299002754549754001800465630367398262023925781250e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -8.066762598005509099508003600931260734796524047851562500e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 4.033381299002754549754001800465630367398262023925781250e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -1.449545371157945350404361306573264300823211669921875000e+00;
a[2] = -1.030104190885922088583015465701464563608169555664062500e-02;
a[3] = 3.881857047554073680828423675848171114921569824218750000e-01;
a[4] = 7.171589940116777917022972133054281584918498992919921875e-02;
break;
case 24000:
b[0] = 3.786678621924967069745093795063439756631851196289062500e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -7.573357243849934139490187590126879513263702392578125000e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 3.786678621924967069745093795063439756631851196289062500e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -1.529945307555420797029910318087786436080932617187500000e+00;
a[2] = 1.283553182116208835061854642844991758465766906738281250e-01;
a[3] = 3.494608072385725350272878131363540887832641601562500000e-01;
a[4] = 5.217291949300089520802359288609295617789030075073242188e-02;
break;
case 32000:
b[0] = 2.977986488230693340462096330156782642006874084472656250e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -5.955972976461386680924192660313565284013748168945312500e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 2.977986488230693340462096330156782642006874084472656250e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -1.812455387128179218336754274787381291389465332031250000e+00;
a[2] = 6.425013281155662614452239722595550119876861572265625000e-01;
a[3] = 1.619857574578579817448087396769551560282707214355468750e-01;
a[4] = 7.987649713547682189807019881300220731645822525024414062e-03;
break;
case 44100:
b[0] = 2.170085619492190254220531642204150557518005371093750000e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -4.340171238984380508441063284408301115036010742187500000e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 2.170085619492190254220531642204150557518005371093750000e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -2.134674963687040794013682898366823792457580566406250000e+00;
a[2] = 1.279333533236062692139967111870646476745605468750000000e+00;
a[3] = -1.495598460893957093453821016737492755055427551269531250e-01;
a[4] = 4.908700174624683852664386307651511742733418941497802734e-03;
break;
case 48000:
b[0] = 1.978871200263932761398422144338837824761867523193359375e-01;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -3.957742400527865522796844288677675649523735046386718750e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 1.978871200263932761398422144338837824761867523193359375e-01;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -2.219172914052801814932536217384040355682373046875000000e+00;
a[2] = 1.455135878947171557129536267893854528665542602539062500e+00;
a[3] = -2.484960738877830532800317087094299495220184326171875000e-01;
a[4] = 1.253882314727246607977129144728678511455655097961425781e-02;
break;
case 88200:
b[0] = 9.221909851156021020734954163344809785485267639160156250e-02;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -1.844381970231204204146990832668961957097053527832031250e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 9.221909851156021020734954163344809785485267639160156250e-02;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -2.785795902923448696952846148633398115634918212890625000e+00;
a[2] = 2.727736758747444145711824603495188057422637939453125000e+00;
a[3] = -1.097007502819661528548067508381791412830352783203125000e+00;
a[4] = 1.550674356752141103132913713125162757933139801025390625e-01;
break;
case 96000:
b[0] = 8.182864044979756834585771230194950476288795471191406250e-02;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -1.636572808995951366917154246038990095257759094238281250e-01;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 8.182864044979756834585771230194950476288795471191406250e-02;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -2.856378516857566829401093855267390608787536621093750000e+00;
a[2] = 2.897640237559524045707348705036565661430358886718750000e+00;
a[3] = -1.225265958339703198376469117647502571344375610351562500e+00;
a[4] = 1.840048283551226071530493300087982788681983947753906250e-01;
break;
case 192000:
b[0] = 2.784755468532278815940728122768632601946592330932617188e-02;
b[1] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[2] = -5.569510937064557631881456245537265203893184661865234375e-02;
b[3] = 0.000000000000000000000000000000000000000000000000000000e+00;
b[4] = 2.784755468532278815940728122768632601946592330932617188e-02;
a[0] = 1.000000000000000000000000000000000000000000000000000000e+00;
a[1] = -3.333298856144166322224009491037577390670776367187500000e+00;
a[2] = 4.111467536240339448738723149290308356285095214843750000e+00;
a[3] = -2.222889041651291641699117462849244475364685058593750000e+00;
a[4] = 4.447204118126878991112960193277103826403617858886718750e-01;
break;
default:
AUBIO_ERROR ( "sampling rate of C-weighting filter is %d, should be one of\
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, 192000.\n",
samplerate );
return 1;
}
return 0;
}
aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate) {
aubio_filter_t * f = new_aubio_filter(5);
if (aubio_filter_set_c_weighting(f,samplerate) != AUBIO_OK) {
del_aubio_filter(f);
return NULL;
}
return f;
}

88
deps/aubio/src/temporal/c_weighting.h vendored Normal file
View file

@ -0,0 +1,88 @@
/*
Copyright (C) 2003-2015 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUBIO_FILTER_C_DESIGN_H
#define AUBIO_FILTER_C_DESIGN_H
/** \file
C-weighting filter coefficients
This file creates a C-weighting digital filter, which reduces low and high
frequencies and enhance the middle ones to reflect the ability of the human
hearing.
The implementation is based on the following standard:
- IEC/CD 1672: Electroacoustics-Sound Level Meters, IEC, Geneva, Nov. 1996,
for A- and C-weighting filters.
See also:
- <a href="http://en.wikipedia.org/wiki/A-weighting">A-Weighting on
Wikipedia</a>
- <a href="http://en.wikipedia.org/wiki/Weighting_filter">Weighting filter on
Wikipedia</a>
- <a href="http://www.mathworks.com/matlabcentral/fileexchange/69">Christophe
Couvreur's 'octave' toolbox</a>
The coefficients in this file have been computed using Christophe Couvreur's
scripts in octave 3.0 (debian package 1:3.0.5-6+b2 with octave-signal
1.0.9-1+b1 on i386), with <pre> [b, a] = cdsign(1/Fs) </pre> for various
sampling frequencies (8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000,
88200, 96000, and 192000 Hz).
The sampling frequency should normally be higher than 20kHz, but most common
file sampling rates have been included for completeness.
\example temporal/test-c_weighting.c
*/
#ifdef __cplusplus
extern "C" {
#endif
/** create new C-design filter
\param samplerate sampling frequency of the signal to filter. Should be one of
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
192000 Hz
\return a new filter object
*/
aubio_filter_t *new_aubio_filter_c_weighting (uint_t samplerate);
/** set feedback and feedforward coefficients of a C-weighting filter
\param f filter object to get coefficients from
\param samplerate sampling frequency of the signal to filter. Should be one of
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and
192000 Hz
*/
uint_t aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate);
#ifdef __cplusplus
}
#endif
#endif /* AUBIO_FILTER_C_DESIGN_H */

163
deps/aubio/src/temporal/filter.c vendored Normal file
View file

@ -0,0 +1,163 @@
/*
Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
/* Requires lsmp_t to be long or double. float will NOT give reliable
* results */
#include "aubio_priv.h"
#include "fvec.h"
#include "lvec.h"
#include "mathutils.h"
#include "temporal/filter.h"
struct _aubio_filter_t
{
uint_t order;
uint_t samplerate;
lvec_t *a;
lvec_t *b;
lvec_t *y;
lvec_t *x;
};
void
aubio_filter_do_outplace (aubio_filter_t * f, const fvec_t * in, fvec_t * out)
{
fvec_copy (in, out);
aubio_filter_do (f, out);
}
void
aubio_filter_do (aubio_filter_t * f, fvec_t * in)
{
uint_t j, l, order = f->order;
lsmp_t *x = f->x->data;
lsmp_t *y = f->y->data;
lsmp_t *a = f->a->data;
lsmp_t *b = f->b->data;
for (j = 0; j < in->length; j++) {
/* new input */
x[0] = KILL_DENORMAL (in->data[j]);
y[0] = b[0] * x[0];
for (l = 1; l < order; l++) {
y[0] += b[l] * x[l];
y[0] -= a[l] * y[l];
}
/* new output */
in->data[j] = y[0];
/* store for next sample */
for (l = order - 1; l > 0; l--) {
x[l] = x[l - 1];
y[l] = y[l - 1];
}
}
}
/* The rough way: reset memory of filter between each run to avoid end effects. */
void
aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp)
{
uint_t j;
uint_t length = in->length;
/* apply filtering */
aubio_filter_do (f, in);
aubio_filter_do_reset (f);
/* mirror */
for (j = 0; j < length; j++)
tmp->data[length - j - 1] = in->data[j];
/* apply filtering on mirrored */
aubio_filter_do (f, tmp);
aubio_filter_do_reset (f);
/* invert back */
for (j = 0; j < length; j++)
in->data[j] = tmp->data[length - j - 1];
}
lvec_t *
aubio_filter_get_feedback (const aubio_filter_t * f)
{
return f->a;
}
lvec_t *
aubio_filter_get_feedforward (const aubio_filter_t * f)
{
return f->b;
}
uint_t
aubio_filter_get_order (const aubio_filter_t * f)
{
return f->order;
}
uint_t
aubio_filter_get_samplerate (const aubio_filter_t * f)
{
return f->samplerate;
}
uint_t
aubio_filter_set_samplerate (aubio_filter_t * f, uint_t samplerate)
{
f->samplerate = samplerate;
return AUBIO_OK;
}
void
aubio_filter_do_reset (aubio_filter_t * f)
{
lvec_zeros (f->x);
lvec_zeros (f->y);
}
aubio_filter_t *
new_aubio_filter (uint_t order)
{
aubio_filter_t *f = AUBIO_NEW (aubio_filter_t);
if ((sint_t)order < 1) {
AUBIO_FREE(f);
return NULL;
}
f->x = new_lvec (order);
f->y = new_lvec (order);
f->a = new_lvec (order);
f->b = new_lvec (order);
/* by default, samplerate is not set */
f->samplerate = 0;
f->order = order;
/* set default to identity */
f->a->data[0] = 1.;
f->b->data[0] = 1.;
return f;
}
void
del_aubio_filter (aubio_filter_t * f)
{
del_lvec (f->a);
del_lvec (f->b);
del_lvec (f->x);
del_lvec (f->y);
AUBIO_FREE (f);
return;
}

176
deps/aubio/src/temporal/filter.h vendored Normal file
View file

@ -0,0 +1,176 @@
/*
Copyright (C) 2003-2015 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUBIO_FILTER_H
#define AUBIO_FILTER_H
/** \file
Digital filter
This object stores a digital filter of order \f$n\f$.
It contains the following data:
- \f$ n*1 b_i \f$ feedforward coefficients
- \f$ n*1 a_i \f$ feedback coefficients
- \f$ n*c x_i \f$ input signal
- \f$ n*c y_i \f$ output signal
For convenience, the samplerate of the input signal is also stored in the
object.
Feedforward and feedback parameters can be modified using
aubio_filter_get_feedback() and aubio_filter_get_feedforward().
The function aubio_filter_do_outplace() computes the following output signal
\f$ y[n] \f$ from the input signal \f$ x[n] \f$:
\f{eqnarray*}{
y[n] = b_0 x[n] & + & b_1 x[n-1] + b_2 x[n-2] + ... + b_P x[n-P] \\
& - & a_1 y[n-1] - a_2 y[n-2] - ... - a_P y[n-P] \\
\f}
The function aubio_filter_do() executes the same computation but modifies
directly the input signal (in-place).
The function aubio_filter_do_filtfilt() version runs the filter twice, first
forward then backward, to compensate with the phase shifting of the forward
operation.
Some convenience functions are provided:
- new_aubio_filter_a_weighting() and aubio_filter_set_a_weighting(),
- new_aubio_filter_c_weighting() and aubio_filter_set_c_weighting().
- new_aubio_filter_biquad() and aubio_filter_set_biquad().
\example temporal/test-filter.c
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Digital filter
*/
typedef struct _aubio_filter_t aubio_filter_t;
/** filter input vector (in-place)
\param f filter object as returned by new_aubio_filter()
\param in input vector to filter
*/
void aubio_filter_do (aubio_filter_t * f, fvec_t * in);
/** filter input vector (out-of-place)
\param f filter object as returned by new_aubio_filter()
\param in input vector to filter
\param out output vector to store filtered input
*/
void aubio_filter_do_outplace (aubio_filter_t * f, const fvec_t * in, fvec_t * out);
/** filter input vector forward and backward
\param f ::aubio_filter_t object as returned by new_aubio_filter()
\param in ::fvec_t input vector to filter
\param tmp memory space to use for computation
*/
void aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp);
/** returns a pointer to feedback coefficients \f$ a_i \f$
\param f filter object to get parameters from
\return a pointer to the \f$ a_0 ... a_i ... a_P \f$ coefficients
*/
lvec_t *aubio_filter_get_feedback (const aubio_filter_t * f);
/** returns a pointer to feedforward coefficients \f$ b_i \f$
\param f filter object to get coefficients from
\return a pointer to the \f$ b_0 ... b_i ... b_P \f$ coefficients
*/
lvec_t *aubio_filter_get_feedforward (const aubio_filter_t * f);
/** get order of the filter
\param f filter to get order from
\return the order of the filter
*/
uint_t aubio_filter_get_order (const aubio_filter_t * f);
/** get sampling rate of the filter
\param f filter to get sampling rate from
\return the sampling rate of the filter, in Hz
*/
uint_t aubio_filter_get_samplerate (const aubio_filter_t * f);
/** get sampling rate of the filter
\param f filter to get sampling rate from
\param samplerate sample rate to set the filter to
\return the sampling rate of the filter, in Hz
*/
uint_t aubio_filter_set_samplerate (aubio_filter_t * f, uint_t samplerate);
/** reset filter memory
\param f filter object as returned by new_aubio_filter()
*/
void aubio_filter_do_reset (aubio_filter_t * f);
/** create new filter object
This function creates a new ::aubio_filter_t object, given the order of the
filter.
\param order order of the filter (number of coefficients)
\return the newly created filter object
*/
aubio_filter_t *new_aubio_filter (uint_t order);
/** delete a filter object
\param f filter object to delete
*/
void del_aubio_filter (aubio_filter_t * f);
#ifdef __cplusplus
}
#endif
#endif /* AUBIO_FILTER_H */

100
deps/aubio/src/temporal/resampler.c vendored Normal file
View file

@ -0,0 +1,100 @@
/*
Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aubio_priv.h"
#include "fvec.h"
#include "temporal/resampler.h"
#ifdef HAVE_SAMPLERATE
#if HAVE_AUBIO_DOUBLE
#error "Should not use libsamplerate with aubio in double precision"
#endif
#include <samplerate.h> /* from libsamplerate */
struct _aubio_resampler_t
{
SRC_DATA *proc;
SRC_STATE *stat;
smpl_t ratio;
uint_t type;
};
aubio_resampler_t *
new_aubio_resampler (smpl_t ratio, uint_t type)
{
aubio_resampler_t *s = AUBIO_NEW (aubio_resampler_t);
int error = 0;
s->stat = src_new (type, 1, &error); /* only one channel */
if (error) {
AUBIO_ERR ("Failed creating resampler: %s\n", src_strerror (error));
del_aubio_resampler(s);
return NULL;
}
s->proc = AUBIO_NEW (SRC_DATA);
s->ratio = ratio;
return s;
}
void
del_aubio_resampler (aubio_resampler_t * s)
{
if (s->stat) src_delete (s->stat);
AUBIO_FREE (s->proc);
AUBIO_FREE (s);
}
void
aubio_resampler_do (aubio_resampler_t * s, const fvec_t * input, fvec_t * output)
{
s->proc->input_frames = input->length;
s->proc->output_frames = output->length;
s->proc->src_ratio = (double) s->ratio;
/* make SRC_PROC data point to input outputs */
s->proc->data_in = (float *) input->data;
s->proc->data_out = (float *) output->data;
/* do resampling */
src_process (s->stat, s->proc);
}
#else
struct _aubio_resampler_t
{
void *dummy;
};
aubio_resampler_t *
new_aubio_resampler (smpl_t ratio UNUSED, uint_t type UNUSED)
{
AUBIO_ERR ("aubio was not compiled with libsamplerate\n");
return NULL;
}
void
del_aubio_resampler (aubio_resampler_t * s UNUSED)
{
}
void
aubio_resampler_do (aubio_resampler_t * s UNUSED, const fvec_t * input UNUSED, fvec_t * output UNUSED)
{
}
#endif /* HAVE_SAMPLERATE */

65
deps/aubio/src/temporal/resampler.h vendored Normal file
View file

@ -0,0 +1,65 @@
/*
Copyright (C) 2003-2015 Paul Brossier <piem@aubio.org>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with aubio. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUBIO_RESAMPLER_H
#define AUBIO_RESAMPLER_H
/** \file
Resampling object
This object resamples an input vector into an output vector using
libsamplerate. See http://www.mega-nerd.com/SRC/
*/
#ifdef __cplusplus
extern "C" {
#endif
/** resampler object */
typedef struct _aubio_resampler_t aubio_resampler_t;
/** create resampler object
\param ratio output_sample_rate / input_sample_rate
\param type libsamplerate resampling type, see http://www.mega-nerd.com/SRC/api_misc.html#Converters
*/
aubio_resampler_t *new_aubio_resampler (smpl_t ratio, uint_t type);
/** delete resampler object */
void del_aubio_resampler (aubio_resampler_t * s);
/** resample input in output
\param s resampler object
\param input input buffer of size N
\param output output buffer of size N*ratio
*/
void aubio_resampler_do (aubio_resampler_t * s, const fvec_t * input,
fvec_t * output);
#ifdef __cplusplus
}
#endif
#endif /* AUBIO_RESAMPLER_H */