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

s = (BoreSegment)elementAt(h->upstreamBore, segmentCount);<br />

temp = t_0 + t_grad * (x + s->length / 2);<br />

if (temp < t_amb) temp = t_amb;<br />

s->c = speedSound(temp, P_ATM, humid, x_CO2);<br />

s->rho = densityAirGiacomo(temp, P_ATM, humid, x_CO2);<br />

x += s->length;<br />

}<br />

}<br />

x = 0;<br />

/* for each bore segment in downstream */<br />

for (segmentCount = 0; segmentCount < sizeVector(h->downstreamBore);<br />

segmentCount++) {<br />

s = (BoreSegment)elementAt(h->downstreamBore, segmentCount);<br />

temp = t_0 + t_grad * (x + s->length / 2);<br />

if (temp < t_amb) temp = t_amb;<br />

s->c = speedSound(temp, P_ATM, humid, x_CO2);<br />

s->rho = densityAirGiacomo(temp, P_ATM, humid, x_CO2);<br />

x += s->length;<br />

}<br />

/* for each unit cell */<br />

for (cellCount = 0; cellCount < sizeVector(w->cells); cellCount++) {<br />

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

temp = t_0 + t_grad * x;<br />

if (temp < t_amb) temp = t_amb;<br />

cell->hole->c = speedSound(temp, P_ATM, humid, x_CO2);<br />

cell->hole->rho = densityAirGiacomo(temp, P_ATM, humid, x_CO2);<br />

/* for each bore segment in unit cell */<br />

for (segmentCount = 0; segmentCount < sizeVector(cell->bore);<br />

segmentCount++) {<br />

s = (BoreSegment)elementAt(cell->bore, segmentCount);<br />

temp = t_0 + t_grad * (x + s->length / 2);<br />

if (temp < t_amb) temp = t_amb;<br />

s->c = speedSound(temp, P_ATM, humid, x_CO2);<br />

s->rho = densityAirGiacomo(temp, P_ATM, humid, x_CO2);<br />

x += s->length;<br />

}<br />

}<br />

}<br />

void discretiseWoodwind(Woodwind w, double maxLength) {<br />

int cellCount;<br />

UnitCell cell;<br />

discretiseBore(w->head->upstreamBore, maxLength);<br />

discretiseBore(w->head->downstreamBore, maxLength);<br />

for (cellCount = 0; cellCount < sizeVector(w->cells); cellCount++) {<br />

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

discretiseBore(cell->bore, maxLength);<br />

}<br />

}<br />

void discretiseBore(Vector bore, double maxLength) {<br />

int segmentCount, newSegmentCount, numSegments;<br />

BoreSegment s, newSegment;<br />

double radius1, radius2, length;<br />

/* for each bore segment in bore */

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

Saved successfully!

Ooh no, something went wrong!