Could someone point me to the BARK/MEL tables that these macros (from vorbis/scales.h) are trying to approximate? #define toBARK(f) (13.1*atan(.00074*(f))+2.24*atan((f)*(f)*1.85e-8)+1e-4*(f)) #define fromBARK(z) (102.*(z)-2.*pow(z,2.)+.4*pow(z,3)+pow(1.46,z)-1.) #define toMEL(f) (log(1.+(f)*.001)*1442.695) #define fromMEL(m) (1000.*exp((m)/1442.695)-1000.) I was wondering if I could come up with different functions that were easier to compute that would still be good approximations (also, can anyone comment on what a good metric is for judging the 'goodness' of an approximation function). Looking at a graph of toBark() in Mathematica over 0-30,000 makes it look like something way simpler than atan could be used (of course, maybe I've implemented toBark incorrectly in Mathematica, which is why I want to look at the original tables :) -tim --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
"Timothy J. Wood" wrote:> > Could someone point me to the BARK/MEL tables that these macros (from vorbis/scales.h) are trying to approximate? > > #define toBARK(f) (13.1*atan(.00074*(f))+2.24*atan((f)*(f)*1.85e-8)+1e-4*(f)) > #define fromBARK(z) (102.*(z)-2.*pow(z,2.)+.4*pow(z,3)+pow(1.46,z)-1.) > #define toMEL(f) (log(1.+(f)*.001)*1442.695) > #define fromMEL(m) (1000.*exp((m)/1442.695)-1000.) > > I was wondering if I could come up with different functions that were easier to compute > that would still be goodNone of these are performance critical (afaik).> approximations (also, can anyone comment on what a good metric is for judging the > 'goodness' of an approximation function).If it still sounds as good for all possible samples, that's good :-)> > Looking at a graph of toBark() in Mathematica over 0-30,000 makes it look like something > way simpler than atan could be > used (of course, maybe I've implemented toBark incorrectly in Mathematica, which is why I > want to look at the original tablesPlease look at it on a log scale (f log, bark linear). It is important to get the curve right in both ends _and_ in the middle. Bark is an important scale; at any given point in time, the human auditory system can only differentiate one sound in a bark-width band. Essentially, a strong sound makes all other sounds in the bark around it unhearable. Something like that. So bark-scale is nice for doing psycho-acoustic calculations. Dagdag, Segher --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
The following is what I came up with for toBARK().  Mathematica kept crashing
when I tried to make it do the curve fitting, so I just used my own least
squares approximation code.  This evaluates quite a bit faster than the atan
version, but as you note, this function really doesn't seem to be
performance critical, so this was more of a fun exercise than anything terribly
useful (at least there are bigger fish to try right now :)
-tim
/*
  This was obtained by doing a least squares polynomial fit of the previous
  approximation expression:
  
  (13.1*atan(.00074*(f))+2.24*atan((f)*(f)*1.85e-8)+1e-4*(f))
  
  300 points were sampled from 0 to 30000 to provide input to the least squares
algorithm.
  
  The polynomial we're using is 7th degree (8 coefficients) of the form:
  
     ax^7+bx^6+...+gx+h
     
  This particular implementation computes the value via this evaluation:
  
    x(x^2(x^2(ax^2+c)+e)+g) + x^2(x^2(bx^2+d)+f)+h
    
  The advantage of doing this is that it allows for twice as good of pipelining
by adding one extra operation (the computation of x^2).  This form is especially
nice on machines with a fused multiply-add (for example, PowerPC).
  
  On a 500Mhz G4 running MacOS X Public Beta, this version runs in about 53.2%
of the time of the atan version.
*/
#if 0
float toBARK(float x)
{
    return (13.1*atan(.00074*x)+2.24*atan(x*x*1.85e-8)+1e-4*x);
}
#else
float toBARK(float x)
{
    float y1, y2, x2;
    const float h = 0.84005793906439973905975193702033720910549163818359375;
    const float g = 0.00882665372976733364485113497721613384783267974853515625;
    const float f =
-1.817725926848741204474961541404098852581228129565715789794921875e-06;
    const float e =
2.146459018942472620933211994968142256878795848251684219576418399810791015625e-10;
    const float d =
-1.45295852112975684808023645992316556435695711069211455424010637216269969940185546875e-14;
    const float c =
5.570810770808117475022948355275769834319660160043921094674690408510286943055689334869384765625e-19;
    const float b =
-1.123223920358406960940846523644387910381077963581645325926274339711774530314869480207562446594238281e-23;
    const float a =
9.24271837728614272911771559202791472363133792494520212846055753734807327410757937791174754238454625e-29;
    
    x2 = x * x;
    
    y2 = x2 * b + d;
    y1 = x2 * a + c;
    y2 = x2 * y2 + f;
    y1 = x2 * y1 + e;
    y2 = x2 * y2 + h;
    y1 = x2 * y1 + g;
    
    y1 = x * y1 + y2;
    
    return y1;
}
#endif
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to
'vorbis-dev-request@xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.