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

/*<br />

Note.h<br />

By Andrew Botros, 2001-2004<br />

Modified by Paul Dickens, 2007<br />

Listing B.16: Note.h<br />

Note.c is a frequency to musical note converter.<br />

*/<br />

#ifndef NOTE_H_PROTECTOR<br />

#define NOTE_H_PROTECTOR<br />

/* Note: { note struct including name, cents, midi number ) */<br />

typedef struct note_str {<br />

char* name;<br />

int cents;<br />

int midi;<br />

} *Note;<br />

Note note(double input, int round);<br />

/*<br />

Converts the given frequency to a musical note.<br />

Parameters:<br />

input: must be a double between 27.5Hz (A0) <strong>and</strong> 14080Hz (A9)<br />

round: round note to nearest 5 cents if true<br />

Returns:<br />

A note struct which includes:<br />

- name: A string representing the note, such as "C4"<br />

- cents: Number <strong>of</strong> cents as an int, optionally rounded to the<br />

nearest 5 cents<br />

- midi: a midi number corresponding to the closest semitone for<br />

the frequency<br />

*/<br />

... OR NULL if frequency out <strong>of</strong> range.<br />

char* noteString(Note n);<br />

/*<br />

Returns a string representation <strong>of</strong> the note.<br />

Parameters:<br />

n: The note struct pointer<br />

Returns:<br />

A string representation, such as "C4 plus 20 cents" or "A#4 minus<br />

15 cents"<br />

*/<br />

#endif

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

Saved successfully!

Ooh no, something went wrong!