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

/*<br />

Minima.c<br />

By Andrew Botros, 2001-2004.<br />

Modified by Paul Dickens, 2006-2007.<br />

Listing B.14: Minima.c<br />

Characterises the minima <strong>of</strong> acoustic impedance spectra.<br />

Refer to Minima.h for interface details.<br />

IMPORTANT: Calculations are optimised for a spectrum resolution <strong>of</strong><br />

2Hz.<br />

NOTE: The weighting <strong>of</strong> the frequency <strong>of</strong> an impedance extremum fit to<br />

favour the absolute emtremum has been changed to an option in the<br />

function 'parabolaExt' with a default <strong>of</strong> 0 (no weighting). A block<br />

has also been added to the function 'extrema' to h<strong>and</strong>le the case<br />

when the next point to be considered is equal to the previous one<br />

(this fixed a bug in the code).<br />

*/<br />

/* necessary define for some gcc math.h functions */<br />

#ifndef _ISOC99_SOURCE<br />

#define _ISOC99_SOURCE<br />

#endif<br />

#include <br />

#include <br />

#include <br />

#include <br />

#include "Vector.h"<br />

#include "Point.h"<br />

#include "Note.h"<br />

#include "Minima.h"<br />

/* number <strong>of</strong> data points approximated around each minimum */<br />

#define NUM_POINTS 11<br />

/* number <strong>of</strong> points which must be consecutively increasing or<br />

decreasing to define the spectrum as rising or dropping. */<br />

#define TWEAK 5<br />

/* weight fit to absolute extremum? */<br />

#define WEIGHT 0<br />

/* to evaluate harmonics, a window is defined around the frequency f<br />

<strong>of</strong> the fundamental minimum: f +/- HARMONIC_WINDOW/100. Minima which<br />

lie within integer multiples <strong>of</strong> this window are deemed to be<br />

harmonics. */<br />

#define HARMONIC_WINDOW 5.0<br />

/* maximum number <strong>of</strong> harmonics used to calculate average impedance <strong>of</strong><br />

harmonics */<br />

#define HARMONICS_AVERAGED 3<br />

Vector minima(Vector allpoints) {<br />

int i, j;<br />

Vector extv = extrema(allpoints);<br />

Extremum e, searche;

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

Saved successfully!

Ooh no, something went wrong!