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 254<br />

2.0*((sqrt((y0 + 3.0 - a)/c<br />

+ (b/(2.0*c))*(b/(2.0*c))) - (b/(2.0*c))) - x0);<br />

}<br />

else {<br />

ext->type = MAXIMUM;<br />

/* determine analytical maximum from parabola fit */<br />

x0 = -1.0*(b/(2.0*c));<br />

y0 = a + b*x0 + c*x0*x0;<br />

if(weight) {<br />

/* find frequency <strong>of</strong> absolute maximum in data vector */<br />

maxf = highest(points);<br />

numext = numExtrema(points, MAXIMUM);<br />

/* if only one maximum in set, heavily weight to absolute<br />

maximum */<br />

if(numext == 1) {<br />

ext->f = (x0*maxf)/(0.95*x0 + 0.05*maxf);<br />

}<br />

/* otherwise, moderately weight towards absolute maximum */<br />

else {<br />

ext->f = (x0*maxf)/(0.75*x0 + 0.25*maxf);<br />

}<br />

}<br />

/* if weight is false, use fit to determine f */<br />

else<br />

ext->f = x0;<br />

/* construct maximum<br />

impedance is parabola maximum<br />

b<strong>and</strong>width <strong>and</strong> Q factor is 3dB span <strong>of</strong> parabola */<br />

ext->Z = y0;<br />

ext->B =<br />

2.0*((sqrt((y0 - 3.0 - a)/c<br />

+ (b/(2.0*c))*(b/(2.0*c))) - (b/(2.0*c))) - x0);<br />

}<br />

}<br />

return ext;<br />

int progressPoints(Vector points, Vector allpoints, int index) {<br />

Point p = (Point)malloc(size<strong>of</strong>(*p));<br />

/* read points if data still in file */<br />

if(index < sizeVector(allpoints)) {<br />

*p = *((Point)elementAt(allpoints, index));<br />

/* remove oldest point <strong>and</strong> add newly read point */<br />

popFront(points);<br />

addElement(points, p);<br />

return 1;<br />

}<br />

/* otherwise end <strong>of</strong> data reached */<br />

else<br />

return 0;<br />

}<br />

int numExtrema(Vector points, minmax type) {

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

Saved successfully!

Ooh no, something went wrong!