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

/*<br />

Analysis.c<br />

By Andrew Botros, 2001-2004<br />

Modified by Paul Dickens, 2006<br />

Listing B.5: Analysis.c<br />

Analyses an acoustic impedance spectrum for playable<br />

notes. See Analysis.h for interface details.<br />

*/<br />

#include <br />

#include <br />

#include <br />

#include <br />

#include "Note.h"<br />

#include "Vector.h"<br />

#include "ParseImpedance.h"<br />

#include "Minima.h"<br />

#include "Analysis.h"<br />

#include "Point.h"<br />

void Analysis(char* filename, int applypitchcorrection,<br />

int displayharmonicity, AnalysisType at) {<br />

Vector fileData = createVector(), seriesData, minv;<br />

int midi;<br />

Minimum m;<br />

int i;<br />

int series;<br />

/* read <strong>and</strong> parse data file into a Vector <strong>of</strong> Vectors <strong>of</strong> Points */<br />

if(!parseImpedanceFile(fileData, filename)) {<br />

fprintf(stderr, "AnalyseNotes error: ");<br />

fprintf(stderr, "AnalyseNotes failed to parse impedance file.\n");<br />

return;<br />

}<br />

for (series = 0; series < sizeVector(fileData); series++) {<br />

seriesData = (Vector)elementAt(fileData, series);<br />

midi = *((int*)elementAt(seriesData, 0));<br />

popFront(seriesData);<br />

/* evaluate all minima in the data */<br />

minv = minima(seriesData);<br />

/* print MIDI number */<br />

printf("%d\t", midi);<br />

/* determine playable minima */<br />

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

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

/* evaluate musical note from frequency (do not round) */<br />

m->note = note(m->f, 0);<br />

if(m->note->midi == midi)<br />

analyseNote(m, applypitchcorrection, displayharmonicity,<br />

at == NOTES);<br />

}

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

Saved successfully!

Ooh no, something went wrong!