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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

APPENDIX B. PROGRAM LISTINGS 321<br />

double rho = head->embouchureHole->rho;<br />

double entryradius = WW_EMB_RADIUS;<br />

double corr = 2.9370 * log(midi) - 11.6284;<br />

return multz(flangedZ(f, c, rho, entryradius), real(corr));<br />

}<br />

TransferMatrix unitCellMatrix(double f, UnitCell c, double x) {<br />

TransferMatrix m;<br />

Map map = (strcmp(c->hole->fingering, "OPEN") == 0) ?<br />

c->openMatrixMap :<br />

c->closedMatrixMap;<br />

if((x >= boreLength(c->bore)) && containsKey(map, f))<br />

m = (TransferMatrix)get(map, f);<br />

else {<br />

m = traverseHoleMatrix(f, c->hole);<br />

if((x > 0) && (c->bore != NULL))<br />

rmultm(m, boreMatrix(f, c->bore, x));<br />

if (x >= boreLength(c->bore)) {<br />

clear(map);<br />

put(map, f, m);<br />

}<br />

}<br />

return m;<br />

}<br />

TransferMatrix woodwindMatrix(double f, Woodwind w, double entryratio,<br />

double x) {<br />

TransferMatrix m = identitym();<br />

Head h;<br />

complex branchZ;<br />

UnitCell cell;<br />

int cellCount = 0;<br />

if (x >= 0) {<br />

rmultm(m, headMatrix(f, w->head, entryratio, x));<br />

x -= boreLength(w->head->downstreamBore);<br />

while (x > 0 && cellCount < sizeVector(w->cells)) {<br />

cell = (UnitCell)elementAt(w->cells, cellCount);<br />

rmultm(m, unitCellMatrix(f, cell, x));<br />

x -= boreLength(cell->bore);<br />

cellCount++;<br />

}<br />

}<br />

else {<br />

h = w->head;<br />

if (h->embouchureHole != NULL) {<br />

branchZ = woodwindDownstreamZ(f, w);<br />

rmultm(m, embouchureMatrix(f, h->embouchureHole, entryratio,<br />

branchZ));<br />

}<br />

rmultm(m, boreMatrix(f, h->upstreamBore, -x));<br />

}<br />

return m;<br />

}<br />

int getZ0_c(Woodwind w, double x, complex* Z0, double* c) {<br />

Vector bore;

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

Saved successfully!

Ooh no, something went wrong!