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

/*<br />

AnalyseNotes.c<br />

By Andrew Botros, 2004<br />

Modified by Paul Dickens, 2006<br />

Listing B.3: AnalyseNotes.c<br />

Analyses acoustic impedance spectra for playable notes.<br />

*/<br />

#include <br />

#include <br />

#include "Analysis.h"<br />

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

char** filename);<br />

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

int displayharmonicity;<br />

/* do not apply the pitch correction */<br />

int applypitchcorrection = 0;<br />

char* filename;<br />

/* check correct usage */<br />

if(!parseComm<strong>and</strong>Line(argc, argv, &displayharmonicity, &filename)) {<br />

fprintf(stdout,<br />

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

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

fprintf(stderr, "\t-h (Displays harmonicity data)\n\n");<br />

return -1;<br />

}<br />

/* perform analysis on impedance data file */<br />

Analysis(filename, applypitchcorrection, displayharmonicity, NOTES);<br />

return 0;<br />

}<br />

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

char** filename) {<br />

int i;<br />

int hflag = 0;<br />

int numoptions = 1, numinputfiles = 1;<br />

int minargc = 1 + numinputfiles;<br />

int maxargc = minargc + numoptions;<br />

/* Check correct number <strong>of</strong> parameters */<br />

if((argc < minargc) || (argc > maxargc))<br />

return 0;<br />

/* Set default options */<br />

*displayharmonicity = 0;<br />

/* Check <strong>and</strong> set options */<br />

for(i = 1; i < (argc - numinputfiles); i++) {<br />

if(strcmp(argv[i], "-h") == 0) {<br />

if(hflag)<br />

return 0;<br />

*displayharmonicity = 1;<br />

hflag = 1;

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

Saved successfully!

Ooh no, something went wrong!