[music-dsp] Fletcher-Munson loudness curve results
robert bristow-johnson
rbj at audioimagination.com
Tue Mar 15 20:23:36 EST 2005
on 03/15/2005 17:26, david golightly at davigoli at hotmail.com wrote:
>
> C++ implementation of your function, writing the results to a text file:
>
> // fletcherMunsonCalc.cpp
>
> #include <fstream>
> #include <complex>
>
> using namespace std;
>
> const double kA = (6.727242*pow(10.0, 47.0));
> const double TWOPI = 6.283185307179586476925286766559;
> const complex<double> z1(0.0);
> const complex<double> z2(TWOPI*(-0.58), TWOPI*1.03);
> const complex<double> z3(conj(z2));
> const complex<double> z4(TWOPI*(-3.18), TWOPI*8.75);
> const complex<double> z5(conj(z4));
> const complex<double> p1(TWOPI*(-0.18));
> const complex<double> p2(TWOPI*(-1.63));
> const complex<double> p3(TWOPI*(-2.51), TWOPI*3.85);
> const complex<double> p4(conj(p3));
> const complex<double> p5(TWOPI*(-6.62), TWOPI*14.29);
> const complex<double> p6(conj(p5));
const complex<double> j(0.0, 1.0);
inline const double doH(double w)
> {
> return real((kA * pow((s-z1), 3) * (s-z2) * (s-z3) * pow((s-z4), 3) *
> pow((s-z5), 3))/
> (pow((s-p1),3) * pow((s-p2),2) * pow((s-p3),4) * pow((s-p4),4) *
> pow((s-p5),20) * pow((s-p6),20)));
also there is nothing here to make it magnitude nor dB. perhaps this will
work in C++,
complex s = j*w; // however j gets defined
return 20*log10(abs(((kA * pow((s-z1),3) * (s-z2) * (s-z3) *
pow((s-z4),3) * pow((s-z5),3)) / (pow((s-p1),3) * pow((s-p2),2) *
pow((s-p3),4) * pow((s-p4),4) * pow((s-p5),20) * pow((s-p6),20))));
> }
>
> int main()
> {
> ofstream outfile("fletchermunsonvalues.txt");
> if(!outfile) return(1);
> for(double w = 0.01; w <= 20; s *= exp(0.0577624))
> outfile << s << ' ' << doH(s) << '\n';
> return(0);
> }
>
--
r b-j rbj at audioimagination.com
"Imagination is more important than knowledge."
More information about the music-dsp
mailing list