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.

262 APPENDIX B. PROGRAM LISTINGS<br />

maxf = p->x;<br />

maxZ = p->y;<br />

}<br />

}<br />

return maxf;<br />

}<br />

void harmonicity(Vector minv) {<br />

int i;<br />

Vector harmv;<br />

/* for each Minimum in vector... */<br />

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

/* find all the harmonic minima <strong>of</strong> the particular Minimum */<br />

harmv = harmonics(minv, i);<br />

/* record the number <strong>of</strong> harmonics the Minimum has */<br />

((Minimum)elementAt(minv, i))->numharm =<br />

(double)sizeVector(harmv);<br />

/* calculate <strong>and</strong> record the weighted average impedance <strong>of</strong><br />

these harmonic minima. */<br />

((Minimum)elementAt(minv, i))->meanharmZ = harmAvgZ(harmv);<br />

}<br />

return;<br />

}<br />

Vector harmonics(Vector minv, int pos) {<br />

int i;<br />

int harmonic;<br />

double window, left_bound, right_bound;<br />

double df;<br />

int curharmonic;<br />

int found;<br />

/* get the ratios <strong>of</strong> minima frequencies following<br />

the Minimum in question */<br />

double* ha = harmonicsArray(minv, pos);<br />

int arraysize = sizeVector(minv) - pos - 1;<br />

Vector harmv = createVector();<br />

Harmonic h;<br />

i = 1;<br />

/* search for possible integer harmonics until<br />

last Minimum is reached */<br />

for(harmonic = 2; ; harmonic++) {<br />

i--;<br />

/* calculate a window in which harmonic will be defined.<br />

The widest window allowable is 0.5. */<br />

window = (HARMONIC_WINDOW/100.0)*harmonic;<br />

if(window > 0.5)<br />

window = 0.5;<br />

left_bound = harmonic - window;<br />

right_bound = harmonic + window;<br />

found = 0;<br />

/* search for any Minimum which exists in the defined window.<br />

Compare this to previously found minima in the same

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

Saved successfully!

Ooh no, something went wrong!