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

m->R_min_df = searche->f - e->f;<br />

m->R_min_dZ = searche->Z - e->Z;<br />

break;<br />

}<br />

}<br />

/* if none found, set to nan */<br />

if(j >= sizeVector(extv)) {<br />

m->R_min_df = invalidNum();<br />

m->R_min_dZ = invalidNum();<br />

}<br />

/* add minimum to minimum vector */<br />

addElement(minv, m);<br />

}<br />

}<br />

/* set the harmonic details <strong>of</strong> all minima in vector */<br />

harmonicity(minv);<br />

}<br />

return minv;<br />

Vector extrema(Vector allpoints) {<br />

int i, j;<br />

int seq_inc, seq_dec;<br />

int descent, ascent;<br />

Extremum e;<br />

Point p;<br />

Vector extv = createVector();<br />

Vector points = createVector();<br />

/* load vector <strong>of</strong> points with the initial portion <strong>of</strong> data.<br />

All points are equal to the first point in the data. */<br />

for(i = 0; i < NUM_POINTS; i++) {<br />

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

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

addElement(points, p);<br />

}<br />

/* initialise flags */<br />

seq_inc = 0;<br />

seq_dec = 0;<br />

descent = 0;<br />

ascent = 0;<br />

/* progress points one at a time till end <strong>of</strong> data set */<br />

for(i = 0; progressPoints(points, allpoints, i); i++) {<br />

/* if graph increases... */<br />

if(((Point)elementAt(points, sizeVector(points) - 1))->y<br />

> ((Point)elementAt(points, sizeVector(points) - 2))->y) {<br />

/* tally number <strong>of</strong> points increased ... set flag when<br />

we have moved up far enough to expect minimum/maximum */<br />

seq_inc+=2;<br />

if(seq_inc/2 >= TWEAK)<br />

ascent = 1;<br />

if(seq_dec/2 > 0)<br />

seq_dec-=2;

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

Saved successfully!

Ooh no, something went wrong!