11.07.2014 Views

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX B. PROGRAM LISTINGS 199<br />

double ka = k*a;<br />

complex d;<br />

double modR;<br />

complex Z0 = charZ(c, rho, a), Z;<br />

/* define the end correction for the low frequency limit */<br />

d.Re = 0.8216 * a;<br />

/* determine the frequency-dependent end correction (15a) */<br />

d.Re = d.Re / (1 + pow(0.77 * ka,2) / (1 + 0.77 * ka));<br />

/* determine the modulus <strong>of</strong> the reflection coefficient (15b) */<br />

modR = (1 + 0.323 * ka - 0.077 * pow(ka,2)) / (1 + 0.323 * ka<br />

+ (1 - 0.077) * pow(ka,2));<br />

/* calculate the imaginary part <strong>of</strong> the end correction */<br />

d.Im = log(modR) / (2 * k);<br />

/* calculate the impedance (9) */<br />

Z = multz(j, multz(Z0, tanz(multz(real(k), d))));<br />

return Z;<br />

}<br />

TransferMatrix tubeMatrix(double f, double c, double rho, double L,<br />

double a, double alphacorrection) {<br />

complex Zo, jkL, A, B, C, D;<br />

/* check for zero length segment */<br />

if(L == 0.0)<br />

return identitym();<br />

Zo = charZ(c, rho, a);<br />

jkL = multz(j, multz(waveNum(f, c, a, alphacorrection), real(L)));<br />

A = coshz(jkL);<br />

B = multz(Zo, sinhz(jkL));<br />

C = divz(sinhz(jkL), Zo);<br />

D = A;<br />

return createTransferMatrix(A, B, C, D);;<br />

}<br />

TransferMatrix coneMatrix(double f, double c, double rho, double L,<br />

double a1, double a2, double alphacorrection) {<br />

complex k, kL, kx1, kx2, theta1, theta2, sintheta1, sintheta2;<br />

complex A, B, C, D;<br />

double S1, S2, x1, x2, a;<br />

double rhoc = rho*c;<br />

/* check for zero length segment */<br />

if(L == 0.0)<br />

return identitym();<br />

/* calculate apex distance for both ends <strong>of</strong> conical section<br />

based on similar triangles */<br />

x1 = L/(a2/a1 - 1.0);<br />

x2 = x1 + L;<br />

a2 = a1*(1.0 + L/x1);<br />

/* calculate areas <strong>of</strong> each end based on given radii */<br />

S1 = M_PI*a1*a1;<br />

S2 = M_PI*a2*a2;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!