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

}<br />

}<br />

}<br />

}<br />

}<br />

int noteDistance(Minimum m1, Minimum m2, Vector playableminv) {<br />

int i;<br />

Minimum m;<br />

int posm1 = -1, posm2 = -1;<br />

/* find the positions <strong>of</strong> each minimum in vector */<br />

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

m = (Minimum)elementAt(playableminv, i);<br />

if(m == m1)<br />

posm1 = i;<br />

if(m == m2)<br />

posm2 = i;<br />

}<br />

/* check for an invalid condition */<br />

if((posm1 == -1) || (posm2 == -1) || (posm1 >= posm2))<br />

return -1;<br />

else<br />

return (posm2 - posm1);<br />

}<br />

int pitchIndex(Vector minv) {<br />

int i;<br />

Minimum m;<br />

int index = 0;<br />

/* calculate sum <strong>of</strong> squares <strong>of</strong> cents */<br />

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

m = (Minimum)elementAt(minv, i);<br />

index = index + (m->note->cents)*(m->note->cents);<br />

}<br />

return index;<br />

}<br />

char* allNotes(Vector playableminv) {<br />

int i;<br />

Minimum m;<br />

char* all_notes = (char*)malloc(BUFSIZ*size<strong>of</strong>(char));<br />

/* for each note that is playable, concatenate into<br />

one string delimited by a ';' */<br />

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

m = (Minimum)elementAt(playableminv, i);<br />

if(i == 0)<br />

sprintf(all_notes, noteString(m->note));<br />

else {<br />

strcat(all_notes, ";");<br />

strcat(all_notes, noteString(m->note));<br />

}<br />

}<br />

/* return concatenated string */<br />

return all_notes;<br />

}<br />

int harmonic(Minimum m1, Minimum m2, Vector playableminv) {<br />

int i;

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

Saved successfully!

Ooh no, something went wrong!