I am trying to incorporate a natural log function into a mel calculation I am writing. I was wondering if anybody knows if there is a built in function for this or have written one they are willing to share.
Any help is much appreciated.
I've written a routine for calculating the natural log in the distant past. Alas, can't find it as it is embedded in some long forgotten form. The important point from a MEL standpoint, is that powers can be calculated . I calculated the natural log using the Taylor expansion, you can find the details in the Wikipedia section on logarithms. For any real number z that satisfies 0<z<2, the following holds:
ln(z)=((z-1)^1)/1-((z-1)^2)/2+((z-1)^3)/3 -....+...-...+...
You will need to normalize z to satisfy the limits 0<z<2. If you do this by using powers of e, it becomes a simple calculation. If you normalize by powers of 10, then a table could give you the values.
The function rapidly converges and you can check the accuracy as you expand. Good luck.
Believe this may be the function:
{!fn ln(value) {
/* Natural log function */
local a,b,c,d,f,t
a = (value-1)/value
d = a
b = a
f = value*10
for t = 2, t < f, t = t + 1 do
b = b * a
c = (1/t) * b
d = d + c
endfor
return d}
}