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.

308 APPENDIX B. PROGRAM LISTINGS<br />

/*<br />

Waves.c<br />

By Paul Dickens, 2005, 2006<br />

Listing B.29: Waves.c<br />

Calculates the pressure <strong>and</strong> flow distribution along a flute.<br />

*/<br />

#include <br />

#include <br />

#include <br />

#include "Acoustics.h"<br />

#include "Woodwind.h"<br />

#include "ParseXML.h"<br />

int parseComm<strong>and</strong>Line(int argc, char** argv,<br />

char** holestring, double* xres, int* midi,<br />

double* f, char** xml_filename);<br />

/* Default x resolution */<br />

#define XRES 2.0e-3;<br />

int main(int argc, char** argv) {<br />

double f;<br />

double x, xres, xmin, xmax;<br />

int midi;<br />

char* holestring;<br />

char* xml_filename;<br />

Woodwind instrument;<br />

complex Z0, Zin, pin, Uin;<br />

double c;<br />

TransferMatrix m;<br />

complex p, U;<br />

double entryradius = WW_EMB_RADIUS;<br />

/* check correct usage */<br />

if(!parseComm<strong>and</strong>Line(argc, argv, &holestring, &xres, &midi,<br />

&f, &xml_filename)) {<br />

fprintf(stderr,<br />

"Usage: Waves [OPTIONS] \n\n");<br />

fprintf(stderr, " Options:\n");<br />

fprintf(stderr, "\t-s \n");<br />

fprintf(stderr, "\t-r (default 2.0)\n\n");<br />

fprintf(stderr, " :\n");<br />

fprintf(stderr,<br />

"\t- Optional if no holes are defined in XML file.\n");<br />

fprintf(stderr, "\t- Must be a sequence <strong>of</strong> 'O' (open hole) ");<br />

fprintf(stderr, "<strong>and</strong> 'X' (closed hole) characters.\n");<br />

fprintf(stderr,<br />

"\t- Length must be equal to the number <strong>of</strong> defined holes.\n");<br />

fprintf(stderr, "\t- e.g. \"XXOOOOOOXOOOOXOOO\"\n\n");<br />

return -1;<br />

}<br />

/* retrieve data structures from XML file */<br />

if(!parseXMLFile(xml_filename, &instrument)) {

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

Saved successfully!

Ooh no, something went wrong!